:root {
    /* Light Mode (Default) */
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #10b981;

    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-color: #1f2937;
    --text-muted: #6b7280;

    --header-footer-bg: #1f2937;
    --header-footer-text: #ffffff;

    --border-color: #e5e7eb;
    --input-bg: #f9fafb;
    /* Slightly darker than card for contrast */
    --input-border: #d1d5db;

    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(255, 255, 255, 0.5);

    /* Softer, more diffuse shadow */
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);

    /* Status Colors */
    --status-weekend-bg: #fee2e2;
    --status-holiday-bg: #fef3c7;
    --status-vacation-bg: #d1fae5;
    --status-sick-bg: #e0e7ff;
    --status-school-bg: #fbcfe8;

    /* Travel Colors */
    --travel-hin-bg: #fef3c7;
    --travel-rueck-bg: #ecfdf5;
}

.dark-mode {
    /* Dark Mode Overrides */
    --primary-color: #6366f1;
    /* Lighter Indigo */
    --primary-hover: #818cf8;

    --bg-color: #111827;
    /* Gray 900 */
    --card-bg: #1f2937;
    /* Gray 800 */
    --text-color: #f3f4f6;
    /* Gray 100 */
    --text-muted: #9ca3af;
    /* Gray 400 */

    --header-footer-bg: #0f172a;
    /* Slate 900 */
    --header-footer-text: #f3f4f6;

    --border-color: #334155;
    /* Slate 700 */
    --input-bg: #0f172a;
    --input-border: #334155;

    --glass-bg: rgba(30, 41, 59, 0.8);
    --glass-border: rgba(255, 255, 255, 0.05);

    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);

    /* Status Colors (Darker versions) */
    --status-weekend-bg: #7f1d1d;
    /* Red 900 */
    --status-holiday-bg: #78350f;
    /* Amber 900 */
    --status-vacation-bg: #064e3b;
    /* Emerald 900 */
    --status-sick-bg: #312e81;
    /* Indigo 900 */
    --status-school-bg: #831843;
    /* Pink 900 */

    /* Travel Colors (Dark Mode) */
    --travel-hin-bg: #451a03;
    /* Dark Amber/Orange */
    --travel-rueck-bg: #064e3b;
    /* Dark Emerald/Green */
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header & Footer */
header,
footer {
    height: 80px;
    background-color: var(--header-footer-bg);
    color: var(--header-footer-text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    box-sizing: border-box;
}

header {
    top: 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

header .left,
header .right {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1rem;
}

header .center {
    flex: 0 0 auto;
    text-align: center;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

header .right {
    justify-content: flex-end;
}

footer {
    bottom: 0;
    font-size: 0.9rem;
}

/* Main Content */
main {
    margin-top: 80px;
    margin-bottom: 80px;
    padding: 2rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Navigation */
nav {
    background-color: var(--card-bg);
    width: 100%;
    padding: 1rem 2rem;
    position: fixed;
    top: 80px;
    z-index: 900;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    box-sizing: border-box;
}

nav a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

nav a:hover,
nav a.active {
    background-color: var(--primary-color);
    color: white;
}

/* Dropdown */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: var(--card-bg);
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
    z-index: 1;
    border-radius: 0.375rem;
    overflow: hidden;
}

.dropdown-content a {
    color: var(--text-color);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
}

.dropdown:hover .dropdown-content {
    display: block;
}

/* Cards & Glassmorphism */
.card {
    background: var(--card-bg);
    /* Use solid or semi-transparent based on preference, here sticking to theme default */
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    /* More rounded */
    padding: 2rem;
    box-shadow: var(--shadow);
    max-width: 800px;
    width: 100%;
    margin: 1rem auto;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card h2 {
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 1.5rem;
    letter-spacing: -0.025em;
    color: var(--text-color);
}

/* Forms */
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
    width: 100%;
    padding: 0.8rem 1rem;
    margin: 0.5rem 0;
    border: 1px solid var(--input-border);
    border-radius: 0.5rem;
    /* Rounded inputs */
    box-sizing: border-box;
    font-family: inherit;
    font-size: 1rem;
    /* Prevent zoom on iOS */
    background-color: var(--input-bg);
    color: var(--text-color);
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

input[type="checkbox"],
input[type="radio"] {
    appearance: none;
    /* Reset first */
    -webkit-appearance: checkbox !important;
    /* Force native checkbox on iOS */
    -moz-appearance: checkbox;
    display: inline-block;
    width: 20px !important;
    /* Explicit width */
    height: 20px !important;
    /* Explicit height */
    margin-right: 0.5rem;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    accent-color: var(--primary-color);
    transform: scale(1.2);
    box-shadow: none !important;
    vertical-align: middle;
}

input[type="time"] {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(156, 163, 175, 1)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cpolyline points='12 6 12 12 16 14'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.25rem;
    padding-right: 3rem;
    /* Make space for icon */
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

/* Custom Components */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-blue {
    background-color: #dbeafe;
    color: #1e40af;
}

.badge-green {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-yellow {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-red {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-purple {
    background-color: #e0e7ff;
    color: #3730a3;
}

.badge-gray {
    background-color: #f3f4f6;
    color: #374151;
}

.dark-mode .badge-blue {
    background-color: rgba(30, 64, 175, 0.2);
    color: #93c5fd;
}

.dark-mode .badge-green {
    background-color: rgba(6, 95, 70, 0.2);
    color: #6ee7b7;
}

.dark-mode .badge-yellow {
    background-color: rgba(146, 64, 14, 0.2);
    color: #fcd34d;
}

.dark-mode .badge-red {
    background-color: rgba(153, 27, 27, 0.2);
    color: #fca5a5;
}

.dark-mode .badge-purple {
    background-color: rgba(55, 48, 163, 0.2);
    color: #a5b4fc;
}

.dark-mode .badge-gray {
    background-color: rgba(55, 65, 81, 0.4);
    color: #d1d5db;
}

/* Grid for Dashboard Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
    width: 100%;
    /* Ensure it takes full width */
    box-sizing: border-box;
}

.stat-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
    min-width: 0;
    /* Prevent flex/grid overflow issues */
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* Date Navigator */
.date-navigator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    background: var(--input-bg);
    padding: 0.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
}

.date-navigator button {
    background: transparent;
    color: var(--text-color);
    padding: 0.5rem;
    margin: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.date-navigator button:hover {
    background: var(--bg-color);
}

.date-display {
    font-weight: 700;
    font-size: 1.1rem;
    text-align: center;
    min-width: 150px;
}

/* Type Selector Tiles */
.type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    /* Better responsiveness */
    gap: 1rem;
    margin-bottom: 1.5rem;
    width: 100%;
}

.type-option {
    position: relative;
    display: block;
    /* Ensure label takes space */
}

.type-option input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
    /* Ensure it doesn't intercept clicks weirdly */
}

.type-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem 0.5rem;
    background: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    height: 100%;
    min-height: 90px;
    box-sizing: border-box;
    /* Crucial for borders */
}

.type-tile span {
    font-weight: 600;
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.type-option input:checked+.type-tile {
    border-color: var(--primary-color);
    background-color: rgba(79, 70, 229, 0.05);
    color: var(--primary-color);
}

.dark-mode .type-option input:checked+.type-tile {
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

/* Time Input Grid */
.time-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Mobile List View */
.mobile-list-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

button {
    background-color: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s;
}

button:hover {
    background-color: var(--primary-hover);
}

button.danger {
    background-color: #ef4444;
}

button.danger:hover {
    background-color: #dc2626;
}

.button {
    display: inline-block;
    background-color: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.button:hover {
    background-color: var(--primary-hover);
    text-decoration: none;
}

.icon-button {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 999px;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    background-color: var(--card-bg);
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: var(--shadow);
}

th,
td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}

th {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-weight: 600;
}

tr:hover {
    background-color: var(--bg-color);
    /* Or a specific hover color */
    filter: brightness(0.95);
    /* Works for both modes */
}

/* Utility */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-4 {
    margin-top: 1rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.flex {
    display: flex;
}

.justify-between {
    justify-content: space-between;
}

.items-center {
    align-items: center;
}

.gap-2 {
    gap: 0.5rem;
}

.desktop-only-link {
    display: inline-block;
}

.mobile-only-link {
    display: none;
}

.type-table {
    border-collapse: collapse;
}

.type-table td {
    padding: 0.25rem 0.75rem 0.25rem 0;
    vertical-align: middle;
}

.type-table td:first-child {
    width: 40px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: var(--card-bg);
    margin: 15% auto;
    padding: 2rem;
    border: 1px solid #888;
    width: 90%;
    max-width: 400px;
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Login remember-me row */
#login-modal .remember-row {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    justify-content: flex-start;
    margin-top: 0.5rem;
}

#login-modal .remember-row label {
    margin: 0;
    cursor: pointer;
    width: auto;
    text-align: left;
    white-space: nowrap;
}

/* Calendar */
.calendar-grid {
    display: grid;
    grid-template-columns: 100px repeat(31, 1fr);
    gap: 1px;
    background-color: #e5e7eb;
    border: 1px solid #e5e7eb;
    overflow-x: auto;
}

.calendar-cell {
    background-color: white;
    padding: 0.25rem;
    text-align: center;
    font-size: 0.8rem;
    min-width: 25px;
}

.calendar-header {
    background-color: #f9fafb;
    font-weight: bold;
}

.weekend {
    background-color: var(--status-weekend-bg);
    color: var(--text-color);
}

/* Red-ish */
.holiday {
    background-color: var(--status-holiday-bg);
    color: var(--text-color);
}

/* Yellow-ish */
.vacation {
    background-color: var(--status-vacation-bg);
    color: var(--text-color);
}

/* Green-ish */
.sick {
    background-color: var(--status-sick-bg);
    color: var(--text-color);
}

/* Pink 900 */

/* Table Total Row */
.table-total-row {
    font-weight: bold;
    background-color: #e5e7eb;
}

.dark-mode .table-total-row {
    background-color: #374151;
}

/* Arbeitsfrei-Tage optisch hervorheben
   Lightmode: sanftes Grün, Darkmode: etwas kräftigeres Grün */
tr.free {
    background-color: #dcfce7;
    /* hellgrün, ähnliches Level wie Urlaubs-/Feiertags-Hervorhebungen */
}

.dark-mode tr.free {
    background-color: #166534;
    /* dunkleres Grün für gute Lesbarkeit im Darkmode */
}

.school {
    background-color: var(--status-school-bg);
    color: var(--text-color);
}

/* Custom Boxes */
.summary-box {
    background-color: #f0f9ff;
    padding: 1rem;
    border-radius: 0.5rem;
    color: var(--text-color);
}

.form-box {
    background-color: #f9fafb;
    padding: 1rem;
    border-radius: 0.5rem;
    color: var(--text-color);
}

.dark-mode .summary-box {
    background-color: rgba(56, 189, 248, 0.1);
    /* Light Blue transparent */
    border: 1px solid rgba(56, 189, 248, 0.2);
}

.dark-mode .form-box {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
}

.edit-user-box {
    background-color: #fff7ed;
    padding: 1rem;
    border: 1px solid #fdba74;
    border-radius: 0.5rem;
    color: var(--text-color);
}

.dark-mode .edit-user-box {
    background-color: rgba(253, 186, 116, 0.1);
    border: 1px solid rgba(253, 186, 116, 0.2);
}

.list-box {
    background-color: #f9fafb;
    padding: 1rem;
    border-radius: 0.5rem;
    max-height: 400px;
    overflow-y: auto;
    color: var(--text-color);
}

.dark-mode .list-box {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
}

.calculated-box {
    background-color: #f0fdf4;
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid #bbf7d0;
    color: var(--text-color);
}

.dark-mode .calculated-box {
    background-color: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.calendar-grid-cell {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    padding: 0.5rem;
    text-align: center;
    border-radius: 0.25rem;
    color: var(--text-color);
}

.calendar-grid-cell.has-vacation {
    background: #dcfce7;
    border: 1px solid #10b981;
}

.dark-mode .calendar-grid-cell {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
}

.dark-mode .calendar-grid-cell.has-vacation {
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.calendar-header-cell {
    text-align: center;
    font-weight: bold;
    padding: 0.5rem;
    color: var(--text-color);
}

.selected-employee-box {
    background-color: #eff6ff;
    padding: 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 2rem;
    color: var(--text-color);
}

.dark-mode .selected-employee-box {
    background-color: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.selected-row {
    background-color: #dbeafe;
}

.dark-mode .selected-row {
    background-color: rgba(59, 130, 246, 0.2);
}

.success-box {
    background-color: #dcfce7;
    color: #166534;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.dark-mode .success-box {
    background-color: rgba(22, 101, 52, 0.2);
    color: #86efac;
    border: 1px solid rgba(22, 101, 52, 0.4);
}

/* Read-only Hinweis (z.B. Urlaubsübersicht für Supervisor) */
.readonly-hint {
    background-color: #fef3c7;
    padding: 1rem;
    border-radius: 0.5rem;
    color: #92400e;
}

.dark-mode .readonly-hint {
    background-color: rgba(253, 230, 138, 0.15);
    border: 1px solid rgba(252, 211, 77, 0.6);
    color: #fef9c3;
}

/* Mobile */
@media (max-width: 768px) {

    /* Hide fixed footer and simplify layout for mobile */
    footer {
        display: none;
    }

    main {
        margin-top: 72px;
        margin-bottom: 0;
        padding: 1rem 0.75rem 1.5rem;
        width: 100%;
        box-sizing: border-box;
    }

    nav.desktop-nav {
        display: none;
    }

    .mobile-hidden {
        display: none;
    }

    .mobile-nav {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background-color: var(--header-footer-bg);
        flex-direction: column;
        padding: 0;
        z-index: 1000;
        box-sizing: border-box;
        overflow-y: auto;
    }

    .mobile-nav a {
        color: white;
        padding: 1rem;
        display: block;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .desktop-only-link {
        display: none;
    }

    .mobile-only-link {
        display: inline-block;
    }

    /* Header auf Mobil sehr reduziert: nur Hamburger sichtbar */
    header {
        padding: 0 1rem;
        justify-content: flex-start;
        height: 56px;
    }

    header .center,
    header img {
        display: none;
    }

    .card {
        max-width: 100%;
        margin: 0.75rem 0.5rem;
        padding: 1.5rem 1rem;
        border-radius: 1.2rem;
        box-sizing: border-box;
    }

    table {
        font-size: 0.8rem;
    }

    th,
    td {
        padding: 0.5rem;
    }

    /* Supervisor-Tabelle: Aktion-Button auf Mobil in die Zelle einpassen */
    .supervisor-table {
        table-layout: fixed;
    }

    .supervisor-table th:nth-child(1),
    .supervisor-table td:nth-child(1) {
        width: 32%;
    }

    .supervisor-table th:nth-child(2),
    .supervisor-table td:nth-child(2) {
        width: 24%;
    }

    .supervisor-table th:nth-child(3),
    .supervisor-table td:nth-child(3) {
        width: 20%;
    }

    .supervisor-table th:nth-child(4),
    .supervisor-table td:nth-child(4) {
        width: 24%;
    }

    .supervisor-table .action-cell {
        text-align: right;
        white-space: nowrap;
    }

    .supervisor-table .action-button {
        padding: 0.1rem 0.35rem;
        font-size: 0.68rem;
        white-space: nowrap;
    }

    .supervisor-table .action-button-link {
        display: inline-block;
    }

    .card h1,
    .card h2 {
        font-size: 1.5rem;
    }

    /* Login-Modal auf Mobil etwas schmaler und näher am oberen Rand */
    #login-modal .modal-content {
        width: 88%;
        max-width: 320px;
        margin: 10% auto;
        padding: 1.5rem 1.25rem;
    }
}

/* Hamburger Menu */
.hamburger {
    display: none;
    cursor: pointer;
    flex-direction: column;
    gap: 5px;
}

.hamburger div {
    width: 25px;
    height: 2px;
    /* Thinner lines */
    background-color: white;
    transition: 0.3s;
}

@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }

    .left {
        display: flex;
        align-items: center;
        gap: 1rem;
    }
}