/* ============================================================
   AITU Queue — единая дизайн-система
   Используется на всех страницах. Без сборки, без зависимостей.
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
    /* Brand */
    --aitu-navy: #0b1f3a;
    --aitu-navy-2: #122b4f;
    --aitu-blue: #2d7ff9;
    --aitu-blue-dark: #1b5fd0;
    --aitu-cyan: #19c2d6;
    --aitu-violet: #7c5cff;
    --aitu-amber: #f5a623;

    /* Semantic */
    --primary: var(--aitu-blue);
    --primary-dark: var(--aitu-blue-dark);
    --success: #2bb673;
    --warning: #f5a623;
    --danger: #e5484d;
    --info: #19c2d6;

    /* Ticket types */
    --type-basic: var(--aitu-blue);
    --type-benefit: var(--aitu-violet);

    /* Surfaces (light UI) */
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #f0f3f9;
    --border: #e3e8f0;
    --text: #1a2233;
    --text-muted: #6b7689;

    /* Misc */
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 6px 24px rgba(11, 31, 58, 0.08);
    --shadow-lg: 0 12px 40px rgba(11, 31, 58, 0.16);
    --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    --space: 16px;
    --maxw: 1180px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0 0 .5em; font-weight: 700; letter-spacing: -0.01em; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ---------- Layout ---------- */
