/* =========================================================
   YatraSaathi — responsive.css
   Master Responsive Layer — Production Grade
   Mobile-first breakpoint system:
     xs:  320px+
     sm:  480px+
     md:  640px+
     lg:  768px+
     xl:  1024px+
     2xl: 1280px+
     3xl: 1536px+
   ========================================================= */

/* ── 1. GLOBAL DEFENSIVE RESETS ──────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  overflow-x: hidden;
  min-height: 100svh; /* svh = small viewport height — fixes mobile browser chrome */
}

img,
video,
svg,
canvas,
iframe {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ── 2. CONTAINER SYSTEM ─────────────────────────────────── */
.container,
.planner-container,
.budget-container,
.city-container {
  width: 100%;
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 1.5rem);
}

/* Fluid max-widths per breakpoint */
@media (min-width: 640px)  { .container, .planner-container, .budget-container, .city-container { max-width: 640px; } }
@media (min-width: 768px)  { .container, .planner-container, .budget-container, .city-container { max-width: 768px; } }
@media (min-width: 1024px) { .container, .planner-container, .budget-container, .city-container { max-width: 1100px; } }
@media (min-width: 1280px) { .container, .planner-container, .budget-container, .city-container { max-width: 1200px; } }
@media (min-width: 1536px) { .container, .planner-container, .budget-container, .city-container { max-width: 1400px; } }

/* ── 3. FLUID TYPOGRAPHY SYSTEM ──────────────────────────── */
:root {
  --text-xs:   clamp(0.75rem,  1.5vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 2vw,   1rem);
  --text-base: clamp(1rem,     2.5vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 3vw,   1.25rem);
  --text-xl:   clamp(1.25rem,  3.5vw, 1.5rem);
  --text-2xl:  clamp(1.5rem,   4vw,   2rem);
  --text-3xl:  clamp(1.75rem,  4.5vw, 2.5rem);
  --text-4xl:  clamp(2rem,     5vw,   3.25rem);
  --text-5xl:  clamp(2.25rem,  6vw,   4rem);
}

/* ── 4. NAVBAR RESPONSIVE ────────────────────────────────── */

/* Fix landing page dock — stop transform scaling */
@media (max-width: 1023px) {
  .nav-container {
    position: relative;
  }

  /* Dock: switch from absolute scaling to inline flex */
  .dock-panel {
    transform: none !important;
    transform-origin: unset !important;
    max-width: calc(100vw - 140px); /* prevent overlap with logo */
    overflow: hidden;
  }

  /* dock items: shrink padding on tablet */
  .dock-item {
    padding: 6px 10px !important;
  }
}

/* Below 768px: icon-only dock + compact scroll-nav */
@media (max-width: 767px) {
  /* Logo */
  .logo {
    height: 55px;
    flex-shrink: 0;
  }

  .logo img {
    max-width: 120px !important;
    transform: none !important;
    height: 100%;
    width: auto;
    object-fit: contain;
  }

  /* Dock: icon only, no labels */
  .dock-label {
    display: none !important;
  }

  .dock-panel {
    gap: 2px;
    padding: 6px 10px !important;
    border-radius: 20px;
    transform: none !important;
  }

  .dock-item {
    width: 36px;
    height: 36px;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
  }

  /* Scroll-nav: icon only on mobile */
  .scroll-nav {
    transform: none !important;
    max-width: calc(100vw - 140px);
  }

  .scroll-nav-link span,
  .scroll-nav-login span {
    display: none;
  }

  .scroll-nav-link,
  .scroll-nav-login {
    padding: 8px 10px !important;
    font-size: 0 !important;
    gap: 0 !important;
    min-width: 36px;
    justify-content: center;
  }

  .scroll-nav-link i,
  .scroll-nav-login i {
    font-size: 15px !important;
    margin: 0 !important;
  }

  .scroll-nav-signup {
    padding: 8px 14px !important;
    font-size: 12px !important;
  }
}

/* Below 480px: even tighter */
@media (max-width: 479px) {
  .logo img {
    max-width: 100px !important;
  }

  .dock-panel,
  .scroll-nav {
    transform: none !important;
  }

  .dock-item {
    width: 32px;
    height: 32px;
    min-width: 32px;
  }

  .dock-item .dock-icon i,
  .dock-item .dock-icon svg {
    font-size: 14px !important;
  }
}

