/* ===========================================================
   Hesiodex — Mobile & iOS Optimization
   Load AFTER styles.css and chatbot.css.
   =========================================================== */

/* ── iOS / PWA fixes ── */
@supports (padding-top: env(safe-area-inset-top)) {
  .mobile-header { padding-top: env(safe-area-inset-top); height: calc(52px + env(safe-area-inset-top)); }
  .chat-input-area { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}

input, textarea, select { font-size: 16px !important; }
html { -webkit-overflow-scrolling: touch; }

/* ── Tablet (<=900px) ── */
@media (max-width: 900px) {
  :root { --ref-w: 100vw; }
}

/* ── Mobile (<=768px) ── */
@media (max-width: 768px) {
  /* Show mobile header, hide desktop sidebar */
  .mobile-header { display: flex; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    z-index: 300;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }

  /* Main content adjusts for mobile header */
  .main {
    padding-top: 52px;
  }
  @supports (padding-top: env(safe-area-inset-top)) {
    .main { padding-top: calc(52px + env(safe-area-inset-top)); }
  }

  /* Chat adjustments */
  .chat-messages { padding: 16px 16px 8px; }
  .chat-input-area { padding: 0 12px 12px; }
  .chat-input-wrap { border-radius: 14px; }
  .chat-hint { display: none; }

  /* Welcome state */
  .chat-welcome { padding: 40px 16px; }
  .chat-welcome h2 { font-size: 1.2rem; }
  .welcome-chips { gap: 6px; }
  .welcome-chips button { font-size: 0.8rem; padding: 8px 12px; }

  /* Flag button always visible on touch */
  .chat-flag-btn { opacity: 1 !important; }

  /* Reference panel full screen on mobile */
  .ref-panel { width: 100vw; }
}

/* ── Small phones (<=375px) ── */
@media (max-width: 375px) {
  .chat-messages { padding: 12px 10px 6px; }
  .chat-input-area { padding: 0 8px 8px; }
  .chat-welcome h2 { font-size: 1.1rem; }
  .welcome-chips button { font-size: 0.76rem; padding: 7px 10px; }
  .login-card { margin: 0 12px; padding: 32px 20px; }
}

/* ── PWA standalone mode ── */
@media all and (display-mode: standalone) {
  .mobile-header {
    padding-top: env(safe-area-inset-top, 20px);
    height: calc(52px + env(safe-area-inset-top, 20px));
  }
}
