/* =========================================
   MOBILE ADAPTATION (RESPONSIVE DESIGN)
   ========================================= */

/* --- GLOBAL ADJUSTMENTS --- */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
        width: 100%;
    }
    
    /* Fix scroll margin for sticky headers */
    #home, #service, #contacts, #catalog-section, section {
        scroll-margin-top: 80px;
    }

    /* Typography */
    h1 { font-size: 28px !important; }
    h2 { font-size: 24px !important; }
    p { font-size: 14px !important; }
    
    /* Hide scrollbars for cleaner look but allow scroll */
    ::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }
}

/* --- HEADER & NAVIGATION --- */
@media (max-width: 900px) {
    .header-wrapper {
        width: 95%;
        padding: 0 15px;
        height: 60px;
        top: 10px;
        justify-content: space-between;
    }

    /* Hide desktop nav links text */
    .nav-menu ul li:not(.catalog-wrapper) {
        display: none !important; 
    }
    
    /* Adjust Logo */
    .nav-logo span {
        font-size: 18px !important;
    }

    /* Adjust Icons */
    .nav-icons {
        gap: 8px;
        min-width: auto;
        margin-left: 0;
    }
    
    .icon-btn {
        width: 36px;
        height: 36px;
    }
    
    /* Catalog Button Mobile */
    .btn-catalog-trigger span {
        font-size: 14px;
    }
    .btn-catalog-trigger {
        padding: 0 8px;
    }
}

/* --- HERO SECTION --- */
@media (max-width: 768px) {
    .hero {
        flex-direction: column;
        text-align: center;
        padding-top: 100px;
        height: auto;
        min-height: auto;
        padding-bottom: 40px;
    }
    
    .hero-text {
        max-width: 100%;
        margin-bottom: 30px;
        padding: 0 10px;
    }
    
    .hero-img-placeholder {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
        height: auto;
    }
    
    .hero-img-float {
        position: static;
        transform: none;
        max-width: 100%;
    }
}

/* --- CATALOG & PRODUCTS --- */
@media (max-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 columns on mobile */
        gap: 10px;
    }
    
    .product-card {
        padding: 10px;
    }
    
    .product-thumb {
        height: 140px;
        margin-bottom: 10px;
    }
    
    .product-title {
        font-size: 14px;
        height: 40px; /* Limit height */
        overflow: hidden;
    }
    
    .product-price {
        font-size: 16px;
    }
    
    .product-actions {
        margin-top: 10px;
    }
    
    .btn-add-cart {
        padding: 8px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    /* On very small screens, maybe 1 column or keep 2 small ones */
    .products-grid {
        gap: 8px;
    }
    .product-thumb {
        height: 120px;
    }
}

/* --- PRODUCT DETAILS PAGE --- */
@media (max-width: 900px) {
    .product-page-layout {
        display: flex;
        flex-direction: column;
        gap: 20px;
        margin-bottom: 40px;
    }
    
    .product-gallery {
        width: 100%;
        display: flex;
        flex-direction: column-reverse; /* Thumbs below main image */
        gap: 10px;
    }
    
    .thumbs-col {
        flex-direction: row;
        width: 100%;
        overflow-x: auto;
        justify-content: flex-start;
        padding-bottom: 5px;
    }
    
    .thumb-btn {
        width: 60px;
        height: 60px;
        flex-shrink: 0;
    }
    
    .main-img-wrap {
        height: 300px;
        width: 100%;
    }
    
    .main-product-img {
        object-fit: contain;
    }
    
    .product-info-col {
        width: 100%;
        padding: 0 5px;
    }
    
    .pd-title {
        font-size: 24px;
    }
    
    .pd-actions {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background: white;
        padding: 15px;
        box-shadow: 0 -5px 20px rgba(0,0,0,0.1);
        z-index: 100;
        display: flex;
        gap: 10px;
    }
    
    /* Add padding to body so content isn't hidden behind fixed actions */
    body {
        padding-bottom: 80px; 
    }
    
    .btn-buy {
        height: 50px;
        font-size: 16px;
    }
}

/* --- REVIEWS --- */
@media (max-width: 768px) {
    .reviews-section {
        padding: 20px 0;
    }
    
    .review-card {
        padding: 15px;
        border-radius: 12px;
    }
    
    .review-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .rev-actions {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .rev-actions button {
        padding: 5px 10px;
        font-size: 13px;
    }
}

/* --- ADMIN PANEL --- */
@media (max-width: 1024px) {
    .admin-container {
        display: flex;
        flex-direction: column;
    }
    
    .admin-sidebar {
        width: 100%;
        height: auto;
        position: relative;
        padding: 15px;
        flex-direction: row;
        overflow-x: auto;
        align-items: center;
        gap: 10px;
    }
    
    .admin-sidebar h2 {
        margin-bottom: 0;
        margin-right: 20px;
        font-size: 20px;
        white-space: nowrap;
    }
    
    .admin-nav {
        display: flex;
        gap: 10px;
    }
    
    .admin-nav button {
        width: auto;
        white-space: nowrap;
        padding: 8px 15px;
        margin-bottom: 0;
        font-size: 14px;
    }
    
    .admin-content {
        padding: 15px;
        overflow-x: hidden; /* Prevent horizontal scroll on body */
    }
    
    /* Make tables scrollable */
    .table-responsive, .admin-content {
        overflow-x: auto;
    }
    
    table {
        min-width: 800px; /* Force scroll for wide tables */
    }
    
    /* Chat adjustments */
    .chat-layout {
        grid-template-columns: 1fr; /* Stack chat list and window */
        height: calc(100vh - 150px);
    }
    
    .chat-list {
        display: none; /* Hide list when chat is open? Or show list first */
        /* For simplicity, let's just make it 30% 70% on tablet, and stack on mobile */
    }
}

@media (max-width: 768px) {
    .chat-layout {
        display: flex;
        flex-direction: column;
        height: 80vh;
    }
    
    .chat-list {
        display: flex; /* Show list */
        height: 150px;
        overflow-y: auto;
        border-right: none;
        border-bottom: 1px solid #eee;
    }
    
    .chat-window {
        flex: 1;
    }
}

/* --- FOOTER --- */
@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        gap: 30px;
        text-align: center;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 15px;
    }
    
    .footer-bottom {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
}

/* --- MODALS --- */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        padding: 20px;
    }
    
    .lightbox-img {
        max-width: 95%;
        max-height: 80vh;
    }
}

/* --- CATALOG PAGE --- */
@media (max-width: 900px) {
    .catalog-layout {
        display: flex;
        flex-direction: column;
    }
    
    .filters-sidebar {
        width: 100%;
        margin-bottom: 20px;
        background: #f9f9f9;
        padding: 15px;
        border-radius: 12px;
    }
    
    .catalog-page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .sort-wrapper {
        width: 100%;
    }
    
    .custom-select {
        width: 100%;
    }
}
