:root {
    /* Color Palette - Slate / Professional Blue */
    --bg-app: #0f172a;        /* Very dark blue/slate */
    --bg-sidebar: #1e293b;    /* Lighter slate */
    --bg-card: #1e293b;       /* Same as sidebar for cards */
    --bg-input: #334155;
    
    --text-main: #f1f5f9;     /* Almost white */
    --text-muted: #94a3b8;    /* Gray text */
    
    --accent-primary: #3b82f6; /* Blue */
    --accent-hover: #2563eb;
    --accent-success: #10b981; /* Green */
    --accent-danger: #ef4444;  /* Red */
    --accent-warning: #f59e0b; /* Amber */
    
    --border-color: #334155;
    
    /* Spacing */
    --sidebar-width: 200px;
    --header-height: 60px;
    --status-height: 40px;
    --bp-lg: 1280px;  /* notebook / menší desktop */
    --bp-md: 1024px;  /* tablet landscape */
    --bp-sm: 768px;   /* tablet portrait */
    --bp-xs: 576px;   /* mobil */
}

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

html {
    height: 100%;
    height: 100dvh;
    max-width: 100%;
    overflow: hidden;
}

html,
body {
    width: 100%;
    max-width: 100%;
    min-height: 100%;
}

body {
    font-family: 'Segoe UI', Inter, system-ui, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    min-height: 100dvh;
    height: 100dvh;
    overflow: hidden;
    display: block;
}

/* Blazor: mřížka shellu je na kontejneru, ne na body (přihlášení bez sidebar gridu). */
.pedikura-app-grid {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: 1fr var(--status-height);
    grid-template-areas:
        "sidebar main"
        "sidebar status";
    height: 100%;
    min-height: 0;
    flex: 1 1 auto;
    overflow: hidden;
}

/* --- SIDEBAR --- */
.app-sidebar {
    grid-area: sidebar;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
}

.app-logo {
    font-size: 1.35rem;
    font-weight: bold;
    color: var(--accent-primary);
    margin-bottom: 28px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item a {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    text-decoration: none;
    color: var(--text-muted);
    border-radius: 8px;
    transition: all 0.2s;
    font-weight: 500;
    font-size: 0.95rem;
}

.nav-item a:hover, .nav-item a.active {
    background-color: var(--bg-input);
    color: var(--text-main);
    transform: translateX(3px);
}

.nav-icon {
    margin-right: 12px;
    width: 20px;
    text-align: center;
}

/* --- MAIN CONTENT AREA --- */
.app-main {
    grid-area: main;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden; /* Prevent spillover */
    min-width: 0; /* Allow main area to shrink inside grid */
    min-height: 0;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-app); /* Sticky feel */
    min-width: 0;
    min-height: var(--header-height);
    gap: 12px;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    flex: 0 0 auto;
    min-width: 0;
}

/* Běžící barevný text — mezi názvem stránky a uživatelem */
.app-header-ticker {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 15px;
    color: var(--text-muted);
    min-width: 0;
    max-width: 40%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 0 0 auto;
}
.app-header .actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-profile > span,
.user-profile [data-device-info] {
    display: inline-block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- SCROLLABLE CONTENT --- */
.content-scrollable {
    padding: clamp(10px, 2vw, 30px);
    overflow-y: auto; /* Scroll ONLY here */
    overflow-x: auto;
    /* height: 100% rozbíjí výšku poddělení v gridu po rodiči s minmax(0,1fr) — necháme stretch */
    min-width: 0;
    min-height: 0;
    align-self: stretch;
}

.content-scrollable > * {
    min-width: 0;
}

.card {
    min-width: 0;
}

/* Custom Scrollbar */
.content-scrollable::-webkit-scrollbar {
    width: 8px;
}
.content-scrollable::-webkit-scrollbar-track {
    background: var(--bg-app);
}
.content-scrollable::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
.content-scrollable::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- CARDS & WIDGETS --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.card h3 {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    margin-bottom: 15px;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-main);
}

.stat-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 5px;
}

/* --- FORMS --- */
.form-group {
    margin-bottom: 15px;
}
.form-input {
    width: 100%;
    padding: 10px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    font-family: inherit;
}
.form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* --- STATUS BAR --- */
.app-statusbar {
    grid-area: status;
    background-color: var(--bg-sidebar);
    border-top: 1px solid var(--border-color);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
    min-width: 0;
    flex-wrap: nowrap;
    overflow: hidden;
}

