/* --- style.css (Final Optimized) --- */

/* -------------------------
 * 1. GRUNDEINSTELLUNGEN & RESET
 * ------------------------- */
/* WICHTIG: Box-Sizing für konsistente Breitenberechnung */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Inter (Lokal - Variabel) */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 600;
    font-display: swap;
    src: url('assets/fonts/Inter/Inter-VariableFont_opsz,wght.ttf') format('truetype');
}

/* Montserrat (Lokal - Variabel) */
@font-face {
    font-family: 'Montserrat';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('assets/fonts/Montserrat/Montserrat-VariableFont_wght.ttf') format('truetype');
}

:root {
    --primary-color: #5990BA;
    --primary-hover: #4a789a;
    --bg-light: #f4f7f6;
    --text-light: #FFFFFF;
    --text-dark: #333333;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --input-height: 48px; /* Touch-freundliche Höhe */
}

html {
    /* Verhindert Text-Skalierung im Landscape-Modus auf iPhones */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    /* Schärfere Schrift auf MacOS/iOS */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* -------------------------
 * 2. TITELLEISTE (HEADER)
 * ------------------------- */
.site-header {
    background-color: var(--text-dark);
    color: var(--text-light);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 5px var(--shadow-color);
    position: relative;
    z-index: 20;
}
.site-header .logo-container {
    margin-right: 1rem;
    flex-shrink: 0;
}
.site-header .logo-container img {
    height: 100px;
    width: auto;
    display: block;
}
.site-header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    font-family: 'Montserrat', sans-serif;
    flex: 1;
    text-align: right;
}
.header-link {
    color: inherit;
    text-decoration: none;
    transition: opacity 0.2s;
}
.header-link:hover { opacity: 0.8; }

/* -------------------------
 * 3. BENUTZER-LEISTE
 * ------------------------- */
.user-bar {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
}
.user-bar span {
    font-weight: 500;
    color: var(--text-dark);
}
.button-logout {
    font-family: 'Inter', sans-serif;
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius);
    transition: background-color 0.2s;
}
.button-logout:hover { background-color: var(--bg-light); }
.button-logout i { margin-right: 0.5rem; }

/* -------------------------
 * 4. DASHBOARD & LAYOUT
 * ------------------------- */
.dashboard-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}
.main-navigation {
    width: 100%;
    max-width: 1000px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
}
.nav-button {
    background-color: var(--primary-color);
    color: var(--text-light);
    text-decoration: none;
    border-radius: 10px;
    box-shadow: 0 4px 10px var(--shadow-color);
    padding: 2rem;
    font-size: 1.25rem;
    font-weight: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: transform 0.2s, background-color 0.2s, box-shadow 0.2s;
}
.nav-button i {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}
.nav-button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-5px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
}

.page-container {
    flex: 1;
    width: 100%;
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
}
.card {
    background-color: #FFFFFF;
    border-radius: 10px;
    box-shadow: 0 4px 10px var(--shadow-color);
    padding: 2rem;
    margin-bottom: 2rem;
}
.card h2 {
    margin-top: 0;
    border-bottom: 2px solid var(--bg-light);
    padding-bottom: 0.75rem;
    font-weight: 600;
    font-size: 1.4rem;
}
.card h2 i {
    color: var(--primary-color);
    margin-right: 0.5rem;
}

/* Info Boxen */
.customer-info-box, .notice-bar, .form-group.info-box {
    background-color: var(--bg-light);
    border: 1px solid #e0e0e0;
    padding: 1rem;
    border-radius: var(--border-radius);
    line-height: 1.5;
}
.notice-bar {
    background: #fff;
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}
.form-group.info-box label {
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #ddd;
    padding-bottom: 0.5rem;
    display: block;
}

/* -------------------------
 * 5. FORMULARE
 * ------------------------- */
.form-container {
    max-width: 1000px;
    margin: 0 auto;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}
.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.5rem;
}
.form-group label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #555;
}

/* Standard Inputs */
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group input[type="password"],
.form-group input[type="date"],
.form-group input[type="number"],
.form-group textarea {
    width: 100%;
    min-height: var(--input-height);
    padding: 0.7rem 0.8rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    background-color: #fff;
    color: #333;
    transition: border-color 0.2s, box-shadow 0.2s;
    
    /* Entfernt iOS Schatten */
    -webkit-appearance: none;
    appearance: none;
}

/* -----------------------------------------------------------
 * WICHTIG: DROPDOWN (SELECT) FIX FÜR SAFARI / IOS
 * ----------------------------------------------------------- */
.form-group select {
    display: block;
    width: 100%;
    min-height: var(--input-height);
    padding: 0.7rem 2.5rem 0.7rem 0.8rem; /* Rechts Platz für Pfeil */
    
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    color: #333;
    
    /* Explizite Werte für Safari zwingend notwendig: */
    background-color: #ffffff;
    border: 1px solid #ccc;
    border-radius: 5px;
    
    /* Entfernt natives OS-Design */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    
    /* Neuer, robuster SVG-Pfeil (Dunkelgrau) */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1rem;
    cursor: pointer;
}

/* IE11 Fix */
.form-group select::-ms-expand { display: none; }

/* Fokus-Zustände für alle Inputs */
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(89, 144, 186, 0.2);
    outline: none;
}

.form-group textarea {
    min-height: 120px;
    resize: vertical;
}

