/* Globale Variablen für Farben */
:root {
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --bg-color: #f0f2f5;
    --card-bg: #ffffff;
    --text-color: #333;
    --border-color: #dee2e6;
}

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    max-width: 1100px;
    margin: 0 auto 20px auto;
    background: var(--card-bg);
    padding: 10px 25px 10px 25px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* Header & Navigation */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--bg-color);
    padding-bottom: 15px;
    margin-bottom: 25px;
}

h1, h2, h3 { margin-top: 0; color: var(--text-color); }

h2 { color: #007bff; border-left: 5px solid #007bff; padding-left: 10px; margin-top: 10px; }

label { display: block; margin-bottom: 5px; font-weight: bold; }

/* Tabellen-Design */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}


th {
    background-color: #f8f9fa;
    padding: 12px;
    text-align: left;
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
}

td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

tr:hover { background-color: #fcfcfc; }

/* Spezifische Spaltenbreiten */
.col-date {
    width: 125px;
    white-space: nowrap; /* Verhindert den Umbruch im Datum komplett */
}

.col-ressort {
    width: 80px;
}

.col-hours {
    width: 60px;
    text-align: right;
}

/* Optional: Damit die Einheit 'h' nicht am Zellenrand klebt, 
   geben wir der Spalte ein wenig Padding rechts */
td.col-hours {
    padding-right: 20px;
    font-weight:bold;
}

.col-status {
    width: 110px;
}

.col-action {
    width: 70px;
}


/* Die Tätigkeitsspalte bekommt keine feste Breite, 
   damit sie den restlichen Platz einnimmt */
.col-task {
    word-break: break-word; /* Bricht sehr lange Wörter um, damit das Layout nicht zerschießt */
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9em;
    text-align: center;
}
.btn-signoff {
    background: #dc3545;
    color: white;
}
.btn-blue { background: var(--primary-color); color: white; }
.btn-blue:hover { background: var(--primary-hover); }

.btn-green { background: var(--success-color); color: white; }
.btn-green:hover { opacity: 0.9; }

.btn-red { background: var(--danger-color); color: white; }

.btn-back { display: inline-block; margin-bottom: 20px; text-decoration: none; color: #007bff; font-weight: bold; }

/* Badges & Status */
.badge {
    background: #eee; 
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: bold;
}

.status-badge { padding: 4px 8px; border-radius: 4px; font-size: 0.8em; font-weight: bold; }

.ressort-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;       /* Macht es rund (Pill-Shape) */
    font-size: 0.75em;         /* Etwas kleiner als normaler Text */
    font-weight: bold;
    text-transform: uppercase; /* Alles in Großbuchstaben sieht oft aufgeräumter aus */
    margin-bottom: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1); /* Leichter 3D-Effekt */
}

.status-approved { background: #d4edda; color: #155724; }
.status-pending { background: #fff3cd; color: #856404; }

/* Formular-Elemente */
input, select, textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 14px;
}

input[type="checkbox"], 
input[type="radio"] {
    width: auto;
    margin-right: 5px; /* Etwas Abstand zum Text daneben */
    cursor: pointer;
}

input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
}

