/* ================================================================
   File Portal – main.css
   ================================================================ */

:root {
  --brand:       #2563eb;
  --brand-dark:  #1d4ed8;
  --brand-light: #dbeafe;
  --success:     #16a34a;
  --danger:      #dc2626;
  --warning:     #d97706;
  --gray-50:     #f9fafb;
  --gray-100:    #f3f4f6;
  --gray-200:    #e5e7eb;
  --gray-300:    #d1d5db;
  --gray-400:    #9ca3af;
  --gray-500:    #6b7280;
  --gray-700:    #374151;
  --gray-800:    #1f2937;
  --gray-900:    #111827;
  --radius:      8px;
  --radius-lg:   12px;
  --shadow:      0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:   0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --font: 'Inter', system-ui, sans-serif;
  --font-head: 'Space Grotesk', system-ui, sans-serif;
  --sidebar-w: 220px;
}

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

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--gray-800);
  background: var(--gray-100);
  line-height: 1.6;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Flash messages ─────────────────────────────────────── */
.flash-container { position: fixed; top: 16px; right: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.flash-container--admin { position: static; margin: 16px 24px 0; }
.flash {
  padding: 10px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; max-width: 360px;
  box-shadow: var(--shadow-md); animation: fadeIn .2s ease;
}
.flash--success { background: #dcfce7; color: #15803d; border-left: 3px solid var(--success); }
.flash--error   { background: #fee2e2; color: #b91c1c; border-left: 3px solid var(--danger); }
.flash--warning { background: #fef3c7; color: #92400e; border-left: 3px solid var(--warning); }
.flash--info    { background: var(--brand-light); color: #1e40af; border-left: 3px solid var(--brand); }
@keyframes fadeIn { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:none; } }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; font-family: var(--font);
  border: 1px solid transparent; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap; text-decoration: none !important;
}
.btn--primary   { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn--primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn--ghost     { background: #fff; color: var(--gray-700); border-color: var(--gray-200); }
.btn--ghost:hover { background: var(--gray-50); }
.btn--danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn--danger:hover { background: #b91c1c; }
.btn--danger-text { color: var(--danger); }
.btn--sm        { padding: 5px 12px; font-size: 12px; }
.btn--full      { width: 100%; justify-content: center; }
.btn-group      { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btn-group--wrap { flex-wrap: wrap; }

/* ── Inputs ──────────────────────────────────────────────── */
.input {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--gray-300); border-radius: var(--radius);
  font-size: 14px; font-family: var(--font); color: var(--gray-800);
  background: #fff; transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.input--sm { padding: 6px 10px; font-size: 13px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-weight: 500; font-size: 13px; color: var(--gray-700); }
.form-hint { font-size: 11px; color: var(--gray-400); }
.form-stack { display: flex; flex-direction: column; gap: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 8px; border-top: 1px solid var(--gray-100); }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* ── Toggle switch ───────────────────────────────────────── */
.toggle-label { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 400; margin-top: 6px; }
.toggle-switch {
  position: relative; width: 38px; height: 22px;
  background: var(--gray-300); border-radius: 11px;
  transition: background .2s; flex-shrink: 0;
}
.toggle-switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; background: #fff; border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: left .2s;
}
input[type=checkbox]:checked + .toggle-switch { background: var(--brand); }
input[type=checkbox]:checked + .toggle-switch::after { left: 19px; }
input[type=checkbox] { display: none; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: .3px;
}
.badge--green { background: #dcfce7; color: #15803d; }
.badge--red   { background: #fee2e2; color: #b91c1c; }
.badge--gray  { background: var(--gray-100); color: var(--gray-500); }
.badge--blue  { background: var(--brand-light); color: #1d4ed8; }

/* ── Card ────────────────────────────────────────────────── */
.card {
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg); padding: 20px;
  box-shadow: var(--shadow);
}
.card--qr { text-align: center; }
.card--qr h3 { margin-bottom: 16px; }
.card--form { max-width: 640px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-header h3 { margin: 0; }

/* ── Table ───────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; padding: 8px 12px;
  font-weight: 600; font-size: 11px; text-transform: uppercase;
  letter-spacing: .5px; color: var(--gray-500);
  border-bottom: 1px solid var(--gray-200); background: var(--gray-50);
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--gray-50); }
.table--compact td, .table--compact th { padding: 7px 10px; }
.td--actions { white-space: nowrap; text-align: right; }
.td--mono { font-family: monospace; font-size: 12px; }
.td--ua { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--gray-400); }
.td--ip { font-family: monospace; font-size: 12px; }
.td--filename { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-toolbar { padding: 0 0 14px; }

/* ── Stats row ───────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
@media (max-width: 800px) { .stats-row { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg); padding: 16px 20px;
  box-shadow: var(--shadow);
}
.stat-card__val { font-family: var(--font-head); font-size: 28px; font-weight: 600; color: var(--brand); }
.stat-card__label { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

/* ── Detail list ─────────────────────────────────────────── */
.detail-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; }
.detail-list dt { font-weight: 500; color: var(--gray-500); white-space: nowrap; }
.detail-list dd { color: var(--gray-800); }

/* ── Empty states ────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--gray-400); }
.empty-state__icon { font-size: 40px; margin-bottom: 12px; }
.empty-msg { color: var(--gray-400); font-size: 13px; padding: 16px 0; }

/* ── Two column layout ───────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.two-col > div { display: flex; flex-direction: column; gap: 16px; }

/* ── QR ──────────────────────────────────────────────────── */
.qr-image { width: 200px; height: 200px; margin: 0 auto 12px; display: block; image-rendering: pixelated; border: 1px solid var(--gray-200); border-radius: var(--radius); }
.qr-hint { font-size: 12px; color: var(--gray-400); margin-bottom: 14px; }

/* ── Logo ────────────────────────────────────────────────── */
.logo-img { max-height: 48px; max-width: 200px; object-fit: contain; }
.logo-img--sm { max-height: 32px; }
.logo-preview-wrap { padding: 16px; background: var(--gray-50); border-radius: var(--radius); margin-bottom: 14px; text-align: center; min-height: 80px; display: flex; align-items: center; justify-content: center; }
.logo-preview { max-height: 64px; max-width: 240px; }

/* ── Page header ─────────────────────────────────────────── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-family: var(--font-head); font-size: 22px; font-weight: 600; color: var(--gray-900); }
.back-link { display: inline-block; font-size: 13px; color: var(--gray-500); margin-bottom: 4px; }
.back-link:hover { color: var(--brand); }
.subtitle { color: var(--gray-400); font-size: 13px; margin-top: 2px; }

/* ── Settings grid ───────────────────────────────────────── */
.settings-grid { display: flex; flex-direction: column; gap: 16px; max-width: 640px; }

/* ════════════════════════════════════════════════════════════
   ADMIN LAYOUT
   ════════════════════════════════════════════════════════════ */
.admin-body { background: var(--gray-100); }
.admin-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--gray-900); color: #fff;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar__brand {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 10px;
}
.sidebar__title { font-family: var(--font-head); font-size: 15px; font-weight: 600; color: #fff; }
.sidebar__nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.sidebar__link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; color: rgba(255,255,255,.65);
  transition: background .15s, color .15s; text-decoration: none !important;
}
.sidebar__link:hover, .sidebar__link.active { background: rgba(255,255,255,.1); color: #fff; }
.sidebar__link--danger:hover { background: rgba(220,38,38,.25); color: #fca5a5; }
.sidebar__footer { padding: 12px 8px; border-top: 1px solid rgba(255,255,255,.08); }
.nav-icon { font-size: 15px; width: 18px; text-align: center; }

.admin-main { flex: 1; min-width: 0; overflow-x: hidden; }
.admin-page { padding: 28px 32px; max-width: 1100px; }
@media (max-width: 700px) { .admin-page { padding: 16px; } }

/* ════════════════════════════════════════════════════════════
   CLIENT LAYOUT
   ════════════════════════════════════════════════════════════ */
.client-body { background: var(--gray-50); }
.client-wrap { min-height: 100vh; display: flex; flex-direction: column; }

.client-header {
  background: #fff; border-bottom: 1px solid var(--gray-200);
  padding: 0 32px; height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow);
}
.client-header__logo { display: flex; align-items: center; }
.logo-text { font-family: var(--font-head); font-size: 18px; font-weight: 600; color: var(--brand); }
.client-header__user { display: flex; align-items: center; gap: 12px; }
.user-chip {
  font-size: 13px; font-weight: 500;
  background: var(--brand-light); color: var(--brand-dark);
  padding: 4px 12px; border-radius: 20px;
}
.expires-chip { font-size: 11px; color: var(--gray-400); }

.client-main { flex: 1; padding: 32px; max-width: 900px; margin: 0 auto; width: 100%; }
.section-title { margin-bottom: 24px; }
.section-title h1 { font-family: var(--font-head); font-size: 22px; font-weight: 600; }

.file-grid { display: flex; flex-direction: column; gap: 10px; }
.file-card {
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg); padding: 16px 20px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow); transition: box-shadow .15s;
}
.file-card:hover { box-shadow: var(--shadow-md); }
.file-card__icon {
  width: 44px; height: 44px; background: var(--brand-light);
  color: var(--brand-dark); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; letter-spacing: .5px; flex-shrink: 0;
}
.file-card__info { flex: 1; min-width: 0; }
.file-card__name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-card__meta { font-size: 12px; color: var(--gray-400); margin-top: 2px; }

.client-footer { text-align: center; padding: 20px; font-size: 12px; color: var(--gray-300); }

/* ── Client folders ──────────────────────────────────────── */
.client-folder { margin-bottom: 16px; }
.client-folder__header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: #fff;
  border: 1px solid var(--gray-200); border-radius: var(--radius-lg);
  cursor: pointer; user-select: none; margin-bottom: 8px;
  transition: background .15s;
}
.client-folder__header:hover { background: var(--gray-50); }
.client-folder__icon { font-size: 18px; }
.client-folder__name { font-weight: 500; flex: 1; }
.client-folder__count { font-size: 12px; color: var(--gray-400); }
.client-folder__arrow { font-size: 12px; color: var(--gray-400); transition: transform .2s; }
.client-folder .file-grid { padding-left: 16px; display: flex; flex-direction: column; gap: 8px; }

/* ── Admin folder groups ─────────────────────────────────── */
.folder-group { margin-bottom: 12px; border: 1px solid var(--gray-200); border-radius: var(--radius-lg); overflow: hidden; }
.folder-group__header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  font-size: 13px;
}
.folder-group__header--root { color: var(--gray-500); font-style: italic; }
.folder-count {
  font-size: 11px; background: var(--gray-200); color: var(--gray-600);
  padding: 1px 7px; border-radius: 10px; margin-left: 4px;
}
.folder-actions { margin-left: auto; display: flex; gap: 4px; }
.folder-group .table { border-radius: 0; }

/* ── Inline modals ───────────────────────────────────────── */
.inline-modal {
  background: var(--gray-50); border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg); padding: 16px; margin-bottom: 16px;
}

/* ── Centered card (errors, logout) ──────────────────────── */
.centered-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.centered-card {
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg); padding: 40px 48px;
  text-align: center; max-width: 380px; width: 90%;
  box-shadow: var(--shadow-md);
}
.centered-card--login { max-width: 360px; }
.centered-card__icon { font-size: 40px; margin-bottom: 16px; }
.centered-card h2 { font-family: var(--font-head); font-size: 20px; margin-bottom: 8px; }
.centered-card p { color: var(--gray-500); font-size: 14px; margin-bottom: 0; }
.centered-card .form-stack { margin-top: 24px; text-align: left; }
