/* Patenschaftsverwaltung - Mobile Layout Optimierungen (375px - 640px) */

/* 1. HEADER: einzeilig wie in mitgliederverwaltung.html (feste Hoehe aus components.css bleibt) */
@media (max-width: 640px) {
  .shell {
    padding: 0 0.75rem;
    gap: 0.5rem;
  }

  .shell__logo {
    flex-shrink: 0;
  }

  .shell__divider {
    display: none;
  }

  .shell__logo + .shell__divider + div {
    min-width: 0;
    flex: 0 1 auto;
  }

  .shell__title {
    font-size: 0.8125rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .shell__spacer {
    flex: 1 1 0;
    min-width: 0;
  }

  .shell__back {
    padding: 0.25rem 0.45rem;
    flex-shrink: 0;
    white-space: nowrap;
  }

  .shell__auth {
    flex-shrink: 0;
    min-width: 0;
    gap: 0.4rem;
  }

  .shell__auth .btn--small {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    white-space: nowrap;
  }

  .shell__user {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    max-width: 5rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* 2. TABS: Horizontal scrollbar statt Umbruch */
@media (max-width: 640px) {
  .pv-tablist {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
    scroll-behavior: smooth;
    /* Scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
  }

  .pv-tablist::-webkit-scrollbar {
    height: 4px;
  }

  .pv-tablist::-webkit-scrollbar-track {
    background: transparent;
  }

  .pv-tablist::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 2px;
  }

  .pv-tab {
    white-space: nowrap;
    padding: 0.65rem 0.8rem;
    font-size: 0.9rem;
    flex-shrink: 0;
  }
}

/* 3. TABELLE: Horizontal scrollbar innerhalb .table-wrap */
@media (max-width: 640px) {
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
  }

  .table-wrap::-webkit-scrollbar {
    height: 4px;
  }

  .table-wrap::-webkit-scrollbar-track {
    background: transparent;
  }

  .table-wrap::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 2px;
  }

  /* pv-tauben.html: Tabelle liegt direkt in .card statt in .table-wrap */
  #table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table {
    min-width: 100%;
  }

  .table th,
  .table td {
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
  }
}

/* 4. RADIO & CHECKBOX: Nicht auf volle Breite stretchen */
@media (max-width: 640px) {
  input[type="radio"] {
    width: auto !important;
    height: auto !important;
  }

  /* Kästchen am Handy 24 px statt 13 px, die Zeile mindestens 44 px hoch (#436) */
  input[type="checkbox"] {
    width: 1.5rem !important;
    height: 1.5rem !important;
    flex: none;
    accent-color: var(--blue-dark);
  }

  .checkline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0;
    min-height: var(--tap-min, 2.75rem);
  }

  .checkline label {
    margin: 0;
    flex: 1;
  }

  fieldset {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
  }
}

/* 5. MODAL: Breite auf Mobile reduzieren */
@media (max-width: 640px) {
  .modal-content {
    max-width: calc(100% - 2rem);
    padding: 1.5rem 1rem;
  }

  .modal-actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .modal-actions button {
    width: 100%;
  }
}

/* 6. SEITEN-LAYOUT: Padding und Abstände für Mobile */
@media (max-width: 640px) {
  main.page {
    padding: 1rem 0.75rem;
  }

  .card {
    padding: 1rem;
  }

  .pv-section {
    margin-top: 1.25rem;
  }

  .pv-section__title {
    font-size: 0.95rem;
    padding-bottom: 0.4rem;
  }

  .actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .actions button {
    width: 100%;
  }
}

/* 7. BUTTONS: Volle Breite auf Mobile in Formularen */
@media (max-width: 640px) {
  .actions button,
  .actions a {
    width: 100%;
    display: block;
    text-align: center;
  }
}

/* 8. FELDER: Volle Breite */
@media (max-width: 640px) {
  .field {
    display: block;
  }

  input[type="text"],
  input[type="email"],
  input[type="number"],
  input[type="date"],
  input[type="time"],
  textarea,
  select {
    width: 100%;
    max-width: 100%;
  }
}

/* 9. PATENSCHAFTSFORMULAR: Schritte, Foto-Karten, Zusammenfassung */
@media (max-width: 640px) {
  .pv-steps__item:not([aria-current="step"]) .pv-steps__label {
    display: none;
  }

  .pv-steps__item[aria-current="step"] {
    flex: 3 1 0;
  }

  .pv-stepnav {
    flex-direction: column-reverse;
  }

  .pv-stepnav #weiter-btn,
  .pv-stepnav #submit-btn {
    margin-left: 0;
  }

  .taube-raster {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .taube-karte__radio {
    width: 1px !important;
    height: 1px !important;
  }

  .pv-summary {
    padding: 0.85rem 1rem;
  }

  .pv-summary__liste {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }

  .pv-summary__liste dd {
    margin-bottom: 0.6rem;
  }

  .pv-willkommen .actions a.btn {
    display: block;
  }
}

/* 10. LESBARKEIT AM HANDY (#436): Schrift und Tippflächen wie in den übrigen Web-Tools.
   Text 16 px, Tabellen und Hinweise 15 px, Marken 14 px, Tippflächen mindestens 44 px. */
@media (max-width: 640px) {
  /* Kopfzeile: Name und Login in 14 px, schmalerer Rand */
  .shell__user {
    font-size: var(--fs-tag);
    padding: 0.2rem 0.45rem;
  }

  .shell__auth .btn--small {
    font-size: var(--fs-tag);
  }

  .pv-tab {
    font-size: var(--fs-text);
    min-height: var(--tap-min, 2.75rem);
  }

  .table th,
  .table td {
    font-size: var(--fs-small);
  }

  /* Knöpfe in Tabellenzeilen: 44 statt 31 px hoch */
  .table button {
    font-size: var(--fs-text);
    min-height: var(--tap-min, 2.75rem);
  }

  .field-hint,
  .pv-stat-label,
  .art-card p {
    font-size: var(--fs-small);
  }

  .badge,
  .pv-steps__nr {
    font-size: var(--fs-tag);
  }

  .pv-section__title {
    font-size: var(--fs-text);
  }
}

/* Kopfzeile der Verwaltungsseiten bleibt auf schmalen Handys einzeilig:
   bis 400 px Breite ohne Logo, sonst rutschen Name und Login in eine zweite Zeile (#436) */
@media (max-width: 400px) {
  .shell:has(.shell__auth) .shell__logo {
    display: none;
  }
}
