/*
 * Layout aplikace nad výchozím tématem PrimeFaces (Saga Blue).
 * Horní lišta, postranní menu, obsah a patička. Barvy odpovídají Saga Blue.
 */
:root {
    --app-topbar-height: 3.5rem;
    --app-sidebar-width: 20rem;
    --app-bg: #f8f9fa;
    --app-surface: #ffffff;
    --app-border: #dee2e6;
    --app-text-muted: #6c757d;
    --app-primary: #2196f3;
    --app-primary-soft: #e3f2fd;
}

html {
    font-size: 14px;
}

/* Saga nastavuje písmo jen komponentám, zbytek stránky ho převezme odsud */
body.app-body,
body.app-login-body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    color: #495057;
}

body.app-body {
    margin: 0;
    background: var(--app-bg);
}

/* Horní lišta */
.app-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--app-topbar-height);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1rem;
    background: var(--app-surface);
    border-bottom: 1px solid var(--app-border);
    z-index: 1000;
}

.app-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--app-text-muted);
    cursor: pointer;
}

.app-menu-toggle:hover {
    background: var(--app-bg);
}

.app-menu-toggle .pi {
    font-size: 1.25rem;
}

.app-logo img {
    display: block;
    height: 2.25rem;
}

.app-topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Nápověda vzhledem jako tlačítko uživatele vedle ní (ne jako podtržený odkaz) */
.app-topbar .app-help-link a,
.app-topbar .app-help-link a:hover {
    text-decoration: none;
    color: inherit;
}

/* Postranní menu */
.app-sidebar {
    position: fixed;
    top: var(--app-topbar-height);
    bottom: 0;
    left: 0;
    width: var(--app-sidebar-width);
    overflow-y: auto;
    padding: 0.75rem;
    box-sizing: border-box;
    background: var(--app-surface);
    border-right: 1px solid var(--app-border);
    z-index: 999;
    transition: transform 0.2s;
}

.app-menu.ui-menu {
    width: 100%;
    padding: 0;
    border: 0;
}

/* Nadpisy sekcí menu (Zájezdy, Fakturace a Pokladna, ...) */
.app-menu.ui-menu .ui-widget-header {
    margin-top: 0.75rem;
    background: transparent;
    border: 0;
}

.app-menu.ui-menu .ui-widget-header:first-child {
    margin-top: 0;
}

.app-menu.ui-menu .ui-widget-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--app-text-muted);
}

/* Ikona zůstane vlevo i u dlouhých položek, text se zalomí vedle ní */
.app-menu.ui-menu .ui-menuitem-link {
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.app-menu.ui-menu .ui-menuitem-link .ui-menuitem-icon {
    flex-shrink: 0;
}

.app-menu.ui-menu .ui-menuitem-link.app-menu-active {
    background: var(--app-primary-soft);
    color: var(--app-primary);
    font-weight: 600;
}

.app-menu.ui-menu .ui-menuitem-link.app-menu-active .ui-menuitem-icon,
.app-menu.ui-menu .ui-menuitem-link.app-menu-active .ui-menuitem-text {
    color: var(--app-primary);
}

/* Obsah */
.app-main {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin-left: var(--app-sidebar-width);
    padding-top: var(--app-topbar-height);
    box-sizing: border-box;
    transition: margin-left 0.2s;
}

.app-breadcrumb {
    padding: 0.75rem 1.5rem 0;
    color: var(--app-text-muted);
}

.app-breadcrumb:empty {
    display: none;
}

.app-content {
    flex: 1;
    padding: 1rem 1.5rem;
}

.app-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--app-surface);
    border-top: 1px solid var(--app-border);
    color: var(--app-text-muted);
    font-size: 0.875rem;
}

.app-footer img {
    height: 1.75rem;
}

.app-ajax-status {
    position: fixed;
    right: 0.75rem;
    bottom: 0.75rem;
    z-index: 1100;
    color: var(--app-primary);
    font-size: 1.5rem;
}

.app-mask {
    display: none;
}

/* Desktop: menu lze skrýt */
body.app-menu-hidden .app-sidebar {
    transform: translateX(-100%);
}

body.app-menu-hidden .app-main {
    margin-left: 0;
}

