/* ============================================================
   DROPBOX PERSONALE — Tema "Control Room"
   Palette: blu-slate profondo + ciano dati + ambra segnaletica
   ============================================================ */

:root {
  /* Superfici */
  --bg-base: #0a0e15;
  --bg-surface: #121826;
  --bg-surface-2: #1a2233;
  --bg-surface-3: #212b40;
  --border-subtle: #232c40;
  --border-strong: #303c56;

  /* Testo */
  --text-primary: #eef2fa;
  --text-secondary: #9aa5bd;
  --text-muted: #5f6a83;

  /* Accenti */
  --accent: #2fd6c8;
  --accent-dim: rgba(47, 214, 200, .14);
  --accent-strong: #22b8ab;
  --accent-2: #f5a742;
  --accent-2-dim: rgba(245, 167, 66, .16);
  --danger: #f2596b;
  --danger-dim: rgba(242, 89, 107, .15);
  --success: #35d488;
  --success-dim: rgba(53, 212, 136, .15);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --sidebar-width: 278px;

  --font-display: 'Space Grotesk', 'Inter', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;
}

* { scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }

html, body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6, .navbar-brand, .modal-title, .card-title {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

a { color: var(--accent); }

/* ===== BACKGROUND TEXTURE (sottile, dà profondità senza rumore) ===== */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(47,214,200,.07), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 10%, rgba(245,167,66,.05), transparent 55%);
}

/* ===== LOGIN ===== */
.login-screen {
  min-height: 100vh;
  background: var(--bg-base);
  position: relative;
  overflow: hidden;
}
.login-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--border-subtle) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-subtle) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(ellipse 60% 60% at 50% 40%, black 10%, transparent 75%);
  opacity: .5;
}
.login-screen::after {
  content: '';
  position: absolute;
  top: -20%; left: 50%;
  width: 900px; height: 900px;
  transform: translateX(-50%);
  background: radial-gradient(circle, var(--accent-dim) 0%, transparent 65%);
  pointer-events: none;
}
.login-card {
  width: 100%;
  max-width: 420px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-base) 100%);
  border: 1px solid var(--border-subtle);
  position: relative;
  z-index: 1;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.02) inset;
}
.login-card .display-4 {
  color: var(--accent);
  filter: drop-shadow(0 0 18px var(--accent-dim));
}
.login-card h3 { color: var(--text-primary); font-weight: 700; }
.login-card .text-muted { color: var(--text-muted) !important; }

.form-label { color: var(--text-secondary); font-weight: 500; font-size: .85rem; }
.form-control, .form-select {
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
}
.form-control:focus, .form-select:focus {
  background: var(--bg-surface-2);
  border-color: var(--accent);
  color: var(--text-primary);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled { background: var(--bg-surface); color: var(--text-muted); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border: none;
  color: #06201d;
  font-weight: 600;
  border-radius: var(--radius-sm);
}
.btn-primary:hover, .btn-primary:focus {
  background: linear-gradient(135deg, #3ee6d7, var(--accent));
  color: #06201d;
  box-shadow: 0 0 24px var(--accent-dim);
}
.btn-outline-secondary, .btn-outline-light {
  border-color: var(--border-strong);
  color: var(--text-secondary);
}
.btn-outline-secondary:hover, .btn-outline-light:hover {
  background: var(--bg-surface-3);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.btn-outline-danger { border-color: var(--danger); color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger-dim); color: var(--danger); border-color: var(--danger); }

/* ===== NAVBAR ===== */
.navbar {
  background: var(--bg-surface) !important;
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
  z-index: 5;
}
.navbar::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, var(--accent), transparent 45%);
  opacity: .5;
}
.navbar-brand { color: var(--text-primary) !important; font-weight: 700; }
.navbar-brand i { color: var(--accent); }

/* pallino "online" pulsante — firma visiva dell'app */
.navbar-brand .status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
  margin-left: 6px;
  box-shadow: 0 0 0 0 rgba(53,212,136,.6);
  animation: pulse-dot 2.4s infinite;
}
@keyframes pulse-dot {
  0%   { box-shadow: 0 0 0 0 rgba(53,212,136,.55); }
  70%  { box-shadow: 0 0 0 8px rgba(53,212,136,0); }
  100% { box-shadow: 0 0 0 0 rgba(53,212,136,0); }
}

.btn-dark, .navbar .btn-dark {
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}
.btn-dark:hover { background: var(--bg-surface-3); color: var(--text-primary); }

