/* ============================================================
   Cars.dareco.cz — Mobile-first stylesheet
   Base: 360px | Desktop breakpoint: 768px
   ============================================================ */

/* ── CSS proměnné ─────────────────────────────────────────── */
:root {
    --primary:      #1e3a5f;
    --primary-dark: #152b47;
    --accent:       #f97316;
    --accent-dark:  #ea6c0a;

    --success:  #16a34a;
    --warning:  #d97706;
    --danger:   #dc2626;

    --bg:       #f1f5f9;
    --surface:  #ffffff;
    --border:   #e2e8f0;
    --muted:    #64748b;

    --text:     #0f172a;
    --text-sm:  #334155;

    --radius:   12px;
    --radius-sm:  8px;
    --shadow:   0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.06);
    --shadow-sm:  0 1px 2px rgba(0,0,0,.06);

    --navbar-h: 56px;
    --spacing:  16px;
}

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: contain;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
svg { flex-shrink: 0; }
ul { list-style: none; }

/* ── Navbar ───────────────────────────────────────────────── */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--navbar-h);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 var(--spacing);
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 15px;
    color: #fff;
    white-space: nowrap;
    flex-shrink: 0;
}
.nav-brand svg { opacity: .9; }

.nav-links {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    overflow: hidden;
}

.nav-link {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: rgba(255,255,255,.8);
    white-space: nowrap;
    transition: background .15s, color .15s;
}
.nav-link:hover,
.nav-link.active {
    background: rgba(255,255,255,.15);
    color: #fff;
}

#logout-btn {
    margin-left: auto;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    padding: 6px 10px;
    white-space: nowrap;
}
#logout-btn span { display: none; }

@media (min-width: 480px) {
    #logout-btn span { display: inline; }
}

/* ── Container ────────────────────────────────────────────── */
.container {
    width: 100%;
    max-width: 680px;
    margin: 0 auto;
    padding: var(--spacing);
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, transform .1s, box-shadow .15s;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }

.btn-secondary {
    background: var(--primary);
    color: #fff;
}
.btn-secondary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-outline {
    background: transparent;
    color: rgba(255,255,255,.85);
    border: 1.5px solid rgba(255,255,255,.35);
}
.btn-outline:hover { background: rgba(255,255,255,.12); color: #fff; }

.btn-ghost {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-sm {
    min-height: 36px;
    padding: 0 12px;
    font-size: 13px;
}

.btn-full { width: 100%; }

.btn-icon {
    width: 44px;
    padding: 0;
    border-radius: 50%;
}

/* ── Forms ────────────────────────────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}
.form-group:last-of-type { margin-bottom: 0; }

label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-sm);
    letter-spacing: .02em;
    text-transform: uppercase;
}

.form-control {
    width: 100%;
    min-height: 48px;
    padding: 10px 14px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px; /* 16px prevents iOS zoom */
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
    appearance: none;
    -webkit-appearance: none;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30,58,95,.12);
}
.form-control::placeholder { color: var(--muted); }

textarea.form-control {
    min-height: 96px;
    resize: vertical;
}

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-hint {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 24px;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.card-link {
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    cursor: pointer;
    transition: box-shadow .15s, transform .1s;
    -webkit-tap-highlight-color: transparent;
}
.card-link:active { transform: scale(.99); }
.card-link:hover { box-shadow: 0 4px 16px rgba(0,0,0,.12); }

/* ── Sections ─────────────────────────────────────────────── */
.section {
    margin-bottom: 24px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.section-header h2 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

h2 {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 12px;
}

h3 {
    font-size: 16px;
    font-weight: 700;
}

/* ── Alerts / Upozornění ──────────────────────────────────── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 8px;
}
.alert:last-child { margin-bottom: 0; }

.alert-danger {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}
.alert-warning {
    background: #fffbeb;
    border: 1px solid #fed7aa;
    color: #92400e;
}
.alert-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}
.alert-info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}

.alert-icon { flex-shrink: 0; margin-top: 1px; }

.alert-body strong {
    display: block;
    font-weight: 700;
    margin-bottom: 2px;
}
.alert-body p { margin: 0; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-danger  { background: #fee2e2; color: var(--danger); }
.badge-warning { background: #fef3c7; color: var(--warning); }
.badge-success { background: #dcfce7; color: var(--success); }
.badge-default { background: var(--bg); color: var(--muted); }
.badge-primary { background: #dbeafe; color: #1d4ed8; }

/* ── Car cards ────────────────────────────────────────────── */
.car-cards { display: flex; flex-direction: column; gap: 10px; }

.car-card-icon {
    width: 48px;
    height: 48px;
    background: #dbeafe;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--primary);
}

.car-card-info { flex: 1; min-width: 0; }
.car-card-info h3 {
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.car-card-meta {
    display: flex;
    gap: 8px;
    margin-top: 2px;
    flex-wrap: wrap;
}

.spz {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    font-family: monospace;
    background: var(--primary);
    color: #fff;
    padding: 1px 7px;
    border-radius: 4px;
    letter-spacing: .05em;
}

.chevron {
    color: var(--muted);
    font-size: 20px;
    line-height: 1;
}

/* Tagy STK / olej v kartě auta — inline v .car-card-meta */
.car-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    white-space: nowrap;
    line-height: 1.6;
}

.car-tag-ok     { background: #dcfce7; color: #15803d; }
.car-tag-warn   { background: #fef3c7; color: #b45309; }
.car-tag-danger { background: #fee2e2; color: #dc2626; }
.car-tag-none   { background: var(--bg); color: var(--muted); }

/* ── Servis cards ─────────────────────────────────────────── */
.servis-cards { display: flex; flex-direction: column; gap: 8px; }

.servis-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    cursor: pointer;
    transition: box-shadow .15s;
    -webkit-tap-highlight-color: transparent;
}
.servis-card:hover { box-shadow: var(--shadow); }

.servis-type-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.servis-meta {
    flex: 1;
    min-width: 0;
}
.servis-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.servis-title {
    font-weight: 600;
    font-size: 15px;
}
.servis-sub {
    font-size: 13px;
    color: var(--muted);
    margin-top: 3px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.servis-cena {
    font-weight: 700;
    color: var(--text);
    font-size: 14px;
    white-space: nowrap;
}
.servis-date {
    font-size: 13px;
    color: var(--muted);
}

/* ── Termíny ──────────────────────────────────────────────── */
.terminy-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.termin-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    cursor: pointer;
    transition: box-shadow .15s;
}
.termin-card:hover { box-shadow: var(--shadow); }

.termin-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 4px;
}
.termin-date {
    font-size: 18px;
    font-weight: 700;
}
.termin-status {
    margin-top: 6px;
}

/* ── Filter tabs ──────────────────────────────────────────── */
.filter-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    margin-bottom: 12px;
}
.filter-tabs::-webkit-scrollbar { display: none; }

.filter-tab {
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: 99px;
    border: 1.5px solid var(--border);
    background: var(--surface);
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
    -webkit-tap-highlight-color: transparent;
}
.filter-tab:hover { border-color: var(--primary); color: var(--primary); }
.filter-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ── Auto detail header ───────────────────────────────────── */
.auto-header {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 16px;
}
.auto-header-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.auto-header h1 {
    font-size: 22px;
    font-weight: 800;
    line-height: 1.2;
}
.auto-header-actions { display: flex; gap: 8px; flex-shrink: 0; }
.auto-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}
.auto-info-item label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    margin-bottom: 2px;
}
.auto-info-item span {
    font-size: 15px;
    font-weight: 600;
}

