/* iHub design system — Material 3 inspirace, petrolejová paleta.
   Tokeny + základní elementy + komponentní třídy (.btn, .chip, .banner). */

:root {
    /* barvy — tonální paleta kolem firemní #00abbd */
    --c-primary: #00abbd;
    --c-primary-hover: #0095a5;
    --c-on-primary: #ffffff;
    --c-primary-container: #cdeff2;
    --c-on-primary-container: #00363c;

    --c-surface: #edf5f6;
    --c-surface-container: #ffffff;
    --c-surface-hover: #dfedef;
    --c-on-surface: #161d1e;
    --c-muted: #566366;

    --c-outline: #a9bcbf;
    --c-outline-strong: #6b7e81;

    --c-error: #b3261e;
    --c-error-container: #f9dedc;
    --c-success: #1e6b41;
    --c-success-container: #d3eedd;
    --c-warn: #7a5900;
    --c-warn-container: #f6e8c8;

    /* tvary a stíny */
    --r-control: 8px;
    --r-card: 14px;
    --r-pill: 999px;
    --shadow-1: 0 2px 10px rgba(0, 40, 45, 0.07);
    --rail-width: 56px;
    --rail-width-open: 220px;

    --font: "Segoe UI", "SF Pro Text", system-ui, -apple-system, Roboto, sans-serif;
}

/* druhé téma: hot pink edice 💖 — přepisuje jen tokeny, komponenty beze změny */
:root[data-theme="pink"] {
    --c-primary: #c4157a;
    --c-primary-hover: #e0218a;
    --c-primary-container: #fcd9ec;
    --c-on-primary-container: #47082e;

    --c-surface: #fbf1f6;
    --c-surface-hover: #f4e1eb;
    --c-on-surface: #211318;
    --c-muted: #6b5a63;

    --c-outline: #c9aebc;
    --c-outline-strong: #8a6f7d;

    --shadow-1: 0 2px 10px rgba(60, 0, 35, 0.07);
}

* {
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    margin: 0;
    background: var(--c-surface);
    color: var(--c-on-surface);
    font-size: 14px;
    line-height: 1.45;
    /* sticky footer: krátká stránka má patičku u spodní hrany okna */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ---- top bar + levý navigační rail (layout dle Partners iCare) -------- */

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    height: 56px;
    padding: 0 20px;
    background: var(--c-surface-container);
    border-bottom: 1px solid var(--c-surface-hover);
}

.top-bar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}

.top-bar-user form {
    margin: 0;
}

.top-bar-user button,
.top-bar-user details.menu > summary {
    padding: 5px 14px;
    font-size: 13px;
}

/* přepínač tématu: kulaté tlačítko s kolečkem uprostřed (dvě soustředné
   kružnice), bez rozbalovací šipky; průměr odpovídá výšce ostatních tlačítek */
.top-bar-user details.theme-menu > summary {
    width: 29px;
    height: 29px;
    padding: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
}

.top-bar-user details.theme-menu > summary::after {
    content: none;
}

/* kolečko s hlavní barvou tématu (přepínač v top baru) */
.theme-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--c-primary);
    vertical-align: text-bottom;
}

.theme-dot.petrol {
    background: #00abbd;
}

.theme-dot.pink {
    background: #c4157a;
}

.top-bar .wordmark {
    color: var(--c-primary);
    text-decoration: none;
    font-weight: 700;
    font-size: 19px;
    letter-spacing: 0.01em;
}

.top-bar .wordmark span {
    color: var(--c-muted);
    font-weight: 400;
    font-size: 15px;
}

.shell {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
    flex: 1 0 auto;
}

.nav-rail {
    position: sticky;
    top: 12px;
    flex: none;
    width: var(--rail-width);
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    background: var(--c-primary);
    border-radius: var(--r-card);
    box-shadow: var(--shadow-1);
    overflow: hidden;
    z-index: 20;
    /* hover roztáhne rail PŘES obsah: záporný margin kompenzuje růst šířky,
       takže layout vpravo se neposune */
    transition: width 150ms ease, margin-right 150ms ease;
}

.nav-rail:hover,
.nav-rail:focus-within {
    width: var(--rail-width-open);
    margin-right: calc(var(--rail-width) - var(--rail-width-open));
    box-shadow: 0 4px 18px rgba(0, 40, 45, 0.22);
}

.nav-rail a {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 40px;
    padding: 0 10px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: background 120ms ease, color 120ms ease;
}

.nav-rail a svg {
    flex: none;
    width: 20px;
    height: 20px;
}

.nav-rail .label {
    white-space: nowrap;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: opacity 150ms ease;
}

.nav-rail:hover .label,
.nav-rail:focus-within .label {
    opacity: 1;
}

