/**
 * public/css/responsive.css — mobile-first responsive fixes for all customer-facing pages.
 * Ensures usability at 375px (iPhone SE), 390px (iPhone 14), 430px (iPhone 14 Pro Max).
 * Covers: portal, upload, pricing, login/signup, submission forms, delivery page.
 */

/* ===== GLOBAL MOBILE BASELINE ===== */
@media (max-width: 640px) {

  /* Prevent horizontal overflow everywhere */
  html, body { overflow-x: hidden; max-width: 100%; }
  img, video { max-width: 100%; height: auto; }
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Portal nav — collapse for mobile */
  .portal-nav {
    padding: 0 16px;
    height: 52px;
    flex-wrap: nowrap;
  }

  .portal-nav-brand {
    font-size: 1.1rem;
    flex-shrink: 0;
  }

  /* Stack nav actions on mobile */
  .portal-nav-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
  }

  .portal-nav-link {
    font-size: 0.78rem;
    padding: 0;
  }

  /* Hide secondary nav links on very small screens, keep logout */
  .portal-nav-link.secondary-hide {
    display: none;
  }

  .btn-sm {
    font-size: 0.78rem;
    padding: 6px 12px;
  }

  /* Portal main content padding */
  .portal-main,
  .portal-header,
  .upload-container,
  .portal-container {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Submission cards — full width */
  .submission-card,
  .card,
  .panel {
    margin-left: 0;
    margin-right: 0;
    border-radius: 10px;
  }

  /* Form inputs — minimum 44px tap target, full width */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="url"],
  input[type="number"],
  textarea,
  select {
    width: 100%;
    min-height: 44px;
    font-size: 16px; /* prevents iOS zoom on focus */
    padding: 11px 14px;
  }

  /* Buttons — full width on mobile when stacked */
  .btn-primary,
  .btn-ghost,
  .btn-lg {
    padding: 14px 20px;
    font-size: 0.95rem;
    min-height: 44px;
  }

  /* Upload area — comfortable tap target */
  .upload-area {
    padding: 28px 16px;
  }

  .upload-icon { font-size: 2rem; }

  /* URL input row — stack on mobile */
  .url-row {
    flex-direction: column;
    gap: 10px;
  }

  .url-row input, .url-row button {
    width: 100%;
  }

  /* Hero section */
  .hero {
    padding: 48px 16px 40px;
    min-height: unset;
  }

  .hero h1 {
    font-size: 2rem;
    line-height: 1.15;
  }

  .hero-cta {
    flex-direction: column;
    gap: 12px;
  }

  .hero-cta .btn-primary,
  .hero-cta .btn-ghost {
    width: 100%;
    text-align: center;
  }

  /* Flow diagram — scroll horizontally if needed */
  .flow-diagram {
    flex-direction: column;
    gap: 16px;
    align-items: center;
  }

  .flow-arrow { transform: rotate(90deg); }

  /* Pricing grid — single column */
  .pricing-grid {
    grid-template-columns: 1fr !important;
  }

  .pricing-tier-card,
  .tier-card {
    min-width: 0;
  }

  /* Feature matrix table — horizontal scroll */
  .feature-matrix,
  .pricing-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 0.8rem;
  }

  /* Discount code section */
  .discount-row {
    flex-direction: column;
    gap: 8px;
  }

  .discount-row input,
  .discount-row button {
    width: 100%;
  }

  /* Login / signup forms */
  .login-box,
  .signup-box,
  .auth-card {
    padding: 28px 20px;
    margin: 16px;
  }

  /* Portal dashboard submissions list */
  .submissions-list,
  .submission-table {
    font-size: 0.85rem;
  }

  /* Status badges — don't overflow */
  .status-badge,
  .badge {
    font-size: 0.72rem;
    padding: 4px 8px;
    white-space: nowrap;
  }

  /* Pipeline stage progress — smaller dots */
  .pipeline-stages {
    gap: 6px;
    flex-wrap: wrap;
  }

  /* Delivery page — clips */
  .deliverables-grid {
    grid-template-columns: 1fr;
  }

  .deliverable-card video {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    background: #000;
  }

  /* Download buttons */
  .download-btn,
  .btn-download {
    width: 100%;
    text-align: center;
  }

  /* Admin tables — horizontal scroll */
  .admin-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px;
  }

  /* Caption settings page — stacked layout */
  .caption-settings-grid {
    grid-template-columns: 1fr;
  }

  /* Color swatches — larger tap targets */
  .color-swatch {
    width: 36px;
    height: 36px;
  }

  /* Customize page — step sections */
  .customize-section {
    padding: 20px 0;
  }

  /* Tier upgrade cards — full width */
  .tier-upgrade-card {
    margin: 0;
  }

  /* Stats/metrics bar */
  .stats-bar {
    flex-wrap: wrap;
    gap: 12px;
  }

  .stat-item {
    flex: 1;
    min-width: 120px;
    text-align: center;
  }

  /* Modal dialogs — full screen on mobile */
  .modal-content {
    margin: 0;
    border-radius: 0;
    min-height: 100vh;
    max-width: 100%;
  }

  /* Section headings */
  h1 { font-size: clamp(1.5rem, 7vw, 2.5rem); }
  h2 { font-size: clamp(1.25rem, 5vw, 2rem); }
  h3 { font-size: clamp(1rem, 4vw, 1.5rem); }

  /* Avoid text cut-off in cards */
  .card-title, .submission-title {
    word-break: break-word;
    overflow-wrap: break-word;
  }

  /* Fix overflow on long URLs / filenames */
  .filename, .url-display, code, pre {
    word-break: break-all;
    overflow-wrap: break-word;
  }
}

