/* 
==============================================
OPTIMASI MOBILE UNTUK KARANG TARUNA GIANYAR
==============================================
*/

/* Optimasi global */
@media (max-width: 991.98px) {
  body {
    font-size: 14px;
    padding-top: 60px !important; /* Menyesuaikan dengan ketinggian navbar mobile */
  }
  
  h1, .h1 {
    font-size: 1.8rem !important;
  }
  
  h2, .h2 {
    font-size: 1.5rem !important;
  }
  
  h3, .h3 {
    font-size: 1.3rem !important;
  }
  
  .container {
    padding-left: 15px;
    padding-right: 15px;
  }
  
  .section-padding {
    padding: 40px 0;
  }
  
  /* Memperkecil shadow untuk performa render lebih baik */
  .card, .shadow-lg, .shadow-sm {
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1) !important;
  }
}

/* Optimasi Navbar Mobile */
/* Mobile Carousel Optimization */
@media (max-width: 767.98px) {
    #heroCarousel {
        margin-top: -60px !important;
    }
    
    /* Tinggi carousel yang optimal untuk mobile */
    .carousel-image-container {
        height: 280px !important;
    }
    
    /* Pastikan image tidak zoom berlebihan */
    .carousel-img {
        object-fit: cover !important;
        object-position: center center !important;
        transform: none !important;
    }
    
    /* Mobile caption positioning */
    .mobile-caption-content {
        background: linear-gradient(
            transparent,
            rgba(0, 0, 0, 0.7) 50%,
            rgba(0, 0, 0, 0.9) 100%
        );
        padding: 1.5rem 1rem 1rem;
    }
    
    /* Touch-friendly controls */
    .carousel-control-prev,
    .carousel-control-next {
        width: 15%;
    }
    
    .carousel-control-prev-icon,
    .carousel-control-next-icon {
        width: 2rem;
        height: 2rem;
    }

  
  .navbar-toggler {
    padding: 8px;
    margin-right: 10px;
    min-width: 44px;
    min-height: 44px;
  }
  
  .navbar-collapse {
    margin-top: 10px !important;
    padding: 15px !important;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    background-color: var(--primary-blue) !important;
  }
  
  .navbar-nav .nav-link {
    padding: 12px 15px !important;
    border-radius: 8px;
  }
  
  .navbar-nav .nav-link:hover,
  .navbar-nav .nav-link.active {
    background: rgba(255, 255, 255, 0.1);
  }
  
  .navbar-nav .nav-link::after {
    display: none;
  }
  
  /* Tombol bergabung pada mobile */
  .navbar-nav .btn-accent {
    width: 100%;
    text-align: center;
    margin-top: 10px;
    padding: 12px !important;
  }
  
  /* Hero Carousel Fix */
  #heroCarousel {
    margin-top: -60px !important; /* Sesuaikan dengan tinggi navbar di mobile */
  }
  
  .hero-img {
    height: 80vh !important;
    object-fit: cover;
  }
  
  .main-caption {
    bottom: 0;
    padding: 1.5rem 0.75rem;
  }
  
  .main-caption h1 {
    font-size: 1.5rem !important;
    margin-bottom: 0.5rem;
  }
  
  .main-caption .lead {
    font-size: 0.875rem !important;
    margin-bottom: 1rem;
  }
  
  .caption-buttons {
    flex-direction: column;
    width: 100%;
  }
  
  .caption-buttons .btn {
    width: 100%;
    margin-bottom: 8px;
    padding: 8px 16px;
    font-size: 0.875rem;
  }
  
  .hero-wave {
    display: none; /* Sembunyikan wave di mobile untuk memperbaiki layout */
  }
  
  /* Perbaikan padding global pada mobile */
  .container {
    padding-left: 15px;
    padding-right: 15px;
  }
  
  /* Fix untuk konten beranda */
  .recent-articles .col-md-6 {
    margin-bottom: 15px;
  }
  
  .featured-article .card-img-top {
    height: 250px !important;
  }
    
  .featured-article h3 {
    font-size: 1.25rem;
  }
  
  /* Touch-friendly buttons */
  .btn {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* Sidebar lebih ramping di mobile */
  .card-header {
    padding: 0.75rem 1rem;
  }
  
  .card-body {
    padding: 1rem;
  }
  
  /* Quick Links berukuran lebih kecil */
  .quick-link-icon {
    width: 50px !important;
    height: 50px !important;
  }
  
  .quick-link-icon i {
    font-size: 1.25rem !important;
  }
}

/* Fix untuk Phone Landscape */
@media (max-width: 767.98px) and (orientation: landscape) {
  .hero-img {
    height: 120vh !important;
  }
  
  .main-caption {
    padding: 1rem 0.5rem;
  }
}

/* Perbaikan untuk perangkat dengan layar sangat kecil */
@media (max-width: 359.98px) {
  body {
    font-size: 0.9rem;
  }
  
  h1, .h1 {
    font-size: 1.5rem !important;
  }
  
  h2, .h2 {
    font-size: 1.3rem !important;
  }
  
  .lead {
    font-size: 1rem;
  }
  
  .btn {
    font-size: 0.875rem;
  }
  
  .navbar-brand .kt-text {
    font-size: 10px;
  }
  
  .navbar-brand .gianyar-text {
    font-size: 12px;
  }
  
  #mainNav .logo {
    height: 28px;
  }
}

/* Tombol back-to-top lebih besar untuk touch */
.btn-to-top {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: var(--primary-blue);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 99;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
}

.btn-to-top:hover {
  background-color: var(--secondary-teal);
  transform: translateY(-5px);
}

