/**
 * Responsive Styles for Petro Sinergi Abadi Theme
 * 
 * @package Petro_Sinergi_Abadi
 */

/* ==========================================================================
   Breakpoints:
   - xs: < 576px
   - sm: ≥ 576px
   - md: ≥ 768px
   - lg: ≥ 992px
   - xl: ≥ 1200px
   - xxl: ≥ 1400px
   ========================================================================== */

/* ==========================================================================
   1. Extra Small Devices (phones, less than 576px)
   ========================================================================== */

@media (max-width: 575.98px) {
    /* Typography */
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.75rem;
    }
    
    h3 {
        font-size: 1.5rem;
    }
    
    .display-1 {
        font-size: 3rem;
    }
    
    .display-2 {
        font-size: 2.5rem;
    }
    
    .display-3 {
        font-size: 2.25rem;
    }
    
    .display-4 {
        font-size: 2rem;
    }
    
    .lead {
        font-size: 1rem;
    }
    
    /* Layout */
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    .section-padding {
        padding: 3rem 0;
    }
    
    /* Hero Section */
    .hero-section {
        padding: 5rem 0 3rem;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .hero-cta .btn {
        display: block;
        width: 100%;
        margin-right: 0;
        margin-bottom: 1rem;
    }
    
    .hero-cta .btn:last-child {
        margin-bottom: 0;
    }
    
    /* Navigation */
    .navbar-brand {
        font-size: 1.2rem;
    }
    
    .navbar-brand img {
        max-height: 40px;
    }
    
    /* Sections */
    .section-title {
        font-size: 1.5rem;
        margin-bottom: 2rem;
    }
    
    /* Cards */
    .card-body {
        padding: 1.5rem;
    }
    
    .program-card {
        margin-bottom: 1.5rem;
    }
    
    /* Buttons */
    .btn-lg {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
    
    /* Tables */
    .table-responsive {
        margin-bottom: 1rem;
        border: 1px solid #dee2e6;
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem;
    }
    
    /* Footer */
    .footer {
        padding: 3rem 0 1rem;
    }
    
    .footer-widgets .col-lg-4,
    .footer-widgets .col-lg-3,
    .footer-widgets .col-lg-2 {
        margin-bottom: 2rem;
    }
    
    .footer-bottom {
        text-align: center;
    }
    
    /* WhatsApp Float Button */
    .whatsapp-float {
        width: 50px;
        height: 50px;
        bottom: 20px;
        right: 20px;
        font-size: 25px;
    }   
    
    /* Widgets */
    .widget {
        margin-bottom: 1.5rem;
    }
    
    .widget-title {
        font-size: 1.1rem;
    }
    
    /* Forms */
    .form-control,
    .form-select {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    /* Search Results */
    .search-results-list .card-body {
        padding: 1rem;
    }
    
    /* 404 Page */
    .error-404 .display-1 {
        font-size: 4rem;
    }
    
    .error-404 h2 {
        font-size: 1.5rem;
    }
}

/* ==========================================================================
   2. Small Devices (phones, 576px and up)
   ========================================================================== */

@media (min-width: 576px) and (max-width: 767.98px) {
    /* Typography */
    h1 {
        font-size: 2.25rem;
    }
    
    h2 {
        font-size: 1.875rem;
    }
    
    h3 {
        font-size: 1.625rem;
    }
    
    .display-4 {
        font-size: 2.5rem;
    }
    
    /* Layout */
    .section-padding {
        padding: 3.5rem 0;
    }
    
    /* Hero Section */
    .hero-section {
        padding: 6rem 0 4rem;
    }
    
    .hero-title {
        font-size: 2.5rem;
    }
    
    /* Navigation */
    .navbar-brand {
        font-size: 1.3rem;
    }
    
    /* Sections */
    .section-title {
        font-size: 1.75rem;
    }
    
    /* Cards */
    .card-body {
        padding: 1.75rem;
    }
    
    /* Footer */
    .footer {
        padding: 3.5rem 0 1.5rem;
    }
    
    /* WhatsApp Float Button */
    .whatsapp-float {
        bottom: 25px;
        right: 25px;
    }
}

/* ==========================================================================
   3. Medium Devices (tablets, 768px and up)
   ========================================================================== */

@media (min-width: 768px) and (max-width: 991.98px) {
    /* Typography */
    h1 {
        font-size: 2.75rem;
    }
    
    h2 {
        font-size: 2.25rem;
    }
    
    h3 {
        font-size: 1.875rem;
    }
    
    .display-4 {
        font-size: 3rem;
    }
    
    /* Layout */
    .section-padding {
        padding: 4rem 0;
    }
    
    /* Hero Section */
    .hero-section {
        padding: 7rem 0 4.5rem;
    }
    
    .hero-title {
        font-size: 3rem;
    }
    
    /* Navigation */
    .navbar-nav {
        text-align: center;
    }
    
    .navbar-nav .nav-item {
        margin-bottom: 0.5rem;
    }
    
    .navbar-nav .btn {
        margin-top: 0.5rem;
    }
    
    /* Footer */
    .footer-widgets .col-lg-4,
    .footer-widgets .col-lg-3,
    .footer-widgets .col-lg-2 {
        margin-bottom: 2.5rem;
    }
    
    /* Grid System Adjustments */
    .col-md-6 {
        flex: 0 0 auto;
        width: 50%;
    }
    
    .col-md-4 {
        flex: 0 0 auto;
        width: 33.33333333%;
    }
    
    .col-md-3 {
        flex: 0 0 auto;
        width: 25%;
    }
}

/* ==========================================================================
   4. Large Devices (desktops, 992px and up)
   ========================================================================== */

@media (min-width: 992px) and (max-width: 1199.98px) {
    /* Typography */
    .display-4 {
        font-size: 3.25rem;
    }
    
    /* Layout */
    .container {
        max-width: 960px;
    }
    
    /* Hero Section */
    .hero-title {
        font-size: 3.25rem;
    }
    
    /* Navigation */
    .navbar-nav .nav-link {
        padding: 0.5rem 0.75rem !important;
    }
    
    /* Program Cards */
    .program-card .card-body {
        padding: 1.5rem;
    }
}

/* ==========================================================================
   5. Extra Large Devices (large desktops, 1200px and up)
   ========================================================================== */

@media (min-width: 1200px) and (max-width: 1399.98px) {
    /* Layout */
    .container {
        max-width: 1140px;
    }
}

/* ==========================================================================
   6. Extra Extra Large Devices (larger desktops, 1400px and up)
   ========================================================================== */

@media (min-width: 1400px) {
    /* Layout */
    .container {
        max-width: 1320px;
    }
}

/* ==========================================================================
   7. Orientation Specific
   ========================================================================== */

/* Portrait */
@media (orientation: portrait) {
    .hero-image {
        margin-top: 2rem;
    }
    
    .cta-section .row {
        flex-direction: column;
        text-align: center;
    }
    
    .cta-section .btn {
        margin-top: 1rem;
    }
}

/* Landscape */
@media (orientation: landscape) and (max-height: 500px) {
    .hero-section {
        padding: 4rem 0;
        min-height: auto;
    }
    
    .hero-title {
        font-size: 2.5rem;
    }
    
    .navbar {
        padding: 0.5rem 0;
    }
}

/* ==========================================================================
   8. High DPI Screens (Retina)
   ========================================================================== */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .hero-section {
        background: linear-gradient(135deg, #1a2980 0%, #26d0ce 100%);
    }
    
    .cta-section {
        background: linear-gradient(135deg, #2c3e50 0%, #4ca1af 100%);
    }
    
    .footer {
        background: linear-gradient(135deg, #2c3e50 0%, #1a1a2e 100%);
    }
}

/* ==========================================================================
   9. Print Optimization
   ========================================================================== */

@media print {
    /* Hide unnecessary elements */
    .navbar,
    .footer,
    .cta-section,
    .whatsapp-float,
    .btn,
    .social-icons,
    .announcement-bar,
    .search-form,
    .comment-form,
    .widget {
        display: none !important;
    }
    
    /* Typography */
    body {
        font-size: 12pt;
        line-height: 1.4;
        color: #000 !important;
        background: #fff !important;
    }
    
    h1, h2, h3, h4, h5, h6 {
        color: #000 !important;
        page-break-after: avoid;
    }
    
    /* Links */
    a {
        color: #000 !important;
        text-decoration: underline !important;
    }
    
    a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.9em;
        font-weight: normal;
    }
    
    /* Layout */
    .container {
        width: 100% !important;
        max-width: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    /* Cards and Boxes */
    .card {
        border: 1px solid #ddd !important;
        box-shadow: none !important;
        break-inside: avoid;
    }
    
    /* Tables */
    table {
        page-break-inside: avoid;
    }
    
    /* Images */
    img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }
    
    /* Lists */
    ul, ol {
        page-break-inside: avoid;
    }
    
    /* Page Breaks */
    h1, h2, h3, h4, h5, h6, p, li {
        page-break-inside: avoid;
    }
    
    /* Margins */
    .hero-section,
    .section-padding,
    .py-5,
    .my-5,
    .mt-5,
    .mb-5 {
        padding: 1rem 0 !important;
        margin: 1rem 0 !important;
    }
    
    /* Backgrounds */
    .bg-light,
    .bg-primary,
    .bg-gradient-primary {
        background: #fff !important;
        color: #000 !important;
    }
    
    /* Text Colors */
    .text-primary,
    .text-white,
    .text-muted {
        color: #000 !important;
    }
}

/* ==========================================================================
   10. Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .hero-image,
    .program-icon,
    .whatsapp-float,
    .btn::before {
        animation: none !important;
        transition: none !important;
    }
    
    .hover-lift:hover,
    .hover-scale:hover,
    .btn:hover {
        transform: none !important;
    }
}

/* ==========================================================================
   11. Dark Mode Support
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #3d8bfd;
        --secondary-color: #6c757d;
        --accent-color: #e35d6a;
    }
    
    body {
        background-color: #121212;
        color: #e0e0e0;
    }
    
    .card {
        background-color: #1e1e1e;
        color: #e0e0e0;
    }
    
    .card-header {
        background-color: #2d2d2d;
        color: #e0e0e0;
    }
    
    .card-title {
        color: #e0e0e0;
    }
    
    .table {
        color: #e0e0e0;
    }
    
    .table thead th {
        background-color: #2d2d2d;
        color: #e0e0e0;
    }
    
    .table tbody td {
        border-top: 1px solid #444;
    }
    
    .form-control,
    .form-select {
        background-color: #1e1e1e;
        border-color: #444;
        color: #e0e0e0;
    }
    
    .form-control:focus,
    .form-select:focus {
        background-color: #1e1e1e;
        border-color: var(--primary-color);
        color: #e0e0e0;
    }
    
    .form-control::placeholder {
        color: #888;
    }
}

/* ==========================================================================
   12. Touch Device Optimizations
   ========================================================================== */

@media (hover: none) and (pointer: coarse) {
    /* Increase touch target sizes */
    .btn,
    .nav-link,
    .form-control,
    .form-select {
        min-height: 44px;
    }
    
    /* Remove hover effects */
    .btn:hover,
    .nav-link:hover,
    .program-card:hover,
    .facility-item:hover {
        transform: none;
    }
    
    /* Adjust spacing for touch */
    .nav-link {
        padding: 0.75rem 1rem !important;
    }
    
    /* Prevent zoom on form inputs */
    input,
    select,
    textarea {
        font-size: 16px;
    }
}

/* ==========================================================================
   13. Custom Responsive Utilities
   ========================================================================== */

/* Hide elements on specific breakpoints */
.d-xs-none {
    display: none !important;
}

@media (min-width: 576px) {
    .d-xs-none {
        display: block !important;
    }
    
    .d-sm-none {
        display: none !important;
    }
}

@media (min-width: 768px) {
    .d-sm-none {
        display: block !important;
    }
    
    .d-md-none {
        display: none !important;
    }
}

@media (min-width: 992px) {
    .d-md-none {
        display: block !important;
    }
    
    .d-lg-none {
        display: none !important;
    }
}

@media (min-width: 1200px) {
    .d-lg-none {
        display: block !important;
    }
    
    .d-xl-none {
        display: none !important;
    }
}

/* Text alignment on mobile */
.text-center-xs {
    text-align: center;
}

@media (min-width: 768px) {
    .text-center-xs {
        text-align: left;
    }
}

/* Margin adjustments */
.mb-xs-3 {
    margin-bottom: 1rem !important;
}

@media (min-width: 768px) {
    .mb-xs-3 {
        margin-bottom: 0 !important;
    }
}

/* Padding adjustments */
.px-xs-2 {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
}

@media (min-width: 768px) {
    .px-xs-2 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
}

/* ==========================================================================
   14. Special Cases
   ========================================================================== */

/* iPhone X and newer notch support */
@supports (padding: max(0px)) {
    .hero-section,
    .navbar.fixed-top {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    
    .whatsapp-float {
        right: calc(20px + env(safe-area-inset-right));
    }
}

/* Firefox specific fixes */
@-moz-document url-prefix() {
    .hero-section::before {
        background-attachment: scroll;
    }
    
    .btn::before {
        display: none;
    }
}

/* Edge specific fixes */
@supports (-ms-ime-align: auto) {
    .hero-section {
        background-attachment: scroll;
    }
}

/* Safari specific fixes */
@media not all and (min-resolution: 0.001dpcm) {
    @supports (-webkit-appearance: none) {
        .hero-section::before {
            -webkit-mask-image: -webkit-radial-gradient(white, black);
        }
    }
}

/* ==========================================================================
   15. Performance Optimizations
   ========================================================================== */

@media (max-width: 768px) {
    /* Disable animations on mobile for better performance */
    .hero-image,
    .program-icon,
    .whatsapp-float {
        animation: none;
    }
    
    /* Reduce box-shadows on mobile */
    .card,
    .program-card,
    .btn {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
    }
    
    /* Simplify gradients on mobile */
    .hero-section {
        background: linear-gradient(135deg, #1a2980 0%, #26d0ce 100%);
    }
    
    .cta-section {
        background: linear-gradient(135deg, #2c3e50 0%, #4ca1af 100%);
    }
    
    /* Optimize images for mobile */
    img {
        max-width: 100%;
        height: auto;
    }
}

/* ==========================================================================
   16. Accessibility Improvements
   ========================================================================== */

@media (prefers-contrast: high) {
    :root {
        --primary-color: #0056b3;
        --secondary-color: #495057;
        --accent-color: #c82333;
    }
    
    body {
        color: #000;
        background-color: #fff;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
    
    .nav-link {
        text-decoration: underline;
    }
}

@media (prefers-contrast: more) {
    .hero-section,
    .cta-section,
    .footer {
        background-image: none;
        background-color: #000;
        color: #fff;
    }
    
    .hero-section::before,
    .cta-section::before,
    .footer::before {
        display: none;
    }
}

/* ==========================================================================
   17. JavaScript Detection
   ========================================================================== */

.no-js .navbar-toggler {
    display: none;
}

.no-js .navbar-collapse {
    display: block !important;
}

.no-js .whatsapp-float {
    animation: none;
}

.no-js .loading {
    animation: none;
    border: none;
}