/* =========================================================================
 * CarLog – responzivní styl (mobile-first)
 * ========================================================================= */
:root {
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --bg: #f4f6f8;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --green: #16a34a;
    --amber: #d97706;
    --red: #dc2626;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

* { box-sizing: border-box; }

/* Atribut hidden musí mít přednost i nad display:flex apod. */
[hidden] { display: none !important; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 0; }
a { color: var(--blue); text-decoration: none; }

/* ---------------- Auth ---------------- */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 16px;
}
.auth-card {
    background: var(--card);
    width: 100%;
    max-width: 380px;
    padding: 28px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.auth-logo { text-align: center; font-size: 1.6rem; margin: 0 0 18px; }
.auth-card h2 { margin-bottom: 14px; }
.auth-link { text-align: center; margin-top: 16px; font-size: .9rem; }

/* ---------------- Topbar ---------------- */
.topbar {
    background: var(--blue);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: var(--shadow);
}
.topbar-inner {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    gap: 12px;
}
.brand { color: #fff; font-weight: bold; font-size: 1.1rem; white-space: nowrap; }
.topnav { display: flex; gap: 4px; flex-wrap: wrap; }
.topnav a {
    color: #dbeafe;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: .92rem;
}
.topnav a:hover, .topnav a.active { background: rgba(255, 255, 255, .18); color: #fff; }
.topnav a.logout { color: #fecaca; }

/* ---------------- Container ---------------- */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 16px 16px 90px;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.head-actions { display: flex; gap: 8px; }
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 24px 0 10px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 6px;
}
.breadcrumb { margin-bottom: 8px; font-size: .9rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.empty { color: var(--muted); padding: 16px 0; }
.empty.error { color: var(--red); }
.loader { text-align: center; color: var(--muted); padding: 40px 0; }
.empty-state { text-align: center; padding: 40px 16px; }
.empty-state p { color: var(--muted); margin-bottom: 16px; }

/* ---------------- Cards ---------------- */
.cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
    display: block;
    color: var(--text);
}
.card-link:hover { border-color: var(--blue); }
.card-title { font-weight: 600; font-size: 1.05rem; }
.card-desc { color: var(--muted); font-size: .9rem; margin-top: 4px; }
.card-meta { color: var(--muted); font-size: .85rem; margin-top: 6px; }
.card-badges { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.card-actions { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------- Badges ---------------- */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    line-height: 1.5;
}
.badge-ok { background: #dcfce7; color: #15803d; }
.badge-warn { background: #fef3c7; color: #b45309; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-muted { background: #f1f5f9; color: #64748b; }

/* ---------------- Info grid ---------------- */
.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
}
.info-item { display: flex; flex-direction: column; }
.info-label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.info-value { font-weight: 600; }
.mini-link { font-size: .8rem; font-weight: normal; }

.status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
}

/* ---------------- Service status ---------------- */
.service-status {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}
.service-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
}
.service-item-head { font-weight: 600; display: flex; align-items: center; gap: 8px; justify-content: space-between; }

/* ---------------- Records ---------------- */
.record-list { display: flex; flex-direction: column; gap: 10px; }
.record {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}
.record-main { flex: 1; min-width: 0; }
.record-title { font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.record-meta { margin-top: 2px; }
.record-desc { margin-top: 6px; white-space: pre-wrap; word-break: break-word; }
.record-actions { display: flex; flex-direction: column; gap: 6px; }

.attachments { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; }
.attachment {
    background: #f1f5f9;
    border-radius: 6px;
    padding: 3px 8px;
    font-size: .82rem;
}
.att-del { color: var(--red); font-weight: bold; margin-left: 2px; }

/* ---------------- Members ---------------- */
.member-list { display: flex; flex-direction: column; gap: 8px; }
.member-row {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.member-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ---------------- Forms ---------------- */
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; font-size: .9rem; font-weight: 500; gap: 4px; }
.form input, .form select, .form textarea {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    width: 100%;
    background: #fff;
}
.form input:focus, .form select:focus, .form textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
.form input:disabled { background: #f1f5f9; color: var(--muted); }
.form textarea { resize: vertical; }
.form-actions { display: flex; gap: 8px; margin-top: 4px; }
.form-inline { flex-direction: row; align-items: flex-end; flex-wrap: wrap; }
.form-section {
    font-weight: 700;
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-top: 4px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid-full { grid-column: 1 / -1; }
.interval-pair {
    display: grid;
    grid-template-columns: 1.3fr 1fr 1fr;
    gap: 8px;
    align-items: center;
}
.interval-pair span { font-size: .9rem; font-weight: 500; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.field-label { font-size: .9rem; font-weight: 500; }
.checkbox-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 14px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
}
.check {
    flex-direction: row !important;
    align-items: center;
    gap: 8px !important;
    font-weight: 500 !important;
    cursor: pointer;
}
.check input { width: auto !important; }

.form-msg { font-size: .9rem; min-height: 1em; }
.form-msg.error { color: var(--red); }
.form-msg.success { color: var(--green); }

/* ---------------- Toolbar (filtr / řazení) ---------------- */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.toolbar-group { display: flex; gap: 0; }
.toolbar-group .filter-btn { border-radius: 0; border-right-width: 0; }
.toolbar-group .filter-btn:first-child { border-radius: 8px 0 0 8px; }
.toolbar-group .filter-btn:last-child { border-radius: 0 8px 8px 0; border-right-width: 1px; }
.filter-btn.active {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
}
.toolbar-sort {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .9rem;
    color: var(--muted);
}
.toolbar-sort select {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .9rem;
    font-family: inherit;
    background: #fff;
}

/* ---------------- Datová tabulka (přehled vozidel) ---------------- */
.table-wrap {
    overflow-x: auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    -webkit-overflow-scrolling: touch;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
    min-width: 600px;
}
.data-table th, .data-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table thead th {
    background: #f3f4f6;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--muted);
    white-space: nowrap;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .row-link { cursor: pointer; }
.data-table .row-link:hover { background: #f8fafc; }
.chip-row { display: flex; flex-wrap: wrap; gap: 5px; min-width: 240px; }

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--red); }
.btn-danger:hover { background: #fef2f2; }
.btn-warn { color: var(--amber); border-color: #fde68a; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: .88rem; }
.btn-xs { padding: 4px 9px; font-size: .8rem; }

/* ---------------- Modal ---------------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px 12px;
    z-index: 50;
    overflow-y: auto;
}
.modal {
    background: #fff;
    border-radius: var(--radius);
    width: 100%;
    max-width: 520px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
    margin: auto;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: #fff;
    border-radius: var(--radius) var(--radius) 0 0;
}
.modal-header h3 { margin: 0; font-size: 1.1rem; }
.modal-close {
    border: none;
    background: none;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    color: var(--muted);
}
.modal-body { padding: 20px; }
body.modal-open { overflow: hidden; }

/* ---------------- Toast ---------------- */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: #111827;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: .92rem;
    z-index: 60;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .3);
    max-width: 90vw;
    text-align: center;
}
.toast.error { background: var(--red); }
.toast.success { background: #111827; }

/* ---------------- Bottom nav (mobil) ---------------- */
.bottomnav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    z-index: 30;
    box-shadow: 0 -1px 4px rgba(0, 0, 0, .05);
}
.bottomnav a {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    font-size: .7rem;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.bottomnav a span { font-size: 1.25rem; }
.bottomnav a.active { color: var(--blue); }

/* ---------------- Desktop ---------------- */
@media (min-width: 700px) {
    .cards { grid-template-columns: repeat(2, 1fr); }
    .service-status { grid-template-columns: repeat(2, 1fr); }
    .info-grid { grid-template-columns: repeat(3, 1fr); }
    .bottomnav { display: none; }
    .container { padding-bottom: 40px; }
}
@media (min-width: 1000px) {
    .cards { grid-template-columns: repeat(3, 1fr); }
}
/* Skryj horní navigaci textových odkazů na velmi malých displejích (zůstává spodní nav). */
@media (max-width: 560px) {
    .topnav a[data-nav] { display: none; }
    .topnav a.logout { display: inline-block; }
}
