/* css/global.css — CloudStore Design System */
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── CSS Variables ───────────────────────────────────────────────────────── */
:root {
  --bg-start: #0d0221;
  --bg-mid: #1a0533;
  --bg-end: #0a1628;

  --glass-bg: rgba(255, 255, 255, 0.07);
  --glass-bg-hover: rgba(255, 255, 255, 0.12);
  --glass-bg-active: rgba(255, 255, 255, 0.16);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-border-strong: rgba(255, 255, 255, 0.22);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255,255,255,0.1);

  --grad-primary: linear-gradient(135deg, #a855f7, #3b82f6);
  --grad-primary-hover: linear-gradient(135deg, #9333ea, #2563eb);
  --grad-accent: linear-gradient(135deg, #ec4899, #a855f7);
  --grad-success: linear-gradient(135deg, #10b981, #3b82f6);
  --grad-danger: linear-gradient(135deg, #ef4444, #f97316);

  --purple: #a855f7;
  --blue: #3b82f6;
  --pink: #ec4899;
  --green: #10b981;
  --red: #ef4444;

  --text-primary: rgba(255, 255, 255, 0.95);
  --text-secondary: rgba(255, 255, 255, 0.6);
  --text-muted: rgba(255, 255, 255, 0.35);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 30px;
  --radius-full: 999px;

  --blur: blur(20px);
  --blur-lg: blur(40px);

  --nav-height: 72px;
  --header-height: 60px;

  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

  --font-main: 'Sora', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* ─── Dark Mode ───────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg-start: #050010;
  --bg-mid: #0d0225;
  --bg-end: #030d1a;
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-bg-hover: rgba(255, 255, 255, 0.09);
  --glass-bg-active: rgba(255, 255, 255, 0.13);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-border-strong: rgba(255, 255, 255, 0.16);
  --text-secondary: rgba(255, 255, 255, 0.5);
  --text-muted: rgba(255, 255, 255, 0.28);
}

/* ─── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-main);
  background: var(--bg-start);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── Animated Background ─────────────────────────────────────────────────── */
.bg-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(ellipse at 20% 20%, #3b0764 0%, transparent 50%),
              radial-gradient(ellipse at 80% 80%, #1e3a5f 0%, transparent 50%),
              radial-gradient(ellipse at 50% 50%, #0d0221 0%, #030d1a 100%);
  animation: bgShift 12s ease-in-out infinite alternate;
}
@keyframes bgShift {
  0%   { background-position: 0% 0%; }
  100% { background-position: 100% 100%; }
}
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
  pointer-events: none;
  z-index: -1;
  animation: orbFloat 8s ease-in-out infinite alternate;
}
.bg-orb-1 { width: 400px; height: 400px; background: #7c3aed; top: -100px; left: -100px; }
.bg-orb-2 { width: 300px; height: 300px; background: #2563eb; bottom: 100px; right: -50px; animation-delay: -3s; }
.bg-orb-3 { width: 200px; height: 200px; background: #a855f7; top: 50%; left: 50%; animation-delay: -5s; }
@keyframes orbFloat {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(30px, -30px) scale(1.1); }
}

/* ─── Glass Card ──────────────────────────────────────────────────────────── */
.glass {
  background: var(--glass-bg);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}
.glass-strong {
  background: var(--glass-bg-active);
  backdrop-filter: var(--blur-lg);
  -webkit-backdrop-filter: var(--blur-lg);
  border: 1px solid var(--glass-border-strong);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.15);
}

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn-primary {
  background: var(--grad-primary);
  color: #fff;
  box-shadow: 0 4px 20px rgba(168, 85, 247, 0.4);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(168, 85, 247, 0.5); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost {
  background: var(--glass-bg);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
}
.btn-ghost:hover { background: var(--glass-bg-hover); border-color: var(--glass-border-strong); }
.btn-danger {
  background: var(--grad-danger);
  color: #fff;
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.3);
}
.btn-sm { padding: 8px 16px; font-size: 0.8rem; }
.btn-icon {
  width: 40px; height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  font-size: 1.1rem;
}
.btn-icon:hover { background: var(--glass-bg-hover); color: var(--text-primary); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ─── Inputs ──────────────────────────────────────────────────────────────── */
.input-wrap { position: relative; }
.input {
  width: 100%;
  padding: 14px 18px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.95rem;
  outline: none;
  transition: all var(--transition);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}
.input::placeholder { color: var(--text-muted); }
.input:focus {
  border-color: var(--purple);
  background: var(--glass-bg-hover);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.2);
}
.input-icon { padding-left: 46px; }
.input-wrap .input-prefix {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
  pointer-events: none;
}

/* ─── Labels ─────────────────────────────────────────────────────────────── */
.label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

/* ─── Bottom Navigation ───────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  z-index: 100;
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  align-items: center;
  justify-content: space-around;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  -webkit-tap-highlight-color: transparent;
  min-width: 60px;
}
.nav-item .nav-icon { font-size: 1.3rem; transition: transform var(--transition-spring); }
.nav-item .nav-label { font-size: 0.65rem; font-weight: 600; letter-spacing: 0.04em; }
.nav-item.active { color: var(--purple); }
.nav-item.active .nav-icon { transform: scale(1.15); }
.nav-item:hover { color: var(--text-primary); background: var(--glass-bg); }

/* ─── Page Layout ─────────────────────────────────────────────────────────── */
.page {
  display: none;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-height) + 16px);
  padding-top: 16px;
  padding-left: 16px;
  padding-right: 16px;
  animation: pageIn 0.3s ease;
}
.page.active { display: block; }
@keyframes pageIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ─── Header ──────────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-top: 8px;
}
.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── Storage Ring ────────────────────────────────────────────────────────── */
.storage-ring-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.storage-ring-wrap svg { transform: rotate(-90deg); }
.storage-ring-bg { fill: none; stroke: rgba(255,255,255,0.08); stroke-width: 8; }
.storage-ring-fill {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  stroke: url(#ringGrad);
  transition: stroke-dashoffset 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.storage-ring-center {
  position: absolute;
  text-align: center;
  pointer-events: none;
}
.storage-pct { font-size: 1.6rem; font-weight: 700; color: var(--text-primary); }
.storage-label { font-size: 0.7rem; color: var(--text-muted); font-weight: 500; }

/* ─── File Cards ──────────────────────────────────────────────────────────── */
.files-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.file-card {
  border-radius: var(--radius-lg);
  padding: 14px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.file-card:hover { transform: translateY(-3px); background: var(--glass-bg-hover); }
.file-card:active { transform: scale(0.97); }
.file-thumb {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  background: var(--glass-bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  margin-bottom: 10px;
  overflow: hidden;
}
.file-thumb img, .file-thumb video {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: var(--radius-md);
}
.file-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-meta { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }
.file-menu-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px; height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition);
}
.file-card:hover .file-menu-btn, .file-card.menu-open .file-menu-btn { opacity: 1; }

/* ─── Folder List Row ─────────────────────────────────────────────────────── */
.folder-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 8px;
}
.folder-row:hover { background: var(--glass-bg-hover); }
.folder-icon { font-size: 1.8rem; flex-shrink: 0; }
.folder-name { font-weight: 600; font-size: 0.95rem; flex: 1; }
.folder-meta { font-size: 0.75rem; color: var(--text-muted); }

/* ─── Context Menu ────────────────────────────────────────────────────────── */
.ctx-menu {
  position: fixed;
  z-index: 500;
  min-width: 180px;
  border-radius: var(--radius-lg);
  padding: 6px;
  animation: ctxIn 0.18s var(--transition-spring);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
@keyframes ctxIn { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }
.ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text-primary);
  transition: background var(--transition);
  border: none;
  background: transparent;
  width: 100%;
  font-family: var(--font-main);
}
.ctx-item:hover { background: var(--glass-bg-hover); }
.ctx-item.danger { color: #f87171; }
.ctx-item .ctx-icon { font-size: 1rem; width: 20px; text-align: center; }
.ctx-divider { height: 1px; background: var(--glass-border); margin: 4px 0; }

/* ─── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}
@media (min-width: 600px) {
  .modal-overlay { align-items: center; padding: 24px; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%;
  max-width: 500px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 28px 24px;
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
  animation: slideUp 0.35s var(--transition-spring);
}
@media (min-width: 600px) {
  .modal { border-radius: var(--radius-xl); padding-bottom: 28px; }
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-handle {
  width: 40px; height: 4px;
  background: var(--glass-border-strong);
  border-radius: 999px;
  margin: 0 auto 20px;
}
.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 20px;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
@media (min-width: 600px) { .modal-handle { display: none; } }

/* ─── Preview Modal ───────────────────────────────────────────────────────── */
.preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 700;
  display: flex;
  flex-direction: column;
  background: rgba(0,0,0,0.95);
  animation: fadeIn 0.2s ease;
}
.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  flex-shrink: 0;
}
.preview-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 16px;
}
.preview-body img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--radius-md); }
.preview-body video { max-width: 100%; max-height: 100%; border-radius: var(--radius-md); }
.preview-body iframe { width: 100%; height: 100%; min-height: 60vh; border: none; border-radius: var(--radius-md); }

