/* ==========================================================================
   Kokolando — design tokens
   Paleta: eggshell krem, hlinena cervena (vrata kurniku), mechova zelen (tráva),
   slunecna zluta zloutku - pouzita ustridmene jen jako akcent stavu "volitelna".
   ========================================================================== */
:root {
    --cream: #F5F1E6;
    --cream-2: #FBF9F3;
    --ink: #2B2926;
    --ink-soft: #6B6558;
    --barn-red: #B3492B;
    --barn-red-dark: #8F3820;
    --moss: #5C6E4A;
    --moss-dark: #48592F;
    --yolk: #E8B33D;
    --line: #E4DCC8;

    --state-potreba: #E8833A;
    --state-potreba-bg: #FBEADB;
    --state-volitelna: #F0DFA0;
    --state-volitelna-bg: #FBF6E4;
    --state-zadna: #C9C3B2;
    --state-zadna-bg: #EBE8DE;

    --radius: 14px;
    --radius-lg: 22px;
    --shadow: 0 2px 10px rgba(43, 41, 38, 0.08);
    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--cream);
    color: var(--ink);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    max-width: 100%;
}

body { padding-bottom: 40px; }

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 8px;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
p { margin: 0 0 12px; }
.muted { color: var(--ink-soft); font-size: 0.88rem; }
a { color: var(--barn-red); }

/* ---- topbar ---- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: var(--barn-red);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: var(--shadow);
}
.topbar-brand { display: flex; align-items: center; gap: 8px; }
.brand-emoji { font-size: 1.4rem; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.role-chip {
    font-size: 0.72rem;
    background: rgba(255,255,255,0.18);
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.icon-link {
    color: #fff;
    text-decoration: none;
    font-size: 1.1rem;
    opacity: 0.9;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.icon-link:hover { opacity: 1; }

/* ---- layout ---- */
.app-main {
    max-width: 620px;
    margin: 0 auto;
    padding: 16px 14px 8px;
}
.centered-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.card {
    background: var(--cream-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 18px 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.status-card { text-align: center; max-width: 380px; }
.status-emoji { font-size: 2.6rem; margin-bottom: 6px; }
.page-title { margin: 6px 0 14px; }
.back-link { display: inline-block; margin-bottom: 8px; font-size: 0.9rem; text-decoration: none; color: var(--ink-soft); }
.hint-text { font-size: 0.86rem; color: var(--ink-soft); padding: 0 4px; }
.app-footer { text-align: center; color: var(--ink-soft); font-size: 0.78rem; padding: 24px 0 10px; }

/* ---- buttons ---- */
.btn {
    display: inline-block;
    border: none;
    border-radius: 10px;
    padding: 11px 18px;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: transform 0.06s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--barn-red); color: #fff; }
.btn-primary:hover { background: var(--barn-red-dark); }
.btn-secondary { background: var(--moss); color: #fff; }
.btn-outline { background: transparent; color: var(--barn-red); border: 1.5px solid var(--barn-red); }
.btn-danger { color: #B3261E; border-color: #B3261E; }
.btn-block { display: block; width: 100%; margin-top: 6px; }
.btn-sm { padding: 7px 12px; font-size: 0.82rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---- calendar ---- */
.calendar-wrap { padding: 14px 12px; }
.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.calendar-nav h2 { text-transform: capitalize; }
.icon-btn {
    background: var(--cream);
    border: 1px solid var(--line);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--barn-red);
}
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-potreba { background: var(--state-potreba); }
.dot-volitelna { background: var(--state-volitelna); }
.dot-zadna { background: var(--state-zadna); }

/* ---- traffic-light dots (stav kontroly) ---- */
.tl-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.tl-yellow { background: #E8B33D; }
.tl-green { background: #4C9A5B; }
.tl-red { background: #D6473C; }

.tl-cross {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 10px;
    height: 10px;
    flex-shrink: 0;
    color: #D6473C;
}
.tl-cross svg { width: 100%; height: 100%; }
.alert-text-warning { color: var(--barn-red-dark); font-weight: 700; }

/* ---- legenda (pod kalendářem) — samostatné "chipy", které se bezpečně zalamují ---- */
.legend-box {
    background: var(--cream);
    border-radius: 12px;
    padding: 10px 12px;
    margin-top: 10px;
}
.legend-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 8px;
    margin-bottom: 6px;
}
.legend-row:last-child { margin-bottom: 0; }
.legend-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--ink-soft);
    background: var(--cream-2);
    border: 1px solid var(--line);
    padding: 4px 9px;
    border-radius: 20px;
}
.legend-pill strong { color: var(--ink); }

.weekday-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 0.72rem;
    color: var(--ink-soft);
    margin-bottom: 4px;
    font-weight: 600;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
    width: 100%;
}
.day-cell {
    position: relative;
    min-width: 0;
    overflow: hidden;
    aspect-ratio: 1 / 1.55;
    border-radius: 10px 10px 14px 14px;
    background: var(--state-volitelna-bg);
    border: 1.5px solid transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 4px 1px 3px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--ink);
    -webkit-tap-highlight-color: transparent;
}
.day-cell.type-potreba { background: var(--state-potreba-bg); border-color: var(--state-potreba); }
.day-cell.type-volitelna { background: var(--state-volitelna-bg); border-color: var(--state-volitelna); }
.day-cell.type-zadna { background: var(--state-zadna-bg); border-color: var(--state-zadna); color: var(--ink-soft); }
.day-cell.outside-month { opacity: 0.35; }
.day-cell.is-today { box-shadow: 0 0 0 2px var(--barn-red) inset; font-weight: 700; }
.day-num { font-weight: 600; }
.day-weekday {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.day-cell .egg-badge {
    margin-top: 1px;
    font-size: 0.62rem;
    background: #fff;
    border-radius: 8px;
    padding: 1px 5px;
    color: var(--ink-soft);
}
.day-cell .reserved-dot {
    position: absolute;
    top: 4px;
    right: 5px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--moss);
}
.day-cell .mismatch-flag {
    position: absolute;
    bottom: 3px;
    right: 4px;
    font-size: 0.65rem;
}

/* ---- ráno/večer semaforové indikátory v buňce dne ---- */
/* Dva sloupce vedle sebe (R | V), v každém sloupci nahoře popisek, pod ním ikonka.
   Vizuálně tak vznikne řádek "R  V" a pod ním řádek s ikonkami. */
.shift-indicators {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: auto;
    padding-top: 3px;
    width: 100%;
}
.tl-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 0.62rem;
    font-weight: 700;
    color: var(--ink-soft);
    letter-spacing: 0.02em;
    position: relative;
    cursor: help;
}
.tl-chip .tl-dot,
.tl-chip .tl-cross { margin: 0; }

/* jednoduchý CSS tooltip při najetí myší */
.tl-chip[data-tooltip] {
    -webkit-tap-highlight-color: transparent;
}
.tl-chip[data-tooltip]:hover::after,
.tl-chip[data-tooltip]:focus::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 130%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: #fff;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 500;
    white-space: nowrap;
    z-index: 30;
    box-shadow: var(--shadow);
    pointer-events: none;
}
.tl-chip[data-tooltip]:hover::before,
.tl-chip[data-tooltip]:focus::before {
    content: '';
    position: absolute;
    bottom: 118%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--ink);
    z-index: 30;
    pointer-events: none;
}

