/* --- CSS PROMĚNNÉ PRO LIGHT/DARK MODE --- */
:root {
    /* LIGHT MODE (Výchozí) */
    --clr-bg-primary: #f4f4f4; /* Pozadí body */
    --clr-bg-secondary: white; /* Pozadí .container */
    --clr-text-primary: #333;
    --clr-text-secondary: #2c3e50; /* Nadpisy */
    --clr-border: #ddd;
    --clr-table-head: #34495e;
    --clr-table-hover: #f1f1f1;
}

/* DARK MODE */
body.dark-mode {
    --clr-bg-primary: #121212;
    --clr-bg-secondary: #1e1e1e;
    --clr-text-primary: #ddd;
    --clr-text-secondary: #f0f0f0;
    --clr-border: #333;
    --clr-table-head: #3a3a3a;
    --clr-table-hover: #2a2a2a;
}
/* ------------------------------------------ */


/* Základní nastavení stránky */
body {
    font-family: 'Segoe UI', Arial, sans-serif; 
    background-color: var(--clr-bg-primary); 
    margin: 0;
    padding: 10px; 
    color: var(--clr-text-primary);
    
    /* --- POZADÍ S TRAMVAJÍ (MUSÍ BÝT NAHRÁN SOUBOR tramka.png) --- */
    background-image: url('tramka.png'); 
    background-attachment: fixed;
    background-size: cover;
    background-position: center center;
}

/* Hlavní kontejner (udržuje obsah čitelný nad pozadím) */
.container {
    max-width: 1200px;
    margin: 0 auto; 
    background: var(--clr-bg-secondary);
    padding: 20px; 
    border-radius: 8px; 
    box-shadow: 0 0 15px rgba(0,0,0,0.4); 
    overflow-x: hidden; 
}

/* Nadpisy */
h1, h2 {
    color: var(--clr-text-secondary);
    border-bottom: 3px solid #3498db; 
    padding-bottom: 10px;
    margin-bottom: 20px;
}

/* Odkazy a tlačítka v menu */
a {
    text-decoration: none;
    color: #3498db;
}

.top-menu {
    text-align: right;
    margin-bottom: 15px;
}

/* --- TLAČÍTKA V HORNÍM MENU (Vysoký kontrast) --- */
.btn-admin {
    background-color: #34495e; 
    color: white;
    padding: 8px 12px;
    border-radius: 5px;
    font-weight: bold;
    transition: 0.2s;
    display: inline-block;
    margin-left: 10px;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.2); 
}

/* STYL PRO TLAČÍTKO "Administrace" (Aktivní sekce) */
.btn-admin[href="admin.php"]:not([style*="background:#95a5a6"]) {
    background-color: #2980b9; 
}
/* Styly na indexu pro odlišení od Adminu */
.btn-admin[style*="background:#1abc9c;"] {
    background-color: #1abc9c !important; 
}

/* STYL PRO TLAČÍTKO "Odhlásit se" */
.btn-admin[href="logout.php"] {
    background-color: #e74c3c !important; 
}

/* HOVER EFEKT */
.btn-admin:hover {
    filter: brightness(1.2);
}

/* Styl pro toggle switch (přepínač Dark Mode) */
#dark-mode-toggle {
    cursor: pointer;
    background-color: #555;
    color: white;
    padding: 8px 12px;
    border-radius: 5px;
    font-weight: bold;
    transition: 0.2s;
    display: inline-block;
}
#dark-mode-toggle:hover {
    filter: brightness(1.2);
}
/* ---------------------------------------------------------------------- */


