/* =====================================================================
   QR Track - egyszerű, mobilbarát stíluslap
   ===================================================================== */

:root {
    --bg: #f1f5f9;
    --card: #ffffff;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --brand: #1d4ed8;
    --brand-dark: #1d4ed8;
    --ok: #15803d;
    --ok-bg: #dcfce7;
    --err: #b91c1c;
    --err-bg: #fee2e2;
    --warn: #92400e;
    --warn-bg: #fef3c7;
    --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    -webkit-text-size-adjust: 100%;
}

/* --------------------------------------------------------------- admin: bal oldali menü */

.admin-shell {
    display: flex;
    align-items: stretch;
    min-height: 100vh;
}

.admin-sidebar {
    position: relative;
    flex-shrink: 0;
    width: 256px;
    background: #fff;
    border-right: 1px solid var(--line);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    transition: width .3s ease, padding .3s ease;
}

.sidebar-toggle {
    position: absolute;
    right: -12px;
    top: 24px;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--muted);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
    padding: 0;
}

.sidebar-toggle svg { transition: transform .3s ease; }

.admin-brand {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    font-weight: 700;
    letter-spacing: .02em;
    color: var(--brand);
    font-size: 17px;
    padding: 0 8px;
    white-space: nowrap;
    overflow: hidden;
}

.admin-brand svg { flex-shrink: 0; }

.admin-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
}

.nav-item svg { flex-shrink: 0; }

.nav-item:hover { background: #f9fafb; color: var(--ink); }

.nav-item.is-active {
    background: #eff6ff;
    color: #1d4ed8;
}

.admin-main {
    flex: 1 1 auto;
    min-width: 0;
}

/* --------------------------------------------------------------- admin: osszecsukott allapot */

html.sidebar-collapsed .admin-sidebar {
    width: 64px;
    padding: 24px 8px;
}

html.sidebar-collapsed .admin-brand { padding: 0; }
html.sidebar-collapsed .admin-brand .brand-full { display: none; }

html.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 12px 8px;
}
html.sidebar-collapsed .nav-label { display: none; }

html.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }

/* --------------------------------------------------------------- admin: mobil hamburger menu */

.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 28px;
    right: 16px;
    z-index: 50;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: transparent;
    border: 0;
    box-shadow: none;
    align-items: center;
    justify-content: center;
    color: var(--brand);
    cursor: pointer;
    padding: 0;
}

.mobile-menu-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-menu-icon-close { display: none; }

.mobile-menu-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    z-index: 39;
}

@media (max-width: 900px) {
    .mobile-menu-toggle { display: flex; }

    .admin-sidebar {
        position: fixed;
        top: 0;
        right: 0;
        left: auto;
        height: 100vh;
        width: 256px !important;
        padding: 28px 16px 24px !important;
        transform: translateX(100%);
        transition: transform .25s ease;
        z-index: 40;
        border-right: 0;
        border-left: 1px solid var(--line);
        box-shadow: -4px 0 24px rgba(15, 23, 42, .18);
    }
    .admin-sidebar .sidebar-toggle { display: none; }
    .admin-brand {
        min-height: 42px;
        padding: 0 8px !important;
    }
    .admin-brand .brand-full { display: inline !important; }
    .nav-item { justify-content: flex-start !important; padding: 12px 16px !important; }
    .nav-label { display: inline !important; }

    .admin-main { padding-top: 0; }

    html.mobile-nav-open .admin-sidebar { transform: translateX(0); }
    html.mobile-nav-open .mobile-menu-backdrop { display: block; }
    html.mobile-nav-open { overflow: hidden; }
    html.mobile-nav-open .mobile-menu-icon-menu { display: none; }
    html.mobile-nav-open .mobile-menu-icon-close { display: flex; }
}

/* --------------------------------------------------------------- váz */

.wrap {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px 16px 48px;
}

.wrap.narrow { max-width: 480px; }

.admin-main .wrap {
    width: 100%;
    max-width: none;
    padding: 28px clamp(20px, 3vw, 48px) 48px;
}