/* ─── Toast ───────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: calc(100% - 32px);
  max-width: 400px;
  pointer-events: none;
}
.toast {
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 0.88rem;
  font-weight: 500;
  color: #fff;
  animation: toastIn 0.35s var(--transition-spring);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
@keyframes toastIn { from { opacity:0; transform:translateY(-20px) scale(0.9); } to { opacity:1; transform:none; } }
.toast.success { background: linear-gradient(135deg, #059669, #0d9488); }
.toast.error { background: linear-gradient(135deg, #dc2626, #ea580c); }
.toast.info { background: var(--grad-primary); }
.toast.out { animation: toastOut 0.3s ease forwards; }
@keyframes toastOut { to { opacity:0; transform:translateY(-10px) scale(0.9); } }

/* ─── Empty State ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-icon { font-size: 3.5rem; margin-bottom: 16px; opacity: 0.5; }
.empty-title { font-size: 1.1rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.empty-sub { font-size: 0.85rem; color: var(--text-muted); }

/* ─── Upload Zone ─────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--glass-border-strong);
  border-radius: var(--radius-xl);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--purple);
  background: rgba(168, 85, 247, 0.08);
}
.upload-zone input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}

/* ─── Progress bar ────────────────────────────────────────────────────────── */
.progress-bar {
  height: 4px;
  border-radius: 999px;
  background: var(--glass-bg-hover);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--grad-primary);
  transition: width 0.3s ease;
}

