:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --bg-gradient: linear-gradient(135deg, #0b0f19 0%, #111827 50%, #1e1b4b 100%);
  --glass-bg: rgba(255, 255, 255, 0.03);
  --glass-card: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-input: rgba(0, 0, 0, 0.2);
  --text-main: #f8fafc;
  --text-dim: #94a3b8;
  --accent-success: #10b981;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --font-title: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
  overflow-x: hidden;
  position: relative;
}

/* Background Glow Spheres */
.glow-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.glow-sphere {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.15;
  animation: float 20s infinite ease-in-out alternate;
}

.glow-1 {
  top: -10%;
  left: -10%;
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, #6366f1 0%, transparent 70%);
}

.glow-2 {
  bottom: -10%;
  right: -10%;
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, #a855f7 0%, transparent 70%);
  animation-delay: -10s;
}

@keyframes float {
  0% {
    transform: translate(0, 0) scale(1);
  }
  100% {
    transform: translate(5%, 5%) scale(1.1);
  }
}

/* Main Container */
.app-container {
  width: 100%;
  max-width: 900px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 30px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Back Link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  align-self: flex-start;
  transition: var(--transition);
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
}

.back-link:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--glass-border);
  transform: translateX(-2px);
}

/* Header */
.app-header {
  text-align: left;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 20px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--primary);
}

.header-logo svg {
  stroke: url(#logo-grad);
  filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.5));
}