/* Formuláře */
label { display: block; margin-top: 15px; font-weight: bold; }
input[type="text"], input[type="number"], input[type="password"], select {
    width: 100%; padding: 10px; margin-top: 5px; border: 1px solid var(--clr-border); border-radius: 4px; box-sizing: border-box; 
    background-color: var(--clr-bg-secondary);
    color: var(--clr-text-primary);
}
button { margin-top: 20px; background-color: #27ae60; color: white; border: none; padding: 12px 20px; font-size: 16px; cursor: pointer; border-radius: 5px; width: 100%; }
button:hover { background-color: #219150; }

/* --- ADMIN LAYOUT: Ev. Č. a Řazení vedle sebe (50:50) --- */
.flex-row { display: flex; gap: 15px; }
.flex-row > div { flex: 1; }
.flex-row label { margin-top: 0; }
.flex-row input, .flex-row select { margin-top: 5px; }
/* -------------------------------------------------------- */

/* Styl pro lištu řazení */
.sort-bar {
    padding: 10px 0;
    margin-bottom: 20px;
    background: #f0f0f0;
    border-bottom: 1px solid #ddd;
    display: flex;
    gap: 15px;
    align-items: center;
}
.sort-bar label {
    font-weight: bold;
    color: #333;
    margin-left: 10px;
}
.sort-bar select {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
}
.sort-bar button {
    width: auto;
    margin: 0;
    padding: 8px 15px;
}
/* Dark Mode pro lištu řazení */
body.dark-mode .sort-bar {
    background: #2a2a2a;
    border-color: #444;
    color: #ddd;
}
body.dark-mode .sort-bar select {
    background: #3a3a3a;
    color: #ddd;
}


/* === STYLY PRO TABULKU === */
table { width: 100%; border-collapse: collapse; margin-top: 20px; }
th { background-color: var(--clr-table-head); color: white; padding: 12px; text-align: left; }
td { padding: 12px; border-bottom: 1px solid var(--clr-border); }
tr:not([class*="stav-"]):hover { background-color: var(--clr-table-hover); }


/* === PODBARVENÍ ŘÁDKU PODLE STAVŮ (S diakritikou a malými písmeny) === */

/* 1. Dosud nezařazen do provozu: #cacafe */
tr.stav-dosudnezařazendoprovozu { 
    background-color: #cacafe;
}

/* 2. Provozní: #caffc9 */
tr.stav-provozní {
    background-color: #caffc9;
}

/* 3. V dílnách / V opravě: #ffca98 */
tr.stav-vdílnáchvopravě { 
    background-color: #ffca98;
}

/* 4. Dočasně odstaven: #eaeaea */
tr.stav-dočasněodstaven { 
    background-color: #eaeaea;
}

/* 5. Vyřazen: #fecbca */
tr.stav-vyřazen { 
    background-color: #fecbca;
    color: #555; 
}

/* Úpravy pro Dark Mode, aby podbarvení nebylo příliš světlé */
body.dark-mode tr.stav-provozní { background-color: #3b503c; color: white; }
body.dark-mode tr.stav-vyřazen { background-color: #553b3b; color: #aaa; }
body.dark-mode tr.stav-vdílnáchvopravě { background-color: #55443b; color: #fff; }
body.dark-mode tr.stav-dočasněodstaven { background-color: #3a3a3a; color: #ccc; }
body.dark-mode tr.stav-dosudnezařazendoprovozu { background-color: #3b4255; color: #fff; }


/* Ostatní styly pro admin.php */
.management-section { display: flex; gap: 40px; margin-bottom: 40px; }
.management-box { flex: 1; padding: 20px; border: 1px solid var(--clr-border); border-radius: 8px; background-color: var(--clr-bg-secondary); }
.list-group { max-height: 250px; overflow-y: auto; border: 1px solid var(--clr-border); padding: 10px; background: var(--clr-bg-secondary); border-radius: 4px; margin-top: 15px; }
.delete-btn { background: #e74c3c; }
.edit-btn { background: #3498db; margin-left: 5px; }
.edit-btn, .delete-btn { color: white; border: none; padding: 4px 8px; cursor: pointer; border-radius: 3px; font-size: 12px; line-height: 1; }
.list-item { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-bottom: 1px dotted var(--clr-border); }
.warning { background:#fcf8e3; padding:10px; margin-bottom:15px; border:1px solid #faebcc; color:#8a6d3b; border-radius: 5px;}
.success { background:#dff0d8; padding:10px; margin-bottom:15px; border:1px solid #d6e9c6; color:#3c763d; border-radius: 5px;}
.top-menu a { margin-left: 10px; }

/* Dark Mode úprava pro hlášky */
body.dark-mode .warning { background:#333; color: #ffeb90; border-color: #555; }
body.dark-mode .success { background:#333; color: #a3ffac; border-color: #555; }


/* ========================================================= */
/* === MEDIA QUERIES (Optimalizace pro mobilní telefony) === */
/* ========================================================= */

@media screen and (max-width: 768px) {
    
    .container {
        padding: 10px;
    }
    
    /* Zajištění zobrazení sekcí na mobilu pod sebou */
    .management-section {
        flex-direction: column;
        gap: 20px;
    }
    
    /* Převod tabulky na seznam */
    table, thead, tbody, th, td, tr { display: block; }
    
    thead tr {
        position: absolute; 
        top: -9999px;
        left: -9999px;
    }
    
    tr {
        border: 1px solid var(--clr-border);
        margin-bottom: 10px;
        border-radius: 5px;
    }
    
    td {
        border: none;
        border-bottom: 1px solid var(--clr-border);
        position: relative;
        padding-left: 50%; 
        text-align: left;
    }
    
    /* Vložení hlaviček tabulky jako datových atributů (Popisek) */
    td:before {
        content: attr(data-label);
        position: absolute;
        top: 6px;
        left: 6px;
        width: 45%; 
        padding-right: 10px;
        white-space: nowrap;
        font-weight: bold;
        color: var(--clr-text-secondary);
    }
    
    /* Řešení pro Ev. č. a Řazení, aby se nekrčily */
    .flex-row {
        flex-direction: column;
        gap: 0;
    }

    /* Úprava lišty řazení */
    .sort-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 5px;
        padding: 10px;
    }
    .sort-bar label {
        margin-left: 0;
    }
    .sort-bar select {
        margin-bottom: 5px;
    }
}