/* PathLogger — dark UI, Twitch-purple accent. */

:root {
    --bg: #0d0e13;
    --surface: #14161d;
    --surface-2: #1b1e27;
    --surface-3: #232734;
    --border: #272b38;
    --text: #e7e9ef;
    --muted: #99a0b2;
    --accent: #9146ff;
    --accent-soft: #9146ff26;
    --cyan: #37d3f5;
    --good: #5ef2a0;
    --warn: #ffcc66;
    --bad: #ff5c7a;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
    --sidebar-w: 320px;
    --header-h: 60px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(2rem, 5vw, 3.2rem); letter-spacing: -.02em; }
h2 { font-size: 1.5rem; letter-spacing: -.01em; }
h3 { font-size: 1.05rem; }

code {
    font-family: var(--mono);
    font-size: .875em;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: .1em .4em;
}

/* ---------- header / footer ---------- */

.site-header {
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 1.25rem;
    background: rgba(13, 14, 19, .85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 900;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    color: var(--text);
    font-size: 1.05rem;
    letter-spacing: -.01em;
}
.brand:hover { text-decoration: none; }
.brand strong { color: var(--accent); font-weight: 700; }
.brand-mark { width: 26px; height: 26px; color: var(--accent); }

.site-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: .925rem;
}
.site-nav > a { color: var(--muted); }
.site-nav > a:hover { color: var(--text); text-decoration: none; }
.site-nav > a.is-active { color: var(--text); }

.nav-user {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    color: var(--muted);
}
.nav-user img { border-radius: 50%; display: block; }

/* Keep the header on one line on phones: the avatar carries identity, and the
   nav labels matter more than the display name. */
@media (max-width: 620px) {
    .site-header { padding: 0 .8rem; gap: .5rem; }
    .site-nav { gap: .7rem; font-size: .875rem; }
    .nav-user span, .nav-user { font-size: 0; gap: 0; }
    .nav-user img { width: 24px; height: 24px; }
    .site-nav .btn { padding: .45rem .7rem; white-space: nowrap; }
    .brand span { font-size: .95rem; }
}

@media (max-width: 400px) {
    .brand span { display: none; }
}

.site-footer {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.5rem;
    justify-content: space-between;
    padding: 2rem 1.25rem;
    color: var(--muted);
    font-size: .85rem;
    border-top: 1px solid var(--border);
}

/* ---------- buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .55rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: .925rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { text-decoration: none; background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn-lg { padding: .8rem 1.4rem; font-size: 1rem; }

.btn-primary, .btn-twitch {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover, .btn-twitch:hover { background: #a267ff; }

.btn-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}
.btn-ghost:hover { background: var(--surface-2); }

.btn-danger { background: transparent; border-color: #5a2733; color: var(--bad); }
.btn-danger:hover { background: #2a1119; }

.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- alerts ---------- */

.alert {
    padding: .8rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    margin: 1.25rem auto;
    max-width: 1120px;
    font-size: .925rem;
}
.alert-error { border-color: #5a2733; background: #24121a; color: #ffc4cf; }
.alert-warn { border-color: #5a4a22; background: #241f12; color: #ffe4ad; }
.alert-ok { border-color: #235240; background: #10231c; color: #b6f5d8; }

/* ---------- landing ---------- */

.landing {
    max-width: 1120px;
    margin: 0 auto;
    padding: 1rem 1.25rem 4rem;
}

.hero {
    display: grid;
    grid-template-columns: 1.1fr .9fr;
    gap: 3rem;
    align-items: center;
    padding: 3.5rem 0 4rem;
}
.hero-copy .lede {
    font-size: 1.125rem;
    color: var(--muted);
    max-width: 46ch;
}
.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-top: 1.75rem;
}
.hint { color: var(--muted); font-size: .85rem; margin: .75rem 0 0; flex-basis: 100%; }
.hero-map { width: 100%; height: auto; border-radius: 14px; box-shadow: var(--shadow); }

.steps { padding: 2rem 0; }
.step-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0 0;
    padding: 0;
    counter-reset: step;
}
.step-list li {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.step-list p { color: var(--muted); font-size: .9rem; margin: 0; }
.step-num {
    display: inline-grid;
    place-items: center;
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
    font-size: .85rem;
    margin-bottom: .6rem;
}

.install-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    margin: 2rem 0;
}
.install-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1.25rem 0; }
.key-reveal { margin: 1rem 0 1.5rem; }
.key-reveal summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.api-key {
    display: block;
    margin-top: .5rem;
    padding: .7rem .9rem;
    word-break: break-all;
    font-size: .8rem;
    background: var(--bg);
}

/* ---------- masked API key ---------- */

.key-field {
    display: flex;
    align-items: stretch;
    gap: .5rem;
    margin-top: .25rem;
}
.key-field .api-key {
    flex: 1;
    min-width: 0;
    margin-top: 0;
    display: flex;
    align-items: center;
    /* Dots are wide; keep the box from jumping when the real key appears. */
    letter-spacing: .18em;
    color: var(--muted);
    user-select: none;
}
.key-field .api-key.is-revealed {
    letter-spacing: normal;
    color: var(--text);
    user-select: all;
}
.btn-sm { padding: .4rem .7rem; font-size: .85rem; white-space: nowrap; }

@media (max-width: 520px) {
    .key-field { flex-wrap: wrap; }
    .key-field .api-key { flex-basis: 100%; }
}

.faq { padding: 2rem 0 0; }
.faq details {
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
}
.faq summary { cursor: pointer; font-weight: 500; }
.faq p { color: var(--muted); margin: .75rem 0 0; max-width: 70ch; }

@media (max-width: 860px) {
    .hero { grid-template-columns: 1fr; gap: 2rem; padding-top: 2rem; }
    .hero-visual { order: -1; }
}

