/* FileX Modern – UI 2026 */
:root {
  --bg: #0f1216;
  --bg-elevated: #171b20;
  --bg-card: #1d2228;
  --bg-input: #14181d;
  --border: #2a3038;
  --border-hover: #3a424e;
  --text: #eef0f4;
  --text-muted: #8b939e;
  --text-dim: #6b7380;
  --accent: #746AB6;
  --accent-hover: #857BC7;
  --accent-soft: rgba(116, 106, 182, 0.15);
  --accent-ring: rgba(116, 106, 182, 0.35);
  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.12);
  --success-border: rgba(52, 211, 153, 0.28);
  --warning: #fbbf24;
  --warning-bg: rgba(251, 191, 36, 0.12);
  --warning-border: rgba(251, 191, 36, 0.28);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.12);
  --danger-border: rgba(248, 113, 113, 0.3);
  --info: #746AB6;
  --info-bg: var(--accent-soft);
  --info-border: rgba(116, 106, 182, 0.3);
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --max: 1180px;
  --header-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}
a { color: var(--accent-hover); text-decoration: none; }
a:hover { color: #9b92d4; }
img, svg { vertical-align: middle; }

/* —— Layout —— */
.shell {
  width: min(var(--max), 100% - 2.5rem);
  margin-inline: auto;
}
.shell-narrow { width: min(640px, 100% - 2rem); margin-inline: auto; }
.shell-form { width: min(780px, 100%); }

.page {
  padding: 2.25rem 0 3.5rem; /* ~36px top desktop */
  min-height: calc(100dvh - var(--header-h));
}
@media (max-width: 640px) {
  .page { padding-top: 1.35rem; } /* ~22px mobile */
}

/* —— Header / Nav —— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: rgba(15, 18, 22, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  gap: 1.5rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.brand:hover { color: var(--text); }
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #5a5099);
  display: grid;
  place-items: center;
  box-shadow: 0 2px 8px rgba(116, 106, 182, 0.35);
}
.brand-mark svg { width: 18px; height: 18px; fill: #fff; }

.nav-collapse {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  gap: 0.5rem;
}
.nav, .nav-main {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-wrap: nowrap;
}
.nav a,
.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.nav a:hover,
.nav-link:hover {
  color: var(--text);
  background: rgba(255,255,255,0.04);
}
.nav a.active,
.nav-link.active {
  background: var(--accent-soft);
  color: #c4bdf0;
}
.nav-account {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  padding-left: 0.75rem;
  border-left: 1px solid var(--border);
  flex-shrink: 0;
}
.btn-signout {
  height: 34px;
  padding: 0 0.85rem;
  font-size: 0.8rem;
}
.nav-toggle {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  color: var(--text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  margin-left: auto;
}
.nav-toggle svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }

/* Public header: keep Admin on the right */
.topbar-inner > .nav-right {
  display: flex;
  align-items: center;
  margin-left: auto;
}

@media (max-width: 960px) {
  .nav-toggle { display: inline-flex; }
  .nav-collapse {
    display: none;
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.25rem 1rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    flex: none;
  }
  .nav-collapse.open { display: flex; }
  .nav-collapse .nav,
  .nav-collapse .nav-main {
    flex-direction: column;
    align-items: stretch;
    flex-wrap: wrap;
  }
  .nav-collapse .nav-account {
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    border-top: 1px solid var(--border);
    padding-top: 0.65rem;
    margin-top: 0.35rem;
    flex-direction: column;
    align-items: stretch;
  }
  .nav-collapse .btn-signout { width: 100%; }
  .topbar-inner { position: relative; flex-wrap: nowrap; }
}

/* —— Cards —— */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  box-shadow: var(--shadow);
}
.card-title {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.card-sub {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}
.section-title {
  margin: 0 0 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

/* —— Typography —— */
h1.page-title {
  margin: 0 0 0.4rem;
  font-size: clamp(1.6rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  text-align: center;
}
.lead {
  margin: 0 0 1.75rem;
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: auto;
  text-align: center;
}

/* —— Forms —— */
.form-group { margin-bottom: 1.15rem; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
.form-hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}
.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
@media (max-width: 640px) {
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="email"],
input[type="search"],
select,
textarea {
  width: 100%;
  height: 44px;
  padding: 0 0.95rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { height: auto; min-height: 88px; padding: 0.75rem 0.95rem; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--border-hover); }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input[type="file"] {
  width: 100%;
  padding: 0.6rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font: inherit;
}

/* Checkbox row – native, robust, no absolute/transform */
.check-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
}
.check-row input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  min-width: 1.15rem;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
  vertical-align: middle;
}
.check-row input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* Legacy class name kept as alias so old markup still works if present */
.toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}
.toggle input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  min-width: 1.15rem;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
  position: static;
  opacity: 1;
}
.toggle .toggle-track { display: none; }

