/**
 * ═══════════════════════════════════════════════════════════════════════════════════════════════════
 * DEAL MANAGER - RESPONSIVE DESIGN SYSTEM
 * ═══════════════════════════════════════════════════════════════════════════════════════════════════
 * 
 * Ein vollständiges, mobile-first responsives Design-System für die Deal Manager Anwendung.
 * 
 * BREAKPOINTS:
 * ────────────────────────────────────────────────────────────────────────────────────────────────────
 * - xs (Extra Small):   < 480px   → Kleine Smartphones (iPhone SE, etc.)
 * - sm (Small):         480-767px → Smartphones (iPhone 14 Pro Max, etc.)
 * - md (Medium):        768-1023px → Tablets (iPad, etc.)
 * - lg (Large):         1024-1439px → Laptops
 * - xl (Extra Large):   1440-1919px → Desktop Monitore
 * - 2xl (2X Large):     ≥ 1920px → Große Monitore (Full HD+)
 * 
 * DESIGN-PRINZIPIEN:
 * ────────────────────────────────────────────────────────────────────────────────────────────────────
 * 1. Mobile-First: Basis-Styles für kleine Bildschirme, dann aufwärts skalieren
 * 2. Fluid Typography: Schriftgrößen skalieren mit der Viewport-Breite
 * 3. Flexible Grids: Spalten passen sich dem verfügbaren Platz an
 * 4. Touch-First: Alle interaktiven Elemente mindestens 44px
 * 5. Keine horizontalen Scrollbars: Inhalte passen sich immer an
 * 6. Safe Areas: iOS Notch und Home Indicator werden berücksichtigt
 * 
 * Erstellt: 14.12.2025
 * ═══════════════════════════════════════════════════════════════════════════════════════════════════
 */

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   RESPONSIVE CSS CUSTOM PROPERTIES (Mobile-First)
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

