/**
 * MuDream Template - Responsive Optimization
 * Final responsive adjustments and cross-device compatibility
 * Adapted for WebEngine CMS
 */

/* ==========================================================================
   RESPONSIVE UTILITIES & HELPERS
   ========================================================================== */

.container-fluid {
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -15px;
    margin-left: -15px;
}

.col, .col-1, .col-2, .col-3, .col-4, .col-5, .col-6,
.col-7, .col-8, .col-9, .col-10, .col-11, .col-12 {
    position: relative;
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
}

/* Responsive columns */
.col { flex: 1 0 0%; }
.col-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
.col-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
.col-3 { flex: 0 0 25%; max-width: 25%; }
.col-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
.col-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
.col-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
.col-9 { flex: 0 0 75%; max-width: 75%; }
.col-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
.col-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }

/* ==========================================================================
   MOBILE OPTIMIZATIONS (320px - 575px)
   ========================================================================== */

@media (max-width: 575.98px) {
    /* Typography scaling */
    h1 { font-size: 1.8rem; line-height: 1.2; }
    h2 { font-size: 1.5rem; line-height: 1.3; }
    h3 { font-size: 1.3rem; line-height: 1.4; }
    h4 { font-size: 1.1rem; line-height: 1.4; }
    h5 { font-size: 1rem; line-height: 1.5; }
    h6 { font-size: 0.9rem; line-height: 1.5; }
    
    body {
        font-size: 14px;
        line-height: 1.6;
    }
    
    /* Container adjustments */
    .container {
        max-width: 100%;
        padding: 0 10px;
    }
    
    /* Navigation mobile adjustments */
    .main-nav {
        position: fixed;
        top: 0;
        left: -100%;
        width: 280px;
        height: 100vh;
        background: var(--bg-dark);
        z-index: 9999;
        transition: left 0.3s ease;
        padding: 20px;
        overflow-y: auto;
    }
    
    .main-nav.active {
        left: 0;
    }
    
    .nav-toggle {
        display: block;
        background: none;
        border: none;
        color: var(--text-light);
        font-size: 1.5rem;
        cursor: pointer;
        padding: 8px;
    }
    
    .nav-menu {
        display: block;
        padding: 0;
    }
    
    .nav-item {
        margin-bottom: 10px;
    }
    
    .nav-link {
        display: block;
        padding: 12px 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        text-decoration: none;
        color: var(--text-light);
        transition: color 0.3s ease;
    }
    
    .nav-link:hover {
        color: var(--primary-color);
        padding-left: 10px;
    }
    
    /* Header adjustments */
    .header {
        padding: 10px 0;
        position: sticky;
        top: 0;
        z-index: 1000;
    }
    
    .header-content {
        justify-content: space-between;
        align-items: center;
    }
    
    .logo {
        font-size: 1.2rem;
    }
    
    /* Hero section mobile */
    .hero-section {
        min-height: 60vh;
        padding: 40px 0;
    }
    
    .hero-content {
        text-align: center;
        padding: 0 20px;
    }
    
    .hero-title {
        font-size: 2rem;
        margin-bottom: 15px;
    }
    
    .hero-subtitle {
        font-size: 1rem;
        margin-bottom: 25px;
    }
    
    /* Button adjustments */
    .btn {
        width: 100%;
        max-width: 200px;
        margin: 5px auto;
        display: block;
        padding: 12px 20px;
        font-size: 14px;
    }
    
    .btn-group {
        flex-direction: column;
        align-items: center;
    }
    
    .btn-group .btn {
        margin: 5px 0;
    }
    
    /* Card layouts */
    .card {
        margin-bottom: 20px;
    }
    
    .card-deck {
        flex-direction: column;
    }
    
    .card-deck .card {
        margin-bottom: 20px;
        max-width: 100%;
    }
    
    /* Form adjustments */
    .form-group {
        margin-bottom: 20px;
    }
    
    .form-control {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px 15px;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .form-row .form-group {
        width: 100%;
        margin-bottom: 15px;
    }
    
    /* Table responsive */
    .table-responsive {
        border: 0;
    }
    
    .table-responsive table {
        font-size: 12px;
    }
    
    .table-responsive th,
    .table-responsive td {
        padding: 8px 4px;
    }
    
    /* Hide/show elements on mobile */
    .d-mobile-none {
        display: none !important;
    }
    
    .d-mobile-block {
        display: block !important;
    }
    
    /* Social panel mobile */
    .social-panel {
        width: 100%;
        max-width: 300px;
        left: 50%;
        transform: translateX(-50%);
        bottom: 20px;
    }
    
    /* Footer mobile */
    .footer {
        text-align: center;
        padding: 30px 0;
    }
    
    .footer-content {
        flex-direction: column;
    }
    
    .footer-section {
        margin-bottom: 25px;
        width: 100%;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 10px;
    }
    
    /* Modal mobile adjustments */
    .modal-content {
        margin: 20px;
        max-height: calc(100vh - 40px);
        overflow-y: auto;
    }
    
    .modal-header {
        padding: 15px;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .modal-footer {
        padding: 15px;
        flex-direction: column;
    }
    
    .modal-footer .btn {
        margin-top: 10px;
    }
}

/* ==========================================================================
   TABLET OPTIMIZATIONS (576px - 991px)
   ========================================================================== */

@media (min-width: 576px) and (max-width: 991.98px) {
    /* Container adjustments */
    .container {
        max-width: 100%;
        padding: 0 20px;
    }
    
    /* Grid system for tablets */
    .col-sm-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
    .col-sm-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
    .col-sm-3 { flex: 0 0 25%; max-width: 25%; }
    .col-sm-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-sm-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
    .col-sm-6 { flex: 0 0 50%; max-width: 50%; }
    .col-sm-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
    .col-sm-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .col-sm-9 { flex: 0 0 75%; max-width: 75%; }
    .col-sm-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
    .col-sm-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
    .col-sm-12 { flex: 0 0 100%; max-width: 100%; }
    
    /* Hero section tablet */
    .hero-section {
        min-height: 70vh;
        padding: 60px 0;
    }
    
    .hero-title {
        font-size: 2.5rem;
    }
    
    /* Navigation tablet */
    .nav-menu {
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .nav-item {
        margin: 0 10px 10px 0;
    }
    
    /* Card layouts */
    .card-deck {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .card-deck .card {
        flex: 1 1 calc(50% - 20px);
        max-width: calc(50% - 20px);
        margin: 10px;
    }
    
    /* Handle/show elements on tablet */
    .d-tablet-none {
        display: none !important;
    }
    
    .d-tablet-block {
        display: block !important;
    }
    
    .d-tablet-flex {
        display: flex !important;
    }
}

/* ==========================================================================
   DESKTOP OPTIMIZATIONS (992px and up)
   ========================================================================== */

@media (min-width: 992px) {
    /* Grid system for desktop */
    .col-md-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
    .col-md-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
    .col-md-3 { flex: 0 0 25%; max-width: 25%; }
    .col-md-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-md-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
    .col-md-6 { flex: 0 0 50%; max-width: 50%; }
    .col-md-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
    .col-md-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .col-md-9 { flex: 0 0 75%; max-width: 75%; }
    .col-md-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
    .col-md-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
    .col-md-12 { flex: 0 0 100%; max-width: 100%; }
    
    /* Container desktop */
    .container {
        max-width: 1200px;
    }
    
    /* Navigation desktop */
    .nav-toggle {
        display: none;
    }
    
    .main-nav {
        position: static;
        width: auto;
        height: auto;
        background: transparent;
        padding: 0;
    }
    
    .nav-menu {
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    .nav-item {
        margin: 0 15px;
    }
    
    .nav-link {
        display: inline-block;
        padding: 10px 0;
        border-bottom: none;
        position: relative;
    }
    
    .nav-link::after {
        content: '';
        position: absolute;
        width: 0;
        height: 2px;
        bottom: 0;
        left: 50%;
        background: var(--primary-color);
        transition: all 0.3s ease;
    }
    
    .nav-link:hover::after {
        width: 100%;
        left: 0;
    }
    
    /* Card layouts desktop */
    .card-deck .card {
        flex: 1 1 calc(33.333% - 20px);
        max-width: calc(33.333% - 20px);
    }
    
    /* Handle elements on desktop */
    .d-desktop-none {
        display: none !important;
    }
    
    .d-desktop-block {
        display: block !important;
    }
    
    .d-desktop-flex {
        display: flex !important;
    }
}

/* ==========================================================================
   LARGE DESKTOP OPTIMIZATIONS (1200px and up)
   ========================================================================== */

@media (min-width: 1200px) {
    /* Grid system for large desktop */
    .col-lg-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
    .col-lg-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
    .col-lg-3 { flex: 0 0 25%; max-width: 25%; }
    .col-lg-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-lg-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
    .col-lg-6 { flex: 0 0 50%; max-width: 50%; }
    .col-lg-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
    .col-lg-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .col-lg-9 { flex: 0 0 75%; max-width: 75%; }
    .col-lg-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
    .col-lg-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
    .col-lg-12 { flex: 0 0 100%; max-width: 100%; }
    
    .container {
        max-width: 1400px;
    }
    
    .card-deck .card {
        flex: 1 1 calc(25% - 20px);
        max-width: calc(25% - 20px);
    }
}

/* ==========================================================================
   ULTRA-WIDE OPTIMIZATIONS (1400px and up)
   ========================================================================== */

@media (min-width: 1400px) {
    /* Grid system for ultra-wide */
    .col-xl-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
    .col-xl-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
    .col-xl-3 { flex: 0 0 25%; max-width: 25%; }
    .col-xl-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-xl-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
    .col-xl-6 { flex: 0 0 50%; max-width: 50%; }
    .col-xl-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
    .col-xl-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .col-xl-9 { flex: 0 0 75%; max-width: 75%; }
    .col-xl-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
    .col-xl-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
    .col-xl-12 { flex: 0 0 100%; max-width: 100%; }
    
    .container {
        max-width: 1600px;
    }
}

/* ==========================================================================
   PRINT OPTIMIZATIONS
   ========================================================================== */

@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
        color: #000;
        background: #fff;
    }
    
    .header,
    .footer,
    .social-panel,
    .nav-toggle,
    .btn,
    .modal {
        display: none !important;
    }
    
    .container {
        max-width: 100% !important;
        width: 100% !important;
        padding: 0 !important;
    }
    
    h1, h2, h3, h4, h5, h6 {
        color: #000 !important;
        page-break-after: avoid;
    }
    
    p, li {
        page-break-inside: avoid;
    }
    
    table {
        page-break-inside: auto;
    }
    
    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
    
    thead {
        display: table-header-group;
    }
    
    .card,
    .section {
        page-break-inside: avoid;
    }
}

/* ==========================================================================
   ACCESSIBILITY IMPROVEMENTS
   ========================================================================== */

/* Focus indicators */
button:focus,
a:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --bg-primary: #000000;
        --text-primary: #ffffff;
        --border-color: #ffffff;
    }
}

/* 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 preference */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1a1a2e;
        --bg-secondary: #16213e;
        --text-primary: #ffffff;
        --text-secondary: #d1d5db;
    }
}

/* ==========================================================================
   PERFORMANCE OPTIMIZATIONS
   ========================================================================== */

/* GPU acceleration for smoother animations */
.card,
.btn,
.nav-link,
.modal,
.social-panel {
    transform: translateZ(0);
    will-change: transform;
}

/* Optimize image rendering */
img {
    height: auto;
    max-width: 100%;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: optimize-contrast;
}

/* Scroll optimization */
.scrollable {
    -webkit-overflow-scrolling: touch;
    overflow-scrolling: touch;
}

/* Reduce layout shifts */
.hero-section,
.card,
.modal {
    contain: layout style paint;
}