/* —— Buttons —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  height: 44px;
  padding: 0 1.25rem;
  border: none;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn-primary {
  background: #27ae60;
  color: #fff;
}
.btn-primary:hover { background: #27ae60; color: #fff; }
.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  color: var(--text);
  border-color: var(--border-hover);
  background: rgba(255,255,255,0.03);
}
.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}
.btn-danger:hover { background: rgba(248, 113, 113, 0.2); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  height: 36px;
  padding: 0 0.75rem;
  font-size: 0.85rem;
}
.btn-ghost:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.btn-sm { height: 34px; padding: 0 0.7rem; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 8px;
}

/* —— Alerts —— */
.alert {
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.15rem;
  font-size: 0.9rem;
  line-height: 1.45;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-error { background: var(--danger-bg); border: 1px solid var(--danger-border); color: var(--danger); }
.alert-success { background: var(--success-bg); border: 1px solid var(--success-border); color: var(--success); }
.alert-warning { background: var(--warning-bg); border: 1px solid var(--warning-border); color: var(--warning); }
.alert-info { background: var(--info-bg); border: 1px solid var(--info-border); color: #b8b0e8; }

/* —— Dropzone —— */
.dropzone {
  position: relative;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-input);
  padding: 2rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 1.25rem;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  height: 100%;
  padding: 0;
  border: none;
}
.dropzone-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 0.85rem;
  border-radius: 12px;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  color: var(--accent-hover);
}
.dropzone-icon svg { width: 24px; height: 24px; }
.dropzone-title { font-weight: 600; margin: 0 0 0.25rem; }
.dropzone-hint { margin: 0; font-size: 0.85rem; color: var(--text-dim); }
.dropzone-file {
  display: none;
  margin-top: 0.85rem;
  padding: 0.65rem 0.85rem;
  background: var(--bg-elevated);
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text);
  text-align: left;
}
.dropzone-file.show { display: block; }
.dropzone-file strong { font-weight: 600; }
.dropzone-file span { color: var(--text-muted); font-size: 0.8rem; margin-left: 0.5rem; }

/* —— Result / copy rows —— */
.result-box {
  margin-top: 1.5rem;
  padding-top: 1.35rem;
  border-top: 1px solid var(--border);
}
.result-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}
.result-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.result-row input {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--accent-hover);
  height: 40px;
}

/* —— Stats —— */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin: 1.5rem 0 2rem;
}
@media (max-width: 900px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 420px) { .stats-grid { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.35rem;
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  box-shadow: var(--shadow);
}
.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--accent-soft);
  color: var(--accent-hover);
}
.stat-icon svg { width: 20px; height: 20px; }
.stat-icon.danger { background: var(--danger-bg); color: var(--danger); }
.stat-value {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text);
}
.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* —— Table —— */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 640px;
}
.table th {
  text-align: left;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(255,255,255,0.015); }
.table .file-name { font-weight: 500; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

/* Progress bar for downloads */
.dl-progress {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.dl-bar {
  width: 56px;
  height: 6px;
  background: var(--bg-input);
  border-radius: 999px;
  overflow: hidden;
  flex-shrink: 0;
}
.dl-bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}
.dl-text { font-size: 0.85rem; color: var(--text-muted); white-space: nowrap; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-ok { background: var(--success-bg); color: var(--success); }
.badge-expired { background: var(--danger-bg); color: var(--danger); }
.badge-limit { background: var(--warning-bg); color: var(--warning); }

/* —— Download / manage centered —— */
.auth-page {
  min-height: calc(100dvh - var(--header-h));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 2.25rem 1rem 3rem; /* align with .page top rhythm */
}
@media (max-width: 640px) {
  .auth-page { padding-top: 1.35rem; }
}
.auth-card {
  width: min(460px, 100%);
}
.download-card {
  width: min(560px, 100%);
}
.file-preview {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--bg-input);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.file-preview-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  color: var(--accent-hover);
  flex-shrink: 0;
}
.file-preview-icon svg { width: 24px; height: 24px; }
.file-preview-name { font-weight: 600; word-break: break-all; }
.file-preview-meta { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.2rem; }

/* —— Settings sections —— */
.settings-section {
  margin-bottom: 1.75rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.settings-section:last-of-type { border-bottom: none; margin-bottom: 0.5rem; padding-bottom: 0; }

/* —— Footer —— */
.site-footer {
  text-align: center;
  padding: 2rem 0 1.5rem;
  color: var(--text-dim);
  font-size: 0.8rem;
}

/* —— Utilities —— */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.flex-gap { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.text-muted { color: var(--text-muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* Admin layout without old sidebar – top nav only */
.admin-main { padding-top: 0; }

@media (max-width: 480px) {
  .shell { width: calc(100% - 1.5rem); }
  .card { padding: 1.2rem 1.15rem; }
  .btn { height: 42px; }
}

/* —— Upload progress —— */
.fx-upload-progress {
  margin: 1.25rem 0 1rem;
  padding: 1rem 1.1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.fx-upload-status {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.85rem;
  color: var(--text);
}
.fx-upload-item {
  margin-bottom: 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.fx-upload-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}
.fx-file-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.88rem;
  margin-bottom: 0.35rem;
}
.fx-file-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fx-file-pct {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.fx-progress-bar {
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.fx-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 999px;
  transition: width 0.15s ease-out;
}
.fx-file-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.3rem;
  font-size: 0.78rem;
  color: var(--text-dim);
}
.fx-upload-item.is-done .fx-progress-fill {
  background: var(--success, #34d399);
}
.fx-upload-item.is-error .fx-progress-fill {
  background: var(--danger, #f87171);
}
.fx-upload-item.is-error .fx-file-status {
  color: var(--danger, #f87171);
}
.fx-upload-overall {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.fx-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.fx-result-item {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.fx-result-item .result-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}
.fx-result-item .result-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.fx-result-item .result-row input {
  flex: 1;
  min-width: 0;
  font-size: 0.82rem;
  height: 40px;
}