.nav-rail a:hover {
    background: rgba(255, 255, 255, 0.14);
    color: var(--c-on-primary);
}

.nav-rail a.active {
    background: rgba(255, 255, 255, 0.22);
    color: var(--c-on-primary);
}

.rail-divider {
    width: 24px;
    align-self: center;
    border-top: 1px solid rgba(255, 255, 255, 0.35);
    margin: 6px 0;
}

main.page {
    flex: 1;
    min-width: 0;
    max-width: 1100px;
    margin: 0 auto;
    padding: 8px 20px 20px;
}

footer {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 10px 20px 14px;
    font-size: 11px;
    color: var(--c-muted);
    text-align: center;
}

@media (max-width: 760px) {
    .shell {
        flex-direction: column;
        align-items: stretch;
    }

    .nav-rail {
        position: static;
        width: auto;
        flex-direction: row;
        justify-content: center;
        padding: 4px 8px;
    }

    .nav-rail:hover,
    .nav-rail:focus-within {
        width: auto;
        margin-right: 0;
    }

    .nav-rail .label {
        display: none;
    }

    .rail-divider {
        width: 0;
        height: 24px;
        border-top: none;
        border-left: 1px solid rgba(255, 255, 255, 0.35);
        margin: 0 6px;
    }

    main.page {
        padding: 8px 4px;
    }
}

/* ---- typografie -------------------------------------------------------- */

h1 {
    font-size: 25px;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 14px 0 10px;
}

.card {
    background: var(--c-surface-container);
    border-radius: var(--r-card);
    box-shadow: var(--shadow-1);
    padding: 16px 20px;
    margin: 12px 0;
}

h2 {
    font-size: 17px;
    font-weight: 600;
    margin: 22px 0 8px;
}

h3 {
    font-size: 14px;
    font-weight: 600;
    margin: 18px 0 6px;
}

a {
    color: var(--c-primary);
}

.muted {
    color: var(--c-muted);
}

.ok {
    color: var(--c-success);
}

.error {
    color: var(--c-error);
    font-weight: 600;
}

/* aliasy tříd používaných staršími šablonami */
.warning {
    color: var(--c-error);
}

button.happy,
input[type="submit"].happy {
    background: var(--c-success-container);
    color: var(--c-success);
}

/* ---- formulářové prvky -------------------------------------------------- */

button,
input[type="submit"] {
    font: inherit;
    font-weight: 550;
    white-space: nowrap;
    padding: 7px 18px;
    border-radius: var(--r-pill);
    border: none;
    background: var(--c-primary-container);
    color: var(--c-on-primary-container);
    cursor: pointer;
    transition: background 120ms ease, box-shadow 120ms ease;
}

button:hover:not(:disabled),
input[type="submit"]:hover {
    box-shadow: var(--shadow-1);
}

button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn,
button.primary,
input[type="submit"].primary {
    background: var(--c-primary);
    color: var(--c-on-primary);
}

.btn:hover:not(:disabled),
button.primary:hover,
input[type="submit"].primary:hover {
    background: var(--c-primary-hover);
}

.btn-outlined {
    background: transparent;
    border: 1px solid var(--c-outline-strong);
    color: var(--c-primary);
}

.btn-danger,
button.dangerous,
input[type="submit"].dangerous {
    background: var(--c-error-container);
    color: var(--c-error);
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="datetime-local"],
select,
textarea {
    font: inherit;
    padding: 6px 10px;
    border: 1px solid var(--c-outline-strong);
    border-radius: var(--r-control);
    background: var(--c-surface-container);
    color: var(--c-on-surface);
}

:is(button, input, select, textarea, a, [tabindex]):focus-visible {
    outline: 2px solid var(--c-primary);
    outline-offset: 2px;
}

/* ---- tabulky ------------------------------------------------------------ */

table {
    /* separate + rádius na rohových buňkách místo overflow: hidden,
       aby dropdown menu v buňkách nebylo oříznuté */
    border-collapse: separate;
    border-spacing: 0;
    background: var(--c-surface-container);
    border-radius: var(--r-card);
    box-shadow: var(--shadow-1);
    font-variant-numeric: tabular-nums;
    margin: 12px 0;
}

table :where(thead, tbody:first-child) tr:first-child > :first-child {
    border-top-left-radius: var(--r-card);
}

table :where(thead, tbody:first-child) tr:first-child > :last-child {
    border-top-right-radius: var(--r-card);
}

table tbody:last-child tr:last-child > :first-child {
    border-bottom-left-radius: var(--r-card);
}

table tbody:last-child tr:last-child > :last-child {
    border-bottom-right-radius: var(--r-card);
}