.count-info { font-weight: bold; color: #555; }

/* Navigation Styles */
.main-nav {
    padding: 0 20px;
    margin-bottom: 30px;
}

.nav-container {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    border-radius: 12px;
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 90px;
}

.nav-logo {
    margin-left: 30px;
    font-size: 1.5em;
    font-weight: bold;
    color: var(--primary-color);
    text-decoration: none;
    
    /* NEU: Flexbox, damit Bild und Text mittig nebeneinander sind */
    display: flex;       
    align-items: center; 
    gap: 10px;           /* Abstand zwischen Bild und Text */
}

/* Das neue Bild Styling */
.logo-img {
    height: 50px;       /* Höhe anpassen, passend zur Nav-Leiste (90px) */
    width: auto;        /* Breite passt sich automatisch an */
    object-fit: contain;
}


.nav-links {
    list-style: none;
    display: flex;
    gap: 10px;
    margin: 0;
    padding: 0;
    margin-left: 20px;
}

.nav-links a, .nav-label {
    text-decoration: none;
    color: #555;
    font-weight: 500;
    cursor: pointer;
}

/* Container für Profil und Logout */
.nav-user {
    display: flex;
    align-items: center;
    gap: 15px;
    white-space: nowrap; /* Verhindert Zeilenumbruch */
    margin-left: auto;   /* Schiebt den Bereich nach ganz rechts */
}

.nav-user a:first-child:hover {
    opacity: 0.8;
}

.nav-links a:hover { color: var(--primary-color); }

/* Dropdown Logik */
.admin-dropdown { position: relative; }
.dropdown-content {
    display: none;
    position: absolute;
    background: white;
    min-width: 180px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    border-radius: 6px;
    z-index: 1000;
    top: 100%;
}

.dropdown-content a {
    color: #333;
    padding: 12px 16px;
    display: block;
}

.dropdown-content a:hover { background-color: #f8f9fa; }
.admin-dropdown:hover .dropdown-content { display: block; }

.btn-logout {
    color: var(--danger-color);
    text-decoration: none;
    font-size: 0.9em;
    font-weight: bold;
    margin-left: 15px;
    margin-right: 10px;
}

.content-wrapper {
    max-width: 1100px;
    margin: 0 auto;
    flex: 1; /* Drückt den Footer nach unten */
    width: 100%;
}

.main-footer {
    margin-top: 50px;
    padding: 20px 0;
    border-top: 1px solid var(--border-color);
    color: #777;
    font-size: 0.85em;
}

.footer-container {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.main-footer p {
    margin: 0;
}

#userTable thead th {
    vertical-align: middle;
    padding: 8px 12px;
}

/* Reduziert die Polsterung in den Zeilen noch weiter für maximale Kompaktheit */
#userTable tbody td {
    padding: 6px 12px;
}

/* =========================================
   RESPONSIVE DESIGN (MOBILE OPTIMIERUNG)
   ========================================= */

@media screen and (max-width: 768px) {

    /* 1. Allgemeines Layout */
    body {
        padding: 10px; /* Weniger Rand am Bildschirmrand */
    }

    .container {
        padding: 15px; /* Weniger Innenabstand in den Boxen */
        width: 100%;   /* Volle Breite nutzen */
        box-sizing: border-box;
    }

    /* 2. Navigation umbauen (Stapeln) */
    .nav-container {
        height: auto; /* Feste Höhe entfernen */
        flex-direction: column; /* Alles untereinander */
        padding: 15px 0;
        gap: 15px;
    }

    .nav-logo {
        margin: 0;
        margin-bottom: 5px;
        font-size: 1.2em; /* Text etwas kleiner */
    }

    .logo-img {
        height: 35px;
    }
    
    .nav-links {
        margin: 0;
        flex-wrap: wrap; /* Links dürfen umbrechen, wenn es zu viele sind */
        justify-content: center;
        gap: 15px;
    }

    .nav-user {
        margin-left: 0; /* Nicht mehr rechtsbündig */
        width: 100%;
        justify-content: center;
        border-top: 1px solid #eee;
        padding-top: 15px;
    }

    /* 3. Formular-Grid ("Manuelle Erfassung") */
    /* Vorher war es grid-template-columns: 200px 150px ... -> Das sprengt das Handy */
    .form-grid {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .form-grid .form-group {
        width: 100%;
    }

    /* Der Button soll auf dem Handy volle Breite haben und Abstand nach oben */
    .form-grid button, 
    .entry-form button {
        width: 100%;
        margin-top: 10px;
    }
    
    /* Den Label-Text "Zeitpunkt", "Ressort" etc. wieder sichtbar machen, 
       falls er im Desktop-Grid ausgeblendet oder verschoben war */
    .form-grid .form-group label {
        margin-bottom: 5px;
    }

    /* 4. Einsatz-Karten (Geplante Einsätze) */
    .assignment-card {
        flex-direction: column; /* Inhalt oben, Buttons unten */
        align-items: flex-start;
    }

    .assignment-info {
        margin-bottom: 15px;
        width: 100%;
    }

    .assignment-card .assignment-info strong {
        display: block; /* Auf Handy lieber untereinander statt in einer Wurst */
        margin-top: 4px;
    }

    /* Der rechte Bereich mit den Buttons */
    .assignment-card > div:last-child {
        width: 100%;
        display: flex;
        justify-content: space-between; /* "Belegung" links, Button rechts */
        align-items: center;
        border-top: 1px solid #eee;
        padding-top: 10px;
        margin-top: 5px;
    }

    /* 5. Tabellen (Historie) */
    /* Da Tabellen auf Handys extrem schwer sind, machen wir sie scrollbar */
    section {
        overflow-x: hidden; /* Verhindert, dass die ganze Seite wackelt */
    }

    table {
        display: block;
        width: 100%;
        overflow-x: auto; /* Erlaubt seitliches Scrollen NUR in der Tabelle */
        white-space: nowrap; /* Verhindert hässliche Umbrüche in engen Zellen */
    }

    /* Feste Breiten aufheben, damit die Tabelle atmen kann */
    .col-date, .col-ressort, .col-task, .col-hours, .col-status, .col-action {
        width: auto;
        min-width: auto;
    }
    
    /* Etwas mehr Platz in den Zellen für Finger-Bedienung */
    td, th {
        padding: 10px 8px;
    }

    /* 6. Zusammenfassung unten */
    .summary-container {
        flex-direction: column;
        align-items: center;
        gap: 10px;
        text-align: center;
    }
}
