/* A color-scheme mindig a ténylegesen aktív témát tükrözi (app.js állítja be inline style-lal
   document.documentElement-en), sosem "light dark" együtt - az utóbbi miatt a böngésző a gép
   téma-beállítása szerinti alapszínekkel rendereli a még nem stílusozott szöveget/vezérlőket,
   ami a ténylegesen választott témával ütközve olvashatatlanná (pl. láthatatlanná) válhat. */
:root {
    color-scheme: light;
}

* { box-sizing: border-box; }

/* [hidden] must always win over component display rules (e.g. .btn's display:inline-flex),
   otherwise elements marked hidden (admin-only links, modals, badges) stay visible. */
[hidden] { display: none !important; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #fff;
    color: #0f172a;
    transition: background-color .2s, color .2s;
}
body.dark {
    background: #0f172a;
    color: #f1f5f9;
}

a { color: inherit; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }

/* ---------- Nav ---------- */
.topbar {
    position: sticky; top: 0; z-index: 40;
    background: rgba(255,255,255,.9); backdrop-filter: blur(6px);
    border-bottom: 1px solid #e2e8f0;
    padding: .9rem 0;
}
body.dark .topbar { background: rgba(15,23,42,.9); border-color: #1e293b; }
.topbar .container { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 1.15rem; color: #059669; text-decoration: none; }
body.dark .brand { color: #34d399; }
.nav-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.inline-link { color: #059669; font-weight: 600; text-decoration: none; }
.inline-link:hover { text-decoration: underline; }
body.dark .inline-link { color: #34d399; }

.back-link { font-size: .85rem; color: #64748b; text-decoration: none; }
.back-link:hover { color: #059669; text-decoration: underline; }
body.dark .back-link:hover { color: #34d399; }
.login-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.login-card .back-link { display: inline-block; }

.user-chip { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; opacity: .8; }
.user-chip svg { width: 1rem; height: 1rem; flex-shrink: 0; }

.icon-btn svg { width: 1.05rem; height: 1.05rem; display: block; }

.user-chip { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; opacity: .8; }
.user-chip svg { width: 1rem; height: 1rem; flex-shrink: 0; }

.icon-btn svg { width: 1.05rem; height: 1.05rem; display: block; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    border: none; cursor: pointer; border-radius: .6rem;
    padding: .55rem 1rem; font-size: .9rem; font-weight: 600;
    transition: transform .1s, background-color .15s, box-shadow .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: #059669; color: #fff; }
.btn-primary:hover { background: #047857; box-shadow: 0 4px 12px rgba(5,150,105,.28); }
.btn-ghost { background: #e2e8f0; color: #0f172a; }
body.dark .btn-ghost { background: #1e293b; color: #f1f5f9; }
.btn-ghost:hover { filter: brightness(0.95); }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Card / form base ---------- */
.card {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 1rem;
    padding: 1.5rem; box-shadow: 0 1px 3px rgba(15,23,42,.04);
}
body.dark .card { background: #1e293b; border-color: #334155; box-shadow: 0 1px 3px rgba(0,0,0,.2); }

.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; }
.field input, .field select, .field textarea {
    width: 100%; padding: .6rem .75rem; border-radius: .5rem;
    border: 1px solid #cbd5e1; font-size: .95rem; background: #fff; color: #0f172a;
    font-family: inherit; resize: vertical;
}
body.dark .field input, body.dark .field select, body.dark .field textarea { background: #0f172a; border-color: #334155; color: #f1f5f9; }

.error-msg { color: #dc2626; font-size: .85rem; margin-top: .5rem; min-height: 1.1em; }
.success-msg { color: #059669; font-size: .85rem; margin-top: .5rem; min-height: 1.1em; }

/* ---------- Login page ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-size: 1.4rem; margin: 0 0 .25rem; }
.login-card p.subtitle { margin: 0 0 1.5rem; color: #64748b; font-size: .9rem; }

/* ---------- Breadcrumbs ---------- */
.breadcrumbs { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; font-size: .9rem; margin: 1.5rem 0 1rem; color: #64748b; }
.breadcrumbs a { color: #059669; text-decoration: none; display: inline-flex; align-items: center; gap: .3rem; }
body.dark .breadcrumbs a { color: #34d399; }
.breadcrumbs a svg { width: .95rem; height: .95rem; flex-shrink: 0; }
.breadcrumbs a:hover { text-decoration: underline; }

/* ---------- Grid ---------- */
.grid {
    display: grid; gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    margin-bottom: 2rem;
}
.tile {
    border-radius: .8rem; overflow: hidden; cursor: pointer; border: 1px solid #e2e8f0;
    background: #fff; text-align: left; transition: transform .12s, box-shadow .12s;
    box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
body.dark .tile { background: #1e293b; border-color: #334155; box-shadow: none; }
.tile:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0,0,0,.14); }

.tile-thumb { width: 100%; aspect-ratio: 1/1; background: #f1f5f9; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
body.dark .tile-thumb { background: #0f172a; }
.tile-thumb img, .tile-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-name { padding: .5rem .6rem; font-size: .8rem; word-break: break-word; line-height: 1.3; }

/* Mappa-előnézet: két egymásra rakott réteg, amik keresztfade-elnek egymásba */
.tile-thumb .preview-layer {
    position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
    opacity: 0; transition: opacity .6s ease;
}
.tile-thumb .preview-layer.active { opacity: 1; }

.tile-thumb-empty svg { width: 3.2rem; height: 3.2rem; color: #059669; }
body.dark .tile-thumb-empty svg { color: #34d399; }

.folder-badge {
    position: absolute; left: .5rem; bottom: .5rem; z-index: 2;
    width: 1.7rem; height: 1.7rem; border-radius: .5rem;
    background: rgba(15,23,42,.6); backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center;
}
.folder-badge svg { width: 1.05rem; height: 1.05rem; color: #fff; }

.play-badge {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,.15); pointer-events: none;
}
.play-badge svg { width: 2.4rem; height: 2.4rem; filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); }

.empty-state { text-align: center; padding: 3rem 1rem; color: #64748b; }

/* ---------- Lightbox ---------- */
.lightbox-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 100;
    display: flex; align-items: center; justify-content: center; padding: 1.5rem;
}
.lightbox-content { max-width: min(90vw, 1000px); max-height: 85vh; display: flex; flex-direction: column; gap: .75rem; align-items: center; }
.lightbox-content video { max-width: 100%; max-height: 75vh; border-radius: .5rem; }
.lightbox-bar { display: flex; align-items: center; gap: 1rem; color: #fff; font-size: .9rem; }

.lightbox-close, .lightbox-nav {
    background: rgba(255,255,255,.12); border: none; color: #fff; cursor: pointer;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    transition: background-color .15s;
}
.lightbox-close:hover, .lightbox-nav:hover { background: rgba(255,255,255,.25); }
.lightbox-close { position: absolute; top: 1rem; right: 1.2rem; width: 2.4rem; height: 2.4rem; z-index: 5; }
.lightbox-close svg { width: 1.15rem; height: 1.15rem; }

.lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 2.8rem; height: 2.8rem; z-index: 5; }
.lightbox-nav svg { width: 1.4rem; height: 1.4rem; }
.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }

.lightbox-stage {
    position: relative; overflow: hidden; touch-action: none;
    max-width: min(90vw, 1000px); max-height: 75vh;
    display: flex; align-items: center; justify-content: center;
}
.lightbox-stage img {
    max-width: 100%; max-height: 75vh; border-radius: .5rem;
    cursor: zoom-in; user-select: none; transition: transform .12s ease-out;
    will-change: transform;
}
.lightbox-stage.dragging { cursor: grabbing; }
.lightbox-stage.dragging img { cursor: grabbing; transition: none; }

/* ---------- Modal (login change-pw / admin forms) ---------- */
/* z-index a lightbox (100) fölött, mert a jelentés-modal a lightboxból nyílik meg. */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 110;
    display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay[hidden] { display: none; }
.modal { width: 100%; max-width: 380px; }
.modal h2 { margin-top: 0; font-size: 1.15rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; }

/* ---------- Admin table ---------- */
table.users { width: 100%; border-collapse: collapse; margin-top: 1rem; }
table.users th, table.users td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid #e2e8f0; font-size: .9rem; }
body.dark table.users th, body.dark table.users td { border-color: #334155; }
.role-badge { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.role-badge.admin { background: #d1fae5; color: #065f46; }
.role-badge.user { background: #e2e8f0; color: #334155; }
body.dark .role-badge.admin { background: #064e3b; color: #6ee7b7; }
body.dark .role-badge.user { background: #334155; color: #cbd5e1; }

.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

.loading-msg { text-align: center; padding: 2rem; color: #64748b; }
