/* ==========================================================================
   FamilyHub.lu — Responsivo Mobile (v3.2)
   Melhorias para smartphone (320px - 768px)
   ========================================================================== */

/* ========== EXTRA SMALL (320px - 480px) ========== */
@media (max-width: 480px) {
  :root {
    --spacing: 12px;
    --font-base: 14px;
    --touch-target: 44px;
  }

  html { font-size: 14px; }

  /* Tipografia */
  h1 { font-size: 1.5rem; margin: 0 0 12px; }
  h2 { font-size: 1.25rem; margin: 1rem 0 0.5rem; }
  h3 { font-size: 1rem; }

  body { padding: 0; }

  /* Navbar - Hamburger */
  header { position: sticky; top: 0; z-index: 900; }

  .navbar {
    flex-wrap: nowrap;
    min-height: 56px;
    padding: 8px;
    gap: 8px;
  }

  .logo {
    font-size: 1rem;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .tabs {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    background: var(--color-surface);
    border-bottom: 2px solid var(--color-border);
    width: 100%;
    z-index: 899;
  }

  .tabs.active { display: flex; }

  .tab {
    width: 100%;
    padding: 12px 12px;
    font-size: 0.95rem;
    justify-content: flex-start;
    border: none;
    border-left: 3px solid transparent;
    margin: 0;
  }

  .tab.active {
    background: #E3ECF4;
    border-left-color: var(--color-primary);
    border-bottom: none;
  }

  /* Menu toggle button */
  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: transparent;
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    margin-left: auto;
    flex-shrink: 0;
  }

  .quick-controls {
    order: -1;
    margin-left: 0;
    margin-right: auto;
  }

  .control-label { display: none; }

  /* Main content */
  main {
    max-width: 100%;
    padding: 8px 8px 24px;
    margin: 0;
  }

  /* Formulários */
  fieldset {
    padding: 12px;
    margin: 0 0 12px;
  }

  legend {
    font-size: 0.95rem;
    padding: 0 4px;
  }

  label { margin: 6px 0; font-size: 0.95rem; }

  input[type="number"],
  input[type="text"],
  select,
  textarea {
    width: 100%;
    max-width: none;
    min-height: 44px;
    padding: 10px 12px;
    font-size: 16px; /* evita auto-zoom em iOS */
    font-family: inherit;
  }

  input[type="range"] {
    max-width: none;
  }

  .slider-labels {
    max-width: none;
    font-size: 0.85rem;
  }

  /* Botões */
  .btn {
    width: 100%;
    padding: 12px 16px;
    font-size: 0.95rem;
    min-height: 44px;
  }

  /* Creches/CSA */
  .creche-item {
    flex-direction: column;
    align-items: flex-start;
    padding: 12px;
  }

  .price-tag {
    text-align: left;
    font-size: 1.3rem;
  }

  .csa-amount { font-size: 1.8rem; }

  .detail-row {
    flex-direction: column;
    gap: 2px;
  }

  .detail-label { font-size: 0.85rem; }

  .map-container { height: 240px; }

  /* Chat */
  .chat-box { padding: 10px; }

  .chat-messages {
    min-height: 180px;
    max-height: 280px;
    gap: 8px;
    padding: 6px 2px;
  }

  .chat-msg {
    max-width: 90%;
    padding: 8px 12px;
    font-size: 0.95rem;
  }

  .chat-input-row {
    gap: 6px;
    margin-top: 10px;
  }

  .chat-input-row input[type="text"] {
    min-width: 140px;
    font-size: 16px; /* iOS zoom */
  }

  /* Cartas */
  #letter-form { gap: 8px; }

  .letter-result {
    padding: 10px;
    margin-top: 10px;
  }

  #letter-reply-subject,
  #letter-reply-body {
    font-size: 16px;
    padding: 10px 12px;
  }

  /* CV */
  .cv-sheet {
    padding: 12px;
    max-width: 100%;
    margin-top: 10px;
  }

  .cv-sheet .cv-header {
    flex-direction: column;
    gap: 12px;
  }

  .cv-sheet .cv-header img {
    width: 80px;
    height: 110px;
  }

  .cv-sheet h2.cv-name-h { font-size: 1.4rem; }

  .cv-sheet h3 { font-size: 0.9rem; }

  .cv-photo-preview {
    width: 80px;
    height: 110px;
    margin-top: 8px;
  }

  /* Parceiros */
  #partner-form { max-width: 100%; }
  #partner-message { max-width: 100%; }

  /* Grid de serviços */
  .services-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .service-card {
    padding: 12px;
  }

  .service-card h3 { font-size: 1rem; }

  /* Voice guide bar */
  .voice-guide-bar {
    gap: 10px;
    padding: 8px 10px;
    flex-wrap: wrap;
  }

  .voice-guide-bar p { font-size: 0.9rem; }

  /* Acessibilidade */
  #accessibility-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 70vh;
    overflow-y: auto;
  }

  /* Feedback modal */
  #feedback-modal {
    width: 90vw;
    max-width: 90vw;
    margin: auto;
  }

  .modal-content {
    padding: 16px;
  }

  .radio-group {
    flex-direction: column;
    gap: 8px;
  }

  .radio-option {
    flex-direction: row;
    gap: 10px;
  }
}

