/* ============================================================
   KNIHA JÍZD - styly
   Čisté rozhraní, velké ovládací prvky (funguje i na tabletu)
   ============================================================ */

:root {
    --primary: #2563eb;        /* modrá - hlavní akce */
    --primary-dark: #1d4ed8;
    --success: #16a34a;        /* zelená - služební jízdy */
    --warning: #d97706;        /* oranžová - soukromé jízdy */
    --danger: #dc2626;         /* červená - mazání */
    --bg: #f1f5f9;             /* pozadí aplikace */
    --surface: #ffffff;        /* karty, panely */
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    min-height: 100%;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* ============ Horní lišta ============ */

.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    height: 60px;
    padding: 0 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-brand { font-size: 1.3rem; font-weight: 700; white-space: nowrap; }
.topbar-tabs { display: flex; gap: 8px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.tab-btn {
    padding: 10px 22px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s;
}
.tab-btn:hover { background: var(--bg); }
.tab-btn.active { background: var(--primary); color: #fff; }

/* ============ Tlačítka ============ */

.btn {
    padding: 11px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: filter 0.15s, background 0.15s;
    white-space: nowrap;
}
.btn:hover { filter: brightness(0.95); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-light { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-light:hover { background: var(--bg); }
.btn-sm { padding: 7px 12px; font-size: 0.85rem; }

/* ============ Záložky a stránka ============ */

.tab-content { display: none; }
.tab-content.active { display: block; }

.page {
    max-width: 1500px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.page-head {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.page-head h2 { font-size: 1.4rem; }
.page-head .btn { margin-left: auto; }
.page-head .row-gap { margin-left: auto; }

.row-gap { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ============ Filtry ============ */

.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.filters select,
.filters input {
    padding: 11px 14px;
    font-size: 0.95rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}
.filters #filter-search { flex: 1; min-width: 200px; }

/* ============ Souhrnné dlaždice ============ */

.summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 18px;
}
.stat-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.stat-value { font-size: 1.6rem; font-weight: 700; margin-top: 4px; }
.stat-value small { font-size: 0.9rem; font-weight: 600; color: var(--text-muted); }
.stat.business .stat-value { color: var(--success); }
.stat.private .stat-value { color: var(--warning); }

/* ============ Tabulka ============ */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}
.table th,
.table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    background: #f8fafc;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8fafc; }
.table .num { text-align: right; }
.table .muted { color: var(--text-muted); font-size: 0.85rem; }
.table tfoot td { font-weight: 700; background: #f8fafc; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
}
.badge.business { background: #dcfce7; color: #166534; }
.badge.private { background: #ffedd5; color: #9a3412; }

.empty {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
}

/* ============ Vozidla ============ */

.vehicle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.vehicle-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.vehicle-card.inactive { opacity: 0.55; }

.vehicle-head { display: flex; align-items: baseline; gap: 10px; }
.vehicle-name { font-size: 1.15rem; font-weight: 700; }
.vehicle-plate {
    margin-left: auto;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 3px 10px;
    border: 2px solid var(--text-muted);
    border-radius: 6px;
    font-size: 0.85rem;
}

.odo-box {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: var(--radius);
    padding: 14px 16px;
    text-align: center;
}
.odo-box .odo-label { font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.7; }
.odo-box .odo-value {
    font-size: 2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
}
.odo-box .odo-value small { font-size: 0.9rem; opacity: 0.7; }

.vehicle-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.9rem; color: var(--text-muted); }
.vehicle-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }

/* ============ Dialogy ============ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}
.modal-overlay[hidden] { display: none; }

.modal {
    background: var(--surface);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 720px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.modal-narrow { max-width: 460px; }
.modal h3 { font-size: 1.25rem; margin-bottom: 4px; }
.modal-sub { color: var(--text-muted); margin-bottom: 12px; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 14px;
}
.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid input,
.form-grid select {
    padding: 11px 13px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}
.form-grid input:focus,
.form-grid select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

.form-grid textarea {
    padding: 11px 13px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    resize: vertical;
}

.hint { margin-top: 12px; font-size: 0.85rem; color: var(--text-muted); }

/* ============ Rozpis měsíce ============ */

.modal-wide { max-width: 900px; }

.weekday-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 14px;
    padding: 12px 14px;
    background: var(--bg);
    border-radius: var(--radius);
    font-size: 0.9rem;
}
.weekday-label { font-weight: 600; color: var(--text-muted); }
.weekday-row label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.weekday-row input[type="checkbox"] { width: 18px; height: 18px; }
.weekday-row .sep { margin-left: auto; }

.day-cfg {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 3px !important;
    font-weight: 700;
}
.day-cfg select {
    padding: 6px 8px;
    font-size: 0.85rem;
    font-family: inherit;
    font-weight: 500;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

#plan-result { margin-top: 16px; }
#plan-result .summary { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
#plan-result .stat-value { font-size: 1.3rem; }

.plan-preview {
    margin-top: 14px;
    max-height: 340px;
    overflow-y: auto;
}
.plan-preview:empty { display: none; }
.plan-preview .table th { position: sticky; top: 0; z-index: 1; }
.plan-preview tr.same-day td { border-top: none; }
.plan-preview tr.same-day td:first-child { padding-left: 26px; }
.plan-preview .weekend { color: var(--warning); font-weight: 700; }
.plan-preview input.plan-km {
    width: 90px;
    padding: 6px 8px;
    text-align: right;
    font-size: 0.95rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.modal-actions { display: flex; gap: 10px; align-items: center; margin-top: 20px; }
.modal-actions .spacer { flex: 1; }

.odo-history {
    margin-top: 16px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
    max-height: 180px;
    overflow-y: auto;
    font-size: 0.9rem;
}
.odo-history .odo-row {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}
.odo-history .odo-row:last-child { border-bottom: none; }
.odo-history .odo-row .grow { flex: 1; color: var(--text-muted); }
.odo-history .link-danger {
    border: none;
    background: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 0.85rem;
}

/* ============ Toast (hláška) ============ */

.toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    background: #0f172a;
    color: #fff;
    padding: 13px 22px;
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    font-weight: 600;
    z-index: 200;
}
.toast.error { background: var(--danger); }
.toast[hidden] { display: none; }

/* ============ Menší obrazovky ============ */

@media (max-width: 800px) {
    .topbar { gap: 12px; padding: 0 12px; }
    .topbar-brand { font-size: 1.05rem; }
    .tab-btn { padding: 9px 14px; }
    .page { padding: 12px; }
}

/* ============ Přihlašovací stránka ============ */
/* Používá se jen na hostingu (prihlaseni.html). Na Node verzi na firemním
   PC se na ni nikdy nedojde, protože odtamtud žádná 401 nechodí. */

body.login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    padding: 32px 28px;
    text-align: center;
}

.login-icon { font-size: 40px; line-height: 1; }
.login-box h1 { font-size: 1.5rem; font-weight: 700; margin-top: 10px; }
.login-sub { color: var(--text-muted); font-size: 0.9rem; margin-top: 2px; }

.login-label {
    display: block;
    text-align: left;
    margin: 22px 0 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.login-input {
    width: 100%;
    padding: 12px 14px;
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.login-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.login-btn {
    width: 100%;
    margin-top: 16px;
    padding: 12px 16px;
    font: inherit;
    font-weight: 600;
    color: #fff;
    background: var(--primary);
    border: 0;
    border-radius: 10px;
    cursor: pointer;
}
.login-btn:hover { background: var(--primary-dark); }
.login-btn:disabled { opacity: 0.6; cursor: default; }

.login-err {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #fef2f2;
    color: var(--danger);
    font-size: 0.9rem;
    font-weight: 600;
}
.login-err[hidden] { display: none; }

.login-hint {
    margin-top: 20px;
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.5;
}
