:root {
    --bg-color: #f4f6f9;
    --card-bg: #ffffff;
    --primary: #3498db;
    --danger: #e74c3c;
    --text: #2c3e50;
    --border: #dcdde1;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text);
    margin: 0;
    padding: 0;
}

header {
    background: #2c3e50;
    color: white;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.container {
    max-width: 80%;
    margin: 30px auto;
    padding: 0 15px;
}

.card {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.inline-form {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

input, select, button {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
}

button {
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
}

button:hover { opacity: 0.9; }

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th { background: #f8f9fa; }

/* Status-Abzeichen und Buttons */
.badge { padding: 5px 10px; border-radius: 4px; font-weight: bold; font-size: 12px; color: white; display: inline-block; }
.badge-present { background-color: #2ecc71; }
.badge-absent { background-color: #7f8c8d; }

.btn-edit { background: #f1f2f6; color: var(--text); border: 1px solid var(--border); padding: 6px 10px; border-radius: 4px; cursor: pointer; }
.btn-pin { background: #e67e22; color: white; border: none; padding: 6px 10px; border-radius: 4px; cursor: pointer; font-size: 13px; text-decoration: none; }
.btn-delete { color: var(--danger); text-decoration: none; margin-left: 10px; font-weight: bold; }
.btn-maps { text-decoration: none; color: #44bd32; font-weight: bold; }

/* Login-Layout */
.login-body { display: flex; justify-content: center; align-items: center; height: 100vh; background: #2c3e50; }
.login-card { background: white; padding: 40px; border-radius: 8px; width: 300px; }
.login-card form { display: flex; flex-direction: column; gap: 15px; }

/* QR-Management */
.qr-canvas-container { display: flex; flex-direction: column; align-items: center; justify-content: center; background: #fff; padding: 10px; border: 1px solid #eee; border-radius: 4px; }
.btn-print { background: #27ae60; color: white; padding: 5px 10px; border: none; border-radius: 4px; cursor: pointer; font-size: 12px; margin-top: 5px; text-decoration: none; display: inline-block; }

/* Handykamera-Anzeige */
.action-indicator { padding: 15px; margin-bottom: 15px; border-radius: 6px; font-weight: bold; font-size: 18px; text-align: center; }
.status-check_in { background: #e3f2fd; color: #0d47a1; border: 2px solid #1e88e5; }
.status-check_out { background: #ffebee; color: #b71c1c; border: 2px solid #e53935; }

/* Live-Status Statistiken */
.stats-container { display: flex; gap: 20px; margin-bottom: 20px; }
.stats-box { background: #fff; padding: 15px 25px; border-radius: 6px; border-left: 5px solid var(--primary); box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.stats-box.active { border-left-color: #2ecc71; }
.stats-number { font-size: 24px; font-weight: bold; margin-top: 5px; }

/* Menü-Dashboard */
.menu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px; margin-top: 20px; }
.menu-box { text-align: center; padding: 30px; border-top: 4px solid var(--primary); display: flex; flex-direction: column; justify-content: space-between; align-items: center; }
.menu-box a { display: inline-block; margin-top: 15px; background: var(--primary); color: white; padding: 10px 20px; text-decoration: none; border-radius: 4px; font-weight: bold; }

/* Filtermasken */
.filter-card { background: #f8f9fa; border: 1px solid var(--border); padding: 15px; margin-bottom: 20px; border-radius: 6px; }
.filter-form { display: flex; gap: 15px; flex-wrap: wrap; align-items: flex-end; }
.filter-group { display: flex; flex-direction: column; gap: 5px; }
.filter-group label { font-size: 12px; font-weight: bold; color: #555; }
.btn-reset { background: #7f8c8d; color: white; text-decoration: none; padding: 10px 15px; border-radius: 4px; font-size: 14px; text-align: center; }

/* Spinner für Logout */
.logout-box { text-align: center; padding: 30px; }
.spinner { border: 4px solid rgba(0,0,0,0.1); width: 36px; height: 36px; border-radius: 50%; border-left-color: #3498db; animation: spin 1s linear infinite; margin: 20px auto; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ==========================================
   MODAL-FENSTER (MODERN, GROSS & GEFILTERT)
   ========================================== */
.modal { 
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(44, 62, 80, 0.7);
    backdrop-filter: blur(4px);
    justify-content: center; 
    align-items: center; 
    z-index: 9999; 
    padding: 20px;
    box-sizing: border-box;
}

.modal-content { 
    background: var(--card-bg); 
    padding: 35px; 
    border-radius: 8px; 
    width: 100%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2); 
    animation: modalFadeIn 0.3s ease-out;
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 25px;
    color: var(--text);
    font-size: 22px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 10px;
}

.modal-content form { 
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px 20px;
}

.modal-content label { 
    font-weight: bold; 
    font-size: 13px;
    color: #555;
    margin-bottom: -5px;
    grid-column: span 2;
}

.modal-content input { 
    width: 100%; 
    box-sizing: border-box; 
    padding: 12px;
    font-size: 15px;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.modal-content input[type="email"] {
    grid-column: span 2;
}

.modal-actions { 
    grid-column: span 2;
    display: flex; 
    justify-content: flex-end; 
    gap: 12px; 
    margin-top: 20px; 
    border-top: 1px solid var(--border);
    padding-top: 20px;
}

.modal-actions button {
    padding: 12px 25px;
    font-size: 15px;
    font-weight: bold;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- HEADER & NAVIGATION SYSTEM --- */
.main-header {
    background-color: #2c3e50;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 9999; /* Garantiert, dass der Kalender nicht über das Menü rutscht */
    font-family: 'Segoe UI', Arial, sans-serif;
}

.header-container {
    max-width: 80%;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    height: 65px;
}

.header-logo {
    color: #ffffff;
    text-decoration: none;
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-logo span {
    color: #3498db;
}

/* Navigations-Struktur */
.nav-bar {
    height: 100%;
}

.nav-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    height: 100%;
    align-items: center;
}

.nav-menu > li {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

.nav-menu > li > a, 
.dropdown-trigger {
    color: #ecf0f1;
    text-decoration: none;
    padding: 0 20px;
    height: 100%;
    display: flex;
    align-items: center;
    font-weight: 500;
    font-size: 15px;
    transition: background 0.2s, color 0.2s;
    cursor: pointer;
}

.nav-menu > li:hover > a,
.dropdown-trigger:hover {
    background-color: #34495e;
    color: #3498db;
}

/* --- DROPDOWN LOGIK --- */
.dropdown-menu {
    position: absolute;
    top: 65px; /* Exakt die Höhe des Headers */
    left: 0;
    background-color: #ffffff;
    min-width: 240px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
    list-style: none;
    padding: 10px 0;
    margin: 0;
    border-radius: 0 0 6px 6px;
    border-top: 3px solid #3498db;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}

.dropdown-menu li a {
    color: #2c3e50;
    padding: 12px 20px;
    text-decoration: none;
    display: block;
    font-size: 14px;
    font-weight: 400;
    transition: background 0.15s, color 0.15s;
}

.dropdown-menu li a:hover {
    background-color: #f8fafc;
    color: #3498db;
    padding-left: 25px; /* Kleiner Animationseffekt beim Drüberfahren */
}

/* Dropdown sichtbar machen bei Hover */
.dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* --- RECHTE ZONE: USER & LOGOUT --- */
.user-status-zone {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-badge {
    font-size: 12px;
    font-weight: bold;
    padding: 5px 10px;
    border-radius: 20px;
    color: white;
}

.user-badge.admin { background-color: #e74c3c; }
.user-badge.subcontractor { background-color: #f39c12; }

.btn-logout {
    color: #95a5a6;
    text-decoration: none;
    font-size: 14px;
    padding: 8px 12px;
    border: 1px solid #7f8c8d;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-logout:hover {
    color: #ffffff;
    background-color: #c0392b;
    border-color: #c0392b;
}
/* --- HAMBURGER BUTTON (Standardmäßig versteckt) --- */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 21px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 10000;
}

.menu-toggle span {
    width: 100%;
    height: 3px;
    background-color: #ffffff;
    border-radius: 2px;
    transition: all 0.3s ease-in-out;
}

/* Animation zum "X" wenn aktiv */
.menu-toggle.toggle-active span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}
.menu-toggle.toggle-active span:nth-child(2) {
    opacity: 0;
}
.menu-toggle.toggle-active span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

/* ===================================================
   RESPONSIVE ABSTIMMUNG FÜR SMARTPHONES & TABLETS
   =================================================== */
@media (max-width: 992px) {
    .menu-toggle {
        display: flex; /* Zeigt den Button auf Mobilgeräten an */
    }

    .header-container {
        justify-content: space-between;
    }

    /* Versteckt die Navigation standardmäßig außerhalb des Bildschirms */
    .nav-bar {
        position: absolute;
        top: 65px;
        left: 0;
        width: 100%;
        background-color: #2c3e50;
        flex-direction: column;
        align-items: stretch;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease-in-out;
        box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    }

    /* Wird per JavaScript vergeben, um das Menü auszurollen */
    .nav-bar.nav-active {
        max-height: 90vh;
        overflow-y: auto;
    }

    .nav-menu {
        flex-direction: column;
        width: 100%;
        gap: 0;
    }

    .nav-menu > li {
        width: 100%;
        border-bottom: 1px solid #34495e;
    }

    .nav-menu > li > a, 
    .dropdown-trigger {
        padding: 15px 20px;
        width: 100%;
        box-sizing: border-box;
        justify-content: space-between;
    }

    /* --- MOBILES DROPDOWN VERHALTEN --- */
    .dropdown-menu {
        position: relative;
        top: 0;
        width: 100%;
        background-color: #1a252f;
        box-shadow: none;
        border-top: none;
        border-left: 4px solid var(--primary);
        border-radius: 0;
        display: none; /* Per Klick einblenden */
        transform: none;
        opacity: 1;
        visibility: visible;
        padding: 5px 0;
    }

    /* Aktivierungsklasse für mobile Untermenüs */
    .dropdown.dropdown-active .dropdown-menu {
        display: block;
    }

    .dropdown-menu li a {
        color: #ecf0f1;
        padding: 12px 35px;
    }

    /* User-Status-Bereich unten im mobilen Menü anheften */
    .user-status-zone {
        width: 100%;
        padding: 20px;
        box-sizing: border-box;
    }
}