/* ---------- generic page (settings / profile intro) ---------- */

.page {
    max-width: 800px;
    margin: 0 auto;
    padding: 2.5rem 1.25rem 4rem;
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}
.card h2 { margin-top: 0; }
.card p { color: var(--muted); }

.field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.switch { display: inline-flex; align-items: center; gap: .65rem; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
    width: 42px; height: 24px;
    border-radius: 999px;
    background: var(--surface-3);
    border: 1px solid var(--border);
    position: relative;
    transition: background .15s;
    flex: none;
}
.switch-track::after {
    content: "";
    position: absolute;
    top: 2px; left: 2px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform .15s, background .15s;
}
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* ---------- dashboard shell ---------- */

.page-dashboard { overflow: hidden; }

.dash {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    height: calc(100vh - var(--header-h));
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}
.sidebar::-webkit-scrollbar { width: 10px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 6px; }

.panel { border-bottom: 1px solid var(--border); padding-bottom: 1.1rem; }
.panel:last-child { border-bottom: 0; padding-bottom: 0; }
.panel > h3 {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--muted);
    margin: 0 0 .75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.panel-action {
    font-size: .72rem;
    letter-spacing: 0;
    text-transform: none;
    color: var(--cyan);
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}
.panel-action:hover { text-decoration: underline; }

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .6rem;
}
.stat {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .6rem .7rem;
}
.stat-value { font-size: 1.15rem; font-weight: 600; letter-spacing: -.02em; }
.stat-label { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

label.control { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .3rem; }

input[type="date"],
input[type="search"],
input[type="text"],
select {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    font-size: .875rem;
    padding: .45rem .6rem;
    color-scheme: dark;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.date-row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }

.chip-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.chip {
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--muted);
    border-radius: 999px;
    padding: .25rem .65rem;
    font-size: .78rem;
    cursor: pointer;
    font-family: inherit;
    transition: background .12s, color .12s, border-color .12s;
}
.chip:hover { color: var(--text); }
.chip.is-on { background: var(--accent-soft); border-color: var(--accent); color: #cbb2ff; }

.check-list {
    max-height: 260px;
    overflow-y: auto;
    margin-top: .6rem;
    display: flex;
    flex-direction: column;
    gap: .1rem;
}
.check-list::-webkit-scrollbar { width: 8px; }
.check-list::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 6px; }

.check {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .3rem .35rem;
    border-radius: 6px;
    font-size: .85rem;
    cursor: pointer;
}
.check:hover { background: var(--surface-2); }
.check input { accent-color: var(--accent); flex: none; }
.check-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check-count { margin-left: auto; color: var(--muted); font-size: .75rem; flex: none; }
.check-swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }

.map-wrap { position: relative; }
#map { width: 100%; height: 100%; background: #0b0c10; }

.map-toast {
    position: absolute;
    left: 50%;
    top: 14px;
    transform: translateX(-50%);
    z-index: 800;
    background: rgba(20, 22, 29, .95);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: .4rem 1rem;
    font-size: .85rem;
    color: var(--muted);
    box-shadow: var(--shadow);
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s;
}
.map-toast.is-visible { opacity: 1; }

.empty-state {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    text-align: center;
    gap: .5rem;
    padding: 2rem;
    z-index: 700;
    background: rgba(13, 14, 19, .82);
    pointer-events: none;
}
.empty-state.is-hidden { display: none; }
.empty-state h2 { margin: 0; }
.empty-state p { color: var(--muted); margin: 0; max-width: 44ch; }
.empty-state .btn { pointer-events: auto; justify-self: center; margin-top: .5rem; }

/* ---------- first-visit welcome dialog ---------- */

.welcome {
    max-width: 460px;
    width: calc(100% - 2rem);
    padding: 1.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
}
.welcome::backdrop {
    background: rgba(8, 9, 13, .72);
    backdrop-filter: blur(3px);
}
.welcome h2 { margin-top: 0; }
.welcome p { color: var(--muted); margin: 0 0 .75rem; }
.welcome ol {
    color: var(--muted);
    font-size: .925rem;
    margin: 1rem 0;
    padding-left: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: .45rem;
}
.welcome ol::marker { color: var(--accent); }
.welcome ol strong { color: var(--text); font-weight: 600; }
.welcome-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    margin-top: 1.5rem;
}
.welcome-actions .btn { flex: 1; min-width: 140px; }

/* Leaflet dark tweaks */
.leaflet-container { background: #0b0c10; font-family: var(--font); }
.leaflet-control-zoom a {
    background: var(--surface-2) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}
.leaflet-control-zoom a:hover { background: var(--surface-3) !important; }
.leaflet-control-attribution {
    background: rgba(13, 14, 19, .8) !important;
    color: var(--muted) !important;
    font-size: .7rem !important;
}
.leaflet-control-attribution a { color: var(--muted) !important; }

.leaflet-popup-content-wrapper {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}
.leaflet-popup-tip { background: var(--surface-2); border: 1px solid var(--border); }
.leaflet-popup-content { margin: .8rem .9rem; font-size: .85rem; min-width: 200px; }
.leaflet-popup-close-button { color: var(--muted) !important; }

.pop-title { font-weight: 600; margin-bottom: .4rem; font-size: .95rem; }
.pop-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .15rem .8rem;
    color: var(--muted);
}
.pop-grid b { color: var(--text); font-weight: 500; }
.pop-links { margin-top: .6rem; display: flex; gap: .75rem; }

@media (max-width: 900px) {
    .dash { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: auto; }
    .sidebar { border-right: 0; border-bottom: 1px solid var(--border); max-height: 45vh; }
    .map-wrap { height: 60vh; }
}