.app-statusbar [data-status-user] {
    margin-left: auto;
    flex: 0 0 auto;
    white-space: nowrap;
}

/* Stav API v jedné řádce; dlouhé zprávy zkrátí ellipsis (+ tooltip z JS) */
.app-statusbar .connection-status {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    white-space: nowrap;
    overflow: hidden;
    gap: 0;
}

.app-statusbar .connection-status #backend-status-text,
.app-statusbar .connection-status #banking-status-text,
.app-statusbar .connection-status #katastr-status-text,
.app-statusbar .connection-status #s3-status-text {
    display: inline-block;
    max-width: min(200px, 18vw);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
}

.app-statusbar .connection-status #dashboard-s3-hint {
    flex-shrink: 0;
    margin-left: 8px;
}

.running-text-wrap {
    position: relative;
    overflow: hidden;
    width: min(460px, 48vw);
    white-space: nowrap;
}

.running-text-wrap--header {
    width: 100%;
    max-width: min(560px, 100%);
}

/* Dvě stejné kopie za sebou: translateX(-50%) = přesně jedna kopie. gap mezi nimi rozbíjí smyčku (text „stojí“ / cuká). */
.running-text-track {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0;
    width: max-content;
    min-width: max-content;
    will-change: transform;
    animation: backleasTickerX 22s linear infinite;
}

.running-text-item {
    flex: 0 0 auto;
    font-weight: 700;
    letter-spacing: 0.4px;
    /* vizuální mezera mezi opakováními — u obou kopií stejně, aby -50 % sedělo */
    padding-right: 2.75rem;
    background: linear-gradient(90deg, #60a5fa 0%, #34d399 25%, #f59e0b 50%, #f472b6 75%, #60a5fa 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

@keyframes backleasTickerX {
    from {
        transform: translate3d(0, 0, 0);
    }
    to {
        transform: translate3d(-50%, 0, 0);
    }
}

/* Blok „Banka“ ve status baru — při úspěšném RB API zvýraznění zeleně */
.footer-bank-board {
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    margin: 0 2px;
    padding: 2px 8px 2px 4px;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}
.footer-bank-board--pending {
    border-color: rgba(148, 163, 184, 0.25);
}
.footer-bank-board--ok {
    border-color: rgba(34, 197, 94, 0.55);
    background: rgba(34, 197, 94, 0.12);
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.25);
    color: #86efac;
}
.footer-bank-board--ok #banking-status-text {
    color: #bbf7d0;
    max-width: min(240px, 22vw);
}
.footer-bank-board--error {
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.08);
}
.footer-bank-board--skipped {
    border-color: rgba(148, 163, 184, 0.35);
}

.status-indicator {
    height: 10px;
    width: 10px;
    border-radius: 50%;
    display: inline-block;
    background-color: var(--bg-input);
    margin-left: 10px;
}
.status-ok { background-color: var(--accent-success); box-shadow: 0 0 5px var(--accent-success); }
.status-error { background-color: var(--accent-danger); }
.status-warning { background-color: var(--accent-warning); }

.spinner {
    display: inline-block;
    animation: spin 1s linear infinite;
    margin-left: 5px;
    font-weight: bold;
    color: var(--accent-primary);
}
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Login Page Override */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
}
.login-card {
    width: 400px;
    text-align: center;
    padding: 40px;
}
.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
    line-height: 1.2;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.92rem;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: white;
    border: none;
    padding: 10px 20px;
}

.login-card .btn-primary,
.login-panel .btn-primary {
    width: 100%;
    margin-top: 20px;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
}

.btn-secondary {
    background: #334155;
    color: #e2e8f0;
    border: 1px solid #475569;
    padding: 10px 14px;
    width: auto;
    margin-top: 0;
}

.btn-secondary:hover {
    background: #3f5168;
}

/* In app shell views, primary buttons should not stretch full row by default. */
.app-main .btn-primary {
    width: auto;
    margin-top: 0;
}

/* --- RESPONSIVE BREAKPOINTS --- */

/* 1) Menší desktop / notebook */
@media (max-width: 1280px) {
    .app-header {
        padding: 0 18px;
    }

    .content-scrollable {
        padding: 20px;
    }

    .card {
        padding: 16px;
    }
}