h1 { font-size: 22px; margin: 8px 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.card > h2 { display: flex; align-items: center; gap: 8px; }
.card > h2 svg { flex-shrink: 0; color: var(--ink); }

.muted { color: var(--muted); font-size: 14px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.scan-code-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 20px;
    padding: 12px 14px;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    background: #eff6ff;
}

.scan-code-info {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
    flex-wrap: wrap;
}

.scan-code-label {
    color: var(--brand-dark);
    font-size: 15px;
    font-weight: 700;
}

.scan-code-value {
    color: var(--brand-dark);
    font-size: clamp(22px, 6vw, 30px);
    line-height: 1.1;
    letter-spacing: .16em;
    overflow-wrap: anywhere;
}

.scan-code-edit {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    color: var(--brand);
    background: rgba(255, 255, 255, .72);
    text-decoration: none;
}

.scan-code-edit:hover {
    background: #fff;
    color: var(--brand-dark);
}

/* --------------------------------------------------------------- űrlap */

label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 6px;
}

input[type=text], input[type=email], input[type=password], input[type=number], select {
    width: 100%;
    padding: 12px 14px;
    font-size: 17px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
}

input:focus, select:focus {
    outline: 3px solid #bfdbfe;
    border-color: var(--brand);
}

/* --------------------------------------------------------------- checkbox */

input[type=checkbox] {
    appearance: none;
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    border: 2px solid var(--line);
    border-radius: 7px;
    background: #fff;
    flex-shrink: 0;
    cursor: pointer;
    position: relative;
    margin: 0;
}

input[type=checkbox]:checked {
    background: var(--brand);
    border-color: var(--brand);
}

input[type=checkbox]:checked::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 6px;
    height: 11px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: translate(-50%, -60%) rotate(45deg);
    transform-origin: center;
}

input[type=checkbox]:focus-visible {
    outline: 3px solid #bfdbfe;
    outline-offset: 1px;
}

.check-row {
    display: flex;
    gap: 12px;
    align-items: center;
    font-weight: 600;
    cursor: pointer;
}