:root {
    /* ─────────────────────────────────────────────────────────────────────────────────────────────
       BREAKPOINT VALUES (für JS-Zugriff)
       ───────────────────────────────────────────────────────────────────────────────────────────── */
    --breakpoint-xs: 480px;
    --breakpoint-sm: 768px;
    --breakpoint-md: 1024px;
    --breakpoint-lg: 1440px;
    --breakpoint-xl: 1920px;
    
    /* ─────────────────────────────────────────────────────────────────────────────────────────────
       RESPONSIVE SPACING (Mobile-First Base)
       ───────────────────────────────────────────────────────────────────────────────────────────── */
    --r-spacing-xs: 4px;
    --r-spacing-sm: 8px;
    --r-spacing-md: 12px;
    --r-spacing-lg: 16px;
    --r-spacing-xl: 24px;
    --r-spacing-2xl: 32px;
    
    /* ─────────────────────────────────────────────────────────────────────────────────────────────
       RESPONSIVE TYPOGRAPHY (Mobile-First Base)
       ───────────────────────────────────────────────────────────────────────────────────────────── */
    --r-font-xs: 12px;
    --r-font-sm: 13px;
    --r-font-base: 14px;
    --r-font-md: 15px;
    --r-font-lg: 16px;
    --r-font-xl: 18px;
    --r-font-2xl: 22px;
    --r-font-3xl: 28px;
    
    /* ─────────────────────────────────────────────────────────────────────────────────────────────
       LAYOUT DIMENSIONS (Mobile-First Base)
       ───────────────────────────────────────────────────────────────────────────────────────────── */
    --r-sidebar-width: 0px;          /* Versteckt auf Mobile */
    --r-header-height: 56px;
    --r-touch-target: 44px;          /* Minimum Touch Target */
    --r-card-gap: 12px;
    --r-container-padding: 12px;
    --r-border-radius: 10px;
    
    /* ─────────────────────────────────────────────────────────────────────────────────────────────
       SAFE AREAS (für iOS)
       ───────────────────────────────────────────────────────────────────────────────────────────── */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

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

@media screen and (min-width: 768px) {
    :root {
        --r-spacing-xs: 5px;
        --r-spacing-sm: 10px;
        --r-spacing-md: 14px;
        --r-spacing-lg: 20px;
        --r-spacing-xl: 28px;
        --r-spacing-2xl: 40px;
        
        --r-font-xs: 12px;
        --r-font-sm: 13px;
        --r-font-base: 14px;
        --r-font-md: 15px;
        --r-font-lg: 16px;
        --r-font-xl: 19px;
        --r-font-2xl: 24px;
        --r-font-3xl: 32px;
        
        --r-sidebar-width: 260px;
        --r-header-height: 64px;
        --r-card-gap: 16px;
        --r-container-padding: 16px;
        --r-border-radius: 12px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   LAPTOP BREAKPOINT (1024px - 1439px)
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

@media screen and (min-width: 1024px) {
    :root {
        --r-spacing-xs: 5px;
        --r-spacing-sm: 10px;
        --r-spacing-md: 16px;
        --r-spacing-lg: 22px;
        --r-spacing-xl: 32px;
        --r-spacing-2xl: 48px;
        
        --r-font-xs: 12px;
        --r-font-sm: 13px;
        --r-font-base: 14px;
        --r-font-md: 15px;
        --r-font-lg: 17px;
        --r-font-xl: 20px;
        --r-font-2xl: 26px;
        --r-font-3xl: 36px;
        
        --r-sidebar-width: 300px;
        --r-header-height: 68px;
        --r-card-gap: 20px;
        --r-container-padding: 24px;
        --r-border-radius: 14px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   DESKTOP BREAKPOINT (1440px - 1919px)
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

@media screen and (min-width: 1440px) {
    :root {
        --r-spacing-xs: 6px;
        --r-spacing-sm: 12px;
        --r-spacing-md: 18px;
        --r-spacing-lg: 24px;
        --r-spacing-xl: 36px;
        --r-spacing-2xl: 56px;
        
        --r-font-xs: 12px;
        --r-font-sm: 14px;
        --r-font-base: 15px;
        --r-font-md: 16px;
        --r-font-lg: 18px;
        --r-font-xl: 22px;
        --r-font-2xl: 28px;
        --r-font-3xl: 40px;
        
        --r-sidebar-width: 340px;
        --r-header-height: 72px;
        --r-card-gap: 24px;
        --r-container-padding: 28px;
        --r-border-radius: 16px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   LARGE DESKTOP BREAKPOINT (≥ 1920px)
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

@media screen and (min-width: 1920px) {
    :root {
        --r-spacing-xs: 6px;
        --r-spacing-sm: 12px;
        --r-spacing-md: 20px;
        --r-spacing-lg: 28px;
        --r-spacing-xl: 40px;
        --r-spacing-2xl: 64px;
        
        --r-font-xs: 13px;
        --r-font-sm: 14px;
        --r-font-base: 16px;
        --r-font-md: 17px;
        --r-font-lg: 19px;
        --r-font-xl: 24px;
        --r-font-2xl: 32px;
        --r-font-3xl: 48px;
        
        --r-sidebar-width: 380px;
        --r-header-height: 76px;
        --r-card-gap: 28px;
        --r-container-padding: 32px;
        --r-border-radius: 18px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   BASE LAYOUT STRUCTURE (Mobile-First)
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

/* Prevent horizontal scroll globally */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* App Layout Container */
.app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for iOS */
    width: 100%;
    overflow-x: hidden;
}

/* Tablet+ : Horizontal Layout */
@media screen and (min-width: 768px) {
    .app-layout {
        flex-direction: row;
        height: 100vh;
        height: 100dvh;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   SIDEBAR RESPONSIVE STYLES
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

/* Mobile: Off-Canvas Sidebar */
/* ═══ KRITISCH: Sidebar MUSS immer scharf bleiben (iOS Safari PWA Bug-Fix) ═══ */
.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;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
    /* ═══ 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 Overlay - NUR Dimmen, KEIN Blur (Safari-Bug-Fix) */
/* Der Blur wird NICHT verwendet, da er in iOS Safari auf die Sidebar durchschlägt */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    /* KEIN backdrop-filter - verursacht Blur auf Sidebar in iOS Safari PWA */
    /* backdrop-filter: blur(4px); -- DEAKTIVIERT wegen iOS Bug */
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    /* Sicherstellen, dass Overlay UNTER der Sidebar liegt */
    pointer-events: none;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Tablet+: Static Sidebar */
@media screen and (min-width: 768px) {
    .sidebar {
        position: relative;
        width: var(--r-sidebar-width);
        max-width: none;
        transform: none;
        flex-shrink: 0;
        z-index: 1;
        padding-top: 0;
        padding-bottom: 0;
    }
    
    .sidebar.active,
    .sidebar.open {
        box-shadow: none;
    }
    
    .sidebar-overlay {
        display: none !important;
    }
}

/* Sidebar Navigation Items */
.sidebar .nav-item {
    padding: var(--r-spacing-md) var(--r-spacing-lg);
    font-size: var(--r-font-md);
    min-height: var(--r-touch-target);
    display: flex;
    align-items: center;
    gap: var(--r-spacing-md);
}

/* Sidebar Statistics Grid */
.sidebar .stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--r-spacing-sm);
}

.sidebar .stat-card {
    padding: var(--r-spacing-md);
}

.sidebar .stat-card .value {
    font-size: var(--r-font-xl);
}

.sidebar .stat-card .label {
    font-size: var(--r-font-xs);
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   MAIN CONTENT AREA
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevent flex overflow */
    overflow-x: hidden;
    padding-top: var(--safe-top);
}

@media screen and (min-width: 768px) {
    .main-content {
        padding-top: 0;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   HEADER RESPONSIVE STYLES
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: var(--r-spacing-md) var(--r-container-padding);
    padding-left: calc(var(--r-container-padding) + 56px); /* Space for hamburger */
    min-height: var(--r-header-height);
    display: flex;
    align-items: center;
}

/* Tablet+: No hamburger space needed */
@media screen and (min-width: 768px) {
    header {
        padding-left: var(--r-container-padding);
    }
}

/* Header Flex Container */
header > .flex {
    flex-wrap: wrap;
    gap: var(--r-spacing-md);
}

@media screen and (min-width: 1024px) {
    header > .flex {
        flex-wrap: nowrap;
    }
}

/* Search Container */
.search-container {
    flex: 1;
    min-width: 200px;
    max-width: 100%;
}

@media screen and (min-width: 768px) {
    .search-container {
        max-width: 400px;
    }
}

@media screen and (min-width: 1024px) {
    .search-container {
        max-width: 500px;
    }
}

@media screen and (min-width: 1440px) {
    .search-container {
        max-width: 600px;
    }
}

.search-container input {
    width: 100%;
    padding: var(--r-spacing-md) var(--r-spacing-lg);
    padding-left: 44px;
    font-size: 16px; /* Prevent iOS zoom */
    border-radius: var(--r-border-radius);
    min-height: var(--r-touch-target);
}

/* Header Actions - Hide on mobile, show on tablet+ */
.header-actions,
.header .flex.items-center.gap-6:last-child {
    display: none;
}

@media screen and (min-width: 768px) {
    .header-actions,
    .header .flex.items-center.gap-6:last-child {
        display: flex;
        flex-shrink: 0;
    }
}

/* Color Legend - Responsive */
header .flex.items-center.gap-6[style*="background: rgba(255, 255, 255, 0.15)"] {
    display: none;
    font-size: var(--r-font-sm);
    padding: var(--r-spacing-sm) var(--r-spacing-md);
    border-radius: var(--r-border-radius);
    flex-wrap: wrap;
    gap: var(--r-spacing-md);
}

@media screen and (min-width: 1024px) {
    header .flex.items-center.gap-6[style*="background: rgba(255, 255, 255, 0.15)"] {
        display: flex;
        flex-wrap: nowrap;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   MOBILE MENU BUTTON
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

.mobile-menu-btn,
.mobile-menu-toggle {
    position: fixed;
    top: calc(var(--r-spacing-md) + var(--safe-top));
    left: var(--r-spacing-md);
    z-index: 10000;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--vw-blue, #12326D);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-btn:active,
.mobile-menu-toggle:active {
    transform: scale(0.95);
}

/* Hide on Tablet+ */
@media screen and (min-width: 768px) {
    .mobile-menu-btn,
    .mobile-menu-toggle {
        display: none !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   DEALS GRID - RESPONSIVE COLUMNS
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

.deals-grid,
#dealsList,
#completedDealsList {
    display: grid;
    grid-template-columns: 1fr; /* 1 column on mobile */
    gap: var(--r-card-gap);
    padding: var(--r-container-padding);
    padding-bottom: calc(var(--r-container-padding) + var(--safe-bottom) + 80px); /* Space for FAB */
}

/* Tablet: 2 columns */
@media screen and (min-width: 768px) {
    .deals-grid,
    #dealsList,
    #completedDealsList {
        grid-template-columns: repeat(2, 1fr);
        padding-bottom: var(--r-container-padding);
    }
}

/* Laptop: 2-3 columns */
@media screen and (min-width: 1024px) {
    .deals-grid,
    #dealsList,
    #completedDealsList {
        grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    }
}

/* Desktop: 3-4 columns */
@media screen and (min-width: 1440px) {
    .deals-grid,
    #dealsList,
    #completedDealsList {
        grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    }
}

/* Large Desktop: 4+ columns */
@media screen and (min-width: 1920px) {
    .deals-grid,
    #dealsList,
    #completedDealsList {
        grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   DEAL CARDS - RESPONSIVE DESIGN
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

.deal-card-compact {
    width: 100%;
    padding: var(--r-spacing-md) var(--r-spacing-lg);
    border-radius: var(--r-border-radius);
    overflow: hidden;
}

/* Mobile: Kompaktes 2-Zeilen Layout für Deal Cards
   ┌────────────────────────────────────────────────────────────┐
   │ Kundenname [📅][BAR]              24d | 20.11.2025  363 € │
   │ Golf 8 Hybrid   W403284                                   │
   └────────────────────────────────────────────────────────────┘
*/
@media screen and (max-width: 767px) {
    .deal-card-compact {
        max-height: none;
        padding: 10px 12px;
        overflow: visible;
    }
    
    .deal-card-compact.expanded {
        max-height: none;
        overflow: visible;
    }
    
    /* Horizontales Layout: Links Info, Rechts Status */
    .deal-card-compact .collapsed-content {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
        gap: 8px;
    }
    
    .deal-card-compact .collapsed-info {
        flex: 1;
        min-width: 0;
        padding-right: 8px;
    }
    
    /* Rechte Seite: Datum + Provision übereinander */
    .deal-card-compact .collapsed-status {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 2px;
        flex-shrink: 0;
        padding-top: 0;
        margin-top: 0;
        border-top: none;
    }
    
    /* Kundenname */
    .deal-card-compact .customer-name {
        font-size: 14px;
        font-weight: 600;
        margin-bottom: 3px;
        line-height: 1.2;
        color: var(--text-primary, #111418);
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 4px;
    }
    
    /* Fahrzeug */
    .deal-card-compact .vehicle-info {
        font-size: 12px;
        font-weight: 500;
        color: var(--text-secondary, #5B6672);
    }
    
    .deal-card-compact .meta-info {
        font-size: 11px;
        color: var(--text-secondary, #5B6672);
    }
    
    /* Provision - Rechts unten */
    .deal-card-compact .provision-display {
        font-size: 14px;
        font-weight: 700;
        color: var(--accent-green, #0EA570);
    }
    
    /* Datum - Rechts oben */
    .deal-card-compact .date-display {
        font-size: 11px;
        display: flex;
        align-items: center;
        gap: 4px;
    }
    
    .deal-card-compact .days-since-purchase {
        font-weight: 700;
        font-size: 11px;
    }
    
    .deal-card-compact .purchase-date {
        font-size: 11px;
        font-weight: 500;
    }
    
    /* Hide hover info on mobile */
    .hover-text-info {
        display: none !important;
    }
    
    /* Fahrzeug-Zeile: Modell + Nummer IMMER vollständig */
    .vehicle-line {
        display: flex;
        align-items: center;
        gap: 6px;
        width: 100%;
        overflow: visible;
    }
    
    .vehicle-line .vehicle-model {
        font-size: 12px;
        font-weight: 500;
        color: var(--text-secondary, #5B6672);
        overflow: visible;
    }
    
    .vehicle-line .vehicle-number {
        font-size: 11px;
        color: var(--text-secondary, #5B6672);
        overflow: visible;
        white-space: nowrap;
    }
    
    /* Ready Badge Overlay - Absolut positioniert, zentriert */
    .ready-badge-overlay {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        bottom: 6px;
        z-index: 10;
    }
    
    .deal-card-compact .ready-badge {
        padding: 3px 6px;
        font-size: 8px;
    }
    
    .deal-card-compact.expanded .ready-badge-overlay {
        display: none;
    }
}

/* Tablet: Medium Card */
@media screen and (min-width: 768px) and (max-width: 1023px) {
    .deal-card-compact {
        max-height: 75px;
    }
    
    .deal-card-compact .customer-name {
        font-size: var(--r-font-md);
    }
    
    .deal-card-compact .vehicle-info,
    .deal-card-compact .meta-info {
        font-size: var(--r-font-sm);
    }
}

/* Laptop+: Full Card */
@media screen and (min-width: 1024px) {
    .deal-card-compact {
        max-height: 85px;
    }
    
    .deal-card-compact .customer-name {
        font-size: var(--r-font-lg);
    }
    
    .deal-card-compact .vehicle-info,
    .deal-card-compact .meta-info {
        font-size: var(--r-font-base);
    }
}

/* Deal Card Expanded Content */
.deal-card-compact .expanded-content {
    padding-top: var(--r-spacing-md);
    margin-top: var(--r-spacing-md);
}

/* Status Icons Grid */
.status-icons-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--r-spacing-sm);
    width: 100%;
}

@media screen and (max-width: 479px) {
    .status-icons-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media screen and (min-width: 480px) and (max-width: 767px) {
    .status-icons-container {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Status Icons */
.status-icon {
    width: 36px;
    height: 36px;
    font-size: 14px;
    border-radius: 8px;
}

@media screen and (max-width: 767px) {
    .status-icon {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--r-spacing-sm);
}

.action-btn {
    min-width: var(--r-touch-target);
    min-height: var(--r-touch-target);
    padding: var(--r-spacing-sm);
    font-size: var(--r-font-sm);
    border-radius: 8px;
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   MODALS - RESPONSIVE DESIGN
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

.modal-backdrop {
    padding: 0;
}

.modal-dialog {
    position: relative;
    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: var(--r-spacing-lg);
    padding-top: calc(var(--r-spacing-lg) + var(--safe-top));
    background: white;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-header h2,
.modal-title {
    font-size: var(--r-font-xl);
}

/* Modal Body - Scrollable */
.modal-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--r-spacing-lg);
}

/* Modal Footer - Sticky */
.modal-footer {
    position: sticky;
    bottom: 0;
    z-index: 10;
    padding: var(--r-spacing-lg);
    padding-bottom: calc(var(--r-spacing-lg) + var(--safe-bottom));
    background: white;
    border-top: 1px solid var(--border);
    display: flex;
    gap: var(--r-spacing-md);
    flex-shrink: 0;
}

.modal-footer button {
    flex: 1;
    min-height: var(--r-touch-target);
}

/* Tablet+: Centered Modal */
@media screen and (min-width: 768px) {
    .modal-dialog {
        position: relative;
        width: auto;
        height: auto;
        max-width: 90vw;
        max-height: 90vh;
        margin: auto;
        border-radius: var(--r-border-radius);
    }
    
    .modal-header {
        padding-top: var(--r-spacing-lg);
        border-radius: var(--r-border-radius) var(--r-border-radius) 0 0;
    }
    
    .modal-footer {
        padding-bottom: var(--r-spacing-lg);
        border-radius: 0 0 var(--r-border-radius) var(--r-border-radius);
    }
}

/* Deal Form Modal - Specific Sizes */
#dealModal .modal-dialog {
    max-width: 100%;
}

@media screen and (min-width: 768px) {
    #dealModal .modal-dialog {
        max-width: 800px;
    }
}

@media screen and (min-width: 1024px) {
    #dealModal .modal-dialog {
        max-width: 1000px;
    }
}

@media screen and (min-width: 1440px) {
    #dealModal .modal-dialog {
        max-width: 1200px;
    }
}

/* Modal Grid Layouts */
.modal-body .grid,
.modal-body [class*="grid-cols"] {
    display: grid;
    gap: var(--r-spacing-md);
}

/* Mobile: Single Column */
@media screen and (max-width: 767px) {
    .modal-body .grid,
    .modal-body [class*="grid-cols"] {
        grid-template-columns: 1fr !important;
    }
}

/* Tablet: 2 Columns */
@media screen and (min-width: 768px) and (max-width: 1023px) {
    .modal-body .grid-cols-2,
    .modal-body .lg\:grid-cols-2 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .modal-body .grid-cols-3,
    .modal-body .lg\:grid-cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Laptop+: Full Columns */
@media screen and (min-width: 1024px) {
    .modal-body .grid-cols-2,
    .modal-body .lg\:grid-cols-2 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .modal-body .grid-cols-3,
    .modal-body .lg\:grid-cols-3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   FORMS - RESPONSIVE & TOUCH-FRIENDLY
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

/* Prevent iOS zoom on input focus */
input, select, textarea {
    font-size: 16px !important;
}

@media screen and (min-width: 768px) {
    input, select, textarea {
        font-size: var(--r-font-base) !important;
    }
}

/* Form Fields */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="password"],
select,
textarea {
    width: 100%;
    min-height: var(--r-touch-target);
    padding: var(--r-spacing-md);
    border-radius: var(--r-border-radius);
    border: 1px solid var(--border);
    background: white;
    transition: all 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--vw-blue);
    box-shadow: 0 0 0 3px rgba(18, 50, 109, 0.1);
}

/* Labels */
label {
    display: block;
    font-size: var(--r-font-sm);
    font-weight: 500;
    margin-bottom: var(--r-spacing-xs);
    color: var(--text-secondary);
}

/* Form Groups */
.form-group {
    margin-bottom: var(--r-spacing-lg);
}

/* Checkboxes and Radio Buttons */
input[type="checkbox"],
input[type="radio"] {
    width: 22px;
    height: 22px;
    margin-right: var(--r-spacing-sm);
    cursor: pointer;
}

/* Checkbox/Radio Labels */
label:has(input[type="checkbox"]),
label:has(input[type="radio"]),
.checkbox-label,
.radio-label {
    display: flex;
    align-items: center;
    min-height: var(--r-touch-target);
    padding: var(--r-spacing-sm) 0;
    cursor: pointer;
}

/* Buttons */
button,
.btn,
[role="button"] {
    min-height: var(--r-touch-target);
    padding: var(--r-spacing-md) var(--r-spacing-lg);
    font-size: var(--r-font-base);
    border-radius: var(--r-border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

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

/* Primary Button */
.btn-primary {
    background: var(--vw-turquoise);
    color: white;
    border: none;
    font-weight: 600;
}

.btn-primary:hover {
    background: #00796b;
}

/* Secondary Button */
.btn-secondary {
    background: var(--neutral-100);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--neutral-300);
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   TABLES - RESPONSIVE DESIGN
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

/* Table Wrapper for horizontal scroll */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 calc(var(--r-container-padding) * -1);
    padding: 0 var(--r-container-padding);
}

/* Mobile: Card-based table */
@media screen and (max-width: 767px) {
    table.responsive-table {
        display: block;
    }
    
    table.responsive-table thead {
        display: none;
    }
    
    table.responsive-table tbody {
        display: flex;
        flex-direction: column;
        gap: var(--r-spacing-md);
    }
    
    table.responsive-table tr {
        display: block;
        background: var(--card);
        border-radius: var(--r-border-radius);
        padding: var(--r-spacing-md);
        border: 1px solid var(--border);
    }
    
    table.responsive-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: var(--r-spacing-sm) 0;
        border-bottom: 1px solid var(--border);
    }
    
    table.responsive-table td:last-child {
        border-bottom: none;
    }
    
    table.responsive-table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: var(--r-font-sm);
        color: var(--text-secondary);
    }
}

/* Tablet+: Standard Table */
@media screen and (min-width: 768px) {
    table {
        width: 100%;
        border-collapse: collapse;
    }
    
    th, td {
        padding: var(--r-spacing-md);
        text-align: left;
        border-bottom: 1px solid var(--border);
    }
    
    th {
        background: var(--neutral-100);
        font-weight: 600;
        font-size: var(--r-font-sm);
        color: var(--text-secondary);
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   FILTER CHIPS - RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

.filter-container,
.tabs-container,
.filter-bar {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: var(--r-spacing-sm);
    padding: var(--r-spacing-sm) 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.filter-container::-webkit-scrollbar,
.tabs-container::-webkit-scrollbar {
    display: none;
}

.filter-chip,
.chip,
.tab-btn {
    flex-shrink: 0;
    white-space: nowrap;
    padding: var(--r-spacing-sm) var(--r-spacing-md);
    font-size: var(--r-font-sm);
    border-radius: 20px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    gap: var(--r-spacing-xs);
}

@media screen and (min-width: 768px) {
    .filter-chip,
    .chip,
    .tab-btn {
        min-height: 40px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   FLOATING ACTION BUTTON (FAB)
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

.fab,
.floating-action-btn {
    position: fixed;
    bottom: calc(var(--r-spacing-lg) + var(--safe-bottom));
    right: var(--r-spacing-lg);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    z-index: 100;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--vw-turquoise);
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.fab:active,
.floating-action-btn:active {
    transform: scale(0.95);
}

/* Hide FAB on Tablet+ (use regular button) */
@media screen and (min-width: 768px) {
    .fab,
    .floating-action-btn {
        display: none;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   TOAST / NOTIFICATIONS
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

.toast,
.notification,
.alert {
    position: fixed;
    left: var(--r-spacing-md);
    right: var(--r-spacing-md);
    bottom: calc(var(--r-spacing-lg) + var(--safe-bottom));
    max-width: 100%;
    padding: var(--r-spacing-md) var(--r-spacing-lg);
    border-radius: var(--r-border-radius);
    z-index: 10000;
}

@media screen and (min-width: 768px) {
    .toast,
    .notification,
    .alert {
        left: auto;
        right: var(--r-spacing-xl);
        bottom: var(--r-spacing-xl);
        max-width: 400px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   UTILITY CLASSES - RESPONSIVE VISIBILITY
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

/* Hide on specific breakpoints */
.hide-xs { display: none !important; }
.hide-sm { display: none !important; }
.hide-md { display: block !important; }
.hide-lg { display: block !important; }
.hide-xl { display: block !important; }

@media screen and (min-width: 480px) {
    .hide-xs { display: block !important; }
    .show-xs { display: none !important; }
}

@media screen and (min-width: 768px) {
    .hide-sm { display: block !important; }
    .show-sm { display: none !important; }
    .mobile-only { display: none !important; }
    .tablet-up { display: block !important; }
}

@media screen and (min-width: 1024px) {
    .hide-md { display: none !important; }
    .show-md { display: block !important; }
    .laptop-up { display: block !important; }
}

@media screen and (min-width: 1440px) {
    .hide-lg { display: none !important; }
    .show-lg { display: block !important; }
    .desktop-up { display: block !important; }
}

@media screen and (min-width: 1920px) {
    .hide-xl { display: none !important; }
    .show-xl { display: block !important; }
}

/* Desktop only - hide on mobile */
.desktop-only {
    display: none !important;
}

@media screen and (min-width: 768px) {
    .desktop-only {
        display: block !important;
    }
}

/* Mobile only - hide on desktop */
.mobile-only {
    display: block !important;
}

@media screen and (min-width: 768px) {
    .mobile-only {
        display: none !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   TYPOGRAPHY - RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

h1 {
    font-size: var(--r-font-2xl);
    line-height: 1.2;
}

h2 {
    font-size: var(--r-font-xl);
    line-height: 1.3;
}

h3 {
    font-size: var(--r-font-lg);
    line-height: 1.3;
}

h4 {
    font-size: var(--r-font-md);
    line-height: 1.4;
}

p, li {
    font-size: var(--r-font-base);
    line-height: 1.6;
}

small, .text-sm {
    font-size: var(--r-font-sm);
}

.text-xs {
    font-size: var(--r-font-xs);
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   CALENDAR - RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

.fc-view-harness,
.calendar-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Mobile: Day view only */
@media screen and (max-width: 767px) {
    .fc-timeGridWeek-view {
        display: none;
    }
    
    .fc-toolbar-title {
        font-size: var(--r-font-lg) !important;
    }
    
    .fc-button {
        padding: var(--r-spacing-sm) !important;
        font-size: var(--r-font-sm) !important;
    }
}

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

@media screen and (max-width: 767px) and (orientation: landscape) {
    /* Reduce header height */
    header {
        min-height: 48px;
        padding: var(--r-spacing-sm) var(--r-container-padding);
    }
    
    /* Narrower sidebar */
    .sidebar {
        max-width: 280px;
    }
    
    /* Modal adjustments */
    .modal-header,
    .modal-footer {
        padding: var(--r-spacing-sm) var(--r-spacing-md);
    }
}

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

@media all and (display-mode: standalone) {
    /* Extra padding for status bar */
    .pwa-status-bar-spacer {
        height: var(--safe-top);
        background: var(--vw-blue);
    }
    
    /* Adjust header for PWA */
    header {
        padding-top: calc(var(--r-spacing-md) + var(--safe-top));
    }
    
    /* Mobile menu button position */
    .mobile-menu-btn,
    .mobile-menu-toggle {
        top: calc(var(--r-spacing-md) + var(--safe-top));
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   TOUCH FEEDBACK & ANIMATIONS
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

@media (hover: none) and (pointer: coarse) {
    /* Touch devices - no hover effects */
    button:hover,
    .btn:hover,
    a:hover,
    .deal-card-compact:hover {
        transform: none;
        box-shadow: inherit;
    }
    
    /* Active state for touch feedback */
    button:active,
    .btn:active,
    .deal-card-compact:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

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

@media print {
    .sidebar,
    .mobile-menu-btn,
    .mobile-menu-toggle,
    .sidebar-overlay,
    .fab,
    .floating-action-btn,
    .modal-backdrop,
    .toast,
    .notification {
        display: none !important;
    }
    
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .deals-grid {
        display: block;
    }
    
    .deal-card-compact {
        break-inside: avoid;
        page-break-inside: avoid;
        margin-bottom: 1rem;
    }
}

