/* ═══════════════════════════════════════════════
   AIIM Studio — Mobile Responsive Overrides
   Loaded AFTER app.css to override desktop rules
   ═══════════════════════════════════════════════ */

/* Mobile sidebar backdrop */
.mobile-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
  backdrop-filter: blur(4px);
}
.mobile-backdrop.active { display: block; }

/* ═══════════════════════════════════════
   768px — Phone + Small Tablet
   ═══════════════════════════════════════ */
@media (max-width: 768px) {
  html { font-size: 14px; }

  /* Show the hamburger menu on mobile */
  #mobileHeaderToggle { display: inline-flex !important; }

  /* ── App Shell → single column ── */
  .app-shell { flex-direction: column; }

  /* ── Sidebars → fixed overlay drawers ── */
  .sidebar,
  .sidebar.collapsed-left {
    position: fixed !important;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    margin-left: 0 !important;
    transform: translateX(-100%);
    opacity: 1 !important;
    pointer-events: auto !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 8px 0 30px rgba(0,0,0,0.5);
  }
  .sidebar.mobile-open {
    transform: translateX(0) !important;
  }
  .sidebar-right,
  .sidebar-right.collapsed-right {
    left: auto !important; right: 0;
    transform: translateX(100%);
    margin-right: 0 !important;
    box-shadow: -8px 0 30px rgba(0,0,0,0.5);
  }
  .sidebar-right.mobile-open {
    transform: translateX(0) !important;
  }

  /* ── Header — compact ── */
  .app-header {
    padding: 0.5rem 0.75rem;
    gap: 0.4rem;
  }
  .app-header h1 { font-size: 1rem; white-space: nowrap; }
  .session-badge {
    font-size: 0.6rem;
    padding: 0.15rem 0.4rem;
    max-width: 100px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }

  /* ── Step Navigation → horizontal scroll ── */
  .step-nav {
    padding: 0 0.3rem;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }
  .step-nav::-webkit-scrollbar { display: none; }
  .step-tab {
    flex: 0 0 auto;
    padding: 0.6rem 0.5rem;
    font-size: 0.72rem;
    white-space: nowrap;
    gap: 0.25rem;
  }
  .step-tab .step-num { width: 20px; height: 20px; font-size: 0.6rem; }
  .step-tab .step-label { font-size: 0.68rem; }

  /* ── Main Content ── */
  .main-content { padding: 0.6rem; }
  .center-content { height: 100vh; width: 100%; }

  /* ── Cards ── */
  .card { padding: 0.9rem; border-radius: 12px; }
  .card-header h2 { font-size: 0.95rem; }
  .card-header { flex-wrap: wrap; gap: 0.5rem; }
  .card + .card { margin-top: 1rem; }

  /* ── Layout Grids → collapse ── */
  .niche-grid { grid-template-columns: 1fr !important; }
  .profile-grid { grid-template-columns: 1fr !important; }
  .face-gallery { grid-template-columns: repeat(2, 1fr) !important; gap: 0.5rem; }
  .attr-grid { grid-template-columns: 1fr 1fr !important; }
  .qc-scores { gap: 0.3rem; }
  .lora-selection-grid { gap: 0.3rem; }

  /* ── Inline Controls → stack vertically ── */
  .inline-controls { flex-direction: column; gap: 0.5rem; }
  .inline-controls .form-group { min-width: 100%; flex: none; }

  /* ── Buttons — full width for primary ── */
  .card .btn-primary,
  .step-panel .btn-primary { width: 100%; justify-content: center; }

  /* ── Form Controls — touch-friendly sizes ── */
  .form-control {
    padding: 0.75rem 0.85rem;
    font-size: 16px; /* Prevent iOS zoom on focus */
    border-radius: 8px;
  }
  select.form-control { padding-right: 2.5rem; font-size: 16px; }
  textarea.form-control { font-size: 16px; }
  .form-group label { font-size: 0.75rem; }
  .tags-input { min-height: 48px; }
  .tags-input input { font-size: 16px; }

  /* ── Upload Zones ── */
  .upload-zone { padding: 0.6rem !important; }
  .upload-zone .upload-icon { font-size: 1.2rem !important; margin-bottom: 0.1rem !important; }
  .upload-zone .upload-text { font-size: 0.72rem !important; }

  /* ── Reference/LoRA Thumbs ── */
  .ref-thumb { width: 46px; height: 46px; }
  .ref-remove { opacity: 1; transform: scale(1); }
  .lora-thumb { width: 60px; height: 60px; }

  /* ── Niche Cards ── */
  .niche-card { padding: 0.9rem; }
  .niche-card .niche-name { font-size: 0.9rem; }
  .niche-card .niche-desc { font-size: 0.78rem; }
  .niche-card .meta-tag { font-size: 0.65rem; }

  /* ── QC Score Badges ── */
  .score-badge { min-width: 50px; padding: 0.35rem 0.45rem; }
  .score-badge .score-label { font-size: 0.5rem; }
  .score-badge .score-value { font-size: 0.95rem; }

  /* ── Modals → bottom sheet ── */
  .prompt-modal-overlay { align-items: flex-end; }
  .prompt-modal {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 16px 16px 0 0;
    max-height: 90vh;
    padding: 1rem;
  }
  .prompt-modal-actions { flex-direction: column; }
  .prompt-modal-actions .btn { width: 100%; justify-content: center; }

  /* ── Lightbox ── */
  .lightbox-close { top: 10px; right: 12px; font-size: 1.8rem; }
  .lightbox-nav { font-size: 1.8rem; padding: 0.3rem 0.5rem; }
  .lightbox-prev { left: 6px; }
  .lightbox-next { right: 6px; }
  .lightbox-image { max-width: 96vw; max-height: 75vh; border-radius: 8px; }

  /* ── Auth Screen ── */
  .auth-card { padding: 1.5rem 1.2rem; border-radius: 16px; }
  .auth-logo { font-size: 2.5rem; }
  .auth-title { font-size: 1.1rem; }

  /* ── Status Messages ── */
  .status-msg { font-size: 0.75rem; padding: 0.5rem 0.7rem; }

  /* ── Report Preview ── */
  .report-preview { padding: 0.8rem; font-size: 0.78rem; max-height: 350px; }

  /* ── Details/Summary (Advanced Options) ── */
  details summary { font-size: 0.78rem !important; }
  details > div { font-size: 0.82rem; }

  /* ── Prompt Block ── */
  .prompt-block { padding: 0.6rem; font-size: 0.72rem; max-height: 150px; }

  /* ── Face Cards ── */
  .face-card { min-height: 120px; }
  .face-card .face-info { padding: 0.5rem; }
  .face-card .face-status { font-size: 0.65rem; }
  .btn-variations { font-size: 0.65rem; padding: 0.3rem 0.4rem; }

  /* ── Thread/Iteration ── */
  .face-thread-history { max-height: 120px; }
  .thread-item { font-size: 0.68rem; }
  .thread-item img { width: 32px; height: 32px; }
  .thread-input textarea { font-size: 16px; min-height: 28px; }

  /* ── Settings Overlay ── */
  #settingsOverlay {
    align-items: flex-end !important;
  }
  #settingsOverlay > div {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 16px 16px 0 0 !important;
    max-height: 90vh !important;
  }

  /* ── Freestyle Upload Grid (inline style override) ── */
  [style*="grid-template-columns"][style*="repeat(auto-fit"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
  }

  /* ── Platform checkbox labels ── */
  [style*="display: flex"][style*="gap: 1rem"][style*="flex-wrap"] {
    gap: 0.5rem !important;
  }
}

/* ═══════════════════════════════════════
   380px — Very Small Phones
   ═══════════════════════════════════════ */
@media (max-width: 380px) {
  html { font-size: 13px; }
  .step-tab .step-label { display: none; }
  .face-gallery { grid-template-columns: 1fr !important; }
  .attr-grid { grid-template-columns: 1fr !important; }
  .card { padding: 0.7rem; }
  .main-content { padding: 0.4rem; }
  .app-header { padding: 0.4rem 0.5rem; }
  .app-header h1 { font-size: 0.9rem; }

  [style*="grid-template-columns"][style*="repeat(auto-fit"] {
    grid-template-columns: 1fr !important;
  }
}