/* ─── Toggle Switch ───────────────────────────────────────────────────────── */
.toggle-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
}
.toggle {
  position: relative;
  width: 52px;
  height: 28px;
  cursor: pointer;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--glass-bg-active);
  border: 1px solid var(--glass-border);
  transition: background var(--transition);
}
.toggle input:checked ~ .toggle-track { background: var(--grad-primary); border-color: transparent; }
.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transition: transform var(--transition-spring);
}
.toggle input:checked ~ .toggle-thumb { transform: translateX(24px); }

/* ─── Search Bar ──────────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.search-bar .input { flex: 1; }

/* ─── Breadcrumbs ─────────────────────────────────────────────────────────── */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.breadcrumb-item {
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition);
}
.breadcrumb-item:hover { color: var(--text-primary); }
.breadcrumb-item.active { color: var(--text-primary); font-weight: 600; cursor: default; }
.breadcrumb-sep { color: var(--text-muted); font-size: 0.75rem; }

/* ─── Stat Cards ──────────────────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}
.stat-card {
  border-radius: var(--radius-lg);
  padding: 14px 12px;
  text-align: center;
}
.stat-value { font-size: 1.4rem; font-weight: 700; }
.stat-label { font-size: 0.7rem; color: var(--text-muted); font-weight: 600; letter-spacing: 0.06em; margin-top: 2px; }

/* ─── Chip ────────────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--glass-bg-hover);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}
.chip.active { background: rgba(168,85,247,0.2); border-color: rgba(168,85,247,0.5); color: var(--purple); }

/* ─── Skeleton Loader ─────────────────────────────────────────────────────── */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, var(--glass-bg) 25%, var(--glass-bg-hover) 50%, var(--glass-bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* ─── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--glass-border-strong); border-radius: 999px; }

/* ─── Utility ─────────────────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.font-bold { font-weight: 700; }
.font-semi { font-weight: 600; }
.w-full { width: 100%; }
.hidden { display: none !important; }