.page { min-height: 100%; display: flex; flex-direction: column; }
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.container--narrow { max-width: 460px; }
.main { flex: 1; padding: 28px 0 48px; }
.stack > * + * { margin-top: var(--space); }
.grid { display: grid; gap: var(--space); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.row { display: flex; gap: var(--space); flex-wrap: wrap; }
.center { text-align: center; }
.muted { color: var(--text-muted); }
.spacer { flex: 1; }
@media (max-width: 900px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ---------- Header / Brand ---------- */
.appbar {
    background: var(--aitu-navy);
    color: #fff;
    box-shadow: var(--shadow);
}
.appbar .container {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 64px;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 1.15rem; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-logo {
    width: 38px; height: 38px; border-radius: 10px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--aitu-blue), var(--aitu-cyan));
    font-weight: 900; color: #fff; font-size: 1rem;
    object-fit: contain;
}
img.brand-logo { background: none; }

/* Переключатель языка */
.lang-toggle { display: inline-flex; border: 1px solid rgba(255,255,255,.25); border-radius: 999px; overflow: hidden; margin-left: 8px; }
.lang-toggle button {
    background: transparent; color: rgba(255,255,255,.75); border: 0; cursor: pointer;
    font-family: inherit; font-weight: 700; font-size: .8rem; padding: 6px 12px;
}
.lang-toggle button.on { background: var(--aitu-blue); color: #fff; }
.board .lang-toggle { border-color: rgba(255,255,255,.3); }
.appbar .nav { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.appbar .nav a { color: rgba(255,255,255,.82); padding: 8px 12px; border-radius: 8px; font-size: .92rem; }
.appbar .nav a:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.appbar .clock { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
}
.card__title { font-size: 1.1rem; margin-bottom: 14px; }

/* ---------- Stat cards ---------- */
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}
.stat::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
    background: var(--accent, var(--primary));
}
.stat__label { color: var(--text-muted); font-size: .9rem; font-weight: 600; }
.stat__value { font-size: 2.4rem; font-weight: 800; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat--blue { --accent: var(--aitu-blue); }
.stat--green { --accent: var(--success); }
.stat--amber { --accent: var(--warning); }
.stat--violet { --accent: var(--aitu-violet); }
.stat--cyan { --accent: var(--info); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 0; cursor: pointer;
    font-family: inherit; font-size: 1rem; font-weight: 600;
    padding: 11px 20px; border-radius: var(--radius-sm);
    background: var(--surface-2); color: var(--text);
    transition: transform .06s ease, box-shadow .15s ease, background .15s ease, opacity .15s;
    text-decoration: none;
}
.btn:hover { text-decoration: none; box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-dark); }
.btn--success { background: var(--success); color: #fff; }
.btn--danger  { background: var(--danger); color: #fff; }
.btn--ghost   { background: transparent; border: 1px solid var(--border); }
.btn--lg { font-size: 1.25rem; padding: 16px 28px; }
.btn--block { display: flex; width: 100%; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 6px; color: var(--text); }
.input {
    width: 100%; font-family: inherit; font-size: 1.05rem;
    padding: 13px 15px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(45,127,249,.18); }
.input--code {
    text-align: center; letter-spacing: .5em; font-size: 1.8rem; font-weight: 700; padding-left: .5em;
}

/* ---------- Alerts ---------- */
.alert { padding: 13px 16px; border-radius: var(--radius-sm); font-size: .95rem; border: 1px solid transparent; }
.alert--info    { background: #e7f6fb; color: #0b6b7d; border-color: #bfe9f1; }
.alert--success { background: #e6f7ee; color: #136b41; border-color: #bfead2; }
.alert--danger  { background: #fdecec; color: #a3252a; border-color: #f6c9cb; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
    font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
}
.badge--basic   { background: rgba(45,127,249,.14); color: var(--type-basic); }
.badge--benefit { background: rgba(124,92,255,.16); color: var(--type-benefit); }
.badge--served  { background: rgba(43,182,115,.15); color: var(--success); }
.badge--check   { background: rgba(245,166,35,.18); color: #9a6400; }
.badge--cancel  { background: rgba(229,72,77,.14); color: var(--danger); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tbl th, .tbl td { padding: 13px 16px; text-align: left; }
.tbl thead th { background: var(--surface-2); color: var(--text-muted); font-weight: 700; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
.tbl tbody tr { border-top: 1px solid var(--border); }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .num { font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums; }

/* ---------- Ticket tile (вызванные номера) ---------- */
.tiles { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; }
.tile {
    min-width: 150px; border-radius: 20px; padding: 22px 26px; text-align: center;
    color: #fff; box-shadow: var(--shadow-lg);
    background: linear-gradient(135deg, var(--type-basic), var(--aitu-blue-dark));
    animation: tile-in .35s ease;
}
.tile--benefit { background: linear-gradient(135deg, var(--type-benefit), #5a3fd6); }
/* Цвет по секции: проверка документов — синяя, приглашение к столу — зелёная */
.tile--check  { background: linear-gradient(135deg, var(--aitu-blue), var(--aitu-blue-dark)); }
.tile--served { background: linear-gradient(135deg, var(--success), #1e8f5a); }
.tile__num { font-size: 3.4rem; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.tile__where { font-size: 1.15rem; opacity: .92; margin-top: 6px; }
.tile__badge { display: inline-block; margin-bottom: 6px; font-size: .8rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em; opacity: .9; }
@keyframes tile-in { from { opacity: 0; transform: scale(.85) translateY(10px); } to { opacity: 1; transform: none; } }

/* Подсветка последнего вызванного талона */
.tile--latest {
    box-shadow: 0 0 0 4px rgba(255,255,255,.9), 0 0 28px 6px rgba(255,255,255,.5), var(--shadow-lg);
    animation: tile-pulse 1.5s ease-in-out infinite;
    position: relative;
}
.tile--latest::after {
    content: attr(data-now); position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
    background: #fff; color: var(--aitu-navy); font-size: .72rem; font-weight: 800;
    padding: 3px 10px; border-radius: 999px; letter-spacing: .05em;
}
@keyframes tile-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

/* ---------- QR ---------- */
.qr-card { background: #fff; padding: 16px; border-radius: 18px; display: inline-block; box-shadow: var(--shadow-lg); }
.qr-card img, .qr-card canvas { display: block; }

/* ---------- Toast ---------- */
.toast-host { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 9999; }
.toast {
    background: var(--aitu-navy); color: #fff; padding: 13px 18px; border-radius: 12px;
    box-shadow: var(--shadow-lg); font-weight: 600; animation: toast-in .25s ease; max-width: 340px;
}
.toast--success { background: var(--success); }
.toast--danger  { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- Empty state ---------- */
.empty { text-align: center; color: var(--text-muted); padding: 32px 16px; font-size: 1rem; }

/* ============================================================
   BOARD MODE — публичные табло (большие экраны)
   <body class="board"> ... включает тёмную тему и крупный шрифт
   ============================================================ */
body.board {
    background: var(--aitu-navy);
    color: #fff;
}
body.board .board-bg {
    position: fixed; inset: 0; z-index: 0;
    background:
        radial-gradient(900px 600px at 15% 0%, rgba(45,127,249,.20), transparent 55%),
        radial-gradient(800px 600px at 100% 100%, rgba(124,92,255,.18), transparent 55%);
    pointer-events: none;
}
.board-wrap { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; padding: 28px 36px; }
.board-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.board-head .brand { font-size: 1.5rem; }
.board-head .clock { margin-left: auto; font-size: 2.2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.board-title { font-size: 1.7rem; color: rgba(255,255,255,.85); margin: 24px 0 14px; font-weight: 600; }
.board-cols { display: grid; grid-template-columns: 1.6fr 1fr; gap: 32px; flex: 1; }
.board .tile { min-width: 200px; }
.board .tile__num { font-size: 5rem; }
.board .tile__where { font-size: 1.5rem; }
.board .qr-block { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.board .qr-block .hint { font-size: 1.25rem; text-align: center; color: rgba(255,255,255,.9); max-width: 320px; }
/* Контейнер видео 16:9 = совпадает с роликом → без чёрных рамок */
.video-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 18px; overflow: hidden; box-shadow: var(--shadow-lg); background: #000; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
@media (max-width: 1000px) {
    .board-cols { grid-template-columns: 1fr; }
}

/* ---------- Utilities ---------- */
.hidden { display: none !important; }
.mt-0 { margin-top: 0; }
.mt { margin-top: var(--space); }
.mb { margin-bottom: var(--space); }