/* ========== SMALL (481px - 768px) ========== */
@media (min-width: 481px) and (max-width: 768px) {
  :root {
    --spacing: 14px;
    --font-base: 15px;
  }

  html { font-size: 15px; }

  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.4rem; }

  .navbar {
    min-height: 60px;
    padding: 10px 14px;
  }

  .logo { font-size: 1.1rem; }

  .tabs { gap: 6px; }

  .tab {
    padding: 10px 16px;
    font-size: 0.95rem;
  }

  .control-label { display: inline; }

  main {
    max-width: 100%;
    padding: 14px 14px 32px;
  }

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

  textarea {
    max-width: 100%;
  }

  .btn {
    width: auto;
    min-width: 140px;
  }

  .chat-messages { max-height: 360px; }

  .services-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }

  .cv-sheet { padding: 20px; }

  #partner-form { max-width: 100%; }
  #partner-message { max-width: 100%; }
}

/* ========== MEDIUM UP (769px+) ========== */
@media (min-width: 769px) {
  .menu-toggle { display: none; }
  .tabs { display: flex; }
}

/* ========== LANDSCAPE (480px+ height) ========== */
@media (min-height: 480px) and (max-width: 768px) {
  .chat-messages { max-height: 350px; }
}

/* ========== Orientação paisagem ========== */
@media (orientation: landscape) and (max-height: 500px) {
  main {
    padding: 8px 12px 16px;
  }

  h1 { font-size: 1.3rem; margin: 0 0 8px; }
  h2 { font-size: 1.1rem; margin: 0.5rem 0 4px; }

  .navbar { min-height: 48px; }

  input,
  select,
  textarea {
    min-height: 40px;
    font-size: 16px;
  }

  .chat-messages { max-height: 240px; }

  .btn { min-height: 40px; padding: 8px 14px; }
}

/* ========== Modo tátil ========== */
@media (hover: none) and (pointer: coarse) {
  /* Aumentar alvos de toque */
  button, a, input, select, textarea {
    min-height: 44px;
    min-width: 44px;
  }

  /* Remover hover effects */
  button:hover { background-color: initial; }
  a:hover { color: var(--color-primary); }
}

/* ========== Modo escuro ========== */
@media (prefers-color-scheme: dark) {
  body.dark-mode-auto {
    background: #1A1A1A;
    color: #E0E0E0;
  }
}

/* ========== Print ========== */
@media print {
  header, footer, .no-print, .nav, .toolbar { display: none !important; }
  body { background: white; }
  main { max-width: 100%; padding: 0; }
}
