/**
 * ═══════════════════════════════════════════════════════════════════════════════════════════════════
 * DEAL MANAGER - MOBILE PWA ENHANCEMENT STYLES
 * ═══════════════════════════════════════════════════════════════════════════════════════════════════
 * 
 * Diese Datei enthält spezifische PWA-Optimierungen und Mobile-Verbesserungen,
 * die auf dem responsive-system.css aufbauen.
 * 
 * WICHTIG:
 * - Diese Styles ergänzen das Desktop-Layout, ohne es zu verändern
 * - Desktop-Nutzer sind NICHT betroffen
 * - Alle Änderungen sind in Media Queries gekapselt
 * 
 * Aktualisiert: 04.01.2026 (PWA Professional Upgrade)
 * ═══════════════════════════════════════════════════════════════════════════════════════════════════
 */

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   iOS SAFE AREA SUPPORT (Notch, Home Indicator, Dynamic Island)
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

/* Viewport-Einstellungen für Safe Areas */
@supports (padding: env(safe-area-inset-top)) {
    /* HTML Root - Safe Area Variablen */
    :root {
        --safe-area-top: env(safe-area-inset-top, 0px);
        --safe-area-right: env(safe-area-inset-right, 0px);
        --safe-area-bottom: env(safe-area-inset-bottom, 0px);
        --safe-area-left: env(safe-area-inset-left, 0px);
    }
    
    /* Body - Mindesthöhe mit Safe Areas */
    body {
        min-height: 100dvh; /* Dynamic Viewport Height */
        min-height: -webkit-fill-available;
        padding-top: var(--safe-area-top);
        padding-bottom: var(--safe-area-bottom);
        padding-left: var(--safe-area-left);
        padding-right: var(--safe-area-right);
    }
    
    /* Standalone Mode (PWA) - Volle Höhe ohne schwarzen Balken */
    @media all and (display-mode: standalone) {
        html {
            height: 100%;
        }
        
        body {
            height: 100%;
            overflow: auto;
            -webkit-overflow-scrolling: touch;
        }
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   iOS SPECIFIC OPTIMIZATIONS
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

/* iOS Tap Highlight */
@media screen and (max-width: 767px) {
    body {
        -webkit-tap-highlight-color: rgba(18, 50, 109, 0.15);
        -webkit-touch-callout: none;
        overscroll-behavior-y: contain;
    }
    
    /* Prevent pull-to-refresh on iOS */
    html {
        overscroll-behavior-y: none;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   MOBILE HEADER ENHANCEMENTS
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 767px) {
    /* Header - Clean and Simple */
    header {
        background: var(--vw-blue);
        padding: 12px 16px;
        padding-left: 64px; /* Space for hamburger */
        min-height: 56px;
        display: flex;
        align-items: center;
        position: sticky;
        top: 0;
        z-index: 100;
    }
    
    /* Search Container Full Width */
    .search-container {
        flex: 1;
        max-width: 100%;
    }
    
    .search-container input {
        width: 100%;
        padding: 12px 16px 12px 44px;
        font-size: 16px; /* Prevents iOS zoom */
        border-radius: 12px;
        background: white;
        border: none;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    .search-container input:focus {
        outline: none;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    }
    
    .search-container i {
        position: absolute;
        left: 14px;
        top: 50%;
        transform: translateY(-50%);
        color: #9ca3af;
        font-size: 14px;
    }
    
    /* Hide Desktop Status Legend - NOT Search Field */
    header .flex.items-center.gap-6.text-sm.rounded-lg,
    .header-actions {
        display: none !important;
    }
    
    /* Ensure Search Container is Always Visible on Mobile */
    .search-container {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   MOBILE SIDEBAR ENHANCEMENTS
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 767px) {
    /* Sidebar - Off Canvas */
    /* KRITISCH: Sidebar MUSS immer scharf bleiben (kein Blur-Erbe von Parents) */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 85vw;
        max-width: 320px;
        height: 100vh;
        height: 100dvh;
        z-index: 9999;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        /* ═══ BLUR-FIX: Sidebar NIEMALS blurren ═══ */
        filter: none !important;
        -webkit-filter: none !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        /* Eigener Stacking Context - isoliert von Parent-Filtern */
        isolation: isolate;
        will-change: transform;
    }
    
    /* Beide Klassen unterstützen: .active (app.js) und .open (legacy) */
    .sidebar.active,
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 30px rgba(0, 0, 0, 0.3);
    }
    
    /* Sidebar Content */
    .sidebar .p-6:first-child {
        padding: 20px 16px;
    }
    
    .sidebar h1 {
        font-size: 20px;
    }
    
    .sidebar .nav-item {
        padding: 14px 20px;
        font-size: 15px;
        min-height: 48px;
    }
    
    .sidebar .stat-card {
        padding: 12px;
    }
    
    .sidebar .stat-card .value {
        font-size: 18px;
    }
    
    .sidebar .stat-card .label {
        font-size: 11px;
    }
    
    /* Collapsible Sections */
    .collapsible-header {
        padding: 12px 16px;
    }
    
    .collapsible-content[aria-hidden="false"] {
        padding: 12px 16px;
    }
    
    /* Stats Grid - 2 Columns */
    .stats-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    /* Time Filter Buttons */
    .timeframe-button {
        padding: 10px 12px;
        font-size: 12px;
        min-height: 40px;
    }
    
    /* New Deal Button */
    .btn-new-deal {
        width: 100%;
        padding: 14px 20px;
        font-size: 15px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   MOBILE DEAL CARDS - KOMPAKTES 2-ZEILEN LAYOUT
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 767px) {
    /* ═══ MAIN CONTENT - SCROLLBAR FIX ═══ */
    .main-content {
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        height: auto !important;
        min-height: 0 !important;
    }
    
    .view {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .flex-1.overflow-y-auto {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        height: auto !important;
        flex: 1 1 auto !important;
    }
    
    /* Deals Grid - Single Column, Scrollable */
    #dealsList,
    #completedDealsList,
    .deals-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
        padding: 10px !important;
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
        overflow-y: visible !important;
        min-height: auto !important;
    }
    
    /* ═══════════════════════════════════════════════════════════════════
       DEAL CARD - KOMPAKTES 2-ZEILEN LAYOUT
       ┌────────────────────────────────────────────────────────────┐
       │ Kundenname [📅][BAR]              24d | 20.11.2025  363 € │
       │ Golf 8 Hybrid   W403284                                   │
       └────────────────────────────────────────────────────────────┘
       ═══════════════════════════════════════════════════════════════════ */
    .deal-card-compact {
        width: 100% !important;
        padding: 10px 12px !important;
        border-radius: 10px !important;
        margin-bottom: 0 !important;
        position: relative !important;
        flex-shrink: 0 !important;
        z-index: 1 !important; /* Niedriger als Header (z-index: 1000) */
    }
    
    .deal-card-compact.expanded {
        padding: 10px 12px !important;
        z-index: 1 !important;
    }
    
    /* Collapsed Content - Horizontales Layout */
    .deal-card-compact .collapsed-content {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
        gap: 8px !important;
    }
    
    /* Linke Seite: Kundenname + Fahrzeug */
    .deal-card-compact .collapsed-info {
        flex: 1 !important;
        min-width: 0 !important;
        padding-right: 8px !important;
    }
    
    /* ═══ ZEILE 1: KUNDENNAME + ICONS + BADGE ═══ */
    .deal-card-compact .customer-name {
        font-size: 14px !important;
        font-weight: 600 !important;
        margin-bottom: 3px !important;
        line-height: 1.2 !important;
        color: var(--text-primary, #111418) !important;
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 4px !important;
    }
    
    /* Kalender-Icon (Termin gebucht) */
    .deal-card-compact .booked-appointment-badge {
        width: 18px !important;
        height: 18px !important;
        margin-left: 2px !important;
        flex-shrink: 0 !important;
        border-radius: 4px !important;
    }
    
    .deal-card-compact .booked-appointment-badge i {
        font-size: 9px !important;
    }
    
    /* Deal Type Badge (BAR/FIN/LEA) */
    .deal-card-compact .deal-type-badge {
        font-size: 8px !important;
        padding: 1px 5px !important;
        margin-left: 2px !important;
        flex-shrink: 0 !important;
        border-radius: 3px !important;
        font-weight: 600 !important;
    }
    
    /* ═══ ZEILE 2: FAHRZEUG + NUMMER ═══ */
    .deal-card-compact .vehicle-details {
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 6px !important;
        align-items: center !important;
    }
    
    /* Legacy vehicle-info/meta-info Klassen */
    .deal-card-compact .vehicle-info {
        font-size: 12px !important;
        color: var(--text-secondary, #5B6672) !important;
        font-weight: 500 !important;
        overflow: visible !important;
        text-overflow: clip !important;
    }
    
    .deal-card-compact .meta-info {
        font-size: 11px !important;
        color: var(--text-secondary, #5B6672) !important;
        overflow: visible !important;
    }
    
    /* ═══ RECHTE SEITE: DATUM + PROVISION (OBEN RECHTS) ═══ */
    .deal-card-compact .collapsed-status {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-end !important;
        justify-content: flex-start !important;
        gap: 2px !important;
        flex-shrink: 0 !important;
        padding-top: 0 !important;
        margin-top: 0 !important;
        border-top: none !important;
    }
    
    /* Datum Anzeige - Oben rechts */
    .deal-card-compact .date-display {
        display: flex !important;
        align-items: center !important;
        gap: 4px !important;
        font-size: 11px !important;
    }
    
    .deal-card-compact .days-since-purchase {
        font-size: 11px !important;
        font-weight: 700 !important;
        color: var(--text-secondary, #5B6672) !important;
    }
    
    .deal-card-compact .date-separator {
        color: var(--text-secondary, #5B6672) !important;
        opacity: 0.5;
        font-size: 10px !important;
    }
    
    .deal-card-compact .purchase-date {
        font-size: 11px !important;
        font-weight: 500 !important;
        color: var(--text-primary, #111418) !important;
    }
    
    /* ═══ PROVISION - Unter Datum, rechts ═══ */
    .deal-card-compact .provision-display {
        font-size: 14px !important;
        font-weight: 700 !important;
        color: var(--accent-green, #0EA570) !important;
    }
    
    /* ═══ FAHRZEUG-ZEILE: Modell + Nummer IMMER vollständig ═══ */
    .vehicle-line {
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        width: 100% !important;
        overflow: visible !important;
    }
    
    .vehicle-line .vehicle-model {
        font-size: 12px !important;
        color: var(--text-secondary, #5B6672) !important;
        font-weight: 500 !important;
        overflow: visible !important;
        text-overflow: clip !important;
    }
    
    .vehicle-line .vehicle-number {
        font-size: 11px !important;
        color: var(--text-secondary, #5B6672) !important;
        overflow: visible !important;
        white-space: nowrap !important;
    }
    
    /* ═══ READY BADGE OVERLAY - Absolut positioniert, zentriert ═══ */
    .ready-badge-overlay {
        position: absolute !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        bottom: 6px !important;
        z-index: 10 !important;
    }
    
    .deal-card-compact .ready-badge {
        padding: 3px 6px !important;
        font-size: 8px !important;
        border-radius: 8px !important;
    }
    
    .deal-card-compact.expanded .ready-badge-overlay {
        display: none !important;
    }
    
    /* Hide Hover Info on Mobile */
    .hover-text-info {
        display: none !important;
    }
    
    /* ═══ EXPANDED CONTENT ═══ */
    .deal-card-compact .expanded-content {
        margin-top: 10px;
        padding-top: 10px;
    }
    
    /* Status Icons Grid */
    .status-icons-container {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 6px !important;
        margin-top: 8px !important;
        padding-top: 8px !important;
        min-width: auto !important;
        width: 100% !important;
    }
    
    .has-customer-proposal .status-icons-container {
        grid-template-columns: repeat(4, 1fr) !important;
        min-width: auto !important;
    }
    
    /* Status Icons */
    .status-icon-container {
        padding: 2px !important;
    }
    
    .status-icon {
        width: 32px !important;
        height: 32px !important;
        font-size: 13px !important;
        border-radius: 6px !important;
    }
    
    .status-label {
        font-size: 9px !important;
        margin-top: 2px !important;
    }
    
    /* Action Buttons */
    .action-buttons {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
        margin-top: 8px !important;
    }
    
    .action-btn {
        min-width: 40px !important;
        min-height: 40px !important;
        width: 40px !important;
        height: 40px !important;
        font-size: 14px !important;
        border-radius: 8px !important;
    }
    
    /* Update Notification Badge */
    .update-notification-badge {
        position: absolute !important;
        top: 6px !important;
        right: 6px !important;
        width: 20px !important;
        height: 20px !important;
        font-size: 10px !important;
    }
}

/* Extra Small Phones (< 380px) */
@media screen and (max-width: 379px) {
    .deal-card-compact {
        padding: 8px 10px !important;
    }
    
    .deal-card-compact .customer-name {
        font-size: 13px !important;
    }
    
    .deal-card-compact .vehicle-info {
        font-size: 11px !important;
    }
    
    .deal-card-compact .meta-info {
        font-size: 10px !important;
    }
    
    .deal-card-compact .provision-display {
        font-size: 13px !important;
    }
    
    .deal-card-compact .date-display,
    .deal-card-compact .days-since-purchase,
    .deal-card-compact .purchase-date {
        font-size: 10px !important;
    }
    
    .status-icons-container {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 4px !important;
    }
    
    .status-icon {
        width: 28px !important;
        height: 28px !important;
        font-size: 11px !important;
    }
    
    .status-label {
        font-size: 8px !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   MOBILE MODALS
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 767px) {
    /* Modal Backdrop */
    .modal-backdrop {
        padding: 0;
    }
    
    /* Modal Dialog - Full Screen */
    .modal-dialog,
    .modal-content {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        margin: 0;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    /* Modal Header - Sticky */
    .modal-header {
        position: sticky;
        top: 0;
        z-index: 10;
        padding: 16px;
        padding-top: calc(16px + env(safe-area-inset-top, 0px));
        background: white;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
    }
    
    .modal-header h2,
    .modal-title {
        font-size: 18px;
    }
    
    /* Modal Body - Scrollable */
    .modal-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 16px;
    }
    
    /* Modal Footer - Sticky */
    .modal-footer {
        position: sticky;
        bottom: 0;
        z-index: 10;
        padding: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        background: white;
        border-top: 1px solid var(--border);
        display: flex;
        gap: 12px;
        flex-shrink: 0;
    }
    
    .modal-footer button {
        flex: 1;
        min-height: 48px;
        font-size: 15px;
    }
    
    /* Form Sections in Modal - Single Column */
    .modal-body .grid,
    .modal-body .grid-cols-2,
    .modal-body .grid-cols-3,
    .modal-body [class*="lg:grid-cols"] {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }
    
    /* Deal Info Grid */
    .deal-info-grid {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }
    
    /* Provision Box */
    .provision-total-card {
        padding: 24px 20px !important;
        border-radius: 16px !important;
    }
    
    .provision-total-card .text-lg {
        font-size: 16px !important;
    }
    
    .provision-total-card .text-3xl {
        font-size: 32px !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   MOBILE FORMS
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 767px) {
    /* All Inputs - Prevent iOS Zoom */
    input,
    select,
    textarea {
        font-size: 16px !important;
    }
    
    /* Input Fields */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    input[type="date"],
    input[type="password"],
    select,
    textarea {
        min-height: 48px;
        padding: 14px 16px;
        border-radius: 12px;
        font-size: 16px;
    }
    
    .input-field,
    .modern-input {
        padding: 14px 16px !important;
        border-radius: 12px !important;
        font-size: 16px !important;
    }
    
    /* Labels */
    label {
        font-size: 13px;
        margin-bottom: 6px;
    }
    
    /* Form Groups */
    .form-group {
        margin-bottom: 16px;
    }
    
    /* Checkboxes and Radio Buttons */
    input[type="checkbox"],
    input[type="radio"] {
        width: 24px;
        height: 24px;
        margin-right: 10px;
    }
    
    /* Checkbox/Radio Items */
    .checkbox-item-vertical {
        padding: 12px 14px;
        min-height: 48px;
    }
    
    /* Buttons */
    button,
    .btn,
    [role="button"] {
        min-height: 48px;
        padding: 14px 20px;
        font-size: 15px;
        border-radius: 12px;
    }
    
    .btn-primary {
        padding: 14px 24px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   MOBILE FILTER CHIPS
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 767px) {
    /* Filter Container - Horizontal Scroll */
    .filter-container,
    .tabs-container,
    #filterchips-content .flex {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 8px;
        padding: 8px 0;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .filter-container::-webkit-scrollbar,
    .tabs-container::-webkit-scrollbar,
    #filterchips-content .flex::-webkit-scrollbar {
        display: none;
    }
    
    /* Filter Chips */
    .filter-chip {
        flex-shrink: 0;
        white-space: nowrap;
        padding: 10px 14px;
        font-size: 13px;
        border-radius: 20px;
        min-height: 40px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   MOBILE COMPLETED VIEW
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 767px) {
    /* ═══════════════════════════════════════════════════════════════════
       COMPLETED VIEW HEADER - MOBILE (NUR SUCHFELD SICHTBAR)
       ═══════════════════════════════════════════════════════════════════ */
    
    #completedView header {
        flex-direction: column !important;
        gap: 0 !important;
        padding: 12px 16px !important;
        padding-left: 64px !important; /* Space for hamburger menu */
        background: var(--vw-blue) !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 1000 !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
        min-height: 56px !important;
        display: flex !important;
        align-items: center !important;
    }
    
    /* Innerer Container nur für Suchfeld */
    #completedView header > .flex {
        width: 100% !important;
        flex-direction: row !important;
        align-items: center !important;
    }
    
    /* ═══ SUCHFELD - SICHTBAR, STICKY & VOLLE BREITE ═══ */
    #completedView header .search-container {
        width: 100% !important;
        max-width: 100% !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
        z-index: 2 !important;
        margin: 0 !important;
    }
    
    #completedView header .search-container input {
        width: 100% !important;
        padding: 12px 16px 12px 44px !important;
        font-size: 16px !important; /* Prevents iOS zoom */
        border-radius: 12px !important;
        background: white !important;
        border: none !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    }
    
    #completedView header .search-container input:focus {
        outline: none !important;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15) !important;
    }
    
    #completedView header .search-container i {
        position: absolute !important;
        left: 14px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        color: #9ca3af !important;
        font-size: 14px !important;
        z-index: 3 !important;
    }
    
    /* ═══ ZEITRAUMFILTER - KOMPLETT VERSTECKT AUF MOBILE ═══ */
    
    /* Gesamter Filter-Container ausblenden */
    #completedView header .flex.items-center.gap-4 {
        display: none !important;
    }
    
    /* Einzelne Filter-Elemente ausblenden */
    #completedView header .flex.items-center.gap-2 {
        display: none !important;
    }
    
    /* Labels ausblenden */
    #completedView header label {
        display: none !important;
    }
    
    /* Selects ausblenden */
    #completedView header select {
        display: none !important;
    }
    
    /* Date Inputs ausblenden */
    #completedView header input[type="date"] {
        display: none !important;
    }
    
    /* Specific Filter IDs ausblenden */
    #completedTimeFilter,
    #completedYearFilter {
        display: none !important;
    }
    
    /* ═══ DEALS LIST - SAUBERER ABSTAND ZUM STICKY HEADER ═══ */
    
    #completedView .flex-1.overflow-y-auto {
        position: relative !important;
        z-index: 1 !important;
        margin-top: 0 !important;
        padding-top: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        flex: 1 !important;
    }
    
    #completedDealsList {
        position: relative !important;
        z-index: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
        padding: 12px !important;
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
    }
    
    /* Deal Cards - Immer unterhalb des Headers */
    #completedView .deal-card-compact {
        position: relative !important;
        z-index: 1 !important;
        margin-bottom: 0 !important;
    }
    
    #completedView header select {
        flex: 1;
        min-width: 0;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   MOBILE TOASTS & NOTIFICATIONS
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 767px) {
    .toast,
    .notification,
    .alert {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        max-width: calc(100% - 24px);
        padding: 14px 18px;
        border-radius: 12px;
        font-size: 14px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   PWA STANDALONE MODE
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

@media all and (display-mode: standalone) {
    /* Status Bar Spacer */
    .pwa-status-bar-spacer {
        height: env(safe-area-inset-top, 0px);
        background: var(--vw-blue);
    }
    
    @media screen and (max-width: 767px) {
        /* Header padding for PWA */
        header {
            padding-top: calc(12px + env(safe-area-inset-top, 0px));
        }
        
        /* Mobile menu button position */
        .mobile-menu-btn {
            top: calc(12px + env(safe-area-inset-top, 0px));
        }
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   LANDSCAPE MODE
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 767px) and (orientation: landscape) {
    /* Sidebar - Narrower */
    .sidebar {
        max-width: 280px;
    }
    
    /* Header - Compact */
    header {
        padding: 8px 16px;
        padding-left: 56px;
        min-height: 48px;
    }
    
    /* Modal Header/Footer - Compact */
    .modal-header,
    .modal-footer {
        padding: 10px 16px;
    }
    
    .modal-header {
        padding-top: calc(10px + env(safe-area-inset-top, 0px));
    }
    
    .modal-footer {
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   TABLET BREAKPOINT (768px - 1023px)
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

@media screen and (min-width: 768px) and (max-width: 1023px) {
    /* Deals Grid - 2 Columns */
    #dealsList,
    #completedDealsList,
    .deals-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
        padding: 16px;
    }
    
    /* Deal Card */
    .deal-card-compact {
        max-height: 80px;
        padding: 12px 16px;
    }
    
    .deal-card-compact .customer-name {
        font-size: 14px;
    }
    
    .deal-card-compact .vehicle-info,
    .deal-card-compact .meta-info {
        font-size: 13px;
    }
    
    /* Modal - Not Full Screen */
    .modal-dialog {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        bottom: auto;
        width: 90vw;
        height: auto;
        max-width: 800px;
        max-height: 90vh;
        margin: auto;
        border-radius: 16px;
    }
    
    .modal-header {
        padding-top: 20px;
        border-radius: 16px 16px 0 0;
    }
    
    .modal-footer {
        padding-bottom: 20px;
        border-radius: 0 0 16px 16px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   DESKTOP RESET (≥ 768px)
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

@media screen and (min-width: 768px) {
    /* Reset Mobile-Only Elements */
    .mobile-only,
    .show-mobile,
    .mobile-menu-btn {
        display: none !important;
    }
    
    .desktop-only,
    .hide-mobile {
        display: block !important;
    }
    
    /* Sidebar - Static */
    .sidebar {
        position: relative !important;
        transform: none !important;
        width: var(--sidebar-width, 280px) !important;
        max-width: none !important;
        z-index: 1 !important;
    }
    
    .sidebar.active,
    .sidebar.open {
        box-shadow: none !important;
    }
    
    /* Sidebar Overlay - Hidden */
    .sidebar-overlay {
        display: none !important;
    }
    
    /* Header - Normal Padding */
    header {
        padding-left: 24px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   TOUCH FEEDBACK
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

@media screen and (max-width: 767px) {
    /* Touch Feedback */
    button:active,
    .btn:active,
    a:active,
    .deal-card-compact:active,
    .nav-item:active,
    .filter-chip:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    
    /* No Hover Effects on Touch */
    @media (hover: none) {
        button:hover,
        .btn:hover,
        a:hover,
        .deal-card-compact:hover:not(.expanded) {
            transform: none;
            box-shadow: inherit;
        }
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   PRINT STYLES
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

@media print {
    .mobile-only,
    .mobile-menu-btn,
    .sidebar-overlay,
    .fab {
        display: none !important;
    }
}
