/*
  KOFA site: the shared look of every page of kofa.kncsk.hu (home, Komod store, account, admin, translation, docs).
  Tokens and header come from the home page; home/home.css and docs/docs.css only add their own sections.
  Markup of the header, the side menu and the footer: Pages/SiteChrome.cs.
*/
:root {
    --bg: #f5f7fa;
    --bg-alt: #eaeef4;
    --surface: #ffffff;
    --text: #141a22;
    --muted: #5a6573;
    --border: #d8dee6;
    --accent: #0f6cbd;
    --accent-2: #12a08a;
    --accent-text: #ffffff;
    --glow: rgba(15, 108, 189, .14);
    --ok: #107c10;
    --warn: #b7791f;
    --danger: #c42b1c;
    --mono: ui-monospace, "Cascadia Code", SFMono-Regular, Menlo, Consolas, monospace;
    --header: 60px;
    --side: 248px;
    --side-collapsed: 60px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0e1116;
        --bg-alt: #141922;
        --surface: #1a2029;
        --text: #e9edf2;
        --muted: #98a3b1;
        --border: #2b3340;
        --accent: #4f9fe8;
        --accent-2: #39c9a9;
        --accent-text: #08131f;
        --glow: rgba(79, 159, 232, .18);
        --ok: #6ccb5f;
        --warn: #e0a63a;
        --danger: #ef6f61;
        color-scheme: dark;
    }
}

/* Language: pages with both texts in the markup (home) show one by the html data-lang attribute. */
html[data-lang="hu"] body [lang="en"],
html[data-lang="en"] body [lang="hu"] { display: none !important; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header) + 12px); }
body { margin: 0; font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; font-weight: normal; }
code, .key { font-family: var(--mono); font-size: .86em; }