/* Tablet a mobil: menu se vysouvá přes obsah */
@media (max-width: 991px) {
    .app-sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }

    .app-main {
        margin-left: 0;
    }

    body.app-menu-open .app-sidebar {
        transform: none;
        box-shadow: 0 0 1.5rem rgba(0, 0, 0, 0.2);
    }

    body.app-menu-open .app-mask {
        display: block;
        position: fixed;
        inset: var(--app-topbar-height) 0 0 0;
        background: rgba(0, 0, 0, 0.3);
        z-index: 998;
    }

    .app-content {
        padding: 0.75rem;
    }
}

/* Na telefonu jen ikona uživatele, jméno se nevejde */
@media (max-width: 575px) {
    .app-topbar .app-user-menu .ui-button .ui-button-text {
        display: none;
    }

    .app-topbar .app-user-menu .ui-button {
        width: 2.5rem;
        height: 2.5rem;
        padding: 0;
    }

    .app-topbar .app-user-menu .ui-button .ui-button-icon-left {
        left: 50%;
        margin-left: 0;
        transform: translateX(-50%);
    }

    /* Nápověda na telefonu jen jako ikona */
    .app-topbar .app-help-link .ui-button-text {
        display: none;
    }
}

/* Přihlašovací a chybová stránka */
body.app-login-body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    box-sizing: border-box;
    background: var(--app-bg) center / cover no-repeat;
}

.app-login-card {
    width: 100%;
    max-width: 26rem;
    padding: 2rem;
    box-sizing: border-box;
    background: var(--app-surface);
    border-radius: 6px;
    box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.15);
}

.app-login-card h1 {
    margin: 0 0 1.5rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.app-login-card .app-login-logo {
    display: block;
    height: 3rem;
    max-width: 100%;
    margin-bottom: 1rem;
}

/* personalizované přihlášení agentury: pod názvem agentury název aplikace */
.app-login-card .app-login-sub {
    margin: -0.5rem 0 1rem;
    color: #6c757d;
}

.app-login-card .field label {
    display: block;
    margin-bottom: 0.375rem;
}

/* Testovací prostředí: výrazný žlutý pruh, aby si uživatelé nespletli test s produkcí */
body.app-env-test .app-topbar {
    background: #ffd600;
    border-bottom-color: #c7a500;
}

.app-env-badge {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: #212529;
    white-space: nowrap;
}

.app-env-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 0.75rem;
    background: #ffd600;
    color: #212529;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-align: center;
    z-index: 1000;
}

@media (max-width: 575px) {
    .app-env-badge {
        font-size: 1rem;
        letter-spacing: 0.05em;
    }
}

