/* ============================================================
   LSF AG Mitarbeiterportal — Corporate Design CSS
   Mobile-First | Source Sans 3 + Montserrat
   ============================================================ */

/* --- CSS Custom Properties (Corporate Design) --- */
:root {
    --red: #A52A2A;
    --red-dark: #8B1A1A;
    --red-light: #D4534D;
    --grey: #3A3A3A;
    --grey-light: #E5E5E5;
    --grey-medium: #888;
    --bg-alt: #F9F9F9;
    --white: #FFFFFF;
    --black: #1A1A1A;
    --body: #3A3A3A;
    --success: #2E7D32;
    --success-bg: #E8F5E9;
    --warning: #F57F17;
    --warning-bg: #FFF8E1;
    --danger: #C62828;
    --danger-bg: #FFEBEE;
    --info: #1565C0;
    --info-bg: #E3F2FD;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.2s ease;

    /* A1: Spacing-Skala */
    --space-2xs: 0.25rem;   /*  4px */
    --space-xs:  0.5rem;    /*  8px */
    --space-sm:  0.75rem;   /* 12px */
    --space-md:  1rem;      /* 16px */
    --space-lg:  1.5rem;    /* 24px */
    --space-xl:  2rem;      /* 32px */
    --space-2xl: 3rem;      /* 48px */

    --gap-xs:  0.5rem;
    --gap-sm:  0.75rem;
    --gap-md:  1rem;
    --gap-lg:  1.5rem;

    /* A2: Typografie-Skala */
    --text-xs:   0.75rem;   /* 12px — Badges, Hinweistexte */
    --text-sm:   0.8125rem; /* 13px — Labels, Formular-Hints, Filtertext */
    --text-base: 1rem;      /* 16px — Fliesstext, Inputs */
    --text-md:   1.125rem;  /* 18px — Subheadings, hervorgehobene Werte */
    --text-lg:   1.25rem;   /* 20px — Card-Headers, Statistik-Zahlen */
    --text-xl:   1.5rem;    /* 24px — H2, Seitentitel */
    --text-2xl:  1.75rem;   /* 28px — H1, Dashboard-Heading */

    /* A3: Fehlende Farb-Variablen */
    --draft-bg: #FFF3CD;
    --draft-border: #FFCD39;
    --draft-text: #856404;
    --red-bg-light: #fdf6f6;
    --success-dark: #1B5E20;
    --danger-dark: #8E0000;

    /* A3: Einsatzplanung Mitarbeiter-Farben (aus PHP $maFarben Array) */
    --ep-ma-1:  #E57373;
    --ep-ma-2:  #64B5F6;
    --ep-ma-3:  #81C784;
    --ep-ma-4:  #FFB74D;
    --ep-ma-5:  #BA68C8;
    --ep-ma-6:  #4DD0E1;
    --ep-ma-7:  #FF8A65;
    --ep-ma-8:  #AED581;
    --ep-ma-9:  #F06292;
    --ep-ma-10: #7986CB;
    --ep-ma-11: #A1887F;
    --ep-ma-12: #90A4AE;

    /* A3: Einsatzplanung Gebäude-Status-Farben (aus PHP einsatz_gebaeude_setup.php) */
    --ep-status-rohbau:    #D3D1C7;
    --ep-status-grundputz: #B4B2A9;
    --ep-status-trocknung: #EF9F27;
    --ep-status-abrieb:    #5DCAA5;
    --ep-status-fertig:    #97C459;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 400;
    color: var(--black);
    background: var(--bg-alt);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* RTL-Support */
[dir="rtl"] body {
    direction: rtl;
    text-align: right;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    color: var(--black);
    line-height: 1.3;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

a {
    color: var(--red);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover { color: var(--red-dark); }

/* --- Header / Navbar --- */
.portal-header {
    background: var(--white);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0.75rem 1rem;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    gap: 1rem;
}

.header-logo img {
    height: 40px;
    width: auto;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--grey);
}

.header-user strong {
    color: var(--black);
}

/* Language Selector */
.lang-select {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--grey-light);
    border-radius: var(--radius);
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.875rem;
    background: var(--white);
    color: var(--black);
    cursor: pointer;
}

/* Hamburger Menu (Mobile) */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    font-size: 1.5rem;
    color: var(--black);
}

/* --- Main Content --- */
.portal-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

/* --- Cards --- */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--grey-light);
}

