/* Responsive Design Fixes for All Devices */
/* Mobile First Approach */

/* Base Mobile Styles (320px - 480px) */
@media screen and (max-width: 480px) {
    /* Typography Adjustments */
    body {
        font-size: 14px !important;
        line-height: 1.6 !important;
    }
    
    h1 {
        font-size: 24px !important;
        line-height: 1.3 !important;
        margin-bottom: 15px !important;
    }
    
    h2 {
        font-size: 20px !important;
        line-height: 1.3 !important;
        margin-bottom: 12px !important;
    }
    
    h3 {
        font-size: 18px !important;
        line-height: 1.3 !important;
    }
    
    /* Container and Layout */
    .container {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
    
    /* Navigation Mobile Menu */
    .navbar-nav {
        background-color: #fff;
        padding: 20px 15px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    }
    
    .navbar-nav li {
        margin: 10px 0 !important;
    }
    
    .navbar-nav a {
        font-size: 16px !important;
        padding: 10px 0 !important;
        display: block;
    }
    
    /* Buttons */
    .btn {
        padding: 12px 20px !important;
        font-size: 14px !important;
        width: 100% !important;
        margin-bottom: 10px !important;
    }
    
    /* Features Section */
    .features-items .single-item {
        margin-bottom: 30px !important;
        padding: 0 10px !important;
    }
    
    .features-items .item {
        padding: 20px !important;
    }
    
    /* About Section */
    .about-style-three ul {
        padding-left: 20px !important;
    }
    
    .about-style-three ul li {
        font-size: 14px !important;
        margin-bottom: 8px !important;
    }
    
    /* Process Section */
    .work-process-items .single-item {
        margin-bottom: 40px !important;
    }
    
    .work-process-items .thumb img {
        width: 100% !important;
        height: auto !important;
    }
    
    /* Images */
    img {
        max-width: 100% !important;
        height: auto !important;
    }
    
    /* Footer */
    .footer-top .f-item {
        margin-bottom: 30px !important;
    }
    
    .footer-top h4 {
        font-size: 18px !important;
        margin-bottom: 15px !important;
    }
    
    /* CTA Buttons Side by Side on Mobile */
    .cta-buttons {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .cta-buttons .btn {
        width: 100% !important;
    }
}

/* Tablet Styles (481px - 768px) */
@media screen and (min-width: 481px) and (max-width: 768px) {
    /* Typography */
    body {
        font-size: 15px !important;
    }
    
    h1 {
        font-size: 28px !important;
        margin-bottom: 18px !important;
    }
    
    h2 {
        font-size: 24px !important;
        margin-bottom: 15px !important;
    }
    
    h3 {
        font-size: 20px !important;
    }
    
    /* Container */
    .container {
        padding-left: 20px !important;
        padding-right: 20px !important;
    }
    
    /* Buttons */
    .btn {
        padding: 12px 25px !important;
        font-size: 15px !important;
    }
    
    /* Two Column Layout for Tablets */
    .features-items {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    /* Process Items */
    .work-process-items .row {
        display: flex;
        flex-wrap: wrap;
    }
    
    .work-process-items .single-item {
        flex: 0 0 50%;
        max-width: 50%;
        margin-bottom: 30px;
    }
    
    /* Footer */
    .footer-top .row {
        display: flex;
        flex-wrap: wrap;
    }
    
    .footer-top .f-item {
        flex: 0 0 50%;
        max-width: 50%;
        margin-bottom: 30px;
    }
}

/* Small Desktop (769px - 991px) */
@media screen and (min-width: 769px) and (max-width: 991px) {
    /* Container Width */
    .container {
        max-width: 900px !important;
    }
    
    /* Three Column Layout */
    .features-items {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
    
    /* Navigation Adjustments */
    .navbar-nav li {
        margin: 0 8px !important;
    }
    
    .navbar-nav a {
        font-size: 14px !important;
        padding: 8px 12px !important;
    }
}

/* Desktop and Large Screens (992px+) */
@media screen and (min-width: 992px) {
    /* Ensure Maximum Readability */
    .container {
        max-width: 1200px !important;
    }
    
    /* Optimal Line Length for Reading */
    p {
        max-width: 750px;
        margin-left: auto;
        margin-right: auto;
    }
    
    /* Features Grid */
    .features-items {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 30px;
    }
    
    /* Hover Effects Desktop Only */
    .btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 5px 15px rgba(0,0,0,0.2);
        transition: all 0.3s ease;
    }
    
    .single-item:hover {
        transform: translateY(-5px);
        transition: transform 0.3s ease;
    }
}

/* Ultra Wide Screens (1920px+) */
@media screen and (min-width: 1920px) {
    .container {
        max-width: 1400px !important;
    }
    
    body {
        font-size: 18px !important;
    }
    
    h1 {
        font-size: 48px !important;
    }
    
    h2 {
        font-size: 36px !important;
    }
}

/* Responsive Image Container */
.img-responsive-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
    overflow: hidden;
}

.img-responsive-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 1000;
}

@media screen and (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }
    
    .navbar-collapse {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        background: white;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
        transition: left 0.3s ease;
        z-index: 999;
        overflow-y: auto;
    }
    
    .navbar-collapse.show {
        left: 0;
    }
}

