/* ============================================================
   PolicyLive — Mobile App UI/UX & Responsive Design System
   Tailored for: 320px, 360px, 375px, 390px, 412px, 430px+
   Native App Feel (Cred / PhonePe / PolicyBazaar density)
   ============================================================ */

/* ---------- 1. Safe-Area Insets & App Root ---------- */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

@media (max-width: 900px) {
  :root {
    --header-h: 54px;
    --app-font-base: 14px;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
  }

  html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
  }

  body {
    font-size: var(--app-font-base);
    line-height: 1.45;
  }
}

@media (max-width: 480px) {
  :root {
    --header-h: 48px;
    --app-font-base: 13.5px;
    --radius: 0.5rem;
  }
}

/* ---------- 2. iOS Safari Input Auto-Zoom Prevention & Compact Forms ---------- */
@media (max-width: 768px) {
  /* iOS requires >= 16px to prevent forceful screen zoom-in */
  input,
  select,
  textarea,
  .form-control {
    font-size: 16px !important;
    line-height: 1.3 !important;
  }

  /* Compact touch heights */
  .form-control {
    padding: 8px 12px !important;
    border-radius: 9px !important;
    min-height: 40px;
  }

  textarea.form-control {
    min-height: 75px;
  }

  .form-group {
    margin-bottom: 8px !important;
  }

  .form-grid {
    gap: 8px !important;
  }

  /* Compact button styling */
  .btn {
    min-height: 40px;
    padding: 9px 16px !important;
    font-size: 0.86rem !important;
    border-radius: 10px !important;
    font-weight: 600;
  }

  .btn--sm {
    min-height: 30px;
    padding: 5px 10px !important;
    font-size: 0.76rem !important;
  }

  .login-card {
    padding: 16px 14px !important;
    border-radius: var(--radius-lg) !important;
  }
}

/* ---------- 3. Compact Native App Header & Navigation ---------- */
@media (max-width: 900px) {
  .site-header {
    height: var(--header-h);
    padding: 0;
    display: flex;
    align-items: center;
    transition: all 300ms ease-in-out;
  }

  .site-header.is-scrolled {
    height: 52px;
    top: 8px;
    width: calc(100% - 16px);
    border-radius: 999px;
    padding: 0 6px;
  }

  .header-inner {
    padding: 0 12px !important;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px !important;
    transition: all 300ms ease-in-out;
  }

  .site-header.is-scrolled .header-inner {
    height: 52px !important;
    padding: 0 8px !important;
  }

  .brand img {
    height: 34px !important;
    width: auto !important;
    max-width: 135px !important;
    object-fit: contain;
    transition: all 300ms ease-in-out;
  }

  .site-header.is-scrolled .brand img {
    height: 28px !important;
    max-width: 120px !important;
  }

  .header-actions {
    display: flex;
    align-items: center;
    gap: 6px !important;
  }

  /* Move 'Become a Partner' into drawer on small screens */
  @media (max-width: 520px) {
    .header-actions .btn--outline {
      display: none !important;
    }
  }

  .nav-toggle {
    width: 38px;
    height: 38px;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
  }

  /* Native-feel Slide-down / Slide-in Drawer */
  .nav-menu {
    top: calc(var(--header-h) + var(--safe-top));
    padding: 14px 14px calc(24px + var(--safe-bottom)) !important;
    border-radius: 0 0 16px 16px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.2);
  }

  .nav-link {
    padding: 12px 10px !important;
    font-size: 0.92rem !important;
    font-weight: 600;
  }
}

/* Ultra-compact screens <= 360px */
@media (max-width: 360px) {
  .brand img {
    height: 28px !important;
    max-width: 115px !important;
  }

  .header-actions .btn {
    display: none !important;
  }
}