.card-header h2 {
    font-size: 1.25rem;
    margin: 0;
}

/* --- Dashboard Module Tiles --- */
.module-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

.module-tile {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    text-decoration: none;
    color: var(--black);
    transition: box-shadow var(--transition), transform var(--transition);
    min-height: 80px;
}

.module-tile:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    color: var(--black);
}

.module-tile .tile-icon {
    width: 52px;
    height: 52px;
    min-width: 52px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--white);
    background: var(--red);
}

.module-tile .tile-content h3 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.module-tile .tile-content p {
    font-size: 0.875rem;
    color: var(--grey-medium);
    margin: 0;
}

/* Tile color variants */
.tile-icon.bg-red { background: var(--red); }
.tile-icon.bg-blue { background: var(--info); }
.tile-icon.bg-green { background: var(--success); }
.tile-icon.bg-orange { background: var(--warning); }

/* --- Forms --- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
    color: var(--grey);
}

.form-group label .required {
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--grey-light);
    border-radius: var(--radius);
    font-family: 'Source Sans 3', sans-serif;
    font-size: 1rem;
    color: var(--black);
    background: var(--white);
    transition: border-color var(--transition), box-shadow var(--transition);
    -webkit-appearance: none;
    appearance: none;
    /* Grosse Touch-Targets */
    min-height: 48px;
}

.form-control:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(165, 42, 42, 0.15);
}

.form-control.error {
    border-color: var(--danger);
}

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%233A3A3A' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

[dir="rtl"] select.form-control {
    background-position: left 1rem center;
    padding-right: 1rem;
    padding-left: 2.5rem;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--grey-medium);
    margin-top: 0.25rem;
}

.form-error {
    font-size: 0.8rem;
    color: var(--danger);
    margin-top: 0.25rem;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    min-height: 48px;
    min-width: 48px;
}

.btn-primary {
    background: var(--red);
    color: var(--white);
}
.btn-primary:hover {
    background: var(--red-dark);
    color: var(--white);
}

.btn-secondary {
    background: var(--grey-light);
    color: var(--black);
}
.btn-secondary:hover {
    background: #D0D0D0;
}

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

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

.btn-outline {
    background: transparent;
    border: 2px solid var(--red);
    color: var(--red);
}
.btn-outline:hover {
    background: var(--red);
    color: var(--white);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    min-height: 40px;
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- Alerts / Messages --- */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.95rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.alert-success { background: var(--success-bg); color: var(--success); }
.alert-warning { background: var(--warning-bg); color: var(--warning); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger); }
.alert-info    { background: var(--info-bg);     color: var(--info); }

/* --- Tables --- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table th,
.table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--grey-light);
}

[dir="rtl"] .table th,
[dir="rtl"] .table td {
    text-align: right;
}

.table th {
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--grey-medium);
    background: var(--bg-alt);
}

.table tbody tr:hover {
    background: var(--bg-alt);
}

/* --- Login Page --- */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    background: linear-gradient(135deg, var(--bg-alt) 0%, var(--grey-light) 100%);
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo img {
    height: 60px;
    width: auto;
}

.login-title {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: var(--black);
}

/* --- Navigation (Mobile Sidebar) --- */
.mobile-nav {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    background: var(--white);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    transition: left 0.3s ease;
    overflow-y: auto;
    padding-top: 1rem;
}

[dir="rtl"] .mobile-nav {
    left: auto;
    right: -280px;
    transition: right 0.3s ease;
}

.mobile-nav.open {
    left: 0;
}

[dir="rtl"] .mobile-nav.open {
    left: auto;
    right: 0;
}

.mobile-nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 199;
}

.mobile-nav-overlay.open {
    display: block;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    color: var(--black);
    font-weight: 500;
    border-bottom: 1px solid var(--grey-light);
    transition: background var(--transition);
    min-height: 52px;
}

.nav-item:hover,
.nav-item.active {
    background: var(--bg-alt);
    color: var(--red);
}

.nav-item .nav-icon {
    font-size: 1.25rem;
    width: 28px;
    text-align: center;
}

.nav-section-title {
    padding: 1rem 1.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--grey-medium);
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-admin { background: var(--red); color: var(--white); }
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-inactive { background: var(--grey-light); color: var(--grey-medium); }

/* --- Utility --- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* --- A4.1: Stats-Grid --- */
.stats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gap-lg);
    align-items: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-2xs);
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--grey-medium);
}

