/* ============================================================
   CHINRA — Media Vault Dashboard
   Dark glassmorphism design system
   ============================================================ */

/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-deep:      #07080f;
  --bg-base:      #0d0e1a;
  --bg-surface:   #121320;
  --bg-elevated:  #1a1b2e;
  --bg-glass:     rgba(255,255,255,0.04);
  --bg-glass-hov: rgba(255,255,255,0.08);

  --border:       rgba(255,255,255,0.07);
  --border-hov:   rgba(255,255,255,0.14);
  --border-accent:rgba(139,92,246,0.4);

  --accent:       #8b5cf6;
  --accent-dim:   rgba(139,92,246,0.15);
  --accent-glow:  rgba(139,92,246,0.4);
  --accent-2:     #06b6d4;
  --danger:       #ef4444;
  --danger-dim:   rgba(239,68,68,0.15);
  --success:      #22c55e;

  --text-primary:   #f1f0ff;
  --text-secondary: #9896b8;
  --text-muted:     #5e5c7a;

  --sidebar-w:    240px;
  --topbar-h:     64px;
  --radius:       12px;
  --radius-sm:    8px;
  --radius-lg:    16px;

  --font: 'Inter', system-ui, sans-serif;
  --transition: 0.18s ease;
}

html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

/* ── App Layout ──────────────────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.sidebar::before {
  content: '';
  position: absolute;
  top: -80px; left: -40px;
  width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(139,92,246,0.12) 0%, transparent 70%);
  pointer-events: none;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
}

.logo-icon {
  font-size: 22px;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.logo-text {
  font-weight: 700;
  font-size: 17px;
  background: linear-gradient(135deg, #c4b5fd, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.3px;
}

.sidebar-section {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 8px 8px;
}

/* Folder Tree */
.folder-tree { display: flex; flex-direction: column; gap: 2px; }

.folder-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  transition: background var(--transition), color var(--transition);
  user-select: none;
}

.folder-item:hover { background: var(--bg-glass-hov); color: var(--text-primary); }
.folder-item.active {
  background: var(--accent-dim);
  color: var(--text-primary);
  border: 1px solid var(--border-accent);
}

.folder-item .folder-icon { font-size: 14px; opacity: 0.7; }

.folder-item.child { padding-left: 26px; }
.folder-item.child-2 { padding-left: 42px; }

.sidebar-bottom {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}

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

.storage-bar {
  height: 3px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.storage-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 99px;
  transition: width 0.6s ease;
}

#storage-text { font-size: 11px; color: var(--text-muted); }

/* ── Main ────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-base);
}

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
  gap: 16px;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  overflow: hidden;
}

.crumb {
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition);
}

.crumb:hover { color: var(--text-primary); }
.crumb.active { color: var(--text-primary); font-weight: 500; cursor: default; }

.crumb-sep { color: var(--text-muted); font-size: 11px; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(139,92,246,0.25);
}
.btn.primary:hover {
  background: #7c3aed;
  box-shadow: 0 0 24px rgba(139,92,246,0.4);
  transform: translateY(-1px);
}

.btn.ghost {
  background: var(--bg-glass);
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn.ghost:hover { background: var(--bg-glass-hov); color: var(--text-primary); border-color: var(--border-hov); }

.btn.small { padding: 6px 12px; font-size: 12px; }

.btn.danger { background: var(--danger-dim); color: var(--danger); border-color: rgba(239,68,68,0.3); }
.btn.danger:hover { background: var(--danger); color: #fff; }

.icon-btn {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-glass);
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  transition: all var(--transition);
}
.icon-btn:hover { background: var(--bg-glass-hov); color: var(--text-primary); }
.icon-btn.active { background: var(--accent-dim); color: var(--accent); border-color: var(--border-accent); }

/* ── Upload Queue ────────────────────────────────────────── */
.upload-queue {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.upload-queue.hidden { display: none; }

.upload-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.upload-item-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.upload-item-bar {
  flex: 1;
  height: 3px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.upload-item-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 99px;
  transition: width 0.1s linear;
}

.upload-item-status { font-size: 11px; white-space: nowrap; }
.upload-item-status.done { color: var(--success); }
.upload-item-status.error { color: var(--danger); }

/* ── File Area ───────────────────────────────────────────── */
.file-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.file-area.drop-active::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  background: rgba(139,92,246,0.06);
  pointer-events: none;
  z-index: 2;
}

/* ── File Grid ───────────────────────────────────────────── */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

.file-grid.list-mode {
  grid-template-columns: 1fr;
  gap: 4px;
}

/* Grid Cards */
.file-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  animation: cardIn 0.2s ease both;
}

.file-card:hover {
  border-color: var(--border-hov);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.file-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 4px 16px rgba(139,92,246,0.2);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.card-thumb {
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.card-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.file-card:hover .card-thumb img { transform: scale(1.05); }

.card-thumb video {
  width: 100%; height: 100%;
  object-fit: cover;
}

.card-thumb .file-icon {
  font-size: 40px;
  opacity: 0.5;
}

.card-play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.35);
  opacity: 0;
  transition: opacity var(--transition);
}