/* 2) Tablet landscape */
@media (max-width: 1024px) {
    .pedikura-app-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr var(--status-height);
        grid-template-areas:
            "sidebar"
            "main"
            "status";
        overflow: hidden;
    }

    .app-sidebar {
        width: 100%;
        max-width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 10px 12px;
        gap: 10px;
    }

    .app-logo {
        margin-bottom: 4px;
        font-size: 1.1rem;
    }

    .nav-links {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 8px;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: thin;
        padding-bottom: 2px;
    }

    .nav-item {
        flex: 0 0 auto;
    }

    .nav-item a {
        padding: 8px 10px;
        font-size: 0.88rem;
        white-space: nowrap;
        transform: none !important;
    }

    .app-main {
        min-height: 0;
    }

    .app-header {
        padding: 10px 14px;
        min-height: var(--header-height);
        height: auto;
        gap: 10px;
    }

    .page-title {
        font-size: 1.1rem;
    }

    .user-profile {
        max-width: 55%;
        font-size: 0.9rem;
    }

    .content-scrollable {
        padding: 14px;
    }

    .app-statusbar {
        padding: 0 12px;
        gap: 8px;
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: thin;
        min-height: var(--status-height);
        height: auto;
    }

    .app-statusbar .connection-status #backend-status-text,
    .app-statusbar .connection-status #banking-status-text,
    .app-statusbar .connection-status #katastr-status-text,
    .app-statusbar .connection-status #s3-status-text {
        max-width: min(140px, 22vw);
    }
}

/* 3) Tablet portrait / velký mobil */
@media (max-width: 768px) {
    .app-sidebar {
        padding: 8px 10px;
    }

    .app-logo {
        font-size: 1rem;
    }

    .app-header {
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
    }

    .app-header .page-title {
        order: 1;
        flex: 1 1 auto;
        font-size: 1.02rem;
        line-height: 1.25;
    }

    .app-header .user-profile {
        order: 2;
    }

    .app-header .actions {
        order: 2;
    }

    .app-header #btn-return-case {
        order: 2;
        flex-shrink: 0;
    }

    .app-header-ticker {
        order: 5;
        flex: 1 1 100%;
        max-width: 100%;
        justify-content: center;
        padding: 4px 0 0;
    }

    .running-text-wrap--header {
        max-width: 100%;
    }

    .user-profile {
        max-width: min(100%, 280px);
        font-size: 0.85rem;
    }

    .content-scrollable {
        padding: 10px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .card {
        border-radius: 10px;
        padding: 12px;
    }

    .app-statusbar {
        font-size: 0.74rem;
        justify-content: flex-start;
    }

    .modal-window {
        width: 96vw !important;
        max-width: 96vw !important;
        max-height: 90vh !important;
        border-radius: 10px;
    }

    .modal-body {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
}

/* 4) Mobil */
@media (max-width: 576px) {
    :root {
        --status-height: 34px;
    }

    .nav-item a {
        padding: 7px 9px;
        font-size: 0.82rem;
    }

    .nav-icon {
        margin-right: 8px;
        width: 16px;
    }

    .app-header {
        padding: 8px 10px;
    }

    .content-scrollable {
        padding: 8px;
    }

    .btn-primary,
    .btn-secondary {
        min-height: 34px;
        font-size: 0.84rem;
        padding: 8px 10px;
    }

    .app-main .btn-primary {
        width: 100%;
    }
}

/* Skrytá správa SMTP (celoobrazovka bez hlavního layoutu) */
.smtp-empty-layout-root {
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    overflow: auto;
    background: var(--bg-app);
    color: var(--text-main);
    padding: 24px 18px 48px;
}

.smtp-admin-page {
    max-width: 640px;
    margin: 0 auto;
}

.smtp-admin-page .panel,
.smtp-admin-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px 22px;
}

.smtp-admin-page h1 {
    font-size: 1.35rem;
    margin-bottom: 8px;
}

.smtp-admin-page .muted {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 18px;
}

.smtp-admin-page .fld-label {
    display: block;
    font-size: 0.88rem;
    color: var(--text-muted);
    margin: 14px 0 6px;
}

.smtp-admin-page .form-control,
.smtp-admin-page input[type="text"],
.smtp-admin-page input[type="password"],
.smtp-admin-page input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-main);
    font-size: 0.95rem;
}

.smtp-admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.smtp-admin-actions .btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.smtp-admin-banner {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
}

.smtp-admin-banner--ok {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
}

.smtp-admin-banner--err {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}
