/* ============================================
   Additional Responsive Fixes for All Devices
   ============================================ */

/* Base responsive images */
img {
    max-width: 100%;
    height: auto;
}

/* Responsive iframes */
iframe {
    max-width: 100%;
}

/* Box sizing fix */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* ============================================
   Mobile First Approach (up to 767px)
   ============================================ */
@media only screen and (max-width: 767px) {

    /* Base adjustments */
    body {
        font-size: 14px;
    }

    /* FIX: Keep menu button on same line as logo */
    .site-header {
        flex-wrap: nowrap !important;
        padding-left: 20px !important;
        padding-right: 20px !important;
        left: 15px !important;
        right: 15px !important;
    }

    .site-header .main-logo {
        flex-shrink: 0;
    }

    #navbar_toggle,
    .navbar-toggle {
        flex-shrink: 0 !important;
        margin-left: auto !important;
    }

    /* FIX: Move menu items down when menu is open to avoid overlap with close button */
    .site-header.dsn-hamburger ul.primary-nav,
    .site-header.dsn-hamburger ul.primary-nav ul {
        top: 140px !important;
        height: calc(100vh - 140px) !important;
        padding-top: 20px !important;
    }

    /* FIX: Make indexName logo bigger and clearer on mobile */
    #dsn_header.home-hero .home-hero-logo {
        left: 20px !important;
        max-width: 70% !important;
        min-width: 280px !important;
    }

    #dsn_header.home-hero .home-hero-logo img {
        width: 100% !important;
        height: auto !important;
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }

    /* Container mobile */
    .container {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }

    /* Single column layout */
    .col-xs-12,
    .col-sm-12,
    .col-md-6,
    .col-md-4,
    .col-md-3,
    .col-lg-6,
    .col-lg-4,
    .col-lg-3 {
        width: 100% !important;
        margin-bottom: 20px;
    }

    /* Typography */
    h1,
    .h1 {
        font-size: 1.75rem !important;
    }

    h2,
    .h2 {
        font-size: 1.5rem !important;
    }

    h3,
    .h3 {
        font-size: 1.25rem !important;
    }

    h4,
    .h4 {
        font-size: 1.1rem !important;
    }

    /* Buttons */
    .btn,
    .button,
    .dsn-btn {
        padding: 10px 20px !important;
        font-size: 0.875rem !important;
        width: 100%;
        margin-bottom: 10px;
    }

    /* Tables */
    table {
        font-size: 0.75rem;
    }

    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Navigation */
    .nav,
    .navbar-nav {
        flex-direction: column;
    }

    /* Spacing */
    .section-padding {
        padding: 40px 0 !important;
    }

    .section-margin {
        margin: 40px 0 !important;
    }

    /* Forms */
    .form-control {
        font-size: 16px !important;
        /* Prevents zoom on iOS */
    }

    /* Hide elements on mobile */
    .hidden-mobile {
        display: none !important;
    }
}

/* ============================================
   Tablet Portrait (768px - 991px)
   ============================================ */
@media only screen and (min-width: 768px) and (max-width: 991px) {

    /* FIX: Make indexName logo bigger and clearer on tablet */
    #dsn_header.home-hero .home-hero-logo {
        left: 30px !important;
        max-width: 55% !important;
        min-width: 350px !important;
    }

    #dsn_header.home-hero .home-hero-logo img {
        width: 100% !important;
        height: auto !important;
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }

    /* Container adjustments */
    .container {
        max-width: 95% !important;
        padding-left: 20px !important;
        padding-right: 20px !important;
    }

    /* Two column layout for medium items */
    .col-md-6 {
        width: 48% !important;
        float: left;
        margin: 1%;
    }

    /* Typography */
    h1,
    .h1 {
        font-size: 2.25rem !important;
    }

    h2,
    .h2 {
        font-size: 1.875rem !important;
    }

    h3,
    .h3 {
        font-size: 1.625rem !important;
    }

    h4,
    .h4 {
        font-size: 1.375rem !important;
    }

    /* Navigation */
    .navbar {
        padding: 15px 20px !important;
    }

    /* Grid layouts */
    .grid-2-cols {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .grid-3-cols {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Cards */
    .card {
        margin-bottom: 20px;
    }

    /* Buttons */
    .btn,
    .button {
        padding: 12px 24px !important;
    }

    /* Hide on tablet */
    .hidden-tablet {
        display: none !important;
    }
}

/* ============================================
   Tablet Landscape & Small Desktop (992px - 1199px)
   ============================================ */
@media only screen and (min-width: 992px) and (max-width: 1199px) {

    .container {
        max-width: 960px !important;
    }

    /* Three column layout */
    .col-lg-4 {
        width: 31.333% !important;
        float: left;
        margin: 1%;
    }

    .col-lg-3 {
        width: 23% !important;
        float: left;
        margin: 1%;
    }

    /* Grid layouts */
    .grid-4-cols {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* ============================================
   Common Responsive Utilities
   ============================================ */

/* Clearfix */
.clearfix::after {
    content: "";
    display: table;
    clear: both;
}

/* Responsive embed (videos, iframes) */
.embed-responsive {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    overflow: hidden;
}

.embed-responsive::before {
    display: block;
    content: "";
}

.embed-responsive-16by9::before {
    padding-top: 56.25%;
    /* 16:9 aspect ratio */
}

.embed-responsive-4by3::before {
    padding-top: 75%;
    /* 4:3 aspect ratio */
}

.embed-responsive iframe,
.embed-responsive embed,
.embed-responsive object,
.embed-responsive video {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Responsive text */
.text-responsive {
    font-size: calc(14px + (18 - 14) * ((100vw - 320px) / (1920 - 320)));
}

/* Touch-friendly buttons */
@media (hover: none) and (pointer: coarse) {

    button,
    a,
    .btn,
    .clickable {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 20px;
    }
}

/* Print styles */
@media print {

    .no-print,
    nav,
    footer,
    .sidebar {
        display: none !important;
    }

    body {
        font-size: 12pt;
    }

    a {
        text-decoration: underline;
    }

    h1,
    h2,
    h3 {
        page-break-after: avoid;
    }
}

/* RTL Support */
[dir="rtl"] {
    direction: rtl;
}

[dir="rtl"] .float-left {
    float: right;
}

[dir="rtl"] .float-right {
    float: left;
}

/* High DPI / Retina displays */
@media only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and (min-resolution: 192dpi) {

    /* Optimize for retina displays */
    img {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Landscape orientation fixes */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .full-height {
        min-height: auto !important;
    }

    header {
        height: auto !important;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    /* Add dark mode styles if needed */
}

/* Fix for iOS Safari bottom bar */
@supports (-webkit-touch-callout: none) {
    .vh-100 {
        height: -webkit-fill-available;
    }
}

/* Smooth scrolling */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}