/* ============================================================
   Flourish - Mobile CSS Fixes
   Patch untuk memperbaiki masalah border-radius, scroll, dan performa
   ============================================================ */

/* --- GLOBAL MOBILE FIXES --- */
@media (max-width: 768px) {
  /* Fix: Ensure all cards and containers have border-radius on mobile */
  .service-card,
  .program-card,
  .artikel-card,
  .testimonial-card,
  .info-card,
  .gcard,
  .card,
  .popup-promo-modal {
    border-radius: var(--radius-lg) !important;
    overflow: hidden;
  }

  /* Fix: Prevent horizontal scroll caused by wide content */
  body,
  html,
  .container,
  .section,
  section {
    max-width: 100%;
    overflow-x: hidden;
  }

  /* Fix: Remove nested scroll containers */
  .navbar,
  .hero,
  .section {
    overflow-x: visible !important;
  }

  /* Fix: Ensure images don't cause overflow */
  img {
    max-width: 100%;
    height: auto;
  }

  /* Fix: Smooth scrolling for main document only */
  html {
    scroll-behavior: smooth;
    overflow-x: hidden;
  }

  body {
    overflow-x: hidden;
    width: 100%;
  }
}

/* --- NAVIGATION MOBILE FIXES --- */
@media (max-width: 768px) {
  .navbar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    background: linear-gradient(to bottom, #ffffff 0%, #f8f9fa 100%) !important;
    border-bottom: 2px solid #e5e7eb !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12) !important;
    z-index: 1000 !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
  }

  .navbar-inner {
    padding: 0 1rem !important;
    height: 72px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
  }

  .nav-menu {
    position: fixed !important;
    top: 72px !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: #ffffff !important;
    flex-direction: column !important;
    padding: 1.5rem !important;
    border-top: 2px solid #e5e7eb !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15) !important;
    max-height: calc(100vh - 72px) !important;
    height: calc(100vh - 72px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    transition: transform 0.3s ease !important;
    transform: translateY(-100%) !important;
    z-index: 1001 !important;
    -webkit-overflow-scrolling: touch !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0.5rem !important;
  }

  .nav-menu.open {
    transform: translateY(0) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .nav-menu.open li {
    width: 100% !important;
    flex-shrink: 0 !important;
    margin-bottom: 0.5rem !important;
  }

  .nav-link {
    display: block !important;
    padding: 1rem 1.5rem !important;
    font-size: 1.1rem !important;
    border-radius: var(--radius-md) !important;
    text-align: center !important;
  }
  
  .nav-link.active {
    background: var(--green-50) !important;
    border-color: var(--green-500) !important;
    color: var(--green-800) !important;
  }

  .nav-cta {
    margin-left: 0 !important;
    margin-top: 1rem !important;
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
    width: 100% !important;
    border-top: 2px solid #e5e7eb !important;
    flex-shrink: 0 !important;
  }
  
  .nav-cta .btn {
    width: 100% !important;
    justify-content: center !important;
    padding: 1.25rem !important;
    font-size: 1.2rem !important;
  }
}

/* --- HERO SECTION MOBILE FIXES --- */
@media (max-width: 768px) {
  .hero {
    min-height: auto;
    padding: 2rem 0 3rem;
    overflow: visible !important;
  }

  .hero-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .hero-content {
    order: 1;
  }

  .hero-visual {
    order: 2;
    width: 100%;
  }

  .hero-tag {
    font-size: 0.7rem;
    padding: 0.3rem 0.8rem;
  }

  .hero h1 {
    font-size: 1.75rem;
    line-height: 1.2;
  }

  .hero-sub {
    font-size: 0.95rem;
    line-height: 1.6;
  }

  .hero-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .hero-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .hero-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
  }

  .hero-stat-num {
    font-size: 1.25rem;
  }

  .hero-stat-label {
    font-size: 0.7rem;
  }

  /* Fix hero slider on mobile */
  .hslider-outer {
    position: relative;
    width: 100%;
    overflow: visible !important;
  }

  .hero-photo-wrap {
    width: 100%;
    border-radius: var(--radius-lg);
    overflow: hidden;
  }

  .hslide-media {
    border-radius: var(--radius-lg);
  }
}

/* --- SERVICES GRID MOBILE FIXES --- */
@media (max-width: 768px) {
  .services-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .service-card {
    padding: 1.5rem;
    border-radius: var(--radius-lg) !important;
  }

  .service-icon {
    width: 56px;
    height: 56px;
    font-size: 1.5rem;
  }

  .service-card h3 {
    font-size: 1.25rem;
  }

  .service-card p {
    font-size: 0.9rem;
  }
}

/* --- PROGRAM GRID MOBILE FIXES --- */
@media (max-width: 768px) {
  .program-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .program-card {
    padding: 1.5rem;
    border-radius: var(--radius-lg) !important;
  }

  .program-card-head h3 {
    font-size: 1.25rem;
  }

  .program-card-body p {
    font-size: 0.9rem;
  }

  .program-meta {
    flex-wrap: wrap;
  }

  .program-card-foot {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .program-card-foot .btn {
    width: 100%;
    justify-content: center;
  }
}

/* --- ARTIKEL GRID MOBILE FIXES --- */
@media (max-width: 768px) {
  .artikel-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .artikel-card {
    border-radius: var(--radius-lg) !important;
    overflow: hidden;
    display: flex !important;
    flex-direction: row !important;
  }

  .artikel-card-img {
    width: 110px !important;
    min-width: 110px !important;
    flex-shrink: 0;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg) !important;
  }

  .artikel-card-body {
    padding: 1rem 1.25rem !important;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0 !important;
  }

  .artikel-card-body h3 {
    font-size: 1.15rem;
  }

  .artikel-card-body p {
    font-size: 0.9rem;
  }
}

/* --- TESTIMONIAL GRID MOBILE FIXES --- */
@media (max-width: 768px) {
  .testimonial-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .testimonial-card {
    padding: 1.5rem;
    border-radius: var(--radius-lg) !important;
  }

  .testi-text {
    font-size: 0.95rem;
    line-height: 1.7;
  }

  .testi-avatar {
    width: 48px;
    height: 48px;
    font-size: 1rem;
  }

  .testi-name {
    font-size: 0.95rem;
  }

  .testi-role {
    font-size: 0.8rem;
  }
}

/* --- FOOTER MOBILE FIXES --- */
@media (max-width: 768px) {
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .footer-col h4 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
  }

  .footer-links li {
    margin-bottom: 0.5rem;
  }

  .footer-links a {
    font-size: 0.9rem;
    padding: 0.25rem 0;
  }

  .footer-contact-item {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
  }

  .footer-bottom {
    text-align: center;
    padding: 1.5rem 0;
  }

  .footer-bottom .container {
    flex-direction: column;
    gap: 0.5rem;
  }
}