.avatar-sm {
  width: 32px; height: 32px; object-fit: cover;
  border: 2px solid var(--border-strong);
}
.dropdown-menu {
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 40px rgba(0,0,0,.5);
}
.dropdown-header { color: var(--text-muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.dropdown-item { color: var(--text-secondary); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--bg-surface-3); color: var(--text-primary); }
.dropdown-item.text-danger:hover { background: var(--danger-dim); color: var(--danger) !important; }
.dropdown-divider { border-color: var(--border-subtle); }

/* ===== APP LAYOUT ===== */
.app-body { display: flex; min-height: calc(100vh - 56px); position: relative; z-index: 1; }
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  flex-shrink: 0;
  transition: transform .25s ease;
}
.app-content { flex: 1; min-width: 0; }

@media (max-width: 991.98px) {
  .app-sidebar {
    position: fixed; top: 56px; bottom: 0; left: 0; z-index: 1040;
    transform: translateX(-100%); overflow-y: auto;
  }
  .app-sidebar.show { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 56px 0 0 0; background: rgba(0,0,0,.55); z-index: 1035; }
  .sidebar-backdrop.show { display: block !important; }
}

.app-sidebar h6.text-uppercase {
  color: var(--text-muted) !important;
  font-size: .7rem;
  letter-spacing: .08em;
  font-family: var(--font-mono);
}

#rootFoldersList .list-group-item {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm) !important;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
#rootFoldersList .list-group-item:hover {
  background: var(--bg-surface-2);
  color: var(--text-primary);
}
#rootFoldersList .list-group-item.active {
  background: var(--accent-dim);
  border-color: rgba(47,214,200,.35);
  color: var(--accent);
}
#rootFoldersList img, #rootFoldersList i {
  width: 30px; height: 30px; object-fit: cover; border-radius: 7px; flex-shrink: 0;
}
#rootFoldersList i { font-size: 1.2rem; display: flex; align-items: center; justify-content: center; }

/* ===== BREADCRUMB ===== */
.breadcrumb { background: transparent; margin: 0; }
.breadcrumb-item, .breadcrumb-item.active { color: var(--text-secondary); font-family: var(--font-mono); font-size: .85rem; }
.breadcrumb-item a { color: var(--text-secondary); text-decoration: none; cursor: pointer; }
.breadcrumb-item a:hover { color: var(--accent); }
.breadcrumb-item.active { color: var(--text-primary); }
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-muted); }

/* ===== FILES GRID ===== */
.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.file-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 10px 12px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: border-color .15s ease, transform .15s ease, background .15s ease;
  user-select: none;
}
.file-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface-2);
  transform: translateY(-3px);
}
.file-card .thumb-wrap {
  width: 100%;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}
/* icona "LED da centralina": tile arrotondato con bagliore del colore del tipo file */
.file-card .thumb-wrap i {
  width: 58px; height: 58px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px;
  font-size: 1.7rem !important;
  background: color-mix(in srgb, currentColor 14%, var(--bg-surface-2));
  box-shadow: 0 0 0 1px color-mix(in srgb, currentColor 25%, transparent);
}
/* tile con sigla testuale (PDF, RAR, MP4...) al posto della sola iconcina,
   sempre leggibile indipendentemente da quanto le icone si somiglino */
.file-icon-tile {
  width: 58px; height: 58px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px;
  position: relative;
  background: color-mix(in srgb, var(--tile-color) 16%, var(--bg-surface-2));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--tile-color) 30%, transparent);
}
.file-icon-tile i {
  font-size: 1.6rem;
  color: color-mix(in srgb, var(--tile-color) 55%, var(--text-muted));
  opacity: .55;
}
.file-icon-tile .file-badge {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--tile-color);
  background: color-mix(in srgb, var(--tile-color) 20%, var(--bg-surface));
  padding: 1px 6px;
  border-radius: 5px;
  white-space: nowrap;
  max-width: 52px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-card .card-actions .btn-play-media:hover { background: var(--accent-dim); color: var(--accent); }