.file-card:hover .card-play-overlay { opacity: 1; }

.card-play-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  color: #111;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

.card-info {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
}

.card-name {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.card-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

.card-select {
  position: absolute;
  top: 8px; left: 8px;
  width: 18px; height: 18px;
  border-radius: 4px;
  border: 1.5px solid rgba(255,255,255,0.5);
  background: rgba(0,0,0,0.5);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity var(--transition);
}

.file-card:hover .card-select,
.file-card.selected .card-select { opacity: 1; }

.file-card.selected .card-select {
  background: var(--accent);
  border-color: var(--accent);
}

/* Folder Cards */
.folder-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: cardIn 0.2s ease both;
}

.folder-card:hover {
  border-color: var(--border-hov);
  background: var(--bg-glass-hov);
}

.folder-card .folder-thumb {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(139,92,246,0.2), rgba(6,182,212,0.2));
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.folder-card .folder-card-info { flex: 1; min-width: 0; }
.folder-card .folder-card-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-card .folder-card-meta { font-size: 11px; color: var(--text-muted); }

/* List Mode */
.file-grid.list-mode .file-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  border-radius: var(--radius-sm);
}

.file-grid.list-mode .card-thumb {
  width: 48px; height: 48px;
  aspect-ratio: unset;
  flex-shrink: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.file-grid.list-mode .card-info {
  flex: 1;
  padding: 0 12px;
  border-top: none;
  border-left: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-grid.list-mode .card-name { flex: 1; }

.file-grid.list-mode .folder-card { border-radius: var(--radius-sm); }

/* ── States ──────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 80px 24px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state.hidden { display: none; }
.empty-icon { font-size: 48px; opacity: 0.5; }
.empty-sub { font-size: 12px; }

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px;
}

.loading-state.hidden { display: none; }

.spinner {
  width: 32px; height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Drop Overlay ────────────────────────────────────────── */
.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7,8,15,0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity var(--transition);
}

.drop-overlay.hidden { display: none; }

.drop-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 60px 80px;
  border: 2px dashed var(--accent);
  border-radius: var(--radius-lg);
  background: var(--accent-dim);
}

.drop-icon {
  font-size: 52px;
  color: var(--accent);
  animation: bounce 1s ease infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.drop-overlay-inner p {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Context Menu ────────────────────────────────────────── */
.ctx-menu {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hov);
  border-radius: var(--radius-sm);
  padding: 6px;
  z-index: 500;
  min-width: 170px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
  animation: ctxIn 0.12s ease;
}

@keyframes ctxIn {
  from { opacity: 0; transform: scale(0.96) translateY(-4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.ctx-menu.hidden { display: none; }

.ctx-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition);
}

.ctx-item:hover { background: var(--bg-glass-hov); color: var(--text-primary); }
.ctx-item.danger { color: var(--danger); }
.ctx-item.danger:hover { background: var(--danger-dim); }

/* ── Modals ──────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7,8,15,0.7);
  backdrop-filter: blur(6px);
  z-index: 600;
}

.modal-backdrop.hidden { display: none; }

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 700;
  pointer-events: none;
}

.modal.hidden { display: none; }

.modal-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-hov);
  border-radius: var(--radius-lg);
  padding: 28px 28px 24px;
  min-width: 340px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 24px 72px rgba(0,0,0,0.6);
  pointer-events: all;
  animation: modalIn 0.18s ease;
}

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

.modal-box h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 18px;
  color: var(--text-primary);
}

.modal-box input[type="text"] {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-hov);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
  margin-bottom: 18px;
}

.modal-box input[type="text"]:focus { border-color: var(--accent); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.folder-list-picker {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 12px;
  padding: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.picker-folder {
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
}

.picker-folder:hover { background: var(--bg-glass-hov); color: var(--text-primary); }
.picker-folder.selected { background: var(--accent-dim); color: var(--text-primary); }

/* ── Lightbox ────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(7,8,15,0.95);
  backdrop-filter: blur(12px);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox.hidden { display: none; }

.lightbox-content {
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-content img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 32px 96px rgba(0,0,0,0.8);
}

.lightbox-content video {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: var(--radius);
  box-shadow: 0 32px 96px rgba(0,0,0,0.8);
}

.lightbox-close {
  position: absolute;
  top: 20px; right: 24px;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--bg-glass);
  border: 1px solid var(--border-hov);
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  z-index: 10;
}

.lightbox-close:hover { background: var(--danger); border-color: var(--danger); }

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--bg-glass);
  border: 1px solid var(--border-hov);
  color: var(--text-primary);
  font-size: 24px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  backdrop-filter: blur(8px);
}

.lightbox-nav:hover { background: var(--accent); border-color: var(--accent); }
.lightbox-nav.prev { left: 24px; }
.lightbox-nav.next { right: 24px; }

.lightbox-info {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-glass);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 6px 18px;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hov); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Utility ─────────────────────────────────────────────── */
.hidden { display: none !important; }