/* ---------- Header (the same on every page) ---------- */
.top {
    position: sticky; top: 0; z-index: 30;
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.top-inner { display: flex; align-items: center; gap: 22px; height: var(--header); padding: 0 20px; max-width: 1440px; margin: 0 auto; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; color: var(--text); letter-spacing: .02em; }
.logo:hover { text-decoration: none; }
.menu { display: flex; gap: 20px; flex: 1; min-width: 0; }
.menu a { color: var(--muted); font-size: .95rem; white-space: nowrap; }
.menu a:hover { color: var(--text); text-decoration: none; }
.menu a.active { color: var(--text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); padding-bottom: 18px; margin-bottom: -20px; }
.top-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.lang-switch { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.lang-switch a, .lang-switch button {
    background: none; border: 0; color: var(--muted); font: inherit; font-size: .8rem; font-weight: 700;
    padding: 4px 9px; cursor: pointer; letter-spacing: .04em;
}
.lang-switch a:hover { text-decoration: none; color: var(--text); }
html[data-lang="hu"] .lang-switch [data-set-lang="hu"],
html[data-lang="en"] .lang-switch [data-set-lang="en"] { background: var(--bg-alt); color: var(--text); }
.menu-toggle, .side-toggle {
    display: none; background: none; border: 1px solid var(--border); border-radius: 8px;
    color: var(--text); font-size: 1.1rem; line-height: 1; padding: 6px 10px; cursor: pointer;
}
.avatar { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 999px; padding: 3px 12px 3px 3px; color: var(--text); background: var(--surface); font-size: .9rem; max-width: 220px; }
.avatar:hover { text-decoration: none; border-color: var(--accent); }
.avatar img, .avatar .initial { width: 26px; height: 26px; border-radius: 50%; flex: none; }
.avatar .initial { display: grid; place-items: center; background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: .8rem; }
.avatar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gh-icon { width: 16px; height: 16px; fill: currentColor; flex: none; }

/* ---------- Buttons ---------- */
.btn, .button, button {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 8px 16px; border-radius: 8px; border: 1px solid var(--accent);
    background: var(--accent); color: var(--accent-text); font: inherit; font-weight: 600; font-size: .95rem;
    cursor: pointer; white-space: nowrap; transition: transform .15s, box-shadow .15s;
}
.btn:hover, .button:hover { text-decoration: none; box-shadow: 0 6px 18px -8px var(--accent); }
.btn-small { padding: 5px 12px; font-size: .88rem; }
.btn-ghost, .button.secondary, button.secondary { background: transparent; color: var(--accent); }
.btn-quiet { background: var(--surface); color: var(--text); border-color: var(--border); }
button.danger, .button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
button.danger.solid { background: var(--danger); color: #fff; }
button:disabled, .btn-disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

/* ---------- App shell: side menu + content ---------- */
.shell { display: flex; max-width: 1440px; margin: 0 auto; min-height: calc(100vh - var(--header)); }
.side {
    position: sticky; top: var(--header); align-self: flex-start; flex: none;
    width: var(--side); height: calc(100vh - var(--header)); overflow: auto;
    border-right: 1px solid var(--border); padding: 16px 10px 20px;
    display: flex; flex-direction: column; gap: 2px; transition: width .2s;
}
.side .group { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 12px 4px; white-space: nowrap; }
.side a {
    display: flex; align-items: center; gap: 12px; padding: 7px 12px; border-radius: 8px;
    color: var(--muted); font-size: .93rem; white-space: nowrap; border-left: 2px solid transparent;
}
.side a:hover { background: var(--bg-alt); color: var(--text); text-decoration: none; }
.side a.active { color: var(--accent); background: var(--bg-alt); border-left-color: var(--accent); font-weight: 600; }
.side .icon { width: 20px; flex: none; text-align: center; font-size: 1rem; }
.side .count { margin-left: auto; font-size: .72rem; background: var(--bg-alt); border-radius: 999px; padding: 0 8px; }
.side .mobile-only { display: none; }
/* The account's pages: always below the page's own menu (docs contents, phone main menu). */
.side-account { display: flex; flex-direction: column; gap: 2px; }
.side.has-contents .side-account { margin-top: 12px; padding-top: 6px; border-top: 1px solid var(--border); }
.side-fold {
    margin-top: auto; background: none; border: 1px solid var(--border); color: var(--muted);
    font-weight: 500; font-size: .85rem; justify-content: flex-start; padding: 6px 12px;
}
.side-fold:hover { color: var(--text); box-shadow: none; }
html.side-collapsed .side { width: var(--side-collapsed); }
html.side-collapsed .side .group, html.side-collapsed .side .label, html.side-collapsed .side .count { display: none; }
html.side-collapsed .side-fold .label { display: none; }
.content { flex: 1; min-width: 0; padding: 28px 36px 64px; }
.content-narrow { max-width: 1040px; margin: 0 auto; padding: 28px 20px 64px; }

/* ---------- Page parts ---------- */
.page-head { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.eyebrow { margin: 0 0 4px; color: var(--accent); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
h1 { font-size: 1.75rem; line-height: 1.25; margin: 0 0 6px; text-wrap: balance; }
h2 { font-size: 1.2rem; line-height: 1.3; margin: 32px 0 12px; text-wrap: balance; }
h3 { font-size: 1.02rem; margin: 0 0 4px; }
.lead { color: var(--muted); max-width: 70ch; margin: 0; }
.notice { padding: 10px 14px; border-radius: 8px; border: 1px solid var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); margin: 0 0 16px; }
.notice.error { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.notice.warn { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, transparent); }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; color: var(--text); min-width: 0; }
a.card:hover { border-color: var(--accent); text-decoration: none; box-shadow: 0 10px 30px -18px var(--accent); }
.card .meta { font-size: .84rem; color: var(--muted); }
.card p { margin: 8px 0 0; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; font-size: .93rem; }
th { font-size: .76rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
tr:last-child td { border-bottom: none; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

input, select, textarea {
    font: inherit; padding: 8px 11px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--glow); border-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { padding: 0; accent-color: var(--accent); }
form.inline { display: inline; }
form.stack { display: grid; gap: 16px; max-width: 580px; }
form.stack label, .field { display: grid; gap: 5px; font-weight: 600; font-size: .95rem; }
form.stack label > .muted, .field > .muted { font-weight: 400; font-size: .86rem; }
form.stack textarea { min-height: 120px; resize: vertical; }
.check { display: flex !important; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; font-weight: 400 !important; }
.check input { margin-top: 5px; }
.field-error { color: var(--danger); font-weight: 400; font-size: .86rem; }
input.quota { width: 9em; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stack-sm { display: grid; gap: 8px; }

.key { display: block; padding: 12px; border-radius: 8px; background: var(--bg-alt); border: 1px dashed var(--accent); word-break: break-all; }
.tag, .pill { display: inline-flex; align-items: center; gap: 4px; font-size: .74rem; font-weight: 600; padding: 1px 9px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.tag.ok { border-color: var(--ok); color: var(--ok); }
.tag.bad { border-color: var(--danger); color: var(--danger); }
.tag.warn { border-color: var(--warn); color: var(--warn); }
.tag.accent { border-color: var(--accent); color: var(--accent); }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }

.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 6px; }
.filter { display: inline-flex; gap: 6px; align-items: center; padding: 4px 13px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: .9rem; }
.filter:hover { border-color: var(--accent); text-decoration: none; }
.filter.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.filter .count { font-size: .76rem; opacity: .75; }

/* Settings rows (account page) */
.settings { display: grid; padding: 4px 18px; }
.settings .line { display: flex; flex-wrap: wrap; gap: 10px 16px; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); }
.settings .line:last-child { border-bottom: 0; }
.settings .line > div { min-width: 0; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.danger-zone h2 { margin-top: 0; color: var(--danger); font-size: 1.05rem; }

/* Devices (Gépeim) */
.devices { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.device { display: grid; gap: 10px; align-content: start; }
.device-head { display: flex; align-items: center; gap: 10px; }
.device-head h3 { margin: 0; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.status { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.status.live { background: var(--accent-2); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent-2) 22%, transparent); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; font-size: .86rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.device details { font-size: .9rem; }
.device details summary { cursor: pointer; color: var(--accent); }
.device ul { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.device li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; justify-content: space-between; }
.code-input { font-family: var(--mono); letter-spacing: .18em; text-transform: uppercase; width: 12em; }
.app-link { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; }
.app-link-qr { background: #fff; border-radius: 10px; padding: 10px; line-height: 0; flex: 0 0 auto; margin: 0 auto; }
.app-link-qr img { width: min(296px, 70vw); height: auto; image-rendering: pixelated; }
.app-link-qr.faded img { opacity: .15; }
.app-link > .stack-sm { flex: 1 1 260px; min-width: 0; }
.app-link-steps { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; }
.device-code { font: 700 2rem/1.2 var(--mono); letter-spacing: .14em; padding: 14px 18px; border: 1px dashed var(--accent); border-radius: 10px; display: inline-block; }

/* Sign-in / registration card */
.auth { display: grid; place-items: start center; padding: 24px 0 40px; }
.auth .card { width: min(520px, 100%); padding: 26px; display: grid; gap: 16px; }
.auth form.stack { max-width: none; }
.gh-id { display: flex; gap: 12px; align-items: center; padding: 10px 12px; background: var(--bg-alt); border-radius: 10px; font-size: .92rem; }
.gh-id img { width: 36px; height: 36px; border-radius: 50%; }

/* Store pages */
.readme { line-height: 1.6; overflow-wrap: anywhere; }
.readme img { max-width: 100%; height: auto; border-radius: 8px; }
.readme pre { overflow-x: auto; padding: 12px; border-radius: 8px; background: var(--bg-alt); border: 1px solid var(--border); }
.readme table { border-collapse: collapse; }
.readme th, .readme td { border: 1px solid var(--border); padding: 4px 8px; }
.readme blockquote { margin: 0; padding-left: 12px; border-left: 3px solid var(--border); color: var(--muted); }
.eula-text { white-space: pre-wrap; font: inherit; line-height: 1.6; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }

/* Community translation (Pages/Forditas) */
.progress { width: 120px; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent-2); }
.admin-tools { margin-top: 6px; font-size: .9rem; }
.admin-tools summary { cursor: pointer; color: var(--muted); }
.admin-tools form { margin-top: 6px; }
.translations { display: grid; gap: 12px; margin: 12px 0; }
.translation { display: grid; gap: 8px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.translation header code { overflow-wrap: anywhere; }
.translation .sources { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.translation .sources p { margin: 2px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.translation label.form { display: grid; gap: 2px; }
.translation textarea { width: 100%; min-height: 3em; resize: vertical; font: inherit; }
.translation textarea[readonly] { background: var(--bg-alt); }
.history-value { white-space: pre-line; overflow-wrap: anywhere; max-width: 320px; }

/* ---------- Footer ---------- */
.foot { border-top: 1px solid var(--border); padding: 26px 0; color: var(--muted); font-size: .88rem; }
.foot-inner { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; justify-content: space-between; }
.foot nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.foot a { color: var(--muted); }
.shell + .foot, .content + .foot { margin-top: 0; }

/* ---------- Narrow screens: the top menu moves into the side drawer ---------- */
@media (max-width: 900px) {
    .menu { display: none; }
    .menu-toggle { display: inline-block; }
    .top-inner { gap: 12px; padding: 0 16px; }
    .avatar .name, .btn-signin .label { display: none; }
    .avatar { padding: 3px; }
    .side {
        position: fixed; top: var(--header); left: 0; bottom: 0; height: auto; align-self: stretch; z-index: 25;
        width: min(300px, 86vw); background: var(--bg); transform: translateX(-102%);
        transition: transform .2s; box-shadow: 12px 0 30px -14px rgba(0, 0, 0, .4);
    }
    html.side-collapsed .side { width: min(300px, 86vw); }
    html.side-collapsed .side .group, html.side-collapsed .side .label, html.side-collapsed .side .count { display: revert; }
    html.drawer-open .side { transform: none; }
    .side .mobile-only { display: flex; }
    .side .group.mobile-only { display: block; }
    .side .side-account { margin-top: 12px; padding-top: 6px; border-top: 1px solid var(--border); }
    .side-fold { display: none; }
    .content { padding: 20px 16px 48px; }
    .content-narrow { padding: 20px 16px 48px; }
    .wrap { padding: 0 16px; }
}

/* Pages without an account side menu still get the drawer on phones (it only holds the top menu then). */
.side.drawer-only { display: none; }
@media (max-width: 900px) { .side.drawer-only { display: flex; } }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .side, .btn, .button, button { transition: none; }
}

/* Content width: with the side menu it fills the rest, without it (anonymous visitor) it is centred. */
.content { max-width: 1240px; }
.side.drawer-only + .content { margin: 0 auto; }
@media (min-width: 901px) { .side.drawer-only + .content { padding-left: 20px; padding-right: 20px; } }

/* Admin: visitor statistics (Pages/Admin/Statisztika.cshtml) */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 14px 0; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.stat-label { font-size: .8rem; color: var(--muted); }
.stat-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.25; }
.stat-change { font-size: .8rem; font-weight: 600; color: var(--muted); }
.stat-change.up { color: var(--ok); }
.stat-change.down { color: var(--danger); }
.stat-legend { display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); margin-bottom: 8px; }
.stat-legend .key { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-left: 8px; }
.stat-legend .key:first-child { margin-left: 0; }
.stat-legend .key.views, .stat-chart .fill.views { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.stat-legend .key.visitors, .stat-chart .fill.visitors { background: var(--accent); }
.stat-chart { display: flex; align-items: flex-end; gap: 2px; height: 180px; padding-bottom: 18px; overflow: hidden; }
.stat-chart .bar { position: relative; flex: 1 1 0; min-width: 0; height: 100%; display: flex; align-items: flex-end; }
.stat-chart .bar:hover .fill.views { background: color-mix(in srgb, var(--accent) 55%, transparent); }
.stat-chart .fill { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 3px 3px 0 0; }
.stat-chart .fill.visitors { left: 22%; right: 22%; }
.stat-chart .tick { position: absolute; top: 100%; left: 0; font-size: .68rem; color: var(--muted); white-space: nowrap; margin-top: 3px; }
.stat-tables { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; margin: 16px 0; }
.stat-table h3 { margin: 0 0 8px; font-size: 1rem; }
.stat-table ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.stat-table li { position: relative; display: flex; justify-content: space-between; gap: 10px; padding: 3px 8px; border-radius: 6px; font-size: .88rem; }
.stat-table li::before { content: ""; position: absolute; inset: 0; width: var(--share); background: color-mix(in srgb, var(--accent) 12%, transparent); border-radius: 6px; }
.stat-table .name { position: relative; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.stat-table .count { position: relative; font-variant-numeric: tabular-nums; color: var(--muted); }