/* Form yang lebih touch-friendly */
@media (max-width: 767.98px) {
  input, select, textarea, .form-control {
    font-size: 16px !important; /* Mencegah zoom pada iOS */
    padding: 12px 15px;
    min-height: 44px;
  }
  
  /* Memperbaiki tata letak footer di mobile */
  .footer-area {
    margin-top: 40px;
  }

  .footer-links h4 {
    font-size: 1.1rem;
  }
  
  .social-icon {
    width: 40px;
    height: 40px;
  }
}

/* Fix untuk modal pada mobile */
@media (max-width: 767.98px) {
  .modal-dialog {
    margin: 10px;
  }
  
  .modal-content {
    border-radius: 15px;
  }
  
  .modal-header {
    padding: 15px;
  }
  
  .modal-body {
    padding: 15px;
  }
  
  .modal-footer {
    padding: 10px 15px;
  }
}

/* MOBILE RESPONSIVE FIX - Hapus Overlay Kosong & Perfect Mobile Display */

/* Reset untuk menghapus konflik dengan CSS lama */
.carousel-caption {
    display: none !important; /* Hapus caption Bootstrap default */
}

/* Mobile First Approach - Responsive Fixes */
@media (max-width: 767.98px) {
    
    /* 1. Carousel positioning yang tepat */
    #heroCarousel {
        margin-top: -60px !important; /* Sesuaikan dengan navbar mobile */
        position: relative !important;
        z-index: 1 !important;
    }
    
    /* 2. Image container mobile optimized */
    .carousel-image-container {
        height: 280px !important;
        position: relative !important;
        overflow: hidden !important;
    }
    
    /* 3. Image mobile styling */
    .carousel-img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        object-position: center !important;
        transform: none !important; /* Hindari zoom effect */
    }
    
    /* 4. Overlay mobile - pastikan tidak kosong */
    .carousel-overlay {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        background: linear-gradient(
            to bottom,
            transparent 0%,
            rgba(0, 0, 0, 0.3) 50%,
            rgba(0, 0, 0, 0.8) 100%
        ) !important;
        z-index: 1 !important;
    }
    
    /* 5. HIDE desktop caption di mobile */
    .carousel-caption-desktop {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }
    
    /* 6. SHOW mobile caption dengan konten */
    .carousel-caption-mobile {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: absolute !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 3 !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    /* 7. Mobile caption content styling */
    .mobile-caption-content {
        background: rgba(0, 0, 0, 0.9) !important;
        padding: 1.2rem 1rem !important;
        text-align: center !important;
        border-top: 2px solid #ffc107 !important;
        margin: 0 !important;
    }
    
    /* 8. Mobile caption text */
    .mobile-caption-content h2 {
        font-size: 1.2rem !important;
        color: white !important;
        margin-bottom: 0.6rem !important;
        font-weight: 600 !important;
        text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8) !important;
        line-height: 1.3 !important;
    }
    
    .mobile-caption-content p {
        font-size: 0.9rem !important;
        color: rgba(255, 255, 255, 0.9) !important;
        margin-bottom: 1rem !important;
        line-height: 1.4 !important;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.6) !important;
    }
    
    /* 9. Mobile buttons */
    .mobile-buttons {
        display: flex !important;
        justify-content: center !important;
        gap: 0.6rem !important;
        flex-wrap: wrap !important;
        margin-top: 0.8rem !important;
    }
    
    .mobile-buttons .btn {
        font-size: 0.8rem !important;
        padding: 0.5rem 1rem !important;
        border-radius: 20px !important;
        font-weight: 500 !important;
    }
    
    .mobile-buttons .btn-primary {
        background-color: #0d6efd !important;
        border-color: #0d6efd !important;
    }
    
    .mobile-buttons .btn-outline-light {
        color: white !important;
        border-color: rgba(255, 255, 255, 0.8) !important;
    }
    
    /* 10. Carousel controls mobile */
    .carousel-control-prev,
    .carousel-control-next {
        width: 15% !important;
        opacity: 0.8 !important;
        z-index: 4 !important;
    }
    
    .carousel-control-prev-icon,
    .carousel-control-next-icon {
        width: 2rem !important;
        height: 2rem !important;
        background-color: rgba(0, 0, 0, 0.6) !important;
        border-radius: 50% !important;
    }
    
    /* 11. Indicators mobile */
    .carousel-indicators {
        bottom: 10px !important;
        z-index: 4 !important;
    }
    
    .carousel-indicators [data-bs-target] {
        width: 8px !important;
        height: 8px !important;
        margin: 0 2px !important;
    }
    
    .carousel-indicators .active {
        width: 20px !important;
        border-radius: 10px !important;
    }
}

/* Extra small mobile devices */
@media (max-width: 575.98px) {
    #heroCarousel {
        margin-top: -55px !important;
    }
    
    .carousel-image-container {
        height: 250px !important;
    }
    
    .mobile-caption-content {
        padding: 1rem 0.8rem !important;
    }
    
    .mobile-caption-content h2 {
        font-size: 1.1rem !important;
    }
    
    .mobile-caption-content p {
        font-size: 0.85rem !important;
    }
    
    .mobile-buttons .btn {
        font-size: 0.75rem !important;
        padding: 0.4rem 0.8rem !important;
    }
}

/* Desktop - pastikan tidak ada interferensi */
@media (min-width: 768px) {
    /* Hide mobile caption di desktop */
    .carousel-caption-mobile {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }
    
    /* Show desktop caption */
    .carousel-caption-desktop {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}

/* Debugging helper - hapus setelah fix */
.carousel-fixed {
    border: 2px solid green; /* Temporary - untuk memastikan fix applied */
}

/* Remove debugging border setelah konfirmasi */
/*.carousel-fixed {
    border: none;
}*/