/* ---- modal bottom sheet ---- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(43,41,38,0.42);
    display: flex;
    align-items: flex-end;
    z-index: 50;
    transition: opacity 0.2s ease;
}
.modal-backdrop.hidden { display: none; }
.modal-sheet {
    background: var(--cream-2);
    width: 100%;
    max-width: 620px;
    margin: 0 auto;
    border-radius: 22px 22px 0 0;
    padding: 10px 18px 26px;
    max-height: 86vh;
    overflow-y: auto;
    box-shadow: 0 -6px 24px rgba(0,0,0,0.18);
    animation: sheet-up 0.2s ease;
}
@keyframes sheet-up {
    from { transform: translateY(24px); opacity: 0.6; }
    to { transform: translateY(0); opacity: 1; }
}
.modal-handle {
    width: 40px;
    height: 4px;
    background: var(--line);
    border-radius: 4px;
    margin: 6px auto 14px;
}

/* ---- forms ---- */
.field { display: block; margin-bottom: 14px; }
.field > span, fieldset.field legend { display: block; font-weight: 600; font-size: 0.88rem; margin-bottom: 6px; }
.field input[type=text],
.field input[type=number],
.field input[type=email],
.field select,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    font-family: var(--font-body);
    font-size: 1rem;
    background: #fff;
    color: var(--ink);
}
.checkbox-field { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.checkbox-field input { width: 18px; height: 18px; }
.radio-inline { margin-right: 16px; font-weight: 500; font-size: 0.92rem; }
fieldset.field { border: none; padding: 0; }
.instruction-box {
    background: var(--state-volitelna-bg);
    border-left: 3px solid var(--yolk);
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-top: 8px;
}
.settings-form { display: flex; flex-direction: column; gap: 4px; }
.inline-form { display: inline-flex; align-items: center; gap: 6px; margin: 0; }

/* ---- range planner ---- */
.range-planner .range-form { display: flex; flex-direction: column; gap: 4px; }
.range-planner .field { margin-bottom: 10px; }

/* ---- egg total block (den) ---- */
.egg-total-block { background: var(--cream); border-radius: 12px; padding: 10px 12px; }
.egg-total-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.egg-total-value { font-size: 1.3rem; font-weight: 700; font-family: var(--font-display); }
.egg-manual-badge {
    font-size: 0.7rem;
    background: var(--state-volitelna-bg);
    color: var(--barn-red-dark);
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
}

/* ---- admin lists ---- */
.user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.user-row:last-child { border-bottom: none; }
.user-info { display: flex; flex-direction: column; }
.table-scroll { overflow-x: auto; }
.log-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.log-table th, .log-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }

/* ---- alerts ---- */
.alert { padding: 10px 14px; border-radius: 10px; font-size: 0.88rem; margin-bottom: 12px; }
.alert-success { background: #E4EEDD; color: var(--moss-dark); }
.alert-warning { background: var(--state-potreba-bg); color: var(--barn-red-dark); }
.alert-info { background: var(--state-volitelna-bg); color: var(--ink); }

/* ---- toast ---- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%);
    background: var(--ink);
    color: #fff;
    padding: 10px 18px;
    border-radius: 30px;
    font-size: 0.88rem;
    z-index: 100;
    box-shadow: var(--shadow);
}
.toast.hidden { display: none; }

/* ---- day detail modal content ---- */
.detail-title { display: flex; align-items: baseline; justify-content: space-between; }
.shift-block { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.shift-block h3 { display: flex; align-items: center; gap: 6px; }
.record-row { display: flex; justify-content: space-between; font-size: 0.9rem; padding: 3px 0; }
.record-row span:first-child { color: var(--ink-soft); }
.warn-banner {
    background: var(--state-potreba-bg);
    color: var(--barn-red-dark);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.85rem;
    margin: 8px 0;
}

@media (min-width: 640px) {
    .app-main { padding-top: 24px; }
    .day-cell { font-size: 0.85rem; }
}