th, td {
    padding: 8px 12px;
    text-align: left;
    vertical-align: middle;
    border: none;
    border-bottom: 1px solid var(--c-surface-hover);
}

th {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--c-muted);
    background: var(--c-surface-container);
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover td {
    background: var(--c-surface-hover);
}

/* ---- data-detail: svislá key-value tabulka jednoho záznamu -------------- */

table.data-detail {
    max-width: 560px;
}

table.data-detail th {
    width: 1%;
    white-space: nowrap;
    vertical-align: top;
    text-transform: none;
    letter-spacing: normal;
    font-size: inherit;
    font-weight: 600;
    color: var(--c-muted);
}

table.data-detail td {
    vertical-align: top;
}

/* ---- chipy a bannery ----------------------------------------------------- */

.chip {
    display: inline-block;
    padding: 2px 10px;
    border-radius: var(--r-pill);
    font-size: 12px;
    font-weight: 550;
    background: var(--c-surface-hover);
    color: var(--c-muted);
}

.chip-ok {
    background: var(--c-success-container);
    color: var(--c-success);
}

.chip-err {
    background: var(--c-error-container);
    color: var(--c-error);
}

.chip-warn {
    background: var(--c-warn-container);
    color: var(--c-warn);
}

.banner {
    padding: 10px 14px;
    border-radius: var(--r-control);
    margin: 12px 0;
}

.banner.ok {
    background: var(--c-success-container);
    color: var(--c-success);
    font-weight: 500;
}

.banner.err {
    background: var(--c-error-container);
    color: var(--c-error);
}

.banner.warn {
    background: var(--c-warn-container);
    color: var(--c-warn);
}

/* ---- dropzone pro upload souborů (cts_documents, amimport) -------------- */

.dropzone {
    border: 2px dashed var(--c-outline);
    border-radius: var(--r-card);
    background: var(--c-surface-container);
    padding: 44px 20px;
    margin: 16px 0;
    text-align: center;
    color: var(--c-muted);
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease;
}

.dropzone.dragging,
.dropzone:hover {
    border-color: var(--c-primary);
    background: var(--c-primary-container);
    color: var(--c-on-primary-container);
}

/* tlačítko odebrání položky ze seznamu před odesláním */
button.remove {
    background: var(--c-error-container);
    color: var(--c-error);
    padding: 4px 12px;
}

/* ---- modální dialogy (nativní <dialog>) -------------------------------- */

dialog {
    border: none;
    border-radius: var(--r-card);
    box-shadow: 0 8px 30px rgba(0, 40, 45, 0.25);
    padding: 22px 26px;
    min-width: 340px;
    max-width: min(480px, 90vw);
    color: var(--c-on-surface);
}

dialog::backdrop {
    background: rgba(0, 40, 45, 0.4);
}

dialog h2 {
    margin-top: 0;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

/* ---- dropdown menu (<details class="menu">) ----------------------------- */

details.menu {
    position: relative;
    display: inline-block;
}

details.menu > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    font-weight: 550;
    padding: 7px 18px;
    border-radius: var(--r-pill);
    background: var(--c-primary-container);
    color: var(--c-on-primary-container);
}

details.menu > summary::-webkit-details-marker {
    display: none;
}

details.menu > summary::after {
    content: " ▾";
}

details.menu[open] > summary {
    box-shadow: var(--shadow-1);
}

details.menu > .menu-items {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 200px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--c-surface-container);
    border-radius: var(--r-control);
    box-shadow: 0 4px 18px rgba(0, 40, 45, 0.18);
    z-index: 30;
}

/* formulář v menu (např. odhlášení) se chová jako běžná položka */
.menu-items form {
    display: contents;
}

.menu-items button {
    background: none;
    border-radius: 8px;
    text-align: left;
    padding: 8px 12px;
    color: var(--c-on-surface);
    font-weight: 500;
}

.menu-items button:hover:not(:disabled) {
    background: var(--c-surface-hover);
    box-shadow: none;
}

.menu-items button.danger-item {
    color: var(--c-error);
}

/* ---- přepínač (switch) pro true/false hodnoty --------------------------- */

.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
    vertical-align: middle;
}

.switch input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.switch .track {
    position: absolute;
    inset: 0;
    border-radius: var(--r-pill);
    background: var(--c-outline);
    transition: background 120ms ease;
}

.switch .track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 40, 45, 0.35);
    transition: transform 120ms ease;
}

.switch input:checked + .track {
    background: var(--c-primary);
}

.switch input:checked + .track::after {
    transform: translateX(20px);
}

.switch input:focus-visible + .track {
    outline: 2px solid var(--c-primary);
    outline-offset: 2px;
}

/* nadpis stránky s akcí vpravo */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}
