/* ============ Design tokens ============ */
:root {
  --bg: #0f1115;
  --bg-soft: #161922;
  --surface: #1b1f2a;
  --surface-2: #222735;
  --border: #2a3040;
  --border-soft: #232838;
  --text: #e7e9ee;
  --text-dim: #9aa3b2;
  --muted: #6b7484;
  --accent: #6c8cff;
  --accent-2: #8a6cff;
  --accent-press: #5a78f0;
  --danger: #ff5f6d;
  --ok: #3ecf8e;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 12px 40px rgba(0,0,0,.45);
  --shadow-sm: 0 4px 16px rgba(0,0,0,.3);
  --maxw: 1180px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; width: 100%; overflow-x: clip; }
body {
  max-width: 100%;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: radial-gradient(1200px 700px at 80% -10%, rgba(108,140,255,.10), transparent 60%),
              radial-gradient(900px 600px at -10% 0%, rgba(138,108,255,.08), transparent 55%),
              var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}
.hidden { display: none !important; }
.muted { color: var(--muted); margin: 4px 0 0; font-size: 14px; }

/* ============ Buttons ============ */
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; border-radius: 12px;
  padding: 10px 16px; font-size: 14px;
  transition: transform .06s ease, background .15s ease, border-color .15s ease, opacity .15s;
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  color: var(--text); background: transparent;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(180deg, var(--accent), var(--accent-press)); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { border-color: var(--border); background: var(--surface); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger-ghost { border-color: rgba(255,95,109,.35); color: var(--danger); background: rgba(255,95,109,.06); }
.btn-danger-ghost:hover { background: rgba(255,95,109,.14); }
.btn-block { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ============ Auth screens ============ */
.auth-screen {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center; padding: 24px;
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 22px; padding: 34px 28px; box-shadow: var(--shadow);
}
.brand { text-align: center; margin-bottom: 24px; }
.brand h1 { margin: 12px 0 0; font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.brand-mark {
  width: 60px; height: 60px; margin: 0 auto; display: grid; place-items: center;
  font-size: 30px; border-radius: 18px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  box-shadow: var(--shadow-sm);
}
.brand-mark.sm { width: 30px; height: 30px; font-size: 17px; border-radius: 9px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-dim); }
input, select {
  font: inherit; color: var(--text); background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
  outline: none; transition: border-color .15s, box-shadow .15s; width: 100%;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(108,140,255,.18); }
.form-error { color: var(--danger); font-size: 13px; margin: 0; }

/* ============ Navbar ============ */
.navbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(15,17,21,.78); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.navbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.nav-brand {
  display: flex; align-items: center; gap: 10px; background: none; border: none;
  color: var(--text); font-weight: 800; font-size: 18px; cursor: pointer; letter-spacing: -.01em;
}
.nav-actions { display: flex; align-items: center; gap: 8px; }
.user-chip {
  font-size: 13px; font-weight: 600; color: var(--text-dim);
  background: var(--surface); border: 1px solid var(--border);
  padding: 7px 12px; border-radius: 999px; cursor: pointer; font-family: inherit;
  transition: border-color .15s, color .15s; max-width: 160px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.user-chip:hover { border-color: var(--accent); color: var(--text); }

/* ============ Layout ============ */
.container { max-width: var(--maxw); margin: 0 auto; padding: 28px 20px 80px; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 22px; flex-wrap: wrap;
}
.page-head h2 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back-link {
  background: none; border: none; color: var(--text-dim); font: inherit; font-weight: 600;
  cursor: pointer; padding: 6px 0; margin-bottom: 8px; font-size: 14px;
}
.back-link:hover { color: var(--text); }

/* ============ Folder grid ============ */
.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.folder-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: transform .12s ease, border-color .15s; text-align: left;
  display: flex; flex-direction: column; padding: 0; color: inherit;
}
.folder-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.folder-cover {
  aspect-ratio: 16/10; background: var(--bg-soft); position: relative; overflow: hidden;
  display: grid; place-items: center;
}
.folder-cover img { width: 100%; height: 100%; object-fit: cover; }
.folder-cover .ph { font-size: 40px; opacity: .35; }
.folder-body { padding: 14px 16px; }
.folder-body h3 { margin: 0; font-size: 16px; font-weight: 700; }
.folder-row { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.folder-date { font-size: 13px; color: var(--text-dim); }
.pill { font-size: 12px; font-weight: 600; color: var(--text-dim); background: var(--surface-2); padding: 3px 9px; border-radius: 999px; }

/* ============ Media grid ============ */
.media-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.media-item {
  position: relative; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden;
  background: var(--bg-soft); cursor: pointer; border: 1px solid var(--border-soft);
}
.media-item img, .media-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-item .play-badge {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
}
.media-item .play-badge span {
  width: 44px; height: 44px; border-radius: 999px; background: rgba(0,0,0,.55);
  display: grid; place-items: center; font-size: 18px; color: #fff; backdrop-filter: blur(2px);
}
.media-del {
  position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 8px;
  background: rgba(0,0,0,.55); border: none; color: #fff; cursor: pointer; opacity: 0;
  transition: opacity .15s; display: grid; place-items: center; font-size: 13px;
}
.media-item:hover .media-del { opacity: 1; }
.media-del:hover { background: var(--danger); }

/* ============ Empty / table ============ */
.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty-icon { font-size: 48px; margin-bottom: 10px; opacity: .5; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; min-width: 540px; }
.table th, .table td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--border-soft); font-size: 14px; }
.table th { color: var(--text-dim); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.table tr:last-child td { border-bottom: none; }
.sub-nick { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.tag { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.tag.admin { background: rgba(138,108,255,.16); color: #b3a4ff; }
.tag.user { background: var(--surface-2); color: var(--text-dim); }
.tag.pending { background: rgba(255,170,60,.16); color: #ffc06b; }
.tag.active { background: rgba(62,207,142,.14); color: var(--ok); }

/* ============ Modal ============ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(5,6,9,.66); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 20px; z-index: 60;
}
.modal {
  width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 26px; box-shadow: var(--shadow);
}
.modal h3 { margin: 0 0 4px; font-size: 20px; font-weight: 800; }
.modal .modal-sub { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; justify-content: center; }
.checkbox { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-dim); cursor: pointer; }
.checkbox input { width: auto; }
.cred-box {
  background: var(--bg-soft); border: 1px dashed var(--border); border-radius: 12px;
  padding: 14px 16px; margin: 14px 0; font-family: ui-monospace, 'Cascadia Code', monospace;
}
.cred-box .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 4px 0; }
.cred-box .k { color: var(--muted); font-size: 13px; }
.cred-box .v { font-weight: 700; font-size: 15px; word-break: break-all; }

/* ============ Lightbox ============ */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 80; display: grid; place-items: center; }
.lightbox-stage { max-width: 92vw; max-height: 86vh; display: grid; place-items: center; }
.lightbox-stage img, .lightbox-stage video { max-width: 92vw; max-height: 86vh; border-radius: 10px; }
.lightbox-close, .lightbox-nav {
  position: absolute; background: rgba(255,255,255,.10); border: none; color: #fff; cursor: pointer;
  border-radius: 999px; display: grid; place-items: center; backdrop-filter: blur(4px); transition: background .15s;
}
.lightbox-close:hover, .lightbox-nav:hover { background: rgba(255,255,255,.22); }
.lightbox-close { top: 18px; right: 18px; width: 44px; height: 44px; font-size: 18px; }
.lightbox-nav { top: 50%; transform: translateY(-50%); width: 52px; height: 52px; font-size: 30px; }
.lightbox-nav.prev { left: 14px; }
.lightbox-nav.next { right: 14px; }

/* ============ Upload bar / toast ============ */
.upload-bar {
  height: 38px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  margin-bottom: 16px; position: relative; overflow: hidden; display: flex; align-items: center;
}
.upload-bar-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .2s; }
.upload-bar span { position: relative; z-index: 1; padding-left: 14px; font-size: 13px; font-weight: 600; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); z-index: 90;
  font-size: 14px; font-weight: 600; max-width: 90vw;
}
.toast.err { border-color: rgba(255,95,109,.5); color: #ffb3ba; }
.toast.ok { border-color: rgba(62,207,142,.5); }

/* ============ Responsive ============ */
@media (max-width: 640px) {
  .container { padding: 20px 14px 80px; }
  .page-head h2 { font-size: 20px; }
  .page-head { margin-bottom: 18px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 7px; }
  .navbar-inner { padding: 10px 12px; }
  .nav-brand span:last-child { display: none; }
  .nav-actions { gap: 6px; }
  .nav-actions .btn { padding: 8px 11px; font-size: 13px; }
  .user-chip { max-width: 84px; padding: 7px 10px; font-size: 12px; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1; justify-content: center; }
  .lightbox-nav { width: 42px; height: 42px; font-size: 24px; }

  /* Admin tábla -> kártyás elrendezés (nincs vízszintes görgetés) */
  .table-wrap { border: none; overflow-x: visible; }
  .table { min-width: 0; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr {
    border: 1px solid var(--border); border-radius: 14px; background: var(--surface);
    padding: 14px 16px; margin-bottom: 12px;
  }
  .table td { border: none; padding: 5px 0; }
  .table td[data-label]::before {
    content: attr(data-label); display: inline-block; min-width: 92px;
    color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
  }
  .table td.cell-actions { padding-top: 12px; margin-top: 8px; border-top: 1px solid var(--border-soft); }
  .table td.cell-actions .head-actions { width: 100%; }
  .table td.cell-actions .btn { flex: 1; }
}