.header-logo h1 {
  font-family: var(--font-title);
  font-size: 2.2rem;
  font-weight: 800;
  background: linear-gradient(to right, #818cf8, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-subtitle {
  color: var(--text-dim);
  font-size: 1rem;
  line-height: 1.5;
}

/* Storage Section */
.storage-section {
  background: var(--glass-card);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 20px;
}

.storage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.storage-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.storage-title {
  font-family: var(--font-title);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.storage-percentage {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.progress-bar-container {
  height: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  background: var(--accent-success);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

.progress-bar.warning {
  background: var(--accent-warning);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}

.progress-bar.danger {
  background: var(--accent-danger);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
}

/* Upload Section */
.drop-zone {
  border: 2px dashed rgba(99, 102, 241, 0.3);
  border-radius: 20px;
  background: rgba(99, 102, 241, 0.01);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
  box-shadow: inset 0 0 20px rgba(99, 102, 241, 0.1);
  transform: translateY(-2px);
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.upload-icon-wrapper {
  background: rgba(99, 102, 241, 0.1);
  border-radius: 50%;
  width: 72px;
  height: 72px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--primary);
  margin-bottom: 8px;
  transition: var(--transition);
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.drop-zone:hover .upload-icon-wrapper, .drop-zone.dragover .upload-icon-wrapper {
  transform: scale(1.1);
  background: rgba(99, 102, 241, 0.2);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

.drop-zone-content h3 {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-main);
}

.drop-subtext {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.limit-badge {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  margin-top: 4px;
}

/* Controls Section (Search & Sort) */
.controls-section {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.search-wrapper {
  flex: 1;
  min-width: 250px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.search-wrapper input {
  width: 100%;
  background: var(--glass-input);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 12px 16px 12px 42px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition);
}

.search-wrapper input:focus {
  border-color: var(--primary);
  background: rgba(0, 0, 0, 0.3);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.sort-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sort-wrapper label {
  font-size: 0.9rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.sort-wrapper select {
  background: var(--glass-input);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 12px 32px 12px 16px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: var(--transition);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.sort-wrapper select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Vault Section & File Cards */
.vault-section {
  min-height: 200px;
  display: flex;
  flex-direction: column;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  background: rgba(255, 255, 255, 0.01);
  border: 1px dashed var(--glass-border);
  border-radius: 16px;
  text-align: center;
  color: var(--text-dim);
  gap: 10px;
}

.empty-state svg {
  margin-bottom: 8px;
  opacity: 0.4;
  color: var(--text-dim);
}

.empty-state p {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
}

.empty-state span {
  font-size: 0.9rem;
}

.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.file-card {
  background: var(--glass-card);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  transition: var(--transition);
}

.file-card:hover {
  transform: translateY(-4px);
  border-color: rgba(99, 102, 241, 0.25);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  background: rgba(255, 255, 255, 0.07);
}

.file-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-icon-box {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  flex-shrink: 0;
  transition: var(--transition);
}

.file-card:hover .file-icon-box {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
}

.file-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.file-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.file-details {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.file-date {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.file-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

/* Button UI */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  outline: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger-text {
  background: transparent;
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: 8px;
}

.btn-danger-text:hover:not(:disabled) {
  color: var(--accent-danger);
  background: rgba(239, 68, 68, 0.08);
}

.btn-danger-text:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  outline: none;
  background: transparent;
}

.btn-download {
  color: var(--accent-success);
  background: rgba(16, 185, 129, 0.08);
}

.btn-download:hover {
  background: rgba(16, 185, 129, 0.18);
  transform: scale(1.05);
}

.btn-delete {
  color: var(--accent-danger);
  background: rgba(239, 68, 68, 0.08);
}

.btn-delete:hover {
  background: rgba(239, 68, 68, 0.18);
  transform: scale(1.05);
}

.btn-danger {
  background: var(--accent-danger);
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
  transform: translateY(-1px);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}

.toast {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 14px 20px;
  color: var(--text-main);
  min-width: 280px;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: var(--transition);
}

@keyframes slideIn {
  from {
    transform: translateX(120%) scale(0.9);
    opacity: 0;
  }
  to {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

.toast.removing {
  animation: slideOut 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideOut {
  from {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
  to {
    transform: translateX(120%) scale(0.9);
    opacity: 0;
  }
}

.toast-success {
  border-left: 4px solid var(--accent-success);
}
.toast-error {
  border-left: 4px solid var(--accent-danger);
}
.toast-warning {
  border-left: 4px solid var(--accent-warning);
}
.toast-info {
  border-left: 4px solid var(--primary);
}

.toast-icon {
  flex-shrink: 0;
}
.toast-success .toast-icon { color: var(--accent-success); }
.toast-error .toast-icon { color: var(--accent-danger); }
.toast-warning .toast-icon { color: var(--accent-warning); }
.toast-info .toast-icon { color: var(--primary); }

.toast-message {
  font-size: 0.9rem;
  font-weight: 500;
  flex: 1;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.modal-card {
  background: rgba(30, 27, 75, 0.8);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 24px;
  width: 90%;
  max-width: 440px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: center;
  animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes modalIn {
  from {
    transform: scale(0.9) translateY(20px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.modal-card h2 {
  font-family: var(--font-title);
  color: var(--text-main);
  font-size: 1.5rem;
}

.modal-card p {
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 8px;
}

.modal-actions button {
  flex: 1;
}

/* Password Auth Modal Styles */
.auth-card {
  max-width: 420px;
  padding: 32px 28px;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(99, 102, 241, 0.3);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6), 0 0 24px rgba(99, 102, 241, 0.2);
}

.auth-icon-wrapper {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px auto;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.auth-input-wrapper {
  display: flex;
  gap: 8px;
}

.auth-input-wrapper input {
  flex: 1;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition);
}

.auth-input-wrapper input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.auth-error {
  color: var(--accent-danger);
  font-size: 0.85rem;
  padding: 8px 12px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 8px;
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* Responsive adjustments */
@media (max-width: 600px) {
  body {
    padding: 20px 10px;
  }
  
  .app-container {
    padding: 20px 15px;
    gap: 16px;
  }

  .header-logo h1 {
    font-size: 1.75rem;
  }

  .controls-section {
    flex-direction: column;
    align-items: stretch;
  }

  .sort-wrapper {
    justify-content: space-between;
  }

  .files-grid {
    grid-template-columns: 1fr;
  }
}
