/**
 * Mind Fitness - Mobile Fixes
 * Responsive fixes for mobile devices
 */

/* =====================================================
   Global Mobile Scaling — ย่อขนาด font, padding, spacing
   ทำให้ทุกหน้าดู compact ขึ้นบนมือถือ
   ===================================================== */
@media (max-width: 768px) {
  body {
    font-size: 14px !important;
  }

  h1 {
    font-size: 26px !important;
    line-height: 1.3 !important;
  }

  h2 {
    font-size: 22px !important;
    line-height: 1.3 !important;
  }

  h3 {
    font-size: 17px !important;
  }

  h4 {
    font-size: 15px !important;
  }

  p {
    font-size: 14px !important;
    line-height: 1.6 !important;
  }

  section {
    padding: 40px 16px !important;
  }

  .container {
    padding: 20px 14px !important;
  }

  .btn-primary,
  .btn-outline,
  .btn-gold,
  .btn-cta-hero {
    padding: 12px 24px !important;
    font-size: 14px !important;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 22px !important;
  }

  h2 {
    font-size: 19px !important;
  }

  h3 {
    font-size: 16px !important;
  }

  p {
    font-size: 13px !important;
  }

  section {
    padding: 30px 14px !important;
  }

  .btn-primary,
  .btn-outline,
  .btn-gold,
  .btn-cta-hero {
    padding: 10px 20px !important;
    font-size: 13px !important;
  }
}

/* =====================================================
   Tablet Scaling (iPad portrait ~768-1024px)
   iPad ได้ desktop styles แต่จอแคบ ต้องย่อลงเล็กน้อย
   ===================================================== */
@media (min-width: 769px) and (max-width: 1024px) {
  body {
    font-size: 15px !important;
  }

  h1 {
    font-size: 32px !important;
    line-height: 1.3 !important;
  }

  h2 {
    font-size: 26px !important;
    line-height: 1.3 !important;
  }

  h3 {
    font-size: 18px !important;
  }

  p {
    font-size: 15px !important;
  }

  section {
    padding: 50px 24px !important;
  }

  .container {
    padding: 24px 20px !important;
  }

  .btn-primary,
  .btn-outline,
  .btn-gold,
  .btn-cta-hero {
    padding: 14px 28px !important;
    font-size: 15px !important;
  }
}

/* Mobile Navigation Fix */
@media (max-width: 768px) {
  .nav-toggle {
    display: block !important;
    background: #0B1E47 !important;
    color: #fff !important;
    border: none !important;
    padding: 12px 16px !important;
    font-size: 24px !important;
    border-radius: 10px !important;
    cursor: pointer !important;
    z-index: 10000 !important;
  }

  #primary-nav,
  .nav {
    display: none !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: #fff !important;
    z-index: 9999 !important;
    padding: 80px 20px 20px !important;
    flex-direction: column !important;
    overflow-y: auto !important;
  }

  #primary-nav.active,
  .nav.active {
    display: flex !important;
  }

  .nav__list {
    flex-direction: column !important;
    width: 100% !important;
    gap: 0 !important;
  }

  .nav__link {
    display: block !important;
    padding: 18px 20px !important;
    font-size: 18px !important;
    border-bottom: 1px solid #f0f0f0 !important;
  }

  /* Hero sections */
  .hero-grid {
    flex-direction: column !important;
    text-align: center;
  }

  .hero__inner {
    grid-template-columns: 1fr !important;
    text-align: center;
  }

  .hero__title {
    font-size: 28px !important;
  }

  .hero-buttons {
    justify-content: center;
  }

  .hero__media {
    order: -1;
  }

  .hero__media img {
    max-width: 250px !important;
  }

  /* Grid layouts */
  .ecosystem-grid,
  .services-grid,
  .components-grid,
  .framework-grid {
    grid-template-columns: 1fr !important;
  }

  /* Flow steps */
  .flow-steps {
    flex-direction: column !important;
    align-items: center;
  }

  .flow-step::after {
    display: none !important;
  }

  .flow-visual {
    flex-direction: column !important;
  }

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

  /* Component rows */
  .component-row {
    flex-direction: column !important;
  }

  .component-row:nth-child(even) {
    flex-direction: column !important;
  }

  /* Forms */
  .form-row {
    grid-template-columns: 1fr !important;
  }

  /* CTA buttons */
  .cta-buttons {
    flex-direction: column;
    align-items: center;
  }

  /* Footer */
  .footer-links {
    flex-direction: column;
    gap: 12px;
  }

  /* Footer logos — keep horizontal, smaller on mobile */
  .site-footer > div:first-child {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: center !important;
    gap: 12px !important;
    margin-bottom: 16px !important;
  }

  .site-footer > div:first-child img {
    height: 30px !important;
    width: auto !important;
  }

  .site-footer > div:first-child a,
  .site-footer > div:first-child > div {
    padding: 8px 12px !important;
  }
}

