/* Import moderního písma podobného webu kspraha.cz */
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&display=swap');

:root {
    --primary-color: #0054a6;
    --accent-color: #003d7a;
    --accent2-color: #012952;
    --text-color: #333;
    --link-color: #ed1c24;
    --bg-color: #f4f7f9;
    --card-bg: #ffffff;
    --border-radius: 8px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

html {
    scroll-behavior: smooth;
}

body {
    -webkit-font-smoothing: antialiased;
    font-family: "PT Sans", sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
    text-align: center; /* Centrování obsahu */
}

/* Typografie */
h1 {
    color: var(--primary-color);
    font-size: 2.6rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.5rem;
    color: #666;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}
.subtitle2 {
    font-size: 1.1rem;
    color: #666;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

h2 {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    display: inline-block;
    padding-bottom: 5px;
    margin-top: 50px;
    margin-bottom: 10px;
    font-size: 1.8rem; 
}

h3 {
    margin-top: 50px;
    color: var(--accent-color);
    font-size: 1.4rem;
    font-weight: 700;
}

/* Podnadpis pod h3 (adresa a časové rozmezí) */
.h3-subtitle {
    font-size: 1rem;
    color: #666;
    margin-top: -10px;
    margin-bottom: 20px;
    font-style: italic;
}

/* Instrukce a seznamy */
ol {
    list-style: none;
    counter-reset: steps-counter;
    text-align: left;
    max-width: 850px;
    margin: 20px auto;
    background: var(--card-bg);
    padding: 30px 40px 30px 60px; /* Větší padding vlevo pro kolečka */
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

ol li {
    counter-increment: steps-counter;
    position: relative;
    margin-bottom: 20px;
    line-height: 1.6;
    display: block; /* Vráceno na block pro správný tok textu */
}

ol li::before {
    content: counter(steps-counter);
    position: absolute;
    /* Umístění kolečka vlevo od textu */
    left: -40px; 
    top: 0.1rem; /* Jemné doladění výšky podle prvního řádku textu */
    
    /* Styling modrého kolečka */
    background-color: var(--primary-color);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    
    /* Vnitřní centrování čísla v kolečku zůstává flexem, to je v pořádku */
    display: flex;
    align-items: center;
    justify-content: center;
    
    font-weight: bold;
    font-size: 0.85rem;
    box-shadow: 0 2px 4px rgba(0, 84, 166, 0.2);
}

ol li:last-child {
    margin-bottom: 0;
}

.warning {
    color: var(--link-color);
    font-weight: bold;
}

/* Navigace po dnech */
.day-nav ul {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 30px 0;
}

.day-nav li {
    margin: 5px 0;
}

.day-nav a {
    text-decoration: none;
    background: var(--primary-color);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    transition: var(--transition);
}

.day-nav a:hover {
    background: var(--accent-color);
    transform: translateY(-2px);
}

/* Formuláře */
form {
    background: var(--card-bg);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    max-width: 600px;
    margin: 20px auto;
    text-align: left;
}

input[type="text"], textarea {
    width: 100%;
    padding: 10px;
    margin: 8px 0;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-family: inherit;
}

input[type="submit"], .button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    width: 100%;
}

input[type="submit"]:hover {
    background-color: var(--accent-color);
}

/* --- TABULKY (Hlavní část) --- */

.table-container {
    display: flex;
    flex-wrap: wrap; /* Klíčové: pokud není místo, hodí tabulku pod sebe */
    gap: 25px;
    margin-top: 30px;
    justify-content: center; /* Vycentruje tabulky, když nejsou přes celou šířku */
}

.timetable {
    flex: 1 1 auto;      /* Tabulka může růst i se smrsknout podle obsahu */
    min-width: 320px;    /* Minimální šířka, aby v klasickém módu byly 3 vedle sebe */
    max-width: 100%;     /* Nikdy nepřeteče šířku obrazovky */
    background: var(--card-bg);
    border-collapse: separate; /* Nutné pro zaoblené rohy u buněk */
    border-spacing: 0;
    box-shadow: var(--shadow);
    font-size: 0.9rem;
    transition: var(--transition);
    height: fit-content;
    border: 1px solid #eee;
    border-radius: var(--border-radius);
    table-layout: auto;  /* Necháme tabulku, aby se roztáhla podle admin sloupců */
}

/* Fixace šířky sloupce JMÉNO */
.timetable th:nth-child(2),
.timetable td:nth-child(2) {
    width: 255px;  
    min-width: 255px;
    max-width: 255px;   /* Fixace šířky */
    word-break: break-word; /* Pokud je jméno moc dlouhé, zalomí se */
    white-space: normal;    /* Povolí zalomení na víc řádků */
}

.timetable td:nth-child(1) {
    text-align: center;
}

/* Zaoblení rohů musíme aplikovat na konkrétní buňky v rozích */
.timetable thead tr:first-child th:first-child {
    border-top-left-radius: var(--border-radius);
}
.timetable thead tr:first-child th:last-child {
    border-top-right-radius: var(--border-radius);
}
.timetable tr:last-child td:first-child {
    border-bottom-left-radius: var(--border-radius);
}
.timetable tr:last-child td:last-child {
    border-bottom-right-radius: var(--border-radius);
}

/* Sticky Header logika */
.timetable thead th {
    position: sticky;
    background: var(--primary-color);
    color: white;
    z-index: 10;
    padding: 12px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    /* Důležité: outline nebo box-shadow místo borderu, 
       aby nevznikaly mezery při scrollování */
    box-shadow: 0 1px 0 rgba(255,255,255,0.2); 
}

.timetable thead tr:nth-child(1) th {
    top: 0;
}

.timetable thead tr:nth-child(2) th {
    top: 48px; /* Upraveno podle reálné výšky prvního řádku */
    background: var(--accent-color);
}

.timetable:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
}

/* Sticky Header logika */
.timetable thead th {
    position: sticky;
    background: var(--primary-color);
    color: white;
    z-index: 10;
    padding: 12px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

/* První řádek thead (Datum) */
.timetable thead tr:nth-child(1) th {
    top: 0;
    font-size: 1.1rem;
}

/* Druhý řádek thead (Čas / Jméno) */
.timetable thead tr:nth-child(2) th {
    top: 45px; /* Výška prvního řádku */
    background: var(--accent-color);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.timetable td {
    padding: 10px;
    border-bottom: 1px solid #eee;
    text-align: left;
}

.timetable td.deleted {
    text-decoration: line-through;
}


.timetable tr.selected {
    background-color: #ffc6c6;
}

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

/* Odkaz "přihlásit se" */
.timetable a {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
    display: block;
    padding: 4px 8px;
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    text-align: center;
    font-size: 0.8rem;
    transition: var(--transition);
}

.timetable a:hover {
    background: var(--primary-color);
    color: white;
}

/* Animace pro načtení */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.timetable {
    animation: fadeIn 0.6s ease-out both;
}

/* Footer */
.footer {
    margin-top: 60px;
    padding: 20px;
    color: #888;
    font-size: 0.9rem;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
}

a {
    color: var(--link-color);
    text-decoration: underline;
}

a:hover {
    text-decoration: none;
}

.note {
    font-size: 1rem;
    color: #666;
    font-style: italic;
}

/* --- PŘEHLEDOVÁ TABULKA (Heatmapa) --- */

.overview-table-wrapper {
    width: 100%;
    overflow-x: auto;
    margin: 20px 0;
}

.overview-table {
    table-layout: fixed; 
    width: auto; /* Tabulka se neroztahuje na 100 %, ale drží si své sloupce */
    border-collapse: collapse; /* Žádné mezery, maximálně kompaktní */
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    overflow: hidden; /* Aby rohy ořízly barvy v rozích */
}

/* První sloupec (datum) - úprava pro fixní šířku */
.overview-table th:first-child, 
.overview-table td:first-child {
    width: 100px; 
    min-width: 100px; /* Zabrání zmenšení pod tuto hranici */
    max-width: 100px; /* Zabrání zvětšení */
    text-align: center;
    padding-left: 10px;
    padding-right: 10px;
    white-space: nowrap; /* KLÍČOVÉ: Zakáže zalomení textu na nový řádek */
    background: #fff;
}

/* Ostatní sloupce (čtverečky) */
.overview-table th:not(:first-child),
.overview-table td:not(:first-child) {
    width: 37px;
    min-width: 37px; /* Vynutí, aby čtverec zůstal čtvercem */
    height: 37px;
    padding: 0;
    text-align: center;
    box-sizing: border-box;
}

.overview-table th {
    font-weight: 600;
    border: 1px solid #eee;
    font-size: 0.75rem;      /* Původně bylo 0.8rem */
    line-height: 1;         /* Minimální řádkování, aby text zůstal ve středu */
}

.overview-table td {
    border: 1px solid #eee; /* Jemná mřížka pro kompaktní vzhled */
    vertical-align: middle;
}

/* Popisky dní vlevo */
.overview-table td.day-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-color);
    background: #fff;
}

/* Stavy buněk */
.overview-table td.occupied { background-color: #ff4d4d; }
.overview-table td.free1 { background-color: var(--primary-color); }
.overview-table td.free2 { background-color: var(--accent-color); }
.overview-table td.na { background-color: #e0e0e0; }

/* Odkaz uvnitř buňky (aby se dalo kliknout na celou plochu čtverečku) */
.overview-table td.free1 a,
.overview-table td.free2 a {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
}

/* Efekty při najetí */
.overview-table td:not(.day-label):hover {
    transform: scale(1.2);
    z-index: 5;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    cursor: default;
}

.overview-table td.free1:hover {
    cursor: pointer;
    background-color: var(--accent-color);
}

.overview-table td.free2:hover {
    cursor: pointer;
    background-color: var(--accent2-color);
}

/* Legenda pod tabulkou */
.overview-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 15px;
    font-size: 0.85rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-box {
    width: 15px;
    height: 15px;
    border-radius: 3px;
}