/* ── 5. LANDING PAGE HERO ────────────────────────────────── */
@media (max-width: 1023px) {
  .hero-container {
    gap: 20px;
  }
  .hero-content {
    max-width: 100%;
  }
}

@media (max-width: 767px) {
  .hero {
    padding: 40px 0 30px;
  }
  .hero-container {
    flex-direction: column;
    text-align: center;
    align-items: center;
  }
  .hero-content {
    order: 1;
  }
  .steps-image {
    order: 2;
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
  }
  .hero-actions {
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
  }
  .hero-title {
    font-size: clamp(2rem, 8vw, 2.75rem) !important;
  }
  .hero-subtitle {
    font-size: clamp(0.8rem, 3vw, 1rem);
    margin-bottom: 16px;
  }
  .hero-text {
    font-size: 14px;
    margin-bottom: 24px;
  }
  /* Trip card inside hero */
  .trip-card {
    max-width: 100%;
    margin: 0 auto;
    padding: 16px;
  }
  .ongoing-card {
    position: relative !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    width: 100%;
    margin-top: 12px;
    transform: none !important;
    animation: none !important;
    translate: 0 !important;
  }
  .ongoing-card.show-scroll {
    translate: 0 0 !important;
    animation: none !important;
  }
  /* Hide decorative glow behind image */
  .steps-image::before {
    display: none;
  }
}

@media (max-width: 479px) {
  .hero-title {
    font-size: clamp(1.75rem, 8vw, 2.25rem) !important;
  }
  .hero-actions {
    flex-direction: column;
    align-items: center;
    width: 100%;
  }
  .hero-actions .btn-primary,
  .hero-actions a {
    width: 100%;
    max-width: 280px;
    justify-content: center;
  }
}

/* ── 6. SECTION SPACING ──────────────────────────────────── */
@media (max-width: 767px) {
  .section-padding {
    padding: 60px 0;
  }
  .destinations, .services, .steps-section,
  .testimonials, .newsletter-section {
    padding: 60px 0;
  }
  .brands {
    padding: 40px 0;
  }
  .section-heading h2 {
    font-size: clamp(1.5rem, 5vw, 2rem) !important;
  }
}

@media (max-width: 479px) {
  .section-padding {
    padding: 48px 0;
  }
}

/* ── 7. GRID CARDS (Destinations, Services) ──────────────── */
@media (max-width: 1023px) {
  .destinations-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .services-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 639px) {
  .destinations-grid,
  .services-grid {
    grid-template-columns: 1fr;
  }
}

/* ── 8. STEPS SECTION ────────────────────────────────────── */
@media (max-width: 1023px) {
  .steps-container {
    flex-direction: column;
    align-items: center;
  }
  .step-items { width: 100%; }
  .steps-image { width: 100%; max-width: 400px; }
}

/* ── 9. TESTIMONIALS ─────────────────────────────────────── */
@media (max-width: 1023px) {
  .testi-container {
    flex-direction: column;
    text-align: center;
    gap: 40px;
  }
  .testi-content { width: 100%; }

  /* Cards wrapper: tall enough + overflow visible so controls show */
  .testi-cards {
    width: 100%;
    min-width: 100%;
    height: auto !important;               /* don't clip controls */
    min-height: 280px;
    padding-bottom: 64px;                  /* space for controls row */
    position: relative;
    align-self: stretch;
    overflow: visible !important;
  }

  /* Active card fills full width */
  .testi-card {
    text-align: center;
    padding-top: 52px;
    width: 100% !important;
    left: 0 !important;
    right: 0 !important;
  }

  /* Stacked back-cards stay in-bounds */
  .testi-card.next {
    left: 0 !important;
    top: 12px !important;
    transform: scale(0.96) !important;
    width: 100% !important;
  }
  .testi-card.hidden-card {
    top: 24px !important;
    left: 0 !important;
    transform: scale(0.92) !important;
    width: 100% !important;
  }

  /* Center avatar */
  .testi-avatar {
    left: 50% !important;
    transform: translateX(-50%) !important;
    top: -28px !important;
  }

  /* Controls: move OUT of card, below it, horizontal */
  .testi-controls {
    position: absolute !important;
    bottom: 16px !important;               /* stick to bottom of padded area */
    right: auto !important;
    left: 50% !important;
    top: auto !important;
    transform: translateX(-50%) !important;
    flex-direction: row !important;
    gap: 16px !important;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(24,30,75,0.08);
    padding: 8px 20px;
    border-radius: 50px;
    box-shadow: 0 4px 14px rgba(24,30,75,0.08);
  }

  .testi-controls i {
    font-size: 18px !important;
    /* rotate chevrons for horizontal prev/next */
    transform: rotate(90deg);
  }
  .testi-controls i:first-child {
    transform: rotate(90deg); /* up → left arrow */
  }
  .testi-controls i:last-child {
    transform: rotate(-90deg); /* down → right arrow */
  }

  /* Dots: centered */
  .testi-dots {
    justify-content: center !important;
    margin-top: 16px !important;
  }
}