/* --- BUTTONS MOBILE OPTIMIZATION --- */
@media (max-width: 768px) {
  .btn {
    min-height: 48px; /* Touch target size */
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
  }

  .btn-sm {
    min-height: 40px;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }

  .btn-lg {
    min-height: 56px;
    padding: 1rem 2rem;
    font-size: 1rem;
  }
}

/* --- FORM INPUTS MOBILE FIXES --- */
@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  textarea,
  select {
    font-size: 16px; /* Prevents zoom on iOS */
    min-height: 48px;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
  }

  textarea {
    min-height: 120px;
    resize: vertical;
  }
}

/* --- GALLERY MOBILE FIXES --- */
@media (max-width: 768px) {
  .loker-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .gcard {
    border-radius: var(--radius-md) !important;
    overflow: hidden;
  }

  .gcard-media {
    border-radius: var(--radius-md);
  }
}

/* --- SCROLL PERFORMANCE OPTIMIZATION --- */
@media (max-width: 768px) {
  /* Hardware acceleration for smoother scrolling */
  .fade-up,
  .service-card,
  .program-card,
  .artikel-card {
    will-change: transform, opacity;
  }

  /* Remove heavy animations on mobile */
  .fade-up {
    transition: opacity 0.3s ease, transform 0.3s ease;
  }

  /* Optimize images */
  img {
    content-visibility: auto;
  }
}

/* --- PREVENT DOUBLE-TAP ZOOM --- */
@media (max-width: 768px) {
  * {
    touch-action: manipulation;
  }

  a, button, input, select, textarea {
    touch-action: manipulation;
  }
}

/* --- POPOUP PROMO MOBILE FIXES --- */
@media (max-width: 768px) {
  .popup-promo-overlay {
    padding: 0.5rem;
  }

  .popup-promo-modal {
    max-width: 95%;
    max-height: 85vh;
    border-radius: var(--radius-xl) !important;
  }

  .popup-promo-close {
    width: 40px;
    height: 40px;
    top: 0.5rem;
    right: 0.5rem;
  }

  .popup-promo-img-mobile {
    max-height: 80vh;
    border-radius: var(--radius-lg);
  }
}

/* --- LOADING PERFORMANCE --- */
@media (max-width: 768px) {
  /* Reduce shadows for better performance */
  .service-card,
  .program-card,
  .artikel-card,
  .testimonial-card {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  }

  .service-card:hover,
  .program-card:hover,
  .artikel-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  }
}

/* --- FIX SCROLL CONTAINERS --- */
@media (max-width: 768px) {
  /* Only main html should scroll */
  html {
    overflow-y: scroll;
    overflow-x: hidden;
  }

  body {
    overflow-x: hidden;
  }

  /* Horizontal scroll only for filter bars */
  .program-filter-bar,
  .loker-tabs {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0;
    margin-bottom: 0;
    border-bottom: 1px solid var(--gray-200);
  }
  .loker-tabs::-webkit-scrollbar {
    display: none;
  }

  /* Remove overflow from sections */
  section,
  .section,
  .container {
    overflow: visible !important;
  }
}

/* --- BORDER RADIUS CONSISTENCY --- */
@media (max-width: 768px) {
  /* Ensure all cards have consistent border-radius */
  [class*="card"],
  .gcard,
  .info-card,
  .popup-promo-modal,
  .lightbox-content {
    border-radius: var(--radius-lg) !important;
  }

  /* Images inside cards */
  [class*="card"] img,
  .gcard img {
    border-radius: inherit;
  }
}

/* --- TOUCH OPTIMIZATIONS --- */
@media (max-width: 768px) {
  /* Larger touch targets */
  a, button {
    min-width: 44px;
    min-height: 44px;
  }

  /* Remove hover effects that don't work on touch */
  .btn:hover,
  .nav-link:hover,
  .service-card:hover {
    transform: none;
  }

  /* Active states instead */
  .btn:active,
  .nav-link:active,
  .service-card:active {
    transform: scale(0.98);
  }
}
