/* Sdílený styl pro analyza/ dashboardy (Analytics / Security / Login security).
   Sloučeno ze 3 dřív téměř identických <style> bloků. */

:root {
    --bg:       #0d0d14;
    --surface:  #16161f;
    --surface2: #1e1e2a;
    --border:   #2a2a38;
    --text:     #e8e8f0;
    --muted:    #7070a0;
    --accent:   #f5a623;
    --accent2:  #7c5cbf;
    --green:    #4caf82;
    --red:      #e05c5c;
    --blue:     #5b8dee;
    --orange:   #f59e0b;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 14px;
}

/* ── Header + menu ────────────────────────────────────────────── */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 1rem;
    flex-wrap: wrap;
}
.header h1 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: .5rem;
    white-space: nowrap;
}
.live-badge {
    font-size: .75rem;
    font-weight: 600;
    color: var(--green);
    background: rgba(76,175,130,.12);
    padding: .2rem .6rem;
    border-radius: 20px;
    margin-left: .5rem;
}
.menu {
    display: flex;
    gap: .25rem;
    background: var(--surface2);
    padding: .25rem;
    border-radius: 8px;
}
.menu a {
    padding: .35rem .75rem;
    border-radius: 6px;
    text-decoration: none;
    color: var(--muted);
    font-weight: 600;
    font-size: .8rem;
    transition: all .15s;
}
.menu a.active,
.menu a:hover {
    background: var(--accent);
    color: #000;
}
.header-links { display: flex; align-items: center; gap: 1rem; }
.logout { color: var(--muted); text-decoration: none; font-size: .8rem; }
.logout:hover { color: var(--text); }

.period-tabs {
    display: flex;
    gap: .25rem;
    background: var(--surface2);
    padding: .25rem;
    border-radius: 8px;
}
.period-tabs a {
    padding: .35rem .75rem;
    border-radius: 6px;
    text-decoration: none;
    color: var(--muted);
    font-weight: 600;
    font-size: .8rem;
    transition: all .15s;
}
.period-tabs a.active,
.period-tabs a:hover {
    background: var(--accent);
    color: #000;
}

.container { padding: 1.5rem 2rem; max-width: 1500px; margin: 0 auto; }

/* ── KPI ───────────────────────────────────────────────────────── */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    position: relative;
    overflow: hidden;
}
.kpi::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--accent);
}
.kpi:nth-child(2)::before { background: var(--blue); }
.kpi:nth-child(3)::before { background: var(--green); }
.kpi:nth-child(4)::before { background: var(--accent2); }
.kpi-label { color: var(--muted); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .5rem; }
.kpi-value { font-size: 2rem; font-weight: 800; line-height: 1; }
.kpi-sub { color: var(--muted); font-size: .75rem; margin-top: .35rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Security dashboard: první KPI card = "danger" červená místo výchozí accent */
.kpi-row.kpi-security .kpi::before { background: var(--red); }
.kpi-row.kpi-security .kpi:nth-child(2)::before { background: var(--blue); }
.kpi-row.kpi-security .kpi:nth-child(3)::before { background: var(--accent); }
.kpi-row.kpi-security .kpi:nth-child(4)::before { background: var(--accent2); }

/* Login security dashboard: 5 KPI karet místo 4 */
.kpi-row.kpi-login-security { grid-template-columns: repeat(5, 1fr); }
.kpi-row.kpi-login-security .kpi::before { background: var(--blue); }
.kpi-row.kpi-login-security .kpi:nth-child(2)::before,
.kpi-row.kpi-login-security .kpi:nth-child(3)::before { background: var(--green); }
.kpi-row.kpi-login-security .kpi:nth-child(4)::before { background: var(--accent); }
.kpi-row.kpi-login-security .kpi:nth-child(5)::before { background: var(--red); }

/* ── Grid layouty ──────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }

/* ── Karty ─────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
}
.card h3 {
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    margin-bottom: 1rem;
}
.card-full { grid-column: 1 / -1; }

/* ── Grafy (Chart.js) ──────────────────────────────────────────── */
.chart-wrap { position: relative; height: 220px; }
.chart-wrap-sm { position: relative; height: 160px; }

/* ── Bar listy ─────────────────────────────────────────────────── */
.bar-list { display: flex; flex-direction: column; gap: .5rem; }
.bar-item { display: flex; align-items: center; gap: .75rem; }
.bar-label {
    min-width: 130px;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .8rem;
    color: var(--text);
}
.bar-label.wide { min-width: 200px; max-width: 300px; }
.bar-label.mono { font-family: monospace; }
.bar-track {
    flex: 1;
    height: 6px;
    background: var(--surface2);
    border-radius: 3px;
    overflow: hidden;
}
.bar-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--accent);
    transition: width .4s ease;
}
.bar-fill.blue   { background: var(--blue); }
.bar-fill.green  { background: var(--green); }
.bar-fill.purple { background: var(--accent2); }
.bar-fill.orange { background: var(--orange); }
.bar-fill.red    { background: var(--red); }
.bar-count { min-width: 36px; text-align: right; font-size: .8rem; font-weight: 700; color: var(--muted); }

/* ── Hodinový heatmap ──────────────────────────────────────────── */
.heatmap {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 3px;
}
.heat-cell {
    aspect-ratio: 1;
    border-radius: 3px;
    background: var(--surface2);
    position: relative;
    cursor: default;
}
.heat-cell:hover::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: .7rem;
    white-space: nowrap;
    z-index: 10;
}
.heat-hours {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 3px;
    margin-top: 4px;
}
.heat-hour { text-align: center; font-size: .6rem; color: var(--muted); }