/* ---------- 4. Compact Typography Scale ---------- */
@media (max-width: 768px) {
  h1, .hero--pro h1, .partner-hero h1 {
    font-size: clamp(1.35rem, 5vw, 1.75rem) !important;
    line-height: 1.22 !important;
    letter-spacing: -0.02em !important;
    margin-bottom: 8px !important;
  }

  h2 {
    font-size: clamp(1.12rem, 4vw, 1.35rem) !important;
    line-height: 1.25 !important;
    margin-bottom: 6px !important;
  }

  h3 {
    font-size: clamp(0.95rem, 3.4vw, 1.12rem) !important;
    line-height: 1.3 !important;
  }

  .eyebrow, .hero-badge {
    font-size: 0.66rem !important;
    padding: 3px 8px !important;
    margin-bottom: 6px !important;
  }

  .hero-text, .section-head p {
    font-size: 0.84rem !important;
    line-height: 1.45 !important;
    margin-bottom: 12px !important;
  }

  /* Compact section vertical paddings */
  .section, .page-hero {
    padding: 24px 0 !important;
  }

  .hero--pro {
    padding: 20px 0 24px !important;
  }

  .container {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* Compact Card Paddings */
  .card,
  .partner-card,
  .dash-card,
  .feature-card,
  .step-card {
    padding: 12px 12px !important;
    border-radius: var(--radius) !important;
  }
}

/* ---------- 5. 2-Column Micro-Grids for Features & Products ---------- */
@media (max-width: 680px) {
  .trust-strip-inner {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  .trust-item {
    padding: 8px 10px !important;
    gap: 10px !important;
    align-items: center !important;
  }

  .trust-ico {
    width: 36px !important;
    height: 36px !important;
    border-radius: 10px !important;
  }

  .trust-ico svg {
    width: 18px !important;
    height: 18px !important;
  }

  .trust-item b {
    font-size: 0.76rem !important;
  }

  .trust-item span {
    font-size: 0.66rem !important;
    line-height: 1.2 !important;
  }

  .grid-3 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  .feature-card {
    padding: 10px 10px !important;
  }

  .feature-card .icon-chip {
    width: 30px !important;
    height: 30px !important;
    margin-bottom: 6px !important;
  }

  .feature-card h3 {
    font-size: 0.82rem !important;
    margin-bottom: 4px !important;
  }

  .feature-card p {
    font-size: 0.72rem !important;
    line-height: 1.32 !important;
  }
}

/* ---------- 6. Compact Hero Stats Pill Strip ---------- */
@media (max-width: 768px) {
  .hero-stats {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 4px !important;
    margin-top: 16px !important;
    padding-top: 12px !important;
  }

  .hero-stat {
    text-align: center;
  }

  .hero--pro .hero-stat strong,
  .hero-stat strong {
    font-size: 1.2rem !important;
    line-height: 1.1 !important;
  }

  .hero-stat span {
    font-size: 0.64rem !important;
    line-height: 1.18 !important;
    margin-top: 2px !important;
  }

  .hero-trust {
    gap: 6px !important;
    font-size: 0.76rem !important;
    margin: 10px 0 14px !important;
  }
}

/* ---------- 7. Native Mobile Bottom-Sheet Modals ---------- */
@media (max-width: 768px) {
  .modal {
    padding: 0 !important;
    align-items: flex-end !important;
    background: rgba(10, 15, 25, 0.65) !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
  }

  .modal-card {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 84vh !important;
    padding: 14px 16px calc(18px + var(--safe-bottom)) !important;
    margin: 0 !important;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3) !important;
    animation: sheetSlideUp 0.28s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }

  /* Visual swipe-down drag indicator handle */
  .modal-card::before {
    content: "";
    display: block;
    width: 38px;
    height: 4px;
    background: rgba(128, 128, 128, 0.35);
    border-radius: 3px;
    margin: 0 auto 10px;
  }

  @keyframes sheetSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
}

/* ---------- 8. Portal Drawer Backdrop & Mobile Top Bar ---------- */
@media (max-width: 900px) {
  .dash-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(5, 10, 20, 0.35);
    z-index: 55;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .dash-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  /* Must stay above the drawer backdrop (partner.css: .dash-backdrop z-index 9990 !important).
     This file loads after partner.css, so a lower value here would put the backdrop over the drawer. */
  .dash-side {
    z-index: 9999 !important;
    width: min(280px, 80vw) !important;
    padding-top: calc(12px + var(--safe-top)) !important;
    padding-bottom: calc(18px + var(--safe-bottom)) !important;
  }

  .dash-top {
    padding: 6px 0 !important;
    gap: 8px !important;
  }

  .dash-top__logo img {
    height: 28px !important;
    width: auto !important;
  }

  .dash-user {
    padding: 3px 8px 3px 4px !important;
    font-size: 0.74rem !important;
  }

  .dash-avatar {
    width: 26px !important;
    height: 26px !important;
    font-size: 0.65rem !important;
  }
}

/* ---------- 9. Compact Portal Cards, KPIs & Dialler Layout ---------- */
@media (max-width: 768px) {
  /* Performance Tiles / KPI Micro-grid */
  .perf-row,
  .perf-row--2,
  .perf-row--3,
  .perf-row--5,
  .dash-kpis {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px !important;
  }

  .perf-tile--sm,
  .dash-kpi {
    padding: 8px 10px !important;
    border-radius: 9px !important;
  }

  .perf-tile--sm strong,
  .dash-kpi strong {
    font-size: 1.15rem !important;
  }

  .perf-tile--sm span,
  .dash-kpi span {
    font-size: 0.62rem !important;
  }

  /* Telecaller Lead Detail Compact Grid */
  .ld-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px !important;
  }

  .ld-f {
    padding: 6px 8px !important;
  }

  .ld-f span {
    font-size: 0.58rem !important;
  }

  .ld-f b {
    font-size: 0.8rem !important;
  }

  .ld2-grid {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .ld2-row {
    grid-template-columns: 90px 1fr !important;
    gap: 6px !important;
    padding: 4px 0 !important;
    font-size: 0.78rem !important;
  }

  /* Telecaller Dialler Action Buttons */
  .lead-detail-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 6px !important;
  }

  .lead-detail-actions .btn {
    width: 100% !important;
  }

  /* Campaign Hub Mobile Grid */
  .camp-tiles {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px !important;
  }

  .camp-tile {
    padding: 10px 4px !important;
  }

  .camp-tile__ico svg {
    width: 20px !important;
    height: 20px !important;
  }

  .camp-tile__name {
    font-size: 0.7rem !important;
  }

  .camp-tile__count {
    font-size: 0.65rem !important;
  }

  /* Partner Overview Cards */
  .pd-status {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .pd-main, .pd-side, .pd-card {
    padding: 12px 12px !important;
  }

  .pd-hello {
    font-size: 1.12rem !important;
  }
}

/* ---------- 10. Table to Mobile Card Responsiveness ---------- */
@media (max-width: 768px) {
  .admin-table,
  .camp-table {
    display: block !important;
    width: 100% !important;
  }

  /* Horizontal card wrapping helper */
  .tablewrap {
    border-radius: 10px;
    box-shadow: inset 0 0 0 1px var(--grey-mid, #e2e8f0);
    -webkit-overflow-scrolling: touch;
  }
}

/* ---------- 11. Safe-Area Floating Controls Clearance ---------- */
@media (max-width: 768px) {
  .wa-chat {
    left: 12px !important;
    bottom: calc(14px + var(--safe-bottom)) !important;
    width: 44px !important;
    height: 44px !important;
    z-index: 45 !important;
  }

  .back-top {
    right: 12px !important;
    bottom: calc(14px + var(--safe-bottom)) !important;
    width: 38px !important;
    height: 38px !important;
    z-index: 45 !important;
  }

  /* Sticky Action Bar Clearance for iPhones */
  .tk-actionbar {
    padding-bottom: calc(12px + var(--safe-bottom)) !important;
  }
}