/* Accessibility Improvements */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip to Content Link */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-to-content:focus {
    top: 0;
}

/* Touch-Friendly Tap Targets */
@media (pointer: coarse) {
    button, a, input, select, textarea {
        min-height: 44px;
        min-width: 44px;
    }
    
    .navbar-nav a {
        padding: 12px 16px !important;
    }
}

/* Print Styles */
@media print {
    .no-print, .navbar, .footer, .btn {
        display: none !important;
    }
    
    body {
        font-size: 12pt !important;
        color: black !important;
        background: white !important;
    }
    
    h1, h2, h3 {
        page-break-after: avoid;
    }
    
    img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }
}

/* Landscape Orientation Mobile */
@media screen and (max-width: 812px) and (orientation: landscape) {
    .navbar {
        padding: 5px 15px !important;
    }
    
    .features-items {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    h1 {
        font-size: 22px !important;
    }
    
    h2 {
        font-size: 18px !important;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .btn-primary {
        border: 2px solid currentColor !important;
    }
    
    a {
        text-decoration: underline !important;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1a1a1a;
        --text-color: #e0e0e0;
        --link-color: #4a9eff;
    }
}

/* Fix for iOS Safari */
@supports (-webkit-touch-callout: none) {
    .container {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* Responsive Tables */
@media screen and (max-width: 600px) {
    table {
        border: 0;
    }
    
    table thead {
        display: none;
    }
    
    table tr {
        display: block;
        margin-bottom: 10px;
        border: 1px solid #ddd;
    }
    
    table td {
        display: block;
        text-align: right;
        padding-left: 50%;
        position: relative;
    }
    
    table td:before {
        content: attr(data-label);
        position: absolute;
        left: 6px;
        width: 45%;
        text-align: left;
        font-weight: bold;
    }
}

/* Logo Consistency Fixes */
.navbar .logo {
    display: block;
    max-width: 240px;
    height: auto;
    transition: all 0.3s ease;
}

.navbar .logo.logo-display {
    /* Default logo (light version for dark background) */
}

.navbar .logo.logo-scrolled {
    /* Scrolled logo (dark version for light background) */
}

.footer .f-item img {
    max-width: 240px;
    height: auto;
    margin-bottom: 20px;
}

/* Mobile Logo Sizing */
@media screen and (max-width: 480px) {
    .navbar .logo,
    .footer .f-item img {
        max-width: 180px;
    }
}

/* Tablet Logo Sizing */
@media screen and (min-width: 481px) and (max-width: 768px) {
    .navbar .logo,
    .footer .f-item img {
        max-width: 200px;
    }
}

/* High DPI Display Support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .navbar .logo,
    .footer .f-item img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Ensure logo visibility on all backgrounds */
.navbar.navbar-light .logo-display {
    display: none;
}

.navbar.navbar-light .logo-scrolled {
    display: block;
}

.navbar:not(.navbar-light) .logo-display {
    display: block;
}

.navbar:not(.navbar-light) .logo-scrolled {
    display: none;
}

/* Footer logo specific styling */
.footer {
    background-color: #1a1a1a; /* Dark background */
}

.footer img[alt*="Integrity Cleaning"] {
    /* Ensure light logo is used in dark footer */
    filter: brightness(1.1);
}
