/* ============================================================================
   MOBILE HEADER NAVIGATION - Tabs im Header, Auto-Hide beim Scrollen
   Version 7.0 - Navigation-Reorganisation
   ============================================================================ */

/* ============================================================================
   1. TABS IM HEADER INTEGRIEREN (MOBILE)
   ============================================================================ */

@media (max-width: 820px) {
  /* Tabs nicht mehr am unteren Rand, sondern im Header */
  .tabs {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    top: auto !important;
    
    display: flex;
    gap: 8px;
    padding: 12px;
    
    background: rgba(238,236,228,.90) !important;
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(107,89,69,.14);
    border-bottom: 1px solid rgba(107,89,69,.14);
    
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    scrollbar-width: none;
    
    /* Karussell-Snap */
    scroll-snap-type: x proximity;
  }
  
  .tabs::-webkit-scrollbar {
    display: none;
  }
  
  /* Topbar wird größer um Tabs aufzunehmen */
  .topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(210,202,191,.95) !important;
    backdrop-filter: blur(12px);
    border-bottom: 2px solid rgba(107,89,69,.20);
    
    /* Auto-Hide beim Scrollen */
    transform: translateY(0);
    transition: transform 0.3s ease, opacity 0.3s ease;
  }
  
  /* Header versteckt sich beim Runterscrollen */
  .topbar.is-hidden {
    transform: translateY(-100%) !important;
    opacity: 0 !important;
  }
  
  /* Main-Content: Kein extra Padding mehr für untere Tabs */
  .main {
    padding-bottom: 40px !important;
  }
  
  /* Tabs größer und besser lesbar */
  .tab {
    min-height: 52px !important;
    padding: 14px 20px !important;
    font-size: 14px !important;
    font-weight: 900 !important;
    white-space: nowrap;
    border-radius: 16px !important;
    border: 2px solid rgba(107,89,69,.20) !important;
    line-height: 1.1 !important;
    
    /* Karussell-Snap */
    scroll-snap-align: start;
    
    /* Text perfekt zentriert */
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
  .tab.is-active {
    background: rgba(188,158,129,.95) !important;
    color: #1A1A1A !important;
    border-color: rgba(107,89,69,.35) !important;
    box-shadow: 0 4px 12px rgba(0,0,0,.12) !important;
  }
  
  /* Header-Komponenten kompakter */
  .brand {
    padding: 12px 12px 8px !important;
  }
  
  .brand__title {
    font-size: 18px !important;
    font-weight: 900 !important;
  }
  
  .brand__subtitle {
    font-size: 12px !important;
  }
  
  .topbar__row {
    padding: 0 12px 8px !important;
    gap: 8px !important;
  }
  
  .topbar__actions {
    padding: 0 12px 8px !important;
    gap: 8px !important;
  }
  
  /* Lehrjahr-Buttons kompakter */
  .yearBtn {
    min-height: 44px !important;
    padding: 10px 14px !important;
    font-size: 15px !important;
  }
  
  /* Stats kompakter */
  .stat {
    min-width: 75px !important;
    padding: 8px 10px !important;
  }
  
  .stat__num {
    font-size: 18px !important;
  }
  
  .stat__label {
    font-size: 11px !important;
  }
  
  /* Export/Import Buttons kompakter */
  .btn {
    min-height: 44px !important;
    padding: 10px 14px !important;
    font-size: 15px !important;
  }
  
  .btn--primary {
    min-height: 48px !important;
    padding: 12px 18px !important;
    font-size: 16px !important;
  }
}

/* ============================================================================
   2. HEADER AUTO-HIDE BEIM SCROLLEN (JavaScript-gesteuert)
   ============================================================================ */

/* Header zeigt sich beim Hochscrollen */
.topbar.is-visible {
  transform: translateY(0) !important;
  opacity: 1 !important;
}

/* Smooth Transitions */
.topbar {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================================
   3. UNTERER BEREICH FREI FÜR KALENDER
   ============================================================================ */

@media (max-width: 820px) {
  /* Kalender-Bottom-Bar wird durch calendar-bottom-bar.css gesteuert */
  
  /* Kalender-Quick-Navigation */
  .calendar-quick-nav {
    display: flex;
    gap: 8px;
    justify-content: space-between;
    align-items: center;
  }
  
  .calendar-quick-nav button {
    min-height: 48px !important;
    padding: 12px 16px !important;
    font-size: 16px !important;
    font-weight: 900 !important;
    border-radius: 14px !important;
    border: 2px solid rgba(107,89,69,.20) !important;
    background: rgba(255,255,255,.90) !important;
  }
  
  .calendar-quick-nav button:active {
    transform: scale(0.96);
    background: rgba(188,158,129,.75) !important;
  }
}

/* ============================================================================
   4. NOTIZFELD BLEIBT PROMINENT
   ============================================================================ */

@media (max-width: 820px) {
  /* Notizfeld-Optimierungen bleiben erhalten */
  #quickNotes {
    min-height: 200px !important;
    font-size: 17px !important;
    line-height: 1.6 !important;
    padding: 16px !important;
    border: 2px solid rgba(188,158,129,.65) !important;
    background: rgba(255,255,255,.95) !important;
    box-shadow: 0 4px 12px rgba(0,0,0,.08) !important;
    border-radius: 16px !important;
  }
  
  #quickNotes:focus {
    border-color: rgba(188,158,129,.95) !important;
    box-shadow: 0 6px 20px rgba(188,158,129,.25) !important;
    outline: none !important;
  }
  
  label[for="quickNotes"] {
    font-size: 15px !important;
    font-weight: 900 !important;
    color: #1A1A1A !important;
  }
}

