/**
 * Mobile Styles for Health Planet Psychotherapy
 * Simple, professional mobile enhancements
 * Only applies on screens ≤ 768px
 */

@media (max-width: 768px) {
  /* ============================================
     VIEWPORT HANDLING - MOBILE OPTIMIZATION
     ============================================ */

  html {
    font-size: 16px;
    /* Prevent iOS zoom on input focus */
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* Prevent horizontal scroll */
    overflow-x: hidden;
    width: 100%;
    /* Safe area insets handled by body and specific elements */
  }

  /* Fix for iOS Safari viewport height and width issues */
  :root {
    --vh: 1vh;
    --vw: 1vw;
    --100vw: 100vw;
    --100vh: 100vh;
    --body-width: 100%;
  }

  /* Ensure full viewport height on mobile */
  html {
    height: 100%;
    min-height: -webkit-fill-available;
  }

  body {
    overflow-x: hidden;
    /* Handle safe area insets */
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    /* Bottom padding so floating chat buttons don't cover content */
    padding-bottom: 80px;
    max-width: 100vw;
    /* GPU-accelerated smooth scrolling on iOS */
    -webkit-overflow-scrolling: touch;
  }

  /* Prevent scrolling when mobile menu is open */
  body.menu-open {
    overflow: hidden;
  }

  /* Fix for containers that might overflow */
  .container,
  section {
    overflow-x: hidden;
  }

  /* ============================================
     CONTAINER & SPACING
     ============================================ */

  .container {
    padding-left: var(--hp-spacing-md);
    padding-right: var(--hp-spacing-md);
    max-width: 100%;
    width: 100%;
    /* Body already handles safe area insets, so containers just need normal padding */
  }

  /* ============================================
     SERVICES SECTION - MOBILE GRID
     ============================================ */

  .services-container {
    padding: 0;
  }

  .services-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--hp-spacing-lg);
    width: 100%;
    padding: 0;
  }

  .service-card {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
  }

  .service-image-wrapper {
    height: 200px;
  }

  .service-content {
    padding: var(--hp-spacing-lg);
  }

  .service-title {
    font-size: 1.25rem;
    margin-bottom: var(--hp-spacing-sm);
  }

  .service-subtitle {
    font-size: 0.95rem;
    margin-bottom: var(--hp-spacing-sm);
  }

  .service-signs {
    font-size: 0.9rem;
  }

  /* ============================================
     TYPOGRAPHY - MOBILE OPTIMIZATION
     ============================================ */

  h1 {
    font-size: 2rem;
    line-height: 1.2;
  }

  h2 {
    font-size: 1.75rem;
    line-height: 1.3;
  }

  h3 {
    font-size: 1.5rem;
    line-height: 1.3;
  }

  h4 {
    font-size: 1.25rem;
  }

  h5 {
    font-size: 1.125rem;
  }

  h6 {
    font-size: 1rem;
  }

  /* ============================================
     NAVIGATION - MOBILE MENU (CRITICAL FIX)
     ============================================ */

  .navbar {
    height: 60px;
    padding: 0 var(--hp-spacing-md);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.98);
  }

  .nav-content {
    height: 60px;
  }

  /* Hamburger button */
  .mobile-menu-toggle {
    display: flex !important;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 1002;
    position: relative;
  }

  .mobile-menu-toggle span {
    width: 24px;
    height: 2px;
    background: var(--hp-green-dark);
    transition: all 0.3s ease;
    display: block;
    transform-origin: center;
  }

  /* Hamburger → X animation */
  .mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
  }

  .mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
  }

  .mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
  }

  /* Mobile slide-in menu */
  .nav-menu {
    position: fixed !important;
    top: 60px !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    background: #ffffff !important;
    flex-direction: column !important;
    padding: var(--hp-spacing-xl) !important;
    gap: var(--hp-spacing-md) !important;
    transform: translateX(100%) !important;
    -webkit-transform: translateX(100%) !important;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
    z-index: 999 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.1) !important;
    will-change: transform;
  }

  .nav-menu.active {
    transform: translateX(0) !important;
    -webkit-transform: translateX(0) !important;
  }

  .nav-menu li {
    width: 100%;
    list-style: none;
  }

  .nav-menu .nav-link {
    display: block;
    padding: 14px 16px;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--hp-text-primary);
    border-radius: 8px;
    transition: background 0.2s ease;
  }

  .nav-menu .nav-link:hover,
  .nav-menu .nav-link.active {
    background: rgba(34, 197, 94, 0.08);
    color: var(--hp-green-dark);
  }

  .nav-menu .nav-cta {
    width: 100%;
    text-align: center;
    margin-top: var(--hp-spacing-md);
  }

  .logo-image {
    height: 40px;
    width: auto;
    max-width: 150px;
    object-fit: contain;
    flex-shrink: 0;
  }

  .logo-text {
    display: flex;
    flex-direction: column;
  }

  .logo-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--hp-green-dark);
    line-height: 1.2;
  }

  .logo-tagline {
    font-size: 0.65rem;
    color: var(--hp-text-muted);
    line-height: 1.2;
  }

  .footer-logo-image {
    height: 50px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
    flex-shrink: 0;
  }

  .footer-logo .logo-text {
    display: flex;
    flex-direction: column;
  }

  .footer-logo .logo-name {
    font-size: 1.25rem;
    color: var(--hp-text-white);
    font-weight: 700;
  }

  .footer-logo .logo-tagline {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
  }


  /* ============================================
     BUTTONS - TOUCH FRIENDLY
     ============================================ */

  button,
  .btn-primary,
  .btn-secondary,
  .btn-hero,
  a.btn-primary,
  a.btn-secondary {
    min-height: 44px;
    min-width: 44px;
    padding: 14px 24px;
    font-size: 1rem;
  }

  .btn-hero {
    width: 100%;
    margin-bottom: var(--hp-spacing-md);
  }

  /* ============================================
     FORMS - MOBILE OPTIMIZATION
     ============================================ */

  .form-input,
  .form-textarea,
  .form-select {
    font-size: 16px !important;
    /* Prevent iOS zoom */
    padding: 12px 16px;
    width: 100%;
  }

  .form-group {
    margin-bottom: var(--hp-spacing-lg);
  }

  /* ============================================
     CARDS - MOBILE LAYOUT
     ============================================ */

  .location-card,
  .testimonial-card,
  .review-card {
    width: 100%;
    margin-bottom: var(--hp-spacing-lg);
  }

  /* ============================================
     SECTIONS - MOBILE SPACING
     ============================================ */

  section {
    padding: var(--hp-spacing-3xl) 0;
  }

  .section-header {
    margin-bottom: var(--hp-spacing-xl);
    text-align: center;
  }

  .section-title {
    font-size: 1.75rem;
    margin-bottom: var(--hp-spacing-sm);
  }

  .section-subtitle {
    font-size: 1rem;
  }

  /* ============================================
     HERO SECTION - MOBILE
     ============================================ */

  .hero {
    min-height: 100vh;
    padding: var(--hp-spacing-2xl) var(--hp-spacing-md);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
  }

  .hero-title {
    font-size: 2rem;
    margin-bottom: var(--hp-spacing-lg);
  }

  .hero-subtitle {
    font-size: 1rem;
    margin-bottom: var(--hp-spacing-xl);
  }

  /* ============================================
     GRID LAYOUTS - MOBILE SINGLE COLUMN
     ============================================ */

  .locations-grid,
  .about-content,
  .donation-content,
  .contact-content {
    grid-template-columns: 1fr;
    gap: var(--hp-spacing-lg);
  }

  /* ============================================
     IMAGES - RESPONSIVE
     ============================================ */

  img {
    max-width: 100%;
    height: auto;
    display: block;
  }

  /* ============================================
     FOOTER - MOBILE
     ============================================ */

  .footer {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    padding: var(--hp-spacing-2xl) var(--hp-spacing-md) var(--hp-spacing-lg);
    box-sizing: border-box;
  }

  .footer .container {
    width: 100%;
    max-width: 100%;
    padding-left: var(--hp-spacing-md);
    padding-right: var(--hp-spacing-md);
    box-sizing: border-box;
  }

  .footer-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--hp-spacing-xl);
    width: 100%;
    max-width: 100%;
    margin-bottom: var(--hp-spacing-xl);
    text-align: center;
    box-sizing: border-box;
  }

  .footer-section {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0;
  }

  .footer-brand {
    width: 100%;
    max-width: 100%;
  }

  .footer-logo {
    width: 100%;
    max-width: 100%;
    justify-content: center;
    margin-bottom: var(--hp-spacing-md);
    flex-wrap: wrap;
  }

  .footer-logo-image {
    max-width: 100%;
    height: auto;
  }

  .footer-description {
    width: 100%;
    max-width: 100%;
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: var(--hp-spacing-lg);
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-sizing: border-box;
  }

  .footer-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--hp-spacing-md);
    text-align: center;
  }

  .footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
    max-width: 100%;
  }

  .footer-links li {
    width: 100%;
    max-width: 100%;
    margin-bottom: var(--hp-spacing-sm);
    box-sizing: border-box;
  }

  .footer-links a {
    display: block;
    width: 100%;
    max-width: 100%;
    padding: var(--hp-spacing-xs) 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-sizing: border-box;
  }

  .footer-contact {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
    max-width: 100%;
  }

  .footer-contact-item {
    width: 100%;
    max-width: 100%;
    margin-bottom: var(--hp-spacing-md);
    display: flex;
    align-items: flex-start;
    gap: var(--hp-spacing-sm);
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-sizing: border-box;
  }

  .footer-contact-item svg {
    flex-shrink: 0;
    margin-top: 2px;
  }

  .footer-contact-item a,
  .footer-contact-item span {
    flex: 1;
    min-width: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    font-size: 0.9rem;
    line-height: 1.5;
  }

  .footer-social {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--hp-spacing-sm);
    margin-top: var(--hp-spacing-md);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .social-link {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .footer-divider {
    width: 100%;
    max-width: 100%;
    margin: var(--hp-spacing-xl) 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-sizing: border-box;
  }

  .footer-bottom {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .footer-bottom-content {
    display: flex;
    flex-direction: column;
    gap: var(--hp-spacing-md);
    text-align: center;
    width: 100%;
    max-width: 100%;
    align-items: center;
    box-sizing: border-box;
  }

  .footer-copyright {
    width: 100%;
    max-width: 100%;
    text-align: center;
    font-size: 0.85rem;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-sizing: border-box;
  }

  .footer-legal {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: var(--hp-spacing-xs);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .footer-legal a {
    font-size: 0.85rem;
    white-space: nowrap;
  }

  .footer-separator {
    color: rgba(255, 255, 255, 0.5);
    margin: 0 var(--hp-spacing-xs);
  }

  /* ============================================
     CONTACT SECTION - MOBILE
     ============================================ */

  /* Hide contact-info section (Phone, Locations, Email, Website) in mobile view */
  .contact .contact-info {
    display: none !important;
  }

  /* Ensure contact form takes full width on mobile */
  .contact .contact-form {
    width: 100%;
    max-width: 100%;
  }

  /* ============================================
     UTILITIES - MOBILE
     ============================================ */

  /* Smooth scrolling */
  html {
    scroll-behavior: smooth;
  }

  /* Touch action optimization */
  a,
  button {
    touch-action: manipulation;
  }

  /* Fix for fixed elements on mobile */
  .navbar {
    width: 100%;
    max-width: 100%;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    /* Ensure fixed elements don't cause horizontal scroll */
    left: 0;
    right: 0;
  }

  /* ============================================
     CHAT BUTTON - MOBILE (ICON ONLY, BOTTOM LEFT)
     ============================================ */

  .floating-chat-container {
    position: fixed !important;
    bottom: 16px !important;
    left: 16px !important;
    right: auto !important;
    z-index: 9999 !important;
    width: auto !important;
    max-width: none !important;
  }

  .chat-button {
    width: auto !important;
    min-width: auto !important;
    max-width: calc(100vw - 120px) !important;
    height: 48px !important;
    min-height: 48px !important;
    padding: 12px 16px !important;
    border-radius: 50px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    box-shadow: 0 4px 20px rgba(34, 197, 94, 0.5) !important;
  }

  .chat-button-text {
    display: inline-block !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
    color: white !important;
  }

  .chat-icon-wrapper {
    margin: 0 !important;
    flex-shrink: 0 !important;
  }

  .chat-icon {
    width: 20px !important;
    height: 20px !important;
    flex-shrink: 0 !important;
  }

  /* Ensure Tawk.to doesn't overlap chat button on mobile */
  #tawkchat-container {
    bottom: 16px !important;
    right: 16px !important;
    left: auto !important;
    z-index: 9998 !important;
  }

  /* Fix for full-width sections */
  section {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  /* Fix for hero section viewport width */
  .hero {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  /* Prevent text selection issues on mobile */
  input,
  textarea,
  select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: 0;
  }

  /* Fix for iOS Safari input zoom */
  @supports (-webkit-touch-callout: none) {

    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    input[type="password"],
    input[type="search"],
    textarea,
    select {
      font-size: 16px !important;
    }
  }
}

/* ============================================
   VERY SMALL SCREENS (≤ 480px)
   ============================================ */

@media (max-width: 480px) {
  .container {
    padding-left: var(--hp-spacing-sm);
    padding-right: var(--hp-spacing-sm);
  }

  .hero-title {
    font-size: 1.75rem;
  }

  .section-title {
    font-size: 1.5rem;
  }

  .service-title {
    font-size: 1.125rem;
  }

  button,
  .btn-primary,
  .btn-secondary {
    padding: 12px 20px;
    font-size: 0.9375rem;
  }
}