/* ===== TABLET (640px-1023px) ===== */
@media (min-width: 641px) and (max-width: 1023px) {
  .portal-main,
  .portal-header,
  .upload-container {
    padding-left: 24px;
    padding-right: 24px;
  }

  .pricing-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .deliverables-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="url"],
  textarea,
  select {
    font-size: 16px;
  }
}

/* ===== PORTAL NAV: mobile hamburger support ===== */
/* The portal nav doesn't have a hamburger, but we can collapse secondary links */
@media (max-width: 480px) {
  .portal-nav-link[data-hide-mobile="true"] {
    display: none;
  }

  /* Landing nav (legacy partials) */
  .landing-nav {
    padding: 0 16px;
    flex-wrap: wrap;
    gap: 8px;
    height: auto;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .landing-nav-brand {
    flex: 1;
  }

  .landing-nav-actions {
    display: flex;
    gap: 8px;
    width: 100%;
    justify-content: flex-end;
  }

  /* Submissions page search + filter row */
  .search-filter-row {
    flex-direction: column;
    gap: 10px;
  }

  .search-filter-row input,
  .search-filter-row select {
    width: 100%;
  }
}

/* ===== VIDEO PLAYBACK: Safari iOS + Chrome Android ===== */
video {
  /* Ensure video elements are responsive */
  max-width: 100%;
  height: auto;
}

/* 9:16 clips need proper mobile framing */
.clip-video,
.deliverable-video {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  display: block;
  border-radius: 8px;
}

@media (max-width: 640px) {
  .clip-video,
  .deliverable-video {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    background: #000;
    border-radius: 6px;
  }
}

/* ===== BEFORE/AFTER PREVIEW ===== */
@media (max-width: 640px) {
  .before-after-row {
    flex-direction: column;
    gap: 16px;
  }

  .before-col, .after-col {
    width: 100%;
  }
}

/* ===== PIPELINE STATUS INDICATOR ===== */
@media (max-width: 640px) {
  .pipeline-progress-row {
    gap: 4px;
    font-size: 0.72rem;
  }

  .pipeline-dot {
    width: 7px;
    height: 7px;
  }

  .pipeline-label {
    display: none; /* Show only dots on mobile */
  }
}

/* ===== CUSTOMIZE PAGE ===== */
@media (max-width: 640px) {
  .customize-grid {
    grid-template-columns: 1fr;
  }

  .preset-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .preset-card {
    padding: 14px 10px;
    font-size: 0.82rem;
  }

  .hook-template-list {
    gap: 8px;
  }

  .hook-template-item {
    font-size: 0.82rem;
    padding: 10px;
  }
}

/* ===== CAPTION SETTINGS PAGE ===== */
@media (max-width: 640px) {
  .caption-preview-area {
    height: 200px;
  }

  .caption-controls-grid {
    grid-template-columns: 1fr;
  }

  .font-select-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
