/* KZL PEP - Mobile-First CSS */

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #ffffff;
    --bg-secondary: #f8fafc;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 0.5rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-secondary);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navbar - Kompakt - IMMER horizontal */
.navbar {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 0.25rem 0.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Container für Toggle und Brand - bleibt IMMER zusammen */
.navbar-left {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 0.5rem;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    flex-wrap: nowrap !important;
    white-space: nowrap !important;
    min-width: fit-content;
}

.navbar-toggle {
    display: flex !important;
    flex-direction: column;
    gap: 2px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    flex-shrink: 0;
    margin: 0;
}

.navbar-toggle span {
    width: 18px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: all 0.3s;
}

.navbar-brand {
    flex-shrink: 0;
    display: flex !important;
    align-items: center;
    margin: 0;
    padding: 0;
    white-space: nowrap !important;
}

.navbar-brand a {
    font-size: 1rem;
    font-weight: bold;
    color: var(--primary);
    text-decoration: none;
    line-height: 1;
    white-space: nowrap;
}

.navbar-menu {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    flex: 1;
}

.navbar-item {
    color: var(--text);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    transition: background 0.2s;
}

.navbar-item:hover {
    background: var(--bg-secondary);
}

.navbar-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-name {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.logout-form {
    display: inline;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    text-decoration: underline;
    font-size: 0.875rem;
}

/* Main Content - Kompakt */
.main-content {
    flex: 1;
    padding: 0.25rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

.page-title {
    font-size: 0.9rem;
    font-weight: bold;
    margin: 0;
    line-height: 1.2;
}

.page-subtitle {
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
}

/* Dashboard - Einheitliche Karten ohne Duplikate */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.dashboard-card {
    background: var(--bg);
    padding: 0.6rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--text);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
    border: 1px solid var(--border);
}

.dashboard-card:active {
    transform: scale(0.98);
}

.dashboard-card:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    border-color: var(--primary);
}

.dashboard-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.3rem;
    width: 100%;
}

.dashboard-card-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    flex: 1;
    line-height: 1.2;
}

.dashboard-card-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary);
    margin-left: 0.5rem;
    white-space: nowrap;
}

.dashboard-card-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.3;
    margin-top: 0.2rem;
}

.dashboard-card-sublabel {
    font-size: 0.6rem;
    color: var(--primary);
    font-weight: 600;
    margin-top: 0.3rem;
}

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

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    background: var(--bg);
    color: var(--text);
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn:active {
    transform: scale(0.98);
}

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

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

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

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

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

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.btn-outline {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    background: var(--bg-secondary);
    border-color: var(--primary);
}

.btn-compact {
    padding: 0.3rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 500;
}

/* Schedule Header */
.schedule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: 0.4rem;
    flex-wrap: nowrap;
}

