/* ============================================
   VFM Einsatzplanung - Styles
   ============================================ */

:root {
    --primary: #002c59;
    --primary-dark: #001a36;
    --primary-light: #d6e4f0;
    --success: #107c10;
    --success-light: #dff6dd;
    --warning: #ffb900;
    --warning-light: #fff4ce;
    --danger: #d13438;
    --danger-light: #fde7e9;
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #e5e5e5;
    --gray-300: #d4d4d4;
    --gray-400: #a3a3a3;
    --gray-500: #737373;
    --gray-600: #525252;
    --gray-700: #404040;
    --gray-800: #262626;
    --gray-900: #171717;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --transition: all 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #002c59 0%, #004a8f 100%);
    min-height: 100vh;
    color: var(--gray-800);
    line-height: 1.6;
}

.hidden {
    display: none !important;
}

/* App Container */
.app-container {
    max-width: 680px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    padding: 16px 0;
    margin-bottom: 8px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.header-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.header-logo {
    height: 28px;
    width: auto;
    object-fit: contain;
}

.app-header h1 {
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,0.9);
    font-size: 0.875rem;
}

/* Cards */
.card {
    background: white;
    border-radius: var(--radius);
    padding: 32px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-md);
    animation: fadeIn 0.3s ease;
}

.card-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.card > p {
    color: var(--gray-500);
    margin-bottom: 24px;
    font-size: 0.9375rem;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline:hover:not(:disabled) {
    background: var(--primary-light);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    width: 100%;
}

.btn-primary.btn-lg svg {
    flex-shrink: 0;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 24px;
}

.tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--gray-500);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.tab.active {
    background: white;
    color: var(--gray-800);
    box-shadow: var(--shadow);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-group small {
    display: block;
    font-size: 0.8125rem;
    color: var(--gray-400);
    margin-top: 4px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9375rem;
    color: var(--gray-800);
    transition: var(--transition);
    background: white;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-input::placeholder {
    color: var(--gray-400);
}

/* Input with suggestions */
.input-with-suggestions {
    position: relative;
}

.suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid var(--gray-200);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: var(--shadow-lg);
}

.suggestion-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.9375rem;
    transition: background 0.15s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.suggestion-item:hover {
    background: var(--primary-light);
}

.suggestion-item .count {
    font-size: 0.75rem;
    color: var(--gray-400);
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 12px;
}

/* Chips */
.chip-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.chip:hover {
    background: var(--primary);
    color: white;
}

.chip.active {
    background: var(--primary);
    color: white;
}

/* Manual fields toggle */
.manual-fields {
    margin-bottom: 20px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 4px 14px;
}

.manual-fields summary {
    cursor: pointer;
    padding: 10px 0;
    font-size: 0.875rem;
    color: var(--gray-500);
    font-weight: 500;
}

.manual-fields[open] summary {
    margin-bottom: 12px;
    border-bottom: 1px solid var(--gray-200);
    padding-bottom: 10px;
}

.manual-fields .form-group {
    margin-bottom: 16px;
}

.parsed-info {
    background: var(--success-light);
    border: 1px solid #a7e3a5;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-top: 8px;
    font-size: 0.8125rem;
    color: var(--success);
}

.parsed-info code {
    font-weight: 600;
    background: rgba(16,124,16,0.1);
    padding: 1px 4px;
    border-radius: 3px;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.upload-area:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-area.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 8px;
}

.upload-area p {
    color: var(--gray-500);
    font-size: 0.9375rem;
}

.upload-area input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* Event List */
.event-list {
    max-height: 70vh;
    overflow-y: auto;
    margin-bottom: 24px;
}

.event-card {
    display: flex;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    transition: var(--transition);
}

/* Prevent zoom on mobile */
html {
    touch-action: pan-x pan-y;
    -ms-touch-action: pan-x pan-y;
}

.event-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.event-date {
    text-align: center;
    min-width: 52px;
    flex-shrink: 0;
}

.event-date .day {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.event-date .month {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: uppercase;
    font-weight: 500;
}

.event-date .weekday {
    font-size: 0.6875rem;
    color: var(--gray-400);
    margin-top: 2px;
}

.event-details {
    flex: 1;
    min-width: 0;
}

.event-details .event-title {
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 4px;
    font-size: 0.9375rem;
}

.event-details .event-time {
    font-size: 0.8125rem;
    color: var(--primary);
    font-weight: 500;
    margin-bottom: 4px;
}

.event-details .event-location {
    font-size: 0.8125rem;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.event-details .event-description {
    font-size: 0.8125rem;
    color: var(--gray-400);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.event-segment {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 6px;
}

.segment-logistik { background: #e3f2fd; color: #1565c0; }
.segment-technik { background: #fce4ec; color: #c62828; }
.segment-orga { background: #e8f5e9; color: #2e7d32; }
.segment-auf-abbau { background: #fff3e0; color: #e65100; }
.segment-default { background: var(--gray-100); color: var(--gray-600); }

/* Preview Info */
.preview-info {
    background: var(--success-light);
    border: 1px solid #a7e3a5;
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 20px;
    font-size: 0.9375rem;
    color: var(--success);
    font-weight: 500;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.loading-overlay p {
    color: white;
    font-size: 1rem;
    margin-top: 16px;
    font-weight: 500;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Messages */
.message-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 200;
    max-width: 400px;
}

.message {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.message-success {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid #a7e3a5;
}

.message-error {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid #f5b7b9;
}

.message-warning {
    background: var(--warning-light);
    color: #996000;
    border: 1px solid #ffd966;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Footer */
.app-footer {
    padding: 24px 0;
    text-align: center;
    color: rgba(255,255,255,0.6);
    font-size: 0.8125rem;
    margin-top: auto;
}

/* ============================================
   Collapsible Filter Header
   ============================================ */
.filter-header {
    display: none; /* shown via JS by removing .hidden */
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--primary);
    user-select: none;
}

.filter-header:not(.hidden) {
    display: flex;
}

.filter-header .filter-toggle-icon {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.filter-header.collapsed .filter-toggle-icon {
    transform: rotate(-90deg);
}

.filter-body.collapsed {
    display: none;
}

.filter-icon-desktop,
.filter-title-desktop,
.filter-desc-desktop {
    display: none;
}

.filter-body {
    /* default: visible */
}

/* ============================================
   Weekday Filter
   ============================================ */
.weekday-filter {
    margin-bottom: 16px;
}

.weekday-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.weekday-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 12px;
    background: var(--gray-100);
    color: var(--gray-600);
    border: 1.5px solid var(--gray-200);
    border-radius: 16px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
    min-width: 36px;
    text-align: center;
}

.weekday-chip:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.weekday-chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* ============================================
   Responsive - Mobile (XS)
   ============================================ */
@media (max-width: 480px) {
    /* --- Fixed layout: no page scroll, only events scroll --- */
    html, body {
        height: 100%;
        overflow: hidden;
    }

    .app-container {
        padding: 8px 10px;
        height: 100%;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .app-header {
        padding: 8px 0;
        margin-bottom: 4px;
        flex-shrink: 0;
    }

    .app-header h1 {
        font-size: 1.1rem;
    }

    .header-logo {
        height: 20px;
    }

    .header-brand {
        gap: 2px;
    }

    .header-content {
        flex-direction: row;
        align-items: center;
    }

    .user-info {
        font-size: 0;
    }

    .user-info #userName {
        display: none;
    }

    .user-info #btnLogout {
        font-size: 0.75rem;
        padding: 4px 8px;
    }

    main.main-content {
        flex: 1;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    /* Cards: compact on mobile */
    .card {
        padding: 12px 14px;
        margin-bottom: 6px;
        border-radius: var(--radius-sm);
    }

    .card-icon {
        font-size: 1.5rem;
        margin-bottom: 4px;
    }

    .card h2 {
        font-size: 1rem;
        margin-bottom: 4px;
    }

    .card > p {
        font-size: 0.8125rem;
        margin-bottom: 12px;
    }

    /* --- Collapsible filter on mobile (already global, just keep body rule) --- */

    /* --- Preview section: fill remaining space --- */
    #sectionPreview {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }

    .preview-icon-desktop,
    .preview-title-desktop {
        display: none;
    }

    .preview-info {
        padding: 8px 10px;
        margin-bottom: 8px;
        font-size: 0.8125rem;
        flex-shrink: 0;
    }

    .weekday-filter {
        margin-bottom: 8px;
        flex-shrink: 0;
    }

    .weekday-chip {
        padding: 4px 8px;
        font-size: 0.6875rem;
    }

    /* Event list scrollable */
    .event-list {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        max-height: none;
        margin-bottom: 8px;
        -webkit-overflow-scrolling: touch;
    }

    .event-card {
        flex-direction: column;
        gap: 4px;
        padding: 10px 12px;
        margin-bottom: 6px;
    }

    .event-date {
        display: flex;
        gap: 6px;
        align-items: baseline;
    }

    .event-date .day {
        font-size: 1.1rem;
    }

    .event-details .event-title {
        font-size: 0.8125rem;
    }

    .event-details .event-time,
    .event-details .event-location,
    .event-details .event-description {
        font-size: 0.75rem;
        white-space: normal;
    }

    .event-segment {
        font-size: 0.625rem;
        padding: 1px 6px;
        margin-bottom: 2px;
    }

    /* Action buttons compact */
    .action-buttons {
        flex-shrink: 0;
        gap: 6px;
    }

    .action-buttons .btn {
        font-size: 0.8125rem;
        padding: 8px 12px;
    }

    .action-buttons .btn-lg {
        padding: 10px 14px;
        font-size: 0.8125rem;
    }

    /* --- Chip container compact --- */
    .chip-container {
        gap: 4px;
        margin-bottom: 8px;
    }

    .chip {
        padding: 4px 8px;
        font-size: 0.6875rem;
    }

    /* --- Toast messages smaller & dezenter --- */
    .message-container {
        top: auto;
        bottom: 12px;
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .message {
        padding: 8px 12px;
        font-size: 0.75rem;
        border-radius: 6px;
        gap: 6px;
    }

    /* Footer hidden on mobile */
    .app-footer {
        display: none;
    }

    /* Hide elements on mobile */
    .hide-mobile {
        display: none !important;
    }
}

/* Medium viewports - keep normal but slightly tighter */
@media (min-width: 481px) and (max-width: 768px) {
    .card {
        padding: 24px 20px;
    }

    .app-header h1 {
        font-size: 1.25rem;
    }
}