/* Barvy příznaků klientů (flags.color) – dřív ze šablony, hodnoty jsou uložené v databázi */
.Red { color: #d32f2f; }
.Green { color: #388e3c; }
.Yellow { color: #f9a825; }
.Blue { color: #1976d2; }
.Orange { color: #ef6c00; }
.Purple { color: #7b1fa2; }
.Gray { color: #616161; }

/* ---------------------------------------------------------------- AI asistent (plovoucí okno) */
.as-fab { position: fixed; right: 18px; bottom: 18px; z-index: 900; width: 72px; height: 72px; padding: 0; border: none;
          background: transparent; cursor: pointer; filter: drop-shadow(0 3px 6px rgba(0,0,0,.25)); transition: transform .15s; }
.as-fab:hover { transform: scale(1.08); }
.as-fab img { width: 100%; height: 100%; object-fit: contain; }
.as-fab-label { position: absolute; right: 80px; bottom: 22px; white-space: nowrap; background: #1F4E79; color: #fff;
                font-size: .85rem; padding: .2rem .6rem; border-radius: 1rem; opacity: 0; pointer-events: none; transition: opacity .15s; }
.as-fab:hover .as-fab-label { opacity: 1; }
.as-actions { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.5rem; }
.as-actions .ui-button { text-align: left; white-space: normal; }
body.as-panel-open .as-fab, body:has(.ui-widget-overlay.ui-dialog-mask) .as-fab { display: none; }
.as-panel { position: fixed; right: 18px; bottom: 18px; z-index: 950; width: 380px; height: 560px; max-height: calc(100vh - 36px);
            display: none; flex-direction: column; background: #fff; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.25);
            overflow: hidden; }
.as-panel.as-open { display: flex; }
.as-panel form { display: flex; flex-direction: column; height: 100%; }
.as-head { display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem; background: #1F4E79; color: #fff; }
.as-head img { width: 36px; height: 36px; object-fit: contain; }
.as-head-actions { margin-left: auto; display: flex; gap: .5rem; }
.as-icon, .as-icon:visited, .as-head .ui-commandlink.as-icon { color: #fff; text-decoration: none; padding: .2rem; }
.as-msgs { flex: 1; overflow-y: auto; padding: .75rem; background: #f4f7fa; }
.as-msg { max-width: 88%; margin: 0 0 .6rem; padding: .5rem .7rem; border-radius: 10px; font-size: .92rem; line-height: 1.4;
          overflow-wrap: anywhere; }
.as-msg p { margin: 0 0 .4rem; } .as-msg p:last-child { margin-bottom: 0; }
.as-msg ul, .as-msg ol { margin: .2rem 0 .4rem; padding-left: 1.2rem; }
.as-bot { background: #fff; border: 1px solid #dfe6ee; }
.as-user { background: #2E86C1; color: #fff; margin-left: auto; white-space: pre-wrap; }
.as-error { border-color: #e6b0aa; background: #fdf2f1; }
.as-typing { display: none; color: #6c757d; font-style: italic; }
.as-sources { margin-top: .4rem; font-size: .8rem; color: #5b6b7b; }
.as-rate { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin-top: .4rem; font-size: .85rem; }
.as-rate a { color: #8a96a3; text-decoration: none; }
.as-rate a.as-rated, .as-rate a:hover { color: #1F4E79; }
.as-rate-note { display: flex; gap: .3rem; width: 100%; }
.as-rate-note input { flex: 1; min-width: 0; }
.as-rate-thanks { color: #6c757d; font-size: .8rem; }
.as-input { display: flex; gap: .4rem; padding: .5rem; border-top: 1px solid #e3e8ee; align-items: center; }
.as-input textarea { flex: 1; resize: none; }
.as-attach, .as-attach:visited { color: #8a96a3; text-decoration: none; font-size: 1.15rem; padding: .2rem; }
.as-attach:hover { color: #1F4E79; }
.as-chips { display: none; flex-wrap: wrap; gap: .3rem; padding: .4rem .6rem 0; }
.as-chip { background: #e8eef5; border-radius: 1rem; padding: .1rem .6rem; font-size: .78rem; color: #1F4E79; }
.as-chip a { color: #8a96a3; text-decoration: none; margin-left: .35rem; font-weight: bold; }
.as-file-msg { display: none; font-size: .78rem; color: #b03a2e; padding: .3rem .6rem 0; }
/* odpovědi podpory Tevonio (agent i člověk) – odlišené od asistenta agentury */
.as-support { border-color: #e9b46c; background: #fffaf1; }
.as-support-tag { font-size: .72rem; color: #a35f00; text-transform: uppercase; letter-spacing: .03em; margin-bottom: .25rem; }
.as-note { font-size: .72rem; color: #6c757d; padding: 0 .6rem .5rem; }
@media (max-width: 600px) {
    .as-fab { width: 56px; height: 56px; right: 12px; bottom: 12px; }
    /* přes celou obrazovku a nad horní lištou aplikace (z-index 1000), jinak lišta zakryje záhlaví se zavřením */
    .as-panel { inset: 0; z-index: 1050; width: auto; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0;
                overflow-x: hidden; }
    /* písmo aspoň 16 px – jinak Safari na iPhonu při ťuknutí do pole stránku přiblíží a okno přeteče mimo obrazovku */
    .as-input textarea, .as-input textarea.ui-inputfield { font-size: 16px; min-width: 0; }
    .as-head { padding-top: calc(.5rem + env(safe-area-inset-top)); }
    .as-icon { font-size: 1.35rem; padding: .35rem .5rem; }
}

/* Prodlení s předplatným: pruh jen pro administrátora agentury, aplikace nic neblokuje */
.app-overdue {
    margin: 1rem 1.5rem 0;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    background: #fff4e5;
    border: 1px solid #f0b46c;
    color: #7a4100;
}

.app-overdue .pi {
    margin-right: 0.5rem;
}

/* Kontrola délky hesla s jezevčíkem (WEB-INF/passwordDog.xhtml, js/password-dog.js) */
.pw-dog {
    margin: 0 0 0.5rem;
    text-align: center;
}
.pw-dog-stage {
    height: 110px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.pw-dog-svg {
    max-width: 100%;
    height: auto;
    overflow: visible;
}
.pw-dog .grow {
    transition: width .25s ease, transform .25s ease;
}
.pw-dog .tail {
    transform-box: view-box;
    transform-origin: 44px 74px;
}
.pw-dog.wag .tail {
    animation: pw-wag .22s ease-in-out infinite alternate;
}
@keyframes pw-wag {
    from { transform: rotate(-18deg); }
    to { transform: rotate(14deg); }
}
.pw-dog.hop [data-part="dogAll"] {
    animation: pw-hop .18s ease-out;
}
@keyframes pw-hop {
    50% { transform: translateY(-3px); }
}
.pw-dog [data-part="face"] > g {
    display: none;
}
.pw-dog-label {
    font-size: 0.85rem;
    font-weight: 600;
    min-height: 1.1em;
}
.pw-dog-label.pw-l0 { color: #d33; }
.pw-dog-label.pw-l1 { color: #b07d00; }
.pw-dog-label.pw-l2 { color: #5d8a00; }
.pw-dog-label.pw-l3 { color: #2a9d3a; }
@media (prefers-reduced-motion: reduce) {
    .pw-dog .grow { transition: none; }
    .pw-dog.wag .tail, .pw-dog.hop [data-part="dogAll"] { animation: none; }
}

/* Registrace agentury: širší karta, údaje z ARES, past na roboty */
.app-login-card.app-register-card {
    max-width: 36rem;
}

.app-register-firm {
    padding: 0.5rem 0.75rem;
    border-left: 3px solid var(--primary-color, #2196f3);
    background: rgba(0, 0, 0, 0.03);
    line-height: 1.5;
}

.app-register-note {
    display: block;
    margin-top: 0.375rem;
    color: #6c757d;
}

.app-register-hp {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Administrace → Předplatné: faktura předplatného k tisku */
.app-subinvoice h3 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
}

.app-subinvoice-note {
    margin: -0.5rem 0 1rem;
    color: #6c757d;
}

.app-subinvoice-table {
    border-collapse: collapse;
}

.app-subinvoice-table td, .app-subinvoice-table th {
    padding: 0.25rem 1.5rem 0.25rem 0;
    text-align: left;
}

.app-subinvoice-items {
    width: 100%;
    margin-top: 1.5rem;
}

.app-subinvoice-items th, .app-subinvoice-items td {
    border-bottom: 1px solid #dee2e6;
    padding: 0.5rem 0.5rem 0.5rem 0;
}

/* Zkušební období: informační pruh pro administrátora */
.app-trial {
    margin: 1rem 1.5rem 0;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    background: #e8f4fd;
    border: 1px solid #90c8f0;
    color: #0b4f7c;
}

.app-trial .pi {
    margin-right: 0.5rem;
}

.app-subinvoice-paid {
    display: inline-block;
    margin: 0 0 1rem;
    padding: 0.25rem 0.75rem;
    border: 2px solid #2e7d32;
    border-radius: 4px;
    color: #2e7d32;
    font-weight: 600;
}

/* buňky tabulky bez zalomení (čísla dokladů, data, období) */
.app-nowrap {
    white-space: nowrap;
}

.app-subinvoice-cancelled {
    border-color: #c62828;
    color: #c62828;
}

/* Administrace → Uživatelé a Pobočky: cena nad základ předplatného */
.app-plan-notice {
    max-width: 60rem;
    margin: 0.75rem 0;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    background: #e8f4fd;
    color: #0b4f7c;
}

.app-plan-notice .pi {
    margin-right: 0.375rem;
}

/* Dárek: promo kód přidělený agentuře */
.app-gift {
    background: #fdf3e6;
    border-color: #e9b46c;
    color: #6b3d00;
}

/* svislé čáry mezi skupinami sloupců (detail zájezdu a klienta: předpis | klient | cestovní kancelář, provize):
   sloupce mají v xhtml border-right-color, téma Saga ale u buněk kreslí jen spodní čáru – doplnit šířku a styl */
.ui-datatable th[style*="border-right-color"],
.ui-datatable td[style*="border-right-color"] {
    border-right-width: 1px !important;
    border-right-style: solid !important;
    border-right-color: #e9ecef !important;   /* jako čáry v záhlaví tabulky */
}

/* Plovoucí záhlaví tabulek (stickyHeader) pod horní lištou (1000), menu (999) a dialogy – PrimeFaces mu jinak dá
   z-index vyšší než dialogu otevřenému hned při načtení stránky (Nový zájezd z menu) */
.ui-datatable-sticky.ui-widget { z-index: 998 !important; }