/* Small mobile */
@media (max-width: 480px) {
  .header__inner {
    padding: 12px 16px;
  }

  .brand__name {
    font-size: 18px !important;
  }

  .brand__logo {
    width: 36px !important;
    height: 36px !important;
  }

  section {
    padding: 40px 16px !important;
  }
}

/* Fix for iOS Safari */
@supports (-webkit-touch-callout: none) {
  .nav.active {
    height: -webkit-fill-available;
  }
}

/* Fix tap highlight on mobile */
* {
  -webkit-tap-highlight-color: transparent;
}

/* Improve touch targets */
button,
.btn-primary,
.btn-outline,
a.nav__link {
  min-height: 44px;
}

/* MindSpace Ecosystem - Mobile Fix */
@media (max-width: 768px) {
  /* Hide orbit animation on mobile */
  .mindspace-orbit-container {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
  }

  /* Show mobile grid instead */
  .mindspace-mobile-grid {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  /* Mobile center card styling */
  .mindspace-mobile-grid .mobile-center-card,
  .mindspace-mobile-grid > a:first-child {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    background: linear-gradient(135deg, #0B1E47, #1e3a5f) !important;
    border-radius: 20px !important;
    padding: 30px !important;
    text-decoration: none !important;
    margin-bottom: 20px !important;
  }

  /* Mobile features grid */
  .mindspace-mobile-grid .mobile-features-grid,
  .mindspace-mobile-grid > div:last-child {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 12px !important;
  }

  /* Feature cards in mobile grid */
  .mindspace-mobile-grid .mobile-features-grid a,
  .mindspace-mobile-grid > div:last-child > a {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    background: #f8fafc !important;
    border-radius: 16px !important;
    padding: 16px 8px !important;
    text-decoration: none !important;
  }

  .mindspace-mobile-grid .mobile-features-grid a:hover {
    background: #e0f2fe !important;
    transform: translateY(-2px);
  }

  /* Ecosystem section padding */
  #mindspace-section.ecosystem {
    padding: 60px 16px 80px !important;
  }
}

/* Small mobile - 2 columns for ecosystem */
@media (max-width: 400px) {
  .mindspace-mobile-grid .mobile-features-grid,
  .mindspace-mobile-grid > div:last-child {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  .mindspace-mobile-grid .mobile-features-grid a img,
  .mindspace-mobile-grid > div:last-child > a img {
    width: 40px !important;
    height: 40px !important;
  }

  .mindspace-mobile-grid .mobile-features-grid a span,
  .mindspace-mobile-grid > div:last-child > a span {
    font-size: 10px !important;
  }
}

/* Psychologist Carousel - Mobile Responsive */
@media (max-width: 768px) {
  /* Carousel container */
  #psychCarouselTrack {
    overflow-x: auto !important;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 10px 20px !important;
    margin: 0 -20px;
  }

  #psychCarouselTrack::-webkit-scrollbar {
    display: none;
  }

  /* Psychologist cards on mobile */
  #psychCarouselTrack > div {
    min-width: 260px !important;
    max-width: 260px !important;
    scroll-snap-align: center;
    padding: 24px 20px !important;
  }

  /* Nav buttons - smaller and repositioned */
  #psychPrevBtn,
  #psychNextBtn {
    width: 40px !important;
    height: 40px !important;
    top: 45% !important;
  }

  #psychPrevBtn {
    left: 4px !important;
  }

  #psychNextBtn {
    right: 4px !important;
  }

  /* Header text adjustments */
  section[style*="linear-gradient(135deg,#00A8A8"] h2 {
    font-size: 28px !important;
  }

  section[style*="linear-gradient(135deg,#00A8A8"] p {
    font-size: 15px !important;
  }

  /* Stats section - stack vertically */
  section[style*="linear-gradient(135deg,#00A8A8"] > div > div:last-child {
    flex-direction: column !important;
    gap: 20px !important;
  }

  section[style*="linear-gradient(135deg,#00A8A8"] > div > div:last-child > div:first-child {
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: 20px !important;
  }

  /* Stats numbers smaller */
  #psychCount,
  section[style*="linear-gradient(135deg,#00A8A8"] div[style*="font-size:36px"] {
    font-size: 28px !important;
  }

  /* CTA button - full width */
  section[style*="linear-gradient(135deg,#00A8A8"] a[href="psychologist.html"] {
    padding: 16px 32px !important;
    font-size: 16px !important;
    width: 100%;
    max-width: 280px;
    justify-content: center;
  }
}

/* Very small screens */
@media (max-width: 380px) {
  #psychCarouselTrack > div {
    min-width: 240px !important;
    max-width: 240px !important;
    padding: 20px 16px !important;
  }

  #psychCarouselTrack > div div[style*="font-size:24px"] {
    font-size: 20px !important;
  }

  .psychologist-avatar {
    width: 72px !important;
    height: 72px !important;
  }

  .psychologist-avatar img {
    width: 72px !important;
    height: 72px !important;
  }
}