@media (max-width: 479px) {
  .testi-card p { font-size: 13px; }
  .testi-cards { min-height: 300px; }
}

/* ── 10. NEWSLETTER ──────────────────────────────────────── */
@media (max-width: 767px) {
  .newsletter-box {
    padding: 40px 20px;
    border-radius: 40px;
  }
  .newsletter-box h2 {
    font-size: clamp(1.25rem, 5vw, 1.75rem) !important;
  }
  .newsletter-form {
    flex-direction: column;
    align-items: stretch;
  }
  .input-wrap {
    width: 100%;
  }
  .btn-subscribe {
    width: 100%;
    text-align: center;
  }
}

/* ── 11. BRANDS ──────────────────────────────────────────── */
@media (max-width: 767px) {
  .brands-container {
    justify-content: center;
    gap: 20px;
  }
  .brands img {
    height: 28px;
  }
}

/* ── 12. FOOTER ──────────────────────────────────────────── */
@media (max-width: 1023px) {
  .footer-container {
    flex-direction: column;
    gap: 40px;
  }
  .footer-links {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }
}

@media (max-width: 767px) {
  .footer {
    padding: 60px 0 30px;
    text-align: center;
  }
  .footer-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .footer-logo {
    margin: 0 auto 14px;
  }
  .footer-desc {
    max-width: 100%;
  }
  .footer-brand-socials {
    justify-content: center;
  }
  .footer-links {
    grid-template-columns: repeat(3, 1fr);
    text-align: left;
    gap: 15px;
  }
  .footer-col h3 {
    font-size: 16px;
    margin-bottom: 14px;
  }
  .footer-col a {
    font-size: 13px;
    margin-bottom: 10px;
  }
  .app-buttons {
    justify-content: center;
  }
  .footer-social .social-icons {
    justify-content: center;
  }
  .footer-bottom {
    margin-top: 20px;
  }
}

@media (max-width: 479px) {
  .footer-links {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── 13. CHATBOT PANEL ───────────────────────────────────── */
@media (max-width: 767px) {
  .chat-panel {
    /* Full-screen on mobile */
    bottom: 0 !important;
    right: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100svh !important;
    border-radius: 0 !important;
    z-index: 10000;
  }

  .floating-chat-btn {
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    font-size: 22px;
  }

  .chat-messages {
    padding: 16px;
  }

  .msg-bubble {
    max-width: 88%;
    font-size: 13px;
  }

  .chat-input-area {
    /* Lift above mobile keyboard */
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .chat-input-area input {
    font-size: 16px; /* prevent iOS zoom */
  }
}

/* ── 14. AUTH PAGE ───────────────────────────────────────── */
@media (max-width: 1023px) {
  .auth-container {
    grid-template-columns: 1fr;
    max-width: 520px;
  }
  .auth-visual {
    display: none;
  }
}

@media (max-width: 639px) {
  .auth-wrapper {
    padding: 5rem 1rem 2rem;
  }
  .auth-form-side {
    padding: 2rem 1.5rem;
  }
  .auth-container {
    max-width: 100%;
    border-radius: 24px;
  }
  .nav-logo-img {
    height: 60px !important;
  }
}

/* ── 15. PLANNER PAGE ────────────────────────────────────── */
@media (max-width: 1023px) {
  .main-row {
    flex-direction: column;
    border-radius: 24px;
    padding: 20px;
    gap: 16px;
  }
  .main-row .form-group {
    border-right: none;
    border-bottom: 1px solid #E5E7EB;
    padding: 12px 0 !important;
    width: 100%;
  }
  .main-row .form-group.btn-wrapper {
    border-bottom: none;
    padding: 0 !important;
  }
  .main-row .generate-btn {
    width: 100%;
    justify-content: center;
  }
  .prefs-row {
    flex-direction: column;
    gap: 20px;
  }
  .budget-selector {
    flex-wrap: wrap;
  }
}

@media (max-width: 767px) {
  .planner-header-text h2 {
    font-size: clamp(1.5rem, 5vw, 2rem) !important;
  }
  .planner-top-bar {
    padding: 40px 0 30px;
    margin-bottom: 40px;
  }
  .result-row {
    flex-direction: column;
  }
  .result-sidebar {
    width: 100%;
  }
}

/* ── 16. BUDGET PAGE ─────────────────────────────────────── */
@media (max-width: 1023px) {
  .budget-hero {
    flex-direction: column;
    align-items: flex-start;
  }
  .budget-hero-visual {
    width: 100%;
  }
  .budget-hero-visual img {
    max-width: 100%;
    width: 100%;
  }
  .budget-hero-blob {
    width: 100%;
    height: 400px;
  }
}

@media (max-width: 767px) {
  .budget-hero-text {
    min-width: unset;
    width: 100%;
  }
  .budget-hero-text p {
    max-width: 100%;
    font-size: 15px;
  }
  .budget-stats-strip {
    grid-template-columns: repeat(2, 1fr);
  }
  .budget-features-row {
    grid-template-columns: 1fr;
  }
  .trip-selector-banner {
    flex-direction: column;
    align-items: flex-start;
  }
  .trip-selector-banner select {
    max-width: 100%;
    width: 100%;
  }
  .expense-form-row {
    flex-direction: column;
  }
  .expense-form-row .form-control,
  .expense-form-row button {
    width: 100%;
  }
}

@media (max-width: 479px) {
  .budget-stats-strip {
    grid-template-columns: 1fr;
  }
  .budget-orb-1,
  .budget-orb-2,
  .budget-orb-3 {
    display: none; /* hide heavy blur on low-end devices */
  }
}

/* ── 17. CITY INSIGHTS PAGE ──────────────────────────────── */
@media (max-width: 1023px) {
  .city-hero {
    grid-template-columns: 1fr;
    gap: 40px;
  }
  .city-hero-visual {
    width: 100%;
  }
  .hero-img-main {
    height: 300px;
  }
  .hero-stat-badge {
    right: 10px !important;
    top: 10px !important;
  }
  .hero-img-float {
    left: -10px;
    bottom: -10px;
    width: 120px;
    height: 80px;
  }
  .stats-strip {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 767px) {
  .city-search-pill {
    flex-wrap: wrap;
    border-radius: 20px;
    gap: 8px;
    max-width: 100%;
  }
  .city-search-pill input {
    width: 100%;
    min-width: 100%;
  }
  .city-search-pill button[type="submit"] {
    width: 100%;
    border-radius: 14px;
    padding: 12px;
  }
  .city-hero p {
    max-width: 100%;
    font-size: 15px;
  }
  .weather-grid,
  .insights-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 479px) {
  .stats-strip {
    grid-template-columns: 1fr;
  }
  .hero-img-main {
    height: 220px;
    border-radius: 24px;
  }
}

/* ── 18. DASHBOARD PAGE ──────────────────────────────────── */
@media (max-width: 1023px) {
  .dash-widgets {
    grid-template-columns: repeat(2, 1fr);
  }
  .dash-main-grid {
    grid-template-columns: 1fr;
  }
  .alerts-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 767px) {
  .dash-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  .dash-title {
    font-size: clamp(1.5rem, 5vw, 2rem) !important;
  }
  .dash-widgets {
    grid-template-columns: 1fr;
  }
  .alerts-grid {
    grid-template-columns: 1fr;
  }
  .dash-actions {
    flex-wrap: wrap;
    gap: 0.75rem;
  }
  .dash-panel {
    padding: 1.25rem;
  }
}

/* ── 19. HOME (USER DASHBOARD) ───────────────────────────── */
@media (max-width: 1023px) {
  .stats-banner {
    flex-wrap: wrap;
    gap: 20px;
  }
  .stat-item {
    flex: 1 1 calc(50% - 20px);
  }
}

@media (max-width: 767px) {
  .stats-banner {
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    margin-bottom: 40px;
  }
  .stat-item {
    flex: 1 1 100%;
    text-align: center;
  }
  .my-plans-section {
    padding-bottom: 60px;
  }
  .insights-section {
    padding-bottom: 40px;
  }
  .insight-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .user-hero-content h1 {
    font-size: clamp(1.5rem, 5vw, 2rem) !important;
  }
}

/* ── 20. ZIVA AI PANEL ───────────────────────────────────── */
@media (max-width: 767px) {
  .ziva-panel-wrapper,
  .ziva-iframe-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    height: 60svh !important;
    border-radius: 20px !important;
  }
  .ziva-header {
    padding: 12px 16px;
  }
  .ziva-title {
    font-size: 15px !important;
  }
  .ziva-mic-btn {
    width: 52px;
    height: 52px;
    font-size: 20px;
  }
}

/* ── 21. MAIN.CSS (Dark Sci-Fi Pages) ────────────────────── */
@media (max-width: 767px) {
  .nav {
    padding: 0 1rem;
  }
  .nav-links,
  .nav-actions .btn-ghost {
    display: none;
  }
  .nav-hamburger {
    display: flex;
  }
  .section {
    padding: 3rem 1rem;
  }
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
  .section-title {
    font-size: clamp(1.75rem, 6vw, 2.5rem) !important;
  }
  .section-subtitle {
    font-size: 1rem;
  }
}

@media (max-width: 479px) {
  html { font-size: 15px; }
  .nav { padding: 0 0.75rem; }
  .section { padding: 2.5rem 0.75rem; }
}

/* ── 22. ULTRA-WIDE (3xl: 1536px+) ──────────────────────── */
@media (min-width: 1536px) {
  .hero-title {
    font-size: 5rem !important;
  }
  .section-heading h2 {
    font-size: 3.5rem !important;
  }
  .destinations-grid,
  .services-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ── 23. ACCESSIBILITY & TOUCH TARGETS ───────────────────── */
@media (max-width: 767px) {
  /* Minimum 44x44px touch targets */
  button,
  .btn,
  .nav-link,
  .dock-item,
  .scroll-nav-link,
  .auth-tab,
  input[type="checkbox"],
  input[type="radio"] {
    min-height: 44px;
    min-width: 44px;
  }

  /* Prevent iOS zoom on input focus */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="search"],
  input[type="tel"],
  input[type="url"],
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* ── 24. REDUCED MOTION ──────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .trip-card,
  .ongoing-card,
  .auth-float-card,
  .bg-glow,
  .budget-orb {
    animation: none !important;
  }
}

/* ── 25. SAFE AREA INSETS (Notch/Home Bar) ───────────────── */
@supports (padding: env(safe-area-inset-bottom)) {
  .chat-input-area,
  .ziva-bottom-area,
  footer.footer {
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }

  .floating-chat-btn {
    bottom: max(20px, calc(env(safe-area-inset-bottom) + 10px));
  }
}

/* ── 26. LANDSCAPE ORIENTATION (Phones) ──────────────────── */
@media (max-width: 896px) and (orientation: landscape) {
  .hero {
    padding: 30px 0;
  }
  .hero-container {
    flex-direction: row;
    text-align: left;
  }
  .hero-actions {
    justify-content: flex-start;
  }
  .chat-panel {
    height: 100svh !important;
  }
  .ziva-panel-wrapper {
    height: 80svh !important;
  }
  .auth-wrapper {
    padding-top: 3rem;
  }
}

/* ── 27. PREVENT HORIZONTAL SCROLL (Global Guard) ────────── */
body,
.page-wrapper,
.planner-section,
.budget-page,
.city-page {
  overflow-x: hidden;
  max-width: 100vw;
}

/* Catch any remaining fixed-width children that could overflow */
.auth-float-card,
.hero-stat-badge,
.budget-orb-1,
.budget-orb-2 {
  pointer-events: none;
}

@media (max-width: 479px) {
  /* Hide floating decorative elements that cause overflow on tiny screens */
  .auth-float-card,
  .hero-img-float {
    display: none;
  }
  .hero-stat-badge {
    right: 5px !important;
    top: 5px !important;
    padding: 10px 12px;
    font-size: 11px;
  }
}