.file-card img.thumb-img {
  width: 100%; height: 72px; object-fit: cover; border-radius: 10px;
  box-shadow: 0 0 0 1px var(--border-subtle);
  cursor: zoom-in;
  transition: box-shadow .15s ease;
}
.file-card img.thumb-img:hover {
  box-shadow: 0 0 0 2px var(--accent);
}
.file-card .file-name {
  font-size: .82rem;
  font-weight: 500;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text-primary);
}
.file-card .file-meta {
  font-size: .68rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 2px;
}
.file-card .card-actions {
  position: absolute;
  top: 8px; right: 8px;
  display: none;
  gap: 4px;
}
.file-card:hover .card-actions { display: flex; }
.file-card .card-actions button {
  width: 26px; height: 26px; padding: 0; font-size: .72rem;
  border-radius: 50%;
  background: var(--bg-surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
}
.file-card .card-actions button:hover { background: var(--accent-dim); color: var(--accent); border-color: transparent; }

#emptyState { color: var(--text-muted); }
#emptyState i { color: var(--border-strong); }

/* ===== DROP ZONE ===== */
.drop-zone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 26px;
  text-align: center;
  color: var(--text-muted);
  background: var(--bg-surface);
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.drop-zone i { color: var(--text-muted); }
.drop-zone.dragover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
.drop-zone.dragover i { color: var(--accent); }

/* ===== TOASTS ===== */
.toast { border-radius: var(--radius-sm); border: none; box-shadow: 0 12px 30px rgba(0,0,0,.45); }
.text-bg-success { background: var(--success) !important; color: #06231a !important; }
.text-bg-danger { background: var(--danger) !important; color: #2a0a0e !important; }
.text-bg-warning { background: var(--accent-2) !important; color: #2a1a04 !important; }
.text-bg-primary { background: var(--accent) !important; color: #06201d !important; }

/* ===== MODALI ===== */
.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
}
.modal-header { border-bottom: 1px solid var(--border-subtle); }
.modal-header.bg-dark { background: var(--bg-surface-2) !important; }
.modal-footer { border-top: 1px solid var(--border-subtle); }
.btn-close { filter: invert(1) grayscale(1) brightness(1.6); opacity: .7; }
.btn-close:hover { opacity: 1; }

/* ===== LIGHTBOX (ingrandimento immagini) ===== */
.lightbox-content {
  background: rgba(10,14,21,.96);
  border: none;
  box-shadow: none;
}
.lightbox-close {
  position: absolute;
  top: 16px; right: 16px;
  z-index: 5;
  background: var(--bg-surface-2);
  border-radius: 50%;
  padding: .5rem;
}
.lightbox-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  min-height: 50vh;
}
.lightbox-body img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: var(--radius-md);
  box-shadow: 0 30px 90px rgba(0,0,0,.6);
}
.lightbox-caption {
  margin-top: 16px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: .85rem;
}

/* ===== PLAYER VIDEO/AUDIO ===== */
.media-player-video {
  width: 100%;
  max-height: 75vh;
  border-radius: var(--radius-md);
  background: #000;
  box-shadow: 0 30px 90px rgba(0,0,0,.6);
}
.media-player-audio-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 10px 0;
}
.media-player-audio-icon {
  width: 96px; height: 96px;
  border-radius: 22px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.6rem;
  background: color-mix(in srgb, var(--accent) 16%, var(--bg-surface-2));
  color: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent);
}
.media-player-audio-wrap audio { width: 100%; max-width: 420px; }
.media-player-name {
  color: var(--text-primary);
  font-weight: 600;
  font-size: .95rem;
  text-align: center;
  word-break: break-word;
}

/* ===== ADMIN ===== */
.admin-nav { border-color: var(--border-subtle) !important; background: var(--bg-surface); }
.admin-nav .nav-link {
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: .9rem;
}
.admin-nav .nav-link:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.admin-nav .nav-link.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.folder-admin-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-surface-2);
}
.folder-admin-card .thumb {
  height: 110px;
  background: var(--bg-surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
}
.folder-admin-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.folder-admin-card .text-muted { color: var(--text-muted) !important; }
.folder-admin-card .fw-semibold { color: var(--text-primary); }
.personal-badge {
  background: var(--accent-2-dim);
  color: var(--accent-2);
  font-size: .62rem;
  font-weight: 600;
  vertical-align: middle;
  padding: .28em .55em;
}

.quota-bar { height: 6px; border-radius: 4px; background: var(--bg-surface-3); overflow: hidden; }
.quota-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

.table { color: var(--text-primary); --bs-table-color: var(--text-primary); }
.table > :not(caption) > * > * { background: transparent; border-bottom-color: var(--border-subtle); color: var(--text-primary); }
.table thead { color: var(--text-muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }

.badge.bg-secondary { background: var(--bg-surface-3) !important; color: var(--text-secondary); }
.badge.bg-danger { background: var(--danger) !important; color: #2a0a0e; }

.list-group-item {
  background: var(--bg-surface-2);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}
.list-group-item-action:hover { background: var(--bg-surface-3); color: var(--text-primary); }

.form-check-input {
  background-color: var(--bg-surface-3);
  border-color: var(--border-strong);
}
.form-check-input:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}
.form-check-label { color: var(--text-secondary); }

.form-text { color: var(--text-muted); }

/* Sidebar admin mobile: impilata invece che a colonna */
@media (max-width: 767.98px) {
  .admin-nav .nav.flex-md-column { flex-direction: row !important; flex-wrap: wrap; }
}
