/**
 * Mobile Optimizations für PWA
 * =============================
 *
 * Touch-freundliche UI und Responsive Design
 */

/* Grundlegende Mobile-Anpassungen */
@media (max-width: 768px) {
  /* Größere Touch-Targets (min. 44x44px) */
  button,
  .btn,
  .btn-primary,
  .btn-secondary,
  input[type="checkbox"],
  input[type="radio"] {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 20px;
    font-size: 16px;
  }

  /* Eingabefelder größer für bessere Lesbarkeit */
  input[type="text"],
  input[type="number"],
  input[type="email"],
  select,
  textarea {
    font-size: 16px; /* Verhindert Auto-Zoom auf iOS */
    padding: 12px;
    min-height: 44px;
  }

  /* Container mit mehr Padding auf Mobile */
  .container,
  .section-card {
    padding: 16px;
    margin: 12px;
  }

  /* Szenario-Karten stacken auf Mobile */
  .scenario-grid {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }

  .scenario-card {
    padding: 16px;
  }

  /* Event Cards im Life Planner */
  .event-card {
    padding: 16px;
    margin-bottom: 16px;
  }

  .event-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .star-rating {
    margin-top: 8px;
    width: 100%;
    justify-content: flex-start;
  }

  .star {
    font-size: 28px; /* Größere Touch-Targets für Sterne */
    padding: 8px;
  }

  /* Form Groups stacken */
  .form-group {
    margin-bottom: 20px;
  }

  .form-grid {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }

  /* Ergebnis-Cards */
  .result-card {
    padding: 16px;
    margin-bottom: 16px;
  }

  /* Navigation & Header */
  h1 {
    font-size: 24px;
    line-height: 1.3;
  }

  h2 {
    font-size: 20px;
    line-height: 1.3;
  }

  h3 {
    font-size: 18px;
  }

  /* Chart Container */
  .chart-container {
    height: 250px !important;
    margin: 16px 0;
  }

  /* Timeline auf Mobile horizontal scrollbar */
  .timeline-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Trade-off Matrix */
  .tradeoff-grid {
    grid-template-columns: 1fr !important;
  }

  /* Bottom Navigation für bessere Mobile UX */
  .mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #ddd;
    padding: 12px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
  }

  /* Verhindere Text-Selection bei Touch */
  .star-rating,
  .btn,
  button {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }

  /* Bessere Table-Darstellung auf Mobile */
  table {
    font-size: 14px;
  }

  table th,
  table td {
    padding: 8px 4px;
  }

  /* Responsive Tables - horizontal scroll */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Install Prompt Banner */
  .install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    animation: slideUp 0.3s ease-out;
  }

  .install-banner.hidden {
    display: none;
  }

  .install-banner button {
    background: white;
    color: #667eea;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
  }

  @keyframes slideUp {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }

  /* iOS Safe Area Support */
  @supports (padding: max(0px)) {
    body {
      padding-bottom: max(16px, env(safe-area-inset-bottom));
    }

    .mobile-nav {
      padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .install-banner {
      padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
  }
}

/* Extra kleine Displays (< 375px) */
@media (max-width: 375px) {
  .container {
    padding: 12px;
    margin: 8px;
  }

  h1 {
    font-size: 22px;
  }

  h2 {
    font-size: 18px;
  }

  button,
  .btn {
    font-size: 14px;
    padding: 10px 16px;
  }
}

/* Landscape Orientation auf Phones */
@media (max-width: 768px) and (orientation: landscape) {
  .event-card,
  .scenario-card {
    padding: 12px;
  }

  .form-group {
    margin-bottom: 12px;
  }

  h1 {
    font-size: 20px;
  }

  h2 {
    font-size: 18px;
  }
}

/* Dark Mode Support (optional) */
@media (prefers-color-scheme: dark) {
  body {
    background-color: #1a1a1a;
    color: #e0e0e0;
  }

  .section-card,
  .scenario-card,
  .event-card,
  .result-card {
    background: #2a2a2a;
    border-color: #444;
  }

  input,
  select,
  textarea {
    background: #333;
    color: #e0e0e0;
    border-color: #555;
  }

  .mobile-nav {
    background: #2a2a2a;
    border-top-color: #444;
  }
}