.field { margin-bottom: 14px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* --------------------------------------------------------------- címke fixen a mező tetején */
/*
 * Nincs animacio, nincs fokusztol/kitoltestol fuggo allapot: a cimke MINDIG
 * fent, kicsi meretben all - ures, kitoltott, fokuszalt vagy a bongeszo
 * altal automatikusan kitoltott mezonel is egyformán.
 */

.field-float {
    position: relative;
    margin-bottom: 14px;
}

.field-float input {
    padding-top: 20px;
    padding-bottom: 6px;
    padding-left: 11px;
}

.field-float label {
    position: absolute;
    left: 11px;
    top: 0;
    transform: translateY(-50%);
    margin: 0;
    padding: 0 3px;
    max-width: calc(100% - 22px);
    background: #fff;
    color: var(--ink);
    font-size: 11px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: none;
}

/* a nagybetűs, kozepre igazitott Neptun mezoknel a cimke is kozepen all */
.field-float.neptun-field label {
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.row > * { flex: 1 1 140px; min-width: 0; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 18px;
    font-size: 17px;
    font-weight: 600;
    border: 0;
    border-radius: 10px;
    background: var(--brand);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: #e2e8f0; color: var(--ink); }
.btn.danger { background: var(--err); }
.btn.auto { width: auto; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > * { flex: 1 1 140px; }

/* --------------------------------------------------------------- jelzések */

.msg {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 15px;
}
.msg.ok { background: var(--ok-bg); color: var(--ok); }
.msg.err { background: var(--err-bg); color: var(--err); }
.msg.warn { background: var(--warn-bg); color: var(--warn); }
.msg.info { background: #dbeafe; color: var(--brand-dark); }

.hidden { display: none !important; }

/* --------------------------------------------------------------- modal (natív <dialog>) */

.modal {
    border: 0;
    border-radius: var(--radius);
    padding: 0;
    width: min(720px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    background: var(--card);
    box-shadow: 0 20px 40px rgba(15, 23, 42, .25);
}

.modal::backdrop {
    background: rgba(15, 23, 42, .5);
}

.modal-box {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 64px);
}

.modal-confirm {
    width: min(520px, calc(100vw - 32px));
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 16px 0;
    flex-shrink: 0;
}

.modal-head h2 { margin: 0; }

.modal-close {
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    flex-shrink: 0;
}

.modal-close:hover { background: #f1f5f9; color: var(--ink); }

.modal-body {
    padding: 16px;
    overflow-y: auto;
}

/* --------------------------------------------------------------- listák */

.event-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.event-list li {
    border: 1px solid var(--line);
    background: var(--card);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
}

.event-list .name {
    font-size: 17px;
    font-weight: 700;
    text-decoration: none;
    color: var(--ink);
    display: block;
}

.event-title-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.event-title-row .name {
    flex: 1 1 auto;
    min-width: 0;
}

.event-list .meta { font-size: 13px; color: var(--muted); margin-top: 4px; }
.event-list .actions {
    display: flex;
    flex-shrink: 0;
    gap: 6px;
}

.event-list .icon-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .72);
    color: var(--muted);
    text-decoration: none;
}

.event-list .icon-action:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: var(--brand);
}

.event-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 20px;
}

.event-header h1 { margin: 0; }

.event-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.event-actions .btn {
    width: auto;
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .72);
    color: var(--muted);
    font-size: 13px;
    box-shadow: none;
}

.event-actions .btn:hover {
    background: #fff;
    border-color: #bfdbfe;
    color: var(--brand);
}

.event-actions .btn.danger {
    background: rgba(255, 247, 247, .72);
    border-color: #fecaca;
    color: var(--err);
}

.event-actions .btn.danger:hover {
    background: #fff1f2;
    border-color: #fca5a5;
    color: var(--err);
}

.event-actions .btn svg {
    flex-shrink: 0;
}

@media (max-width: 700px) {
    .event-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    .event-actions { justify-content: flex-start; }
}

@media (max-width: 1200px) {
    .event-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    .event-list { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------- csemperagos elrendezes (rendezveny oldal) */

.event-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
}

.event-grid .card { margin-bottom: 0; }
.event-grid .span-2 { grid-column: 1 / -1; }

@media (max-width: 800px) {
    .event-grid { grid-template-columns: 1fr; }
}

table { width: 100%; border-collapse: collapse; font-size: 15px; table-layout: fixed; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
th { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
td.num, th.num { text-align: right; }
td.truncate {
    max-width: 1px; /* a table-layout:fixed miatt ez szabja meg a tenyleges oszlopszelesseget */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    color: var(--muted);
}
.icon-btn:hover { background: #f1f5f9; color: var(--ink); }
.icon-btn.danger { color: var(--err); }
.icon-btn.danger:hover { background: var(--err-bg); }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: #dbeafe;
    color: var(--brand-dark);
}
.badge.off { background: #fee2e2; color: var(--err); }

/* --------------------------------------------------------------- Neptun bevitel */

.neptun-input {
    text-transform: uppercase;
    letter-spacing: .35em;
    font-size: 28px !important;
    text-align: center;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    padding: 26px 10px 12px !important;
}

.countdown {
    font-size: 15px;
    font-weight: 700;
    color: var(--brand-dark);
}

/* --------------------------------------------------------------- olvasó */

#scanner { position: relative; }

.video-box {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
}

.video-box video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.video-box .frame {
    position: absolute;
    inset: 12%;
    border: 3px solid rgba(255, 255, 255, .9);
    border-radius: 12px;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .28);
}

.result {
    margin-top: 24px;
    padding: 30px 24px 28px;
    border-radius: 20px;
    text-align: center;
    font-size: 18px;
    font-weight: 700;
}
.result.ok {
    background: linear-gradient(145deg, #f0fdf4 0%, #ecfdf5 100%);
    border: 1px solid #bbf7d0;
    color: var(--ink);
    box-shadow: 0 12px 28px rgba(21, 128, 61, .12);
}
.result.err { background: var(--err-bg); color: var(--err); }

.big-ok {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin: 0 auto 18px;
    border-radius: 50%;
    background: var(--ok);
    color: #fff;
    font-size: 38px;
    line-height: 1;
    box-shadow: 0 8px 18px rgba(21, 128, 61, .25);
}

.success-message {
    color: var(--ok);
    font-size: 20px;
    line-height: 1.3;
}

.success-event-label {
    margin-top: 24px;
    color: var(--brand-dark);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.success-event {
    margin-top: 5px;
    color: var(--brand-dark);
    font-size: 24px;
    font-weight: 800;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

/* --------------------------------------------------------------- QR kijelző */

body.qr-screen {
    background: #000;
    height: 100vh;
    overflow: hidden;
}

#qr-stage {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

#qr-holder {
    width: 80vmin;
    height: 80vmin;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

#qr-holder svg { width: 100%; height: 100%; display: block; }

#qr-overlay {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 14px 16px;
    background: rgba(0, 0, 0, .82);
    color: #e2e8f0;
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    font-size: 14px;
    transform: translateY(110%);
    transition: transform .18s ease-out;
}

#qr-overlay.is-open { transform: translateY(0); }
#qr-overlay a { color: #93c5fd; }
#qr-overlay .spacer { margin-left: auto; }

#qr-error {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 10px 16px;
    background: #b91c1c;
    color: #fff;
    font-size: 14px;
    text-align: center;
}
