/* ==========================================================================
   GINNY HOMES — MASTER RESPONSIVE DESIGN SYSTEM
   Optimized for Ultra-Wide, Desktop, Laptops, Tablets, and Smartphones
   Zero Horizontal Scrolling • Fluid Typography • Touch-Optimized Navigation
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. GLOBAL FLUID RESETS & STRICT CONTAINER CONSTRAINTS
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box !important;
}

html, body {
  overflow-x: hidden !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  -webkit-text-size-adjust: 100%;
  position: relative;
}

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

.container {
  width: 100%;
  max-width: var(--container-max, 1280px);
  margin-left: auto;
  margin-right: auto;
  padding-left: 24px;
  padding-right: 24px;
  box-sizing: border-box !important;
}

/* Ensure mobile form inputs don't trigger iOS Safari auto-zoom */
@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="password"],
  input[type="url"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* --------------------------------------------------------------------------
   2. LARGE DESKTOP & WIDE MONITORS (Max 1440px)
   -------------------------------------------------------------------------- */
@media (max-width: 1440px) {
  .container {
    max-width: 1280px;
  }
  .header-inner {
    max-width: 1360px;
    padding: 0 20px;
  }
  .nav-menu {
    gap: 14px;
  }
  .nav-link {
    font-size: 0.85rem;
  }
  .nav-signin-btn {
    padding: 7px 14px;
    font-size: 0.82rem;
  }
  .nav-cta {
    padding: 8px 16px;
    font-size: 0.82rem;
  }
}

/* --------------------------------------------------------------------------
   3. STANDARD DESKTOPS & COMPACT LAPTOPS (Max 1260px)
   -------------------------------------------------------------------------- */
@media (max-width: 1260px) {
  .header-inner {
    padding: 0 16px;
    gap: 10px;
  }
  .nav-menu {
    gap: 10px;
  }
  .nav-link {
    font-size: 0.81rem;
    padding: 6px 0;
  }
  .brand-logo img {
    height: 34px;
    width: auto;
  }
  .nav-signin-btn {
    padding: 6px 12px;
    font-size: 0.78rem;
    gap: 4px;
  }
  .nav-cta {
    padding: 8px 13px;
    font-size: 0.78rem;
  }
  .dropdown-menu {
    min-width: 420px;
  }
  .hero-title, .hero h1 {
    font-size: clamp(2.3rem, 4.2vw, 3.1rem);
  }
  .split-layout, .split-grid {
    gap: 32px;
  }
  .footer-top, .footer-grid {
    grid-template-columns: 1.4fr 1fr 1fr 1fr 1.2fr;
    gap: 24px;
  }
}

/* --------------------------------------------------------------------------
   4. NAVIGATION BREAKPOINT: SWITCH TO MOBILE DRAWER (Max 1160px)
   -------------------------------------------------------------------------- */
@media (max-width: 1160px) {
  :root {
    --header-height: 70px;
  }

  body {
    padding-top: var(--header-height);
  }

  /* Completely Hide Desktop Navigation & Show Mobile Hamburger */
  .desktop-nav {
    display: none !important;
  }

  .mobile-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    cursor: pointer;
    background: transparent;
    border: none;
    z-index: 1001;
  }

  /* Header Layout */
  .header-inner {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    width: 100%;
    max-width: 100%;
  }

  .header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  /* Mobile Drawer (Hidden by default; slides in only on toggle) */
  .mobile-nav-drawer {
    display: block !important;
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    left: auto !important;
    width: min(340px, 86vw) !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    background: var(--color-green-dark, #0B2518) !important;
    color: #FFFFFF !important;
    z-index: 2000 !important;
    transform: translateX(105%) !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease, visibility 0.35s ease !important;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 80px 24px 36px 24px !important;
  }

  .mobile-nav-drawer.is-active,
  .mobile-nav-drawer.open,
  .mobile-nav-drawer.is-open {
    transform: translateX(0) !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  /* Grids at 1160px */
  .grid-4, .timeline-grid, .features-grid-4, .pricing-grid-4 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 24px;
  }

  .trust-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

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

  .footer-top, .footer-grid, .bank-details-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 36px;
  }
}