/* ── Poslední 24h sparkline (login security) ──────────────────── */
.spark {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 3px;
    align-items: end;
    min-height: 90px;
}
.spark-bar {
    width: 100%;
    background: linear-gradient(180deg, rgba(91,141,238,0.9), rgba(124,92,191,0.9));
    border-radius: 3px 3px 0 0;
    min-height: 2px;
}
.spark-hours {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 3px;
    margin-top: 6px;
}
.spark-hour { text-align: center; color: var(--muted); font-size: .6rem; }

/* ── Bezpečnostní funnel (login security) ─────────────────────── */
.funnel-stack { display: flex; flex-direction: column; gap: .65rem; }
.funnel-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: .6rem;
    align-items: center;
    font-size: .82rem;
}
.funnel-arrow { color: var(--muted); font-weight: 700; }
.funnel-label { color: var(--text); }
.funnel-value { color: var(--text); font-weight: 800; }
.funnel-note { color: var(--muted); font-size: .74rem; margin-left: 1.4rem; }
.funnel-note.warn { color: var(--accent); }
.funnel-note.block { color: var(--red); }

.split-block { display: flex; flex-direction: column; gap: .45rem; }
.split-title { color: var(--muted); font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.split-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .8rem;
    font-size: .8rem;
    padding: .45rem .55rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,.01);
}
.split-item strong { color: var(--text); }
.split-right { display: flex; align-items: center; gap: .55rem; }
.split-count { color: var(--text); font-weight: 800; min-width: 20px; text-align: right; }
.split-item .pct {
    font-weight: 900;
    font-size: .86rem;
    letter-spacing: .01em;
    padding: .2rem .45rem;
    border-radius: 999px;
    border: 1px solid transparent;
    min-width: 62px;
    text-align: center;
}
.pct-red     { color: #ffb3b3; background: rgba(224,92,92,.18);  border-color: rgba(224,92,92,.45); }
.pct-orange  { color: #ffd8a1; background: rgba(245,166,35,.18); border-color: rgba(245,166,35,.45); }
.pct-green   { color: #b7f5de; background: rgba(76,175,130,.18); border-color: rgba(76,175,130,.45); }
.pct-neutral { color: #d9d9ea; background: rgba(112,112,160,.18); border-color: rgba(112,112,160,.45); }

/* ── Tabulky ───────────────────────────────────────────────────── */
.ref-table { width: 100%; border-collapse: collapse; }
.ref-table td { padding: .4rem .5rem; border-bottom: 1px solid var(--border); font-size: .8rem; }
.ref-table td:last-child { text-align: right; font-weight: 700; color: var(--accent); }
.ref-table tr:last-child td { border-bottom: none; }
.ref-url { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; display: block; }

.log-table { width: 100%; border-collapse: collapse; font-size: .78rem; }
.log-table th {
    text-align: left;
    padding: .5rem .75rem;
    border-bottom: 2px solid var(--border);
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: .7rem;
    letter-spacing: .04em;
}
.log-table td {
    padding: .45rem .75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.log-table tr:last-child td { border-bottom: none; }
.log-table tr:hover td { background: var(--surface2); }
.td-mono { font-family: monospace; font-size: .75rem; color: var(--muted); }
.td-path { font-family: monospace; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-route { font-family: monospace; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-ua { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

/* ── Badge ─────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 20px;
    font-size: .7rem;
    font-weight: 700;
}
.badge-red     { background: rgba(224,92,92,.18);  color: var(--red); }
.badge-orange  { background: rgba(245,166,35,.18); color: var(--accent); }
.badge-blue    { background: rgba(91,141,238,.18); color: var(--blue); }
.badge-purple  { background: rgba(124,92,191,.18); color: var(--accent2); }
.badge-gray    { background: rgba(112,112,160,.18); color: var(--muted); }
.badge-success { background: rgba(76,175,130,.18); color: var(--green); }
.badge-warning { background: rgba(245,166,35,.18); color: var(--accent); }
.badge-block   { background: rgba(224,92,92,.18); color: var(--red); }
.badge-neutral { background: rgba(112,112,160,.18); color: var(--muted); }

/* ── Prázdný stav ──────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.empty-state .icon { font-size: 2.5rem; margin-bottom: .75rem; }

/* ── Přihlašovací formulář (view/login.php) ───────────────────── */
.login-page {
    font-family: system-ui, sans-serif;
    background: #0f0f13;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-form { background: #1a1a24; padding: 2rem; border-radius: 12px; width: 320px; }
.login-form h2 { margin-bottom: 1.5rem; font-size: 1.2rem; color: var(--accent); display: flex; align-items: center; gap: .5rem; }
.login-form input { width: 100%; padding: .75rem 1rem; background: #0f0f13; border: 1px solid #333; border-radius: 8px; color: #fff; margin-bottom: 1rem; font-size: 1rem; }
.login-form button { width: 100%; padding: .75rem; background: var(--accent); border: none; border-radius: 8px; color: #000; font-weight: 700; cursor: pointer; font-size: 1rem; }
.login-form .err { color: #e05c5c; font-size: .85rem; margin-bottom: .75rem; }

/* ── Responzivita ──────────────────────────────────────────────── */
@media (max-width: 1200px) {
    .kpi-row.kpi-login-security { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .container { padding: 1rem; }
    .header { flex-wrap: wrap; justify-content: flex-start; }
}