.schedule-header-actions {
    display: flex;
    gap: 0.3rem;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

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

.card-header {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Mobile Responsive - Kompakt */
@media (max-width: 768px) {
    .navbar {
        padding: 0.25rem 0.5rem;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important; /* Center statt flex-start */
        gap: 0.5rem;
    }
    
    /* Navbar-Left Container: Toggle und Brand bleiben IMMER zusammen - KEIN Umbrechen */
    .navbar-left {
        display: inline-flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        gap: 0.5rem !important;
        flex-shrink: 0 !important;
        flex-basis: auto !important;
        width: auto !important;
        min-width: fit-content !important; /* Mindestbreite = Inhalt */
        max-width: none !important;
        order: 1 !important;
        white-space: nowrap !important;
        /* Verhindere Umbrechen - zwinge auf erste Zeile */
        flex-grow: 0 !important;
        overflow: visible !important;
    }
    
    .navbar-toggle {
        display: flex !important;
        flex-shrink: 0 !important;
        flex-grow: 0 !important;
        margin: 0 !important;
        padding: 0.25rem;
        width: auto !important;
        min-width: 18px !important; /* Mindestbreite für Toggle */
    }
    
    .navbar-brand {
        flex-shrink: 0 !important;
        flex-grow: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        display: inline-flex !important; /* inline-flex statt flex */
        align-items: center !important;
        white-space: nowrap !important;
        width: auto !important;
        min-width: fit-content !important;
    }
    
    .navbar-brand a {
        font-size: 0.9rem;
        line-height: 1;
        white-space: nowrap !important;
        display: inline-block !important;
        /* Verhindere Textumbruch */
        word-break: keep-all !important;
        overflow: visible !important;
    }
    
    /* Zweite Zeile: Menu (wird bei Bedarf umgebrochen) */
    .navbar-menu {
        display: none;
        flex-direction: column;
        width: 100%;
        margin-top: 0.5rem;
        gap: 0.5rem;
        order: 3;
    }
    
    .navbar-menu.active {
        display: flex;
    }
    
    .navbar-item {
        padding: 0.5rem;
        font-size: 0.875rem;
    }
    
    .navbar-user {
        margin-left: 0;
        width: 100%;
        justify-content: space-between;
        padding-top: 0.5rem;
        border-top: 1px solid var(--border);
        font-size: 0.875rem;
    }
    
    .main-content {
        padding: 0.5rem;
    }
    
    .page-title {
        font-size: 1rem;
    }
    
    .schedule-header {
        flex-wrap: nowrap;
        gap: 0.3rem;
        margin-bottom: 0.4rem;
    }
    
    .schedule-header-actions {
        gap: 0.25rem;
    }
    
    .btn-compact {
        padding: 0.25rem 0.5rem;
        font-size: 0.65rem;
    }
    
    .btn-sm {
        padding: 0.3rem 0.5rem;
        font-size: 0.7rem;
    }
}

/* Zusätzliche Regel für sehr kleine Bildschirme - garantiert dass Toggle und Brand zusammen bleiben */
@media (max-width: 480px) {
    .navbar {
        align-items: center !important;
        justify-content: flex-start !important;
    }
    
    .navbar-left {
        /* Zwinge auf erste Zeile - keine Umbrüche */
        order: 1 !important;
        flex: 0 0 auto !important;
        width: auto !important;
        max-width: 100% !important;
        min-width: fit-content !important;
    }
    
    .navbar-toggle {
        /* Minimale Größe für Toggle */
        min-width: 24px !important;
        width: 24px !important;
    }
    
    .navbar-brand {
        /* Minimale Größe für Brand */
        min-width: fit-content !important;
        max-width: calc(100vw - 80px) !important; /* Maximalbreite = Viewport - Toggle - Padding */
    }
    
    .navbar-brand a {
        /* Text darf nicht umbrechen */
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }
    
    .page-subtitle {
        font-size: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.4rem;
    }
    
    .dashboard-card {
        padding: 0.4rem;
    }
    
    .dashboard-card-title {
        font-size: 0.75rem;
    }
    
    .dashboard-card-value {
        font-size: 1rem;
    }
    
    .dashboard-card-desc {
        font-size: 0.6rem;
    }
    
    .dashboard-card-sublabel {
        font-size: 0.5rem;
    }
    
    .page-title {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }
    
    .dashboard-card {
        padding: 0.5rem;
    }
    
    .schedule-header {
        gap: 0.25rem;
        margin-bottom: 0.3rem;
    }
    
    .schedule-header-actions {
        gap: 0.2rem;
    }
    
    .btn-compact {
        padding: 0.2rem 0.4rem;
        font-size: 0.6rem;
    }
    
    .btn-sm {
        padding: 0.25rem 0.4rem;
        font-size: 0.65rem;
    }
    
    .page-title {
        font-size: 0.9rem;
    }
}

/* Offline Indicator */
.offline-indicator {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    background: var(--warning);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: none;
}

.offline-indicator.show {
    display: block;
}

/* Loading Spinner */
.spinner {
    border: 3px solid var(--border);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* V1.0 */