/* ── Costs overview ───────────────────────────────────────── */
.naklady-total {
    font-size: 32px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 16px;
}
.naklady-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.naklady-item {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.naklady-item-label { font-size: 13px; color: var(--muted); }
.naklady-item-val { font-weight: 700; font-size: 14px; }

/* ── Login screen ─────────────────────────────────────────── */
.login-screen {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary) 0%, #2d5a9e 100%);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 32px 28px;
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
}

.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
    color: var(--primary);
}

.login-card h1 {
    font-size: 24px;
    font-weight: 800;
    text-align: center;
    color: var(--primary);
    margin-bottom: 4px;
}

.login-subtitle {
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 28px;
}

.login-card .form-group { margin-bottom: 16px; }
.login-card .alert { margin-bottom: 16px; }
.login-card .btn-primary { margin-top: 8px; }

/* ── Loading & empty states ───────────────────────────────── */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 20px;
    gap: 16px;
    color: var(--muted);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; color: var(--text-sm); }
.empty-state p { font-size: 14px; margin-bottom: 20px; }

/* ── Back button ──────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.page-header h1 {
    font-size: 20px;
    font-weight: 700;
    flex: 1;
}
.back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    font-size: 14px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    cursor: pointer;
    min-height: 40px;
    text-decoration: none;
}

/* ── Utility ──────────────────────────────────────────────── */
.muted { color: var(--muted); font-size: 13px; }
.text-sm { font-size: 13px; }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-sm { gap: 8px; }

.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

/* ── Naklady rok picker ───────────────────────────────────── */
.rok-picker {
    display: flex;
    align-items: center;
    gap: 8px;
}
.rok-picker select { flex: none; min-height: 40px; padding: 6px 36px 6px 12px; font-size: 15px; }

/* ── Modal / confirm overlay ─────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    animation: fadeIn .2s ease;
}
@media (min-width: 480px) {
    .modal-overlay { align-items: center; padding: 20px; }
}

.modal {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 24px 20px;
    box-shadow: 0 -8px 40px rgba(0,0,0,.2);
    animation: slideUp .25s ease;
}
@media (min-width: 480px) {
    .modal { border-radius: var(--radius); }
}
.modal h3 { font-size: 18px; margin-bottom: 10px; }
.modal p { color: var(--text-sm); margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Toast ────────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    pointer-events: none;
}

.toast {
    background: var(--text);
    color: #fff;
    padding: 10px 20px;
    border-radius: 99px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0,0,0,.3);
    animation: toastIn .25s ease;
    white-space: nowrap;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(12px) scale(.95); }
    to   { opacity: 1; transform: none; }
}

/* ── Desktop adjustments ──────────────────────────────────── */
@media (min-width: 768px) {
    :root { --spacing: 24px; }

    .container { padding: 24px; }

    .terminy-grid { grid-template-columns: repeat(3, 1fr); }

    .naklady-grid { grid-template-columns: repeat(3, 1fr); }

    .form-actions { flex-direction: row; }
    .form-actions .btn-full { flex: 1; }
}
