/* =====================================================
   Musosi Platform - Mobile Responsive CSS
   Author: Joseph Kitonga
   Last Updated: August 2025
   ===================================================== */

/* ===== Base Responsive Settings ===== */
* {
    box-sizing: border-box;
}

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

img {
    max-width: 100%;
    height: auto;
}

/* ===== Mobile Navigation Toggle ===== */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    font-size: 28px;
    cursor: pointer;
    padding: 10px;
    color: #333;
}

.mobile-menu-toggle i {
    font-size: 32px;
}

/* ===== Mobile Navigation Overlay ===== */
.mobile-nav-overlay {
    position: fixed;
    top: 0;
    left: -100%;
    width: 85%;
    max-width: 350px;
    height: 100%;
    background: #fff;
    z-index: 9999;
    transition: left 0.3s ease-in-out;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

.mobile-nav-overlay.active {
    left: 0;
}

.mobile-nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.mobile-nav-close {
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
}

.mobile-nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mobile-nav-menu li {
    border-bottom: 1px solid #e9ecef;
}

.mobile-nav-menu a {
    display: block;
    padding: 15px 20px;
    color: #333;
    text-decoration: none;
    font-size: 16px;
    transition: background 0.3s;
}

.mobile-nav-menu a:hover {
    background: #f8f9fa;
    color: #ff6b35;
}

.mobile-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
}

.mobile-backdrop.active {
    display: block;
}

/* ===== Responsive Grid System ===== */
@media (max-width: 1200px) {
    .container.wide {
        max-width: 100%;
        padding: 0 20px;
    }
}

