/* ============================================
   RESPONSIVE FIX - Konsistensi di Semua Device
   ============================================ */

/* Base Reset untuk Konsistensi */
* {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    font-size: 16px;
}

body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    position: relative;
}

/* Container Global - Only apply to containers without specific max-width */
.container:not([style*="max-width"]) {
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}

/* Prevent Horizontal Scroll - Only for Bootstrap rows */
.row:not(.service-card-inner) {
    margin-right: -15px;
    margin-left: -15px;
}

.row:not(.service-card-inner) > * {
    padding-right: 15px;
    padding-left: 15px;
}

/* Image Responsive */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Viewport Specific Fixes */
@media (max-width: 1400px) {
    .container:not(.layanan-section .container):not(.layanan-cta-section .container):not(.services-intro .container) {
        max-width: 1320px;
    }
}

@media (max-width: 1200px) {
    .container:not(.layanan-section .container):not(.layanan-cta-section .container):not(.services-intro .container) {
        max-width: 1140px;
    }
}

@media (max-width: 992px) {
    .container:not(.layanan-section .container):not(.layanan-cta-section .container):not(.services-intro .container) {
        max-width: 960px;
    }
    
    /* Ensure no overflow on tablet */
    body {
        overflow-x: hidden !important;
    }
}

@media (max-width: 768px) {
    .container:not(.layanan-section .container):not(.layanan-cta-section .container):not(.services-intro .container) {
        max-width: 720px;
    }
    
    /* Mobile specific fixes */
    html {
        font-size: 15px;
    }
}

@media (max-width: 576px) {
    .container:not(.layanan-section .container):not(.layanan-cta-section .container):not(.services-intro .container) {
        max-width: 540px;
    }
    
    html {
        font-size: 14px;
    }
    
    /* Prevent zoom on input focus */
    input, select, textarea {
        font-size: 16px !important;
    }
}

@media (max-width: 400px) {
    .container:not(.layanan-section .container):not(.layanan-cta-section .container):not(.services-intro .container) {
        max-width: 100%;
        padding-right: 12px;
        padding-left: 12px;
    }
    
    html {
        font-size: 13px;
    }
}

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

/* Fix untuk Safari iOS */
@supports (-webkit-touch-callout: none) {
    body {
        -webkit-overflow-scrolling: touch;
    }
}

/* Prevent Text Selection Issues */
::selection {
    background: rgba(1, 78, 154, 0.2);
    color: inherit;
}

::-moz-selection {
    background: rgba(1, 78, 154, 0.2);
    color: inherit;
}

/* Loading State untuk Images */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* Aspect Ratio Helper */
.aspect-ratio-16-9 {
    aspect-ratio: 16/9;
}

.aspect-ratio-1-1 {
    aspect-ratio: 1/1;
}

.aspect-ratio-4-3 {
    aspect-ratio: 4/3;
}

/* Flexbox Utilities untuk Konsistensi */
.d-flex {
    display: flex !important;
}

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

.align-items-center {
    align-items: center !important;
}

.justify-content-center {
    justify-content: center !important;
}

/* Text Utilities */
.text-center {
    text-align: center !important;
}

/* Spacing Utilities dengan Clamp */
.mt-responsive {
    margin-top: clamp(20px, 4vw, 40px);
}

.mb-responsive {
    margin-bottom: clamp(20px, 4vw, 40px);
}

.py-responsive {
    padding-top: clamp(30px, 5vw, 60px);
    padding-bottom: clamp(30px, 5vw, 60px);
}

/* Fix untuk Owl Carousel */
.owl-carousel {
    width: 100%;
    max-width: 100%;
}

.owl-carousel .owl-stage-outer {
    overflow: hidden;
}

/* Prevent Layout Shift */
.prevent-layout-shift {
    contain: layout;
}

/* GPU Acceleration untuk Smooth Animation */
.gpu-accelerate {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-perspective: 1000;
    perspective: 1000;
}

/* Safe Area untuk Notch Devices */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
}

/* Mobile Touch Improvements */
@media (max-width: 768px) {
    /* Better touch targets */
    a, button, .clickable {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Prevent text overflow */
    h1, h2, h3, h4, h5, h6, p {
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }
    
    /* Better spacing for mobile */
    section {
        padding-left: 15px;
        padding-right: 15px;
    }
}

/* Small Mobile Specific */
@media (max-width: 576px) {
    /* Reduce padding for small screens */
    .service-card {
        box-shadow: 0 5px 20px rgba(0,0,0,0.08) !important;
    }
    
    /* Better readability */
    body {
        line-height: 1.6;
    }
    
    /* Optimize button sizes */
    .btn, .cta-btn, .service-cta {
        font-size: 0.9rem !important;
        padding: 12px 20px !important;
    }
}

/* Extra Small Devices */
@media (max-width: 400px) {
    /* Compact spacing */
    .service-card {
        margin-bottom: 20px !important;
    }
    
    /* Smaller text for very small screens */
    body {
        font-size: 0.9rem;
    }
    
    h1 {
        font-size: 1.5rem !important;
    }
    
    h2 {
        font-size: 1.3rem !important;
    }
    
    h3 {
        font-size: 1.2rem !important;
    }
}

/* Landscape Mobile Optimization */
@media (max-width: 768px) and (orientation: landscape) {
    /* Reduce vertical padding in landscape */
    section {
        padding-top: 30px !important;
        padding-bottom: 30px !important;
    }
    
    .layanan-hero {
        padding: 100px 0 40px !important;
    }
}

/* Print Styles */
@media print {
    body {
        overflow: visible !important;
    }
    
    .no-print {
        display: none !important;
    }
}
