/* Mobile-First Optimizations for PersonalFlow */
/* Bottom Navigation, Touch Targets, Responsive Design */

/* ============================================
   IMPORTANT: Hide Bottom Nav on Desktop
   ============================================ */
.bottom-nav {
  display: none; /* Hidden by default on desktop */
}

@media (max-width: 768px) {
  .bottom-nav {
    display: block; /* Show only on mobile */
  }
}

/* ============================================
   1. TOUCH TARGETS (Mindestens 44×44px)
   ============================================ */

/* Mobile Buttons */
@media (max-width: 768px) {
  button,
  a.button,
  .touch-target {
    min-width: 44px;
    min-height: 44px;
    padding: 12px 16px;
  }
  
  /* Menü-Items */
  nav button {
    min-height: 48px;
    padding: 12px 16px;
    font-size: 16px; /* Verhindert Auto-Zoom auf iOS */
  }
  
  /* Mobile Menu Dropdown Items */
  #mobileMenu button {
    min-height: 48px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
  }
  
  #mobileMenu button i {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
  }
}

/* ============================================
   2. BOTTOM NAVIGATION (Mobile)
   ============================================ */

/* Bottom Nav Container */
@media (max-width: 768px) {
  .bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 50;
    padding-bottom: env(safe-area-inset-bottom); /* iOS Safe Area */
  }
  
  .bottom-nav-items {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0;
    max-width: 100%;
  }
  
  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    min-height: 56px;
    text-decoration: none;
    color: #6b7280;
    transition: all 0.2s;
    position: relative;
  }
  
  .bottom-nav-item:active {
    transform: scale(0.95);
    background: rgba(59, 130, 246, 0.1);
    border-radius: 12px;
  }
  
  .bottom-nav-item i {
    font-size: 22px;
    margin-bottom: 4px;
  }
  
  .bottom-nav-item span {
    font-size: 11px;
    font-weight: 500;
  }
  
  .bottom-nav-item.active {
    color: #3b82f6;
  }
  
  .bottom-nav-item.active i {
    color: #2563eb;
  }
  
  /* Badge für Benachrichtigungen */
  .bottom-nav-item .badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 16px);
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
  }
  
  /* More-Menu Button */
  .bottom-nav-more {
    position: relative;
  }
  
  .bottom-nav-more-menu {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    margin-bottom: 8px;
    min-width: 200px;
    max-height: 60vh;
    overflow-y: auto;
    display: none;
  }
  
  .bottom-nav-more-menu.active {
    display: block;
  }
  
  .bottom-nav-more-menu button {
    width: 100%;
    text-align: left;
    padding: 14px 16px;
    border: none;
    background: none;
    color: #374151;
    font-size: 15px;
    display: flex;
    align-items: center;
  }
  
  .bottom-nav-more-menu button:active {
    background: #f3f4f6;
  }
  
  .bottom-nav-more-menu button i {
    width: 24px;
    margin-right: 12px;
    color: #6b7280;
  }
  
  /* Content Padding (wegen Bottom Nav) */
  #mainContent {
    padding-bottom: 80px; /* Platz für Bottom Nav */
  }
}

/* ============================================
   3. RESPONSIVE BREAKPOINTS
   ============================================ */

/* Small Mobile (< 375px) */
@media (max-width: 374px) {
  .bottom-nav-item span {
    font-size: 10px;
  }
  
  .bottom-nav-item i {
    font-size: 20px;
  }
}

/* Tablet (768px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  /* Desktop Nav bleibt, aber kompakter */
  nav button {
    padding: 8px 12px;
    font-size: 14px;
  }
}

/* Desktop (> 1024px) */
@media (min-width: 1025px) {
  /* Volle Desktop-Navigation */
  nav button {
    padding: 8px 16px;
    font-size: 14px;
  }
}

/* ============================================
   4. TOUCH GESTURES & INTERACTIONS
   ============================================ */

/* Tap Highlight entfernen (iOS) */
* {
  -webkit-tap-highlight-color: transparent;
}

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

/* Pull-to-Refresh verhindern (wenn nicht gewünscht) */
body {
  overscroll-behavior-y: contain;
}

/* Buttons: Active State */
button:active,
a:active {
  transform: scale(0.98);
  opacity: 0.9;
}

/* Card: Active State */
.card:active {
  transform: scale(0.99);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ============================================
   5. MOBILE FORMS
   ============================================ */

@media (max-width: 768px) {
  /* Input Fields */
  input,
  select,
  textarea {
    font-size: 16px; /* Verhindert Auto-Zoom auf iOS */
    min-height: 44px;
    padding: 12px 16px;
  }
  
  /* Modal on Mobile: Full Screen */
  .modal-content {
    max-width: 100%;
    min-height: 100vh;
    border-radius: 0;
    margin: 0;
  }
  
  /* Upgrade Modal: Mobile-optimiert */
  #upgradeModal .bg-white {
    max-width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 16px 16px 0 0;
  }
}

/* ============================================
   6. MOBILE TABLES
   ============================================ */

@media (max-width: 768px) {
  /* Horizontal Scroll für Tabellen */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  table {
    min-width: 600px; /* Verhindert zu schmale Tabellen */
  }
  
  /* Card-Layout für Listen */
  .mobile-list-item {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
  }
  
  .mobile-list-item:active {
    background: #f9fafb;
  }
}

/* ============================================
   7. SAFE AREAS (iOS Notch)
   ============================================ */

@supports (padding: max(0px)) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  
  nav {
    padding-top: env(safe-area-inset-top);
  }
  
  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ============================================
   8. PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* GPU-Acceleration für Animationen */
.bottom-nav,
.bottom-nav-item,
button {
  will-change: transform;
  transform: translateZ(0);
}

/* Reduce Motion (für Nutzer mit Präferenz) */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   9. LANDSCAPE MODE
   ============================================ */

@media (max-width: 768px) and (orientation: landscape) {
  /* Bottom Nav im Landscape: Sidebar */
  .bottom-nav {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    right: auto;
    width: 80px;
    border-top: none;
    border-right: 1px solid #e5e7eb;
  }
  
  .bottom-nav-items {
    flex-direction: column;
    height: 100%;
    padding: 16px 0;
  }
  
  .bottom-nav-item {
    width: 100%;
    min-height: 72px;
  }
  
  #mainContent {
    padding-left: 80px;
    padding-bottom: 0;
  }
}

/* ============================================
   10. DARK MODE SUPPORT (Optional)
   ============================================ */

@media (prefers-color-scheme: dark) {
  /* Hier können Dark Mode Styles hinzugefügt werden */
  /* Aktuell: Nur Light Mode */
}