.form-group-split {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1rem;
}

/* Checkboxen */
.form-group-checkbox-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-top: 0.5rem;
}
.form-group-checkbox {
    display: flex;
    align-items: center;
}
.form-group-checkbox input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    margin-right: 0.75rem;
    cursor: pointer;
    accent-color: var(--primary-color);
    /* Checkbox darf nativ aussehen */
    -webkit-appearance: auto;
    appearance: auto;
}
.form-group-checkbox label { margin: 0; cursor: pointer; }
.form-divider {
    border: none;
    border-top: 1px solid var(--bg-light);
    margin: 2rem 0;
}

/* Buttons */
.form-actions {
    text-align: right;
    margin-top: 1.5rem;
}
.form-actions-split {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.button-primary, .button-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 1.8rem;
    height: var(--input-height);
    border-radius: var(--border-radius);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    border: none;
    text-align: center;
}

.button-primary {
    background-color: var(--primary-color);
    color: var(--text-light);
}
.button-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}
.button-secondary {
    background-color: #f0f0f0;
    color: #555;
    border: 1px solid #ccc;
}
.button-secondary:hover {
    background-color: #e0e0e0;
    transform: translateY(-2px);
}
.button-secondary i { margin-right: 0.5rem; }

/* -------------------------
 * 6. TABELLEN & LISTEN
 * ------------------------- */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Weiches Scrollen iOS */
    margin-top: 1rem;
    border: 1px solid #e0e0e0;
    border-radius: var(--border-radius);
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 650px; /* Erzwingt Scrollbar auf Handy */
}
.data-table th,
.data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
    vertical-align: middle;
}
.data-table th {
    background-color: var(--bg-light);
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}
.data-table tbody tr:hover { background-color: #f9f9f9; }
.data-table .actions { text-align: right; white-space: nowrap; }

.button-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: #777;
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
}
.button-icon:hover {
    background-color: #f0f0f0;
    color: var(--primary-color);
}
.button-icon.delete:hover {
    color: #e74c3c;
    background-color: #fce8e6;
}

.status-badge {
    display: inline-block;
    padding: 0.35em 0.65em;
    font-size: 0.85em;
    font-weight: 600;
    border-radius: 4px;
    color: #fff;
    white-space: nowrap;
}
.status-badge.status-aktiv { background-color: #28a745; }
.status-badge.status-inaktiv { background-color: #6c757d; }

.data-table .total-row td {
    border-top: 2px solid #ccc;
    font-weight: bold;
    background-color: #fafafa;
}

/* Tab-Navigation */
.tab-navigation {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 2rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.tab-button {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 1.1rem;
    padding: 1rem 1.5rem;
    border: none;
    background: none;
    cursor: pointer;
    text-decoration: none;
    color: #888;
    margin-bottom: -2px;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
    white-space: nowrap;
}
.tab-button:hover, .tab-button.active { color: var(--primary-color); }
.tab-button.active { border-bottom-color: var(--primary-color); }
.tab-button i { margin-right: 0.75rem; }

/* -------------------------
 * 7. FEEDBACK & FOOTER
 * ------------------------- */
.feedback {
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: var(--border-radius);
    font-weight: 500;
}
.feedback.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.feedback.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.site-footer {
    background-color: var(--text-dark);
    color: var(--text-light);
    padding: 2rem;
    margin-top: auto;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    font-family: 'Montserrat', sans-serif;
}
.font-controls { display: flex; gap: 0.5rem; }
.font-control-button {
    color: var(--text-light);
    text-decoration: none;
    padding: 0.5rem;
    border-radius: 4px;
    background: rgba(255,255,255,0.1);
}

/* -------------------------
 * 8. RESPONSIVE (MOBILE / TABLET)
 * ------------------------- */
@media (max-width: 768px) {
    /* Header */
    .site-header { flex-direction: column; text-align: center; gap: 0.5rem; padding: 1rem; }
    .site-header .logo-container { margin: 0; }
    .site-header h1 { text-align: center; font-size: 1.3rem; }

    /* User-Bar */
    .user-bar { flex-direction: column; gap: 1rem; padding: 1rem; text-align: center; }
    .button-logout { width: 100%; display: block; text-align: center; background-color: #f5f5f5; }

    /* Main Content */
    .dashboard-container, .page-container { padding: 1rem; }
    .card { padding: 1.25rem; }

    /* Navigation */
    .nav-button { padding: 1.5rem; min-height: 130px; }

    /* Formulare */
    .form-group-split { grid-template-columns: 1fr; }
    
    /* WICHTIG FÜR SAFARI IOS: Schriftgröße 16px verhindert Zoom */
    .form-group input, 
    .form-group select, 
    .form-group textarea {
        font-size: 16px !important;
    }
    
    /* Buttons volle Breite */
    .form-actions-split { flex-direction: column-reverse; }
    .button-primary, .button-secondary { width: 100%; }

    /* Footer */
    .site-footer { flex-direction: column; justify-content: center; text-align: center; }
}

@media print {
    .site-header, .user-bar, .main-navigation, .tab-navigation, .form-actions, .button-icon { display: none !important; }
    body, .page-container, .card {
        background: #fff;
        color: #000;
        margin: 0;
        padding: 0;
        box-shadow: none;
        width: 100%;
        border: none;
    }
}