/* --------------------------------------------------------------------------
   5. TABLETS & SMALL LAPTOPS (Max 991px)
   -------------------------------------------------------------------------- */
@media (max-width: 991px) {
  .section {
    padding: 60px 0;
  }

  .section-sm {
    padding: 40px 0;
  }

  /* Stacking Split Layouts Vertically */
  .split-layout, .split-grid, .appraisal-layout-grid, .user-dashboard-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 32px !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .split-content,
  .split-visual,
  .split-image,
  .appraisal-form-card,
  .appraisal-sidebar,
  .user-profile-sidebar,
  .user-dashboard-content {
    flex: 1 1 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .split-visual, .split-image, .appraisal-sidebar {
    order: 2;
  }

  .split-content, .appraisal-form-card {
    order: 1;
  }

  .appraisal-sidebar {
    position: static !important;
  }

  /* News & Resources Hub */
  .resource-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 24px;
  }

  .newsletter-bar {
    grid-template-columns: 1fr !important;
    padding: 32px 24px;
    gap: 24px;
  }

  .featured-law-alert {
    padding: 28px 24px;
  }

  /* Admin Dashboard */
  .admin-sidebar {
    transform: translateX(-100%);
  }

  .admin-sidebar.is-open {
    transform: translateX(0);
  }

  .admin-main-wrap {
    margin-left: 0;
  }

  .admin-sidebar-toggle {
    display: block !important;
  }

  .admin-top-header {
    padding: 0 16px;
  }

  .admin-body-content {
    padding: 20px 16px;
  }
}