/* ============================================================================
   5. TOUCH-FEEDBACK FÜR ALLE BUTTONS
   ============================================================================ */

@media (hover: none) and (pointer: coarse) {
  button:active,
  .btn:active,
  .tab:active,
  .yearBtn:active {
    transform: scale(0.96) !important;
    opacity: 0.85 !important;
    transition: transform 0.1s ease, opacity 0.1s ease !important;
  }
  
  .btn--primary:active {
    transform: scale(0.94) !important;
  }
}

/* ============================================================================
   6. SAFE AREA FÜR IPHONE X+
   ============================================================================ */

@supports (padding: max(0px)) {
  @media (max-width: 820px) {
    .topbar {
      padding-top: max(0px, env(safe-area-inset-top)) !important;
    }
    
    .main {
      padding-bottom: max(40px, calc(40px + env(safe-area-inset-bottom))) !important;
    }
    
    .calendar-bottom-bar {
      padding-bottom: max(12px, calc(12px + env(safe-area-inset-bottom))) !important;
    }
  }
}

/* ============================================================================
   7. LANDSCAPE-MODUS OPTIMIERUNGEN
   ============================================================================ */

@media (max-width: 896px) and (orientation: landscape) {
  .topbar {
    padding-top: 6px !important;
  }
  
  .brand {
    padding: 8px 12px 6px !important;
  }
  
  .brand__title {
    font-size: 16px !important;
  }
  
  .brand__subtitle {
    font-size: 11px !important;
  }
  
  .topbar__row,
  .topbar__actions {
    padding: 0 12px 6px !important;
  }
  
  .tabs {
    padding: 8px 12px !important;
  }
  
  .tab {
    min-height: 44px !important;
    padding: 10px 14px !important;
    font-size: 15px !important;
  }
}

/* ============================================================================
   8. EXTRA KLEINE GERÄTE (<375px)
   ============================================================================ */

@media (max-width: 374px) {
  .brand__title {
    font-size: 16px !important;
  }
  
  .brand__subtitle {
    display: none; /* Platz sparen */
  }
  
  .yearBtn {
    padding: 8px 10px !important;
    font-size: 14px !important;
  }
  
  .stat {
    min-width: 70px !important;
    padding: 6px 8px !important;
  }
  
  .stat__num {
    font-size: 16px !important;
  }
  
  .tab {
    padding: 10px 12px !important;
    font-size: 14px !important;
  }
}

/* ============================================================================
   9. VERBESSERTE SCROLLBAR FÜR TAB-NAVIGATION
   ============================================================================ */

@media (max-width: 820px) {
  .tabs {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
  }
  
  .tabs::-webkit-scrollbar {
    height: 4px;
  }
  
  .tabs::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
  }
  
  .tabs::-webkit-scrollbar-track {
    background: transparent;
  }
}

/* ============================================================================
   10. TOAST-POSITION ANPASSEN (Kein unterer Tab-Bar mehr)
   ============================================================================ */

@media (max-width: 820px) {
  .toast {
    bottom: 30px !important; /* Nicht mehr über Tab-Bar */
  }
}

/* ============================================================================
   11. HEADER SHOW/HIDE INDICATOR (Optional)
   ============================================================================ */

@media (max-width: 820px) {
  /* Kleiner Indikator dass Header versteckt ist */
  .header-indicator {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99;
    
    width: 60px;
    height: 4px;
    background: rgba(188,158,129,.75);
    border-radius: 0 0 4px 4px;
    
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  
  .topbar.is-hidden ~ .header-indicator {
    opacity: 1;
  }
}

/* ============================================================================
   12. OPTIMIERTE INPUT-FELDER (Bleiben erhalten)
   ============================================================================ */

@media (max-width: 820px) {
  input[type="text"],
  input[type="date"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px !important;
    padding: 14px 16px !important;
    min-height: 48px !important;
    border-radius: 14px !important;
    border: 2px solid rgba(107,89,69,.25) !important;
    background: rgba(255,255,255,.90) !important;
  }
  
  input:focus,
  select:focus,
  textarea:focus {
    border-color: rgba(188,158,129,.85) !important;
    box-shadow: 0 4px 16px rgba(188,158,129,.20) !important;
    outline: none !important;
  }
  
  textarea {
    min-height: 120px !important;
    line-height: 1.6 !important;
  }
  
  .field label {
    font-size: 14px !important;
    font-weight: 900 !important;
    letter-spacing: 0.05em !important;
    margin-bottom: 8px !important;
    color: rgba(26,26,26,.85) !important;
  }
}