.stat-value {
    font-size: var(--text-lg);
    font-weight: 700;
    font-family: 'Montserrat', sans-serif;
}

.stat-value--highlight {
    color: var(--red);
}

/* --- A4.2: Filter-Bar --- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--gap-sm);
}

.filter-bar .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 150px;
}

.filter-bar .form-group label {
    font-size: var(--text-sm);
}

.filter-bar .form-control {
    min-height: 40px;
}

/* --- A4.3: Progress-Bar --- */
.progress-track {
    background: var(--grey-light);
    border-radius: 100px;
    height: 12px;
    overflow: hidden;
}

.progress-track--sm {
    height: 8px;
}

.progress-fill {
    height: 100%;
    border-radius: 100px;
    transition: width 0.3s ease;
}

.progress-fill--success { background: var(--success); }
.progress-fill--warning { background: var(--warning); }
.progress-fill--danger  { background: var(--danger); }
.progress-fill--red     { background: var(--red); }

/* --- A4.4: Mini-Card / Info-Tile --- */
.mini-card {
    background: var(--bg-alt);
    border-radius: var(--radius);
    padding: var(--space-sm);
}

.mini-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--gap-sm);
}

/* --- A4.5: Tageszusammenfassung --- */
.day-summary {
    background: var(--bg-alt);
    border: 1.5px solid var(--grey-light);
    border-radius: var(--radius);
    padding: var(--space-md) var(--space-lg);
}

.day-summary__title {
    font-weight: 600;
    font-family: 'Montserrat', sans-serif;
    margin-bottom: var(--space-xs);
}

.day-summary__row {
    display: flex;
    justify-content: space-between;
    padding: var(--space-2xs) 0;
}

.day-summary__divider {
    border: none;
    border-top: 2px solid var(--red);
    margin: var(--space-xs) 0;
}

.day-summary__total {
    font-size: var(--text-md);
    color: var(--red);
    font-weight: 700;
}

/* --- A4.6: Zeitfelder-Grid --- */
.time-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gap-md);
}

/* --- A5: Custom Checkboxen --- */
.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    cursor: pointer;
    min-height: 48px;
}

.form-check input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    min-width: 22px;
    border: 1.5px solid var(--grey-light);
    border-radius: 4px;
    background: var(--white);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.form-check input[type="checkbox"]:checked {
    background: var(--red);
    border-color: var(--red);
}

.form-check input[type="checkbox"]:checked::after {
    content: '';
    display: block;
    width: 6px;
    height: 10px;
    border: solid var(--white);
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg);
    margin-top: -2px;
}

.form-check input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(165, 42, 42, 0.15);
}

.form-check label {
    font-weight: 500;
    cursor: pointer;
    font-size: var(--text-base);
}

/* --- A6: Fehlende Hover-States --- */
.btn-success:hover {
    background: var(--success-dark);
}

.btn-danger:hover {
    background: var(--danger-dark);
}

/* --- A7: Erweiterte Utility-Klassen --- */
.flex-wrap     { flex-wrap: wrap; }
.items-end     { align-items: flex-end; }
.items-center  { align-items: center; }
.gap-lg        { gap: var(--gap-lg); }
.text-sm       { font-size: var(--text-sm); }
.text-muted    { color: var(--grey-medium); }
.text-nowrap   { white-space: nowrap; }
.font-bold     { font-weight: 700; }
.font-heading  { font-family: 'Montserrat', sans-serif; }
.w-full        { width: 100%; }

/* --- A9: Draft-Banner --- */
.alert-draft {
    background: var(--draft-bg);
    border: 1px solid var(--draft-border);
    color: var(--draft-text);
}

/* --- Responsive (Tablet+) --- */
@media (min-width: 600px) {
    .menu-toggle {
        display: none;
    }

    .module-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .login-card {
        padding: 3rem 2.5rem;
    }
}

@media (min-width: 900px) {
    .portal-header {
        padding: 0.75rem 2rem;
    }

    .portal-main {
        padding: 2rem;
    }

    .module-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .card {
        padding: 2rem;
    }
}

/* Show hamburger on mobile only */
@media (max-width: 599px) {
    .menu-toggle {
        display: block;
    }

    .header-user span {
        display: none;
    }
}

/* --- Print Styles --- */
@media print {
    .portal-header,
    .mobile-nav,
    .btn,
    .menu-toggle {
        display: none !important;
    }

    .portal-main {
        padding: 0;
        max-width: none;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