/* --------------------------------------------------------------------------
   6. TABLET PORTRAIT & LARGE PHONES (Max 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  :root {
    --header-height: 68px;
  }

  body {
    padding-top: var(--header-height);
  }

  .site-header {
    height: var(--header-height);
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
  }

  .header-inner {
    padding: 0 16px !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Page Hero & Section Headers */
  .hero-section, .hero, .page-hero {
    min-height: auto !important;
    padding: 40px 0 48px 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
    text-align: center;
  }

  .hero-title, .hero h1, .page-hero-title {
    font-size: clamp(1.85rem, 5.5vw, 2.4rem) !important;
    line-height: 1.2 !important;
    margin-bottom: 14px !important;
    word-wrap: break-word !important;
  }

  .hero-desc, .hero p, .page-hero-desc {
    font-size: 0.98rem !important;
    line-height: 1.6 !important;
    margin-bottom: 24px !important;
    max-width: 100% !important;
  }

  .hero-buttons, .hero-actions {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 12px;
  }

  .hero-buttons .btn, .hero-actions .btn {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  /* Multi-Column Grids Collapse to 1 Column */
  .why-grid, .grid-2, .grid-3, .grid-4, .grid-5, .grid-6,
  .services-grid-3, .services-grid-2, .pricing-grid-4, .terms-card-grid, .bank-details-grid,
  .areas-grid, .timeline-grid, .benefits-grid,
  .features-grid, .location-cards-grid,
  .resource-grid {
    grid-template-columns: 1fr !important;
    gap: 20px;
    width: 100% !important;
    max-width: 100% !important;
  }

  .trust-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  /* Forms & Card Layouts */
  .form-grid, .form-row, .admin-form-row {
    grid-template-columns: 1fr !important;
    gap: 16px;
    width: 100% !important;
  }

  .form-card, .appraisal-form-card, .card, .why-card {
    padding: 24px 18px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .form-card h2, .card h2 {
    font-size: 1.4rem !important;
    line-height: 1.25 !important;
  }

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

  /* Form Inputs and Selects */
  .form-input, select.form-input, textarea.form-input {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Controls & Search */
  .resource-controls-wrap {
    padding: 18px;
    margin-top: -24px;
  }

  .resource-search-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .resource-results-count {
    align-self: flex-start;
  }

  .category-filter-nav {
    gap: 8px;
  }

  .category-filter-btn {
    padding: 7px 14px;
    font-size: 0.82rem;
  }

  .law-alert-grid {
    grid-template-columns: 1fr !important;
  }

  .law-alert-actions {
    flex-direction: column;
    width: 100%;
  }

  .law-alert-actions .btn {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  /* Guides Kit & Portals */
  .guides-kit-grid, .gov-portal-grid {
    grid-template-columns: 1fr !important;
  }

  .guides-kit-section {
    padding: 28px 18px;
  }

  .newsletter-form {
    flex-direction: column;
  }

  .newsletter-form button {
    width: 100%;
  }

  /* Footer */
  .footer-top, .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 32px;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
    gap: 16px;
  }

  .footer-legal-links {
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
  }

  /* Modals */
  .modal-container, .admin-modal-content {
    width: calc(100vw - 24px) !important;
    max-height: 90dvh !important;
    margin: 12px auto;
  }

  .modal-body {
    padding: 24px 18px !important;
  }
}

/* --------------------------------------------------------------------------
   7. SMARTPHONES (Max 480px / 430px / 390px)
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .container {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  .header-actions .nav-cta {
    display: none !important; /* Hide quote button in header on small phones; present in mobile drawer */
  }

  .nav-signin-btn {
    padding: 6px 10px !important;
    font-size: 0.78rem !important;
    gap: 4px !important;
  }

  .brand-logo {
    max-width: 140px !important;
  }

  .brand-logo img {
    height: 30px !important;
    width: auto !important;
  }

  .hero-title, .hero h1, .page-hero-title {
    font-size: 1.75rem !important;
    line-height: 1.2 !important;
  }

  .hero-desc, .hero p, .page-hero-desc {
    font-size: 0.92rem !important;
  }

  .section-title {
    font-size: 1.55rem !important;
  }

  .section-tag, .hero-eyebrow, .page-hero-eyebrow {
    font-size: 0.76rem !important;
  }

  .trust-grid {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }

  /* Custom Solution Builder Category Selector */
  .category-radio-group,
  .form-group [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .category-radio-label {
    padding: 10px !important;
    font-size: 0.88rem !important;
  }

  .checkbox-pill-grid, .radio-group-grid {
    grid-template-columns: 1fr !important;
  }

  .card-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .card-footer .btn {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  .btn {
    padding: 12px 18px;
    font-size: 0.9rem;
    width: 100%;
    box-sizing: border-box !important;
  }

  .btn-lg {
    padding: 14px 20px;
    font-size: 0.95rem;
  }

  .faq-question {
    padding: 14px 12px;
    font-size: 0.92rem;
  }

  .faq-answer {
    padding: 0 12px 14px 12px;
    font-size: 0.88rem;
  }

  /* Toast Notification */
  .toast-container {
    right: 12px;
    bottom: 12px;
    left: 12px;
  }

  .toast-message {
    max-width: 100%;
  }

  /* Admin KPI Grid */
  .kpi-grid {
    grid-template-columns: 1fr !important;
    gap: 14px;
  }

  .admin-property-grid {
    grid-template-columns: 1fr !important;
    padding: 16px;
  }
}

/* --------------------------------------------------------------------------
   8. EXTRA SMALL PHONES (Max 360px & 320px)
   -------------------------------------------------------------------------- */
@media (max-width: 360px) {
  .hero-title, .hero h1, .page-hero-title {
    font-size: 1.55rem !important;
  }

  .btn {
    padding: 10px 14px;
    font-size: 0.84rem;
  }

  .form-card, .appraisal-form-card, .card {
    padding: 18px 12px !important;
  }

  .auth-card {
    padding: 24px 14px;
  }

  .brand-logo {
    max-width: 120px !important;
  }

  .brand-logo img {
    height: 28px !important;
  }
}