/* ===== Tablet Styles (768px - 991px) ===== */
@media (max-width: 991px) {
    /* Header adjustments */
    .mad-pre-header {
        display: none;
    }
    
    .mad-header-items {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 15px 0 !important;
    }
    
    .mad-header-item:first-child {
        display: none;
    }
    
    .mad-logo img {
        max-width: 150px !important;
    }
    
    /* Navigation */
    .mad-navigation-wrap {
        display: none;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    /* Hero sections */
    .rev_slider_wrapper {
        height: auto !important;
    }
    
    .tp-parallax-wrap {
        position: relative !important;
    }
    
    /* Cards and grids */
    .mad-products.mad-grid--3 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .mad-section {
        padding: 40px 0;
    }
    
    /* Forms */
    .mad-form-row {
        flex-direction: column;
    }
    
    .mad-form-row > div {
        width: 100%;
        margin-bottom: 15px;
    }
}

/* ===== Mobile Styles (max-width: 767px) ===== */
@media (max-width: 767px) {
    /* Typography */
    h1, .h1 { font-size: 28px !important; }
    h2, .h2 { font-size: 24px !important; }
    h3, .h3 { font-size: 20px !important; }
    h4, .h4 { font-size: 18px !important; }
    h5, .h5 { font-size: 16px !important; }
    h6, .h6 { font-size: 14px !important; }
    
    .mad-title { 
        font-size: 24px !important; 
        line-height: 1.3;
    }
    
    /* Header */
    .mad-header {
        position: sticky;
        top: 0;
        z-index: 1000;
        background: #fff;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    }
    
    .mad-header-item.align-center {
        text-align: center !important;
        flex: 1;
    }
    
    .mad-logo img {
        max-width: 120px !important;
    }
    
    .mad-actions {
        flex-direction: row;
        gap: 10px;
    }
    
    .mad-actions .mad-item a {
        padding: 8px;
    }
    
    .mad-actions .btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    /* Home page hero */
    .tp-bgimg {
        background-size: cover !important;
        background-position: center !important;
    }
    
    .rs-layer {
        font-size: 16px !important;
    }
    
    /* Product cards */
    .mad-products.mad-grid--3,
    .mad-products.mad-grid--4 {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .mad-product {
        margin-bottom: 20px;
    }
    
    .mad-product-image {
        height: 200px;
        overflow: hidden;
    }
    
    .mad-product-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    /* Chef cards */
    .mad-team-item {
        margin-bottom: 30px;
    }
    
    .mad-team-item .mad-col {
        width: 100%;
        margin-bottom: 20px;
    }
    
    /* Buttons */
    .btn {
        padding: 12px 20px;
        font-size: 14px;
        width: 100%;
        margin-bottom: 10px;
    }
    
    .btn.btn-big {
        padding: 15px 25px;
        font-size: 16px;
    }
    
    /* Forms */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    textarea,
    select {
        width: 100%;
        padding: 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Cart page */
    .cart-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .cart-table table {
        min-width: 500px;
    }
    
    .cart-sidebar {
        position: static;
        width: 100%;
        margin-top: 30px;
    }
    
    /* Checkout */
    .checkout-form .col-md-8,
    .checkout-form .col-md-4 {
        width: 100%;
        padding: 0 15px;
    }
    
    .order-summary {
        margin-top: 30px;
    }
    
    /* Menu item detail */
    .menu-item-detail .row {
        flex-direction: column;
    }
    
    .menu-item-image {
        margin-bottom: 20px;
    }
    
    .quantity-selector {
        justify-content: center;
        margin: 20px 0;
    }
    
    /* Footer */
    .mad-footer .mad-col {
        width: 100%;
        margin-bottom: 30px;
    }
    
    .mad-footer-bottom {
        text-align: center;
    }
    
    .mad-footer-bottom .mad-col {
        width: 100%;
        text-align: center;
    }
    
    /* Modal adjustments */
    .mad-modal {
        width: 90%;
        margin: 5%;
    }
    
    .modal-dialog {
        margin: 20px;
    }
    
    /* Listing page */
    .listing-filters {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .listing-filters select {
        width: 100%;
    }
    
    .chef-card {
        margin-bottom: 20px;
    }
    
    .chef-info {
        padding: 15px;
    }
    
    /* Reviews */
    .review-item {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .rating-stars {
        font-size: 14px;
    }
    
    /* Pagination */
    .pagination {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 5px;
    }
    
    .pagination li {
        margin: 2px;
    }
    
    /* Tabs */
    .nav-tabs {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .nav-tabs .nav-link {
        white-space: nowrap;
        padding: 10px 15px;
        font-size: 14px;
    }
    
    /* Accordion for mobile */
    .accordion-mobile .accordion-header {
        padding: 15px;
        background: #f8f9fa;
        border: 1px solid #dee2e6;
        cursor: pointer;
    }
    
    .accordion-mobile .accordion-body {
        padding: 15px;
        border: 1px solid #dee2e6;
        border-top: none;
    }
    
    /* Floating cart button for mobile */
    .mobile-cart-float {
        position: fixed;
        bottom: 20px;
        right: 20px;
        background: #ff6b35;
        color: white;
        width: 60px;
        height: 60px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 10px rgba(0,0,0,0.2);
        z-index: 1000;
    }
    
    .mobile-cart-float .badge {
        position: absolute;
        top: -5px;
        right: -5px;
        background: #dc3545;
        color: white;
        border-radius: 50%;
        width: 24px;
        height: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
    }
}

/* ===== Small Mobile Styles (max-width: 480px) ===== */
@media (max-width: 480px) {
    /* Extra small typography */
    body {
        font-size: 14px;
    }
    
    h1, .h1 { font-size: 24px !important; }
    h2, .h2 { font-size: 20px !important; }
    h3, .h3 { font-size: 18px !important; }
    
    /* Container padding */
    .container {
        padding: 0 15px;
    }
    
    /* Section padding */
    .mad-section {
        padding: 30px 0;
    }
    
    /* Logo */
    .mad-logo img {
        max-width: 100px !important;
    }
    
    /* Cards */
    .card {
        margin-bottom: 15px;
    }
    
    .card-body {
        padding: 15px;
    }
    
    /* Product grid - single column */
    .row.product-grid {
        margin: 0 -5px;
    }
    
    .row.product-grid > div {
        padding: 0 5px;
    }
    
    /* Table responsive */
    table {
        font-size: 12px;
    }
    
    .table td,
    .table th {
        padding: 8px;
    }
}

/* ===== Utility Classes for Mobile ===== */
.mobile-only {
    display: none;
}

@media (max-width: 767px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none !important;
    }
    
    .text-mobile-center {
        text-align: center !important;
    }
    
    .mobile-mb-20 {
        margin-bottom: 20px !important;
    }
    
    .mobile-mt-20 {
        margin-top: 20px !important;
    }
    
    .mobile-p-15 {
        padding: 15px !important;
    }
}

/* ===== Smooth Scrolling for Mobile ===== */
@media (max-width: 767px) {
    html {
        scroll-behavior: smooth;
    }
    
    .scroll-to-top {
        position: fixed;
        bottom: 80px;
        right: 20px;
        background: rgba(0,0,0,0.7);
        color: white;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 999;
        opacity: 0;
        transition: opacity 0.3s;
    }
    
    .scroll-to-top.show {
        opacity: 1;
    }
}

/* ===== Touch-friendly Elements ===== */
@media (hover: none) and (pointer: coarse) {
    /* Make clickable elements larger for touch */
    a, button, .btn, input[type="submit"] {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Remove hover effects on touch devices */
    a:hover, button:hover, .btn:hover {
        background-color: inherit;
    }
}

/* ===== Print Styles ===== */
@media print {
    .mad-header,
    .mad-footer,
    .mobile-menu-toggle,
    .mobile-nav-overlay,
    .no-print {
        display: none !important;
    }
}
