﻿ 
/* Global box-sizing for consistent layout */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', sans-serif;
    margin: 0;
    background-color: #f4f7f6;
    min-height: 100vh;
    display: block;
    overflow-x: hidden; /* Prevent horizontal scroll when header is full width */
    padding-top: 140px; /* Adjusted padding to create space below sticky header (70px logo + 10px gap + 40px language bar + 20px content gap = 140px) */
}

/* NEW: Wrapper for header sections */
.header-section-wrapper {
    position: relative;
    width: 100%; /* Take full width of the viewport */
    z-index: 1000; /* Ensure headers are above other content */
}

.logo-top-bar {
    background-color: #fff;
    padding: 10px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: fixed; /* Changed to fixed to be truly above all content */
    top: 0;
    width: 100%; /* Ensure it spans full width when fixed */
    z-index: 1001; /* Higher z-index than language bar */
}

.top-language-bar {
    background-color: #e0e0e0;
    padding: 8px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    position: fixed; /* Changed to fixed to be truly above all content */
    top: 80px; /* Adjusted: Below the logo bar (70px) + 10px space */
    width: 100%; /* Ensure it spans full width when fixed */
    z-index: 1000;
}

.lang-buttons-wrapper {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.top-lang-button {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px; /* Rounded corners */
    padding: 5px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    font-weight: 400;
    color: #333;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

    .top-lang-button:hover {
        background-color: #f0f0f0;
        border-color: #bbb;
    }

    .top-lang-button.active {
        background-color: #007bff;
        color: #fff;
        border-color: #007bff;
        font-weight: 700;
    }

.flag-icon {
    width: 15px; /* Reduced width for smaller flags */
    height: 10px; /* Reduced height for smaller flags */
    border-radius: 3px;
}

.location-section {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    color: #555;
    padding: 5px 10px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: background-color 0.3s ease;
    opacity: 1; /* Ensure visibility */
    visibility: visible; /* Ensure visibility */
}

    .location-section:hover {
        background-color: #f0f0f0;
    }

.sidebar {
    position: fixed; /* Make it fixed in the viewport */
    top: 130px; /* Start from under the header */
    right: 0; /* Stick to right edge of viewport */
    width: 200px; /* Reduced sidebar width */
    height: calc(100vh - 130px); /* Full viewport height minus header height */
    z-index: 999; /* Lower z-index than headers, higher than main content */
    background-color: #f0f0f0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow-y: auto; /* Enable scrolling for sidebar content */
    border-radius: 0; /* No border-radius on the fixed edge */
    padding-top: 20px; /* Adjusted padding-top */
    padding-bottom: 20px;
    padding-left: 0;
    padding-right: 0;
}

    .sidebar nav ul {
        list-style: none;
        padding: 0;
        margin: 0;
        display: flex;
        flex-direction: column;
    }

        .sidebar nav ul li {
            margin-bottom: 5px;
        }

.sidebar-link {
    display: flex;
    /* Changed to column to stack image under text */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    text-decoration: none;
    color: #333;
    font-weight: 700;
    transition: background-color 0.3s ease, color 0.3s ease;
    border-radius: 8px;
    margin-left: 10px;
    margin-right: 0;
    text-align: center; /* Center text for stacked layout */
    gap: 0; /* Removed gap for stacked items */
}

    .sidebar-link img {
        width: 28px;
        height: 28px;
        /* Moved margin to top for spacing below text */
        margin: 10px 0 0 0;
        border-radius: 5px;
        object-fit: contain;
        /* Image after text */
        order: 1;
    }

    .sidebar-link span {
        /* Text before image */
        order: 0;
        /* Added margin-bottom for spacing between text and image */
        margin-bottom: 10px;
        flex-grow: unset; /* Prevent text from growing unnecessarily */
        text-align: center; /* Center text for stacked layout */
    }

    .sidebar-link:hover {
        background-color: #e6e6e6;
        color: #007bff;
    }

    .sidebar-link.active {
        background-color: #007bff;
        color: #fff;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
        border-right: none;
        border-bottom: none;
    }

/* Wrapper for the content to the left of the sidebar */
.page-content-wrapper {
    max-width: 1200px; /* Max width for the content area */
    margin: 20px auto; /* Center content area horizontally relative to its new position */
    padding: 20px; /* Padding for the entire content block */
    background-color: #fff; /* White background for the main content block */
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column; /* Stack content elements inside */
    gap: 20px;
}

.main-content {
    margin-right: 200px; /* Add margin to main content to offset fixed sidebar */
    margin-top: 0; /* Removed margin-top as body padding handles it */
}

#home-view, #category-detail-view {
    padding: 0; /* Managed by page-content-wrapper */
    width: 100%;
}

.hidden {
    display: none !important; /* Use important to ensure override */
}

/* Promo Banner and Ad Image Styling */
.promo-banner, .ad-image-wrapper {
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    margin: 0 auto; /* Center banner horizontally */
}

.promo-image, .ad-image {
    width: 100%;
    height: auto;
    max-height: 280px; /* Adjusted default max-height for ad banner */
    display: block;
    object-fit: cover;
    border-radius: 10px;
}

/* Category Grid Styling (Home View) */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
}

.category-item {
    display: flex;
    flex-direction: column; /* Already column, ensuring stacking */
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 15px;
    background-color: #eaf3ff;
    border-radius: 12px;
    text-decoration: none;
    color: #0056b3;
    font-weight: 700;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    min-height: 160px;
}

    .category-item:hover {
        transform: translateY(-5px);
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
        background-color: #d1e7ff;
    }

    .category-item img {
        display: block; /* Make image visible again */
        width: 60px; /* Set desired width for category images */
        height: 60px; /* Set desired height for category images */
        margin: 10px 0 0 0; /* Spacing below text, same as sidebar */
        border-radius: 8px;
        object-fit: contain;
        order: 1; /* Image after text */
    }

    .category-item span {
        font-size: 0.6rem; /* Further reduced font size for main categories */
        line-height: 1.3;
        order: 0; /* Text before image */
        margin-bottom: 10px; /* Added margin for spacing between text and image */
    }

/* Flex container for ad and subcategories in detail view */
.detail-content-wrapper {
    display: flex;
    flex-direction: column; /* Ad always above subcategories */
    gap: 20px;
}

    /* Adjust ad and subcategory containers within detail-content-wrapper */
    .detail-content-wrapper .ad-image-wrapper {
        margin: 0 auto;
    }

    .detail-content-wrapper .subcategories-container {
        display: grid;
        /* Changed to 2 columns for all screen sizes */
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

/* Subcategory item styling to match main category item */
.subcategory-item {
    display: flex;
    flex-direction: column; /* Text on top, image below (but image hidden) */
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 15px; /* Matched category-item padding */
    background-color: #eaf3ff; /* Matched category-item background */
    border: none; /* Removed border to match category-item */
    border-radius: 12px; /* Matched category-item border-radius */
    text-decoration: none;
    color: #0056b3; /* Matched category-item color */
    font-size: 0.6rem; /* Matched category-item font-size */
    font-weight: 700; /* Matched category-item font-weight */
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease; /* Matched category-item transition */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* Matched category-item box-shadow */
    min-height: 160px; /* Matched category-item min-height */
    gap: 0; /* No gap needed between stacked items */
}

    .subcategory-item:hover {
        background-color: #d1e7ff; /* Matched category-item hover background */
        transform: translateY(-5px); /* Matched category-item hover transform */
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15); /* Matched category-item hover box-shadow */
    }

    .subcategory-item.active {
        background-color: #007bff;
        color: #fff;
        border-color: #007bff;
        font-weight: 700;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    }

    .subcategory-item img {
        display: none; /* Image is always hidden in subcategory-item */
    }

    .subcategory-item span {
        order: 0; /* Text before image (though image is hidden) */
        margin-bottom: 0; /* No margin needed if image is gone */
    }


/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

    .modal-overlay.active {
        opacity: 1;
        visibility: visible;
    }

.state-selection-modal {
    background-color: #fff;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 450px;
    text-align: center;
    position: relative;
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active.state-selection-modal {
    transform: translateY(0);
}

.close-modal-button {
    position: absolute;
    top: 15px;
    left: 15px; /* Adjust for RTL */
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #aaa;
    transition: color 0.2s ease;
}

    .close-modal-button:hover {
        color: #555;
    }

.state-selection-modal h2 {
    margin-top: 0;
    margin-bottom: 25px;
    color: #333;
    font-size: 1.8rem;
}

.state-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.state-item {
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    color: #333;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

    .state-item:hover {
        background-color: #e6e6e6;
        border-color: #ccc;
        transform: translateX(5px);
    }

    .state-item.active {
        background-color: #007bff;
        color: #fff;
        border-color: #007bff;
        font-weight: 700;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    }

/* Responsive Adjustments */
@media (min-width: 768px) {
    /* Subcategories in 2 columns on wider screens */
    .detail-content-wrapper .subcategories-container {
        grid-template-columns: repeat(2, 1fr); /* Remains 2 columns for larger screens */
    }
}

/* Ensure fixed sidebar behavior on all screens */
@media (max-width: 768px) {
    /* Adjust main content margin for smaller screens */
    .main-content {
        margin-right: 150px;
    }

    .sidebar {
        width: 150px; /* Further reduced sidebar width for smaller screens */
        padding-top: 20px; /* Keep consistent padding */
        height: calc(100vh - 130px); /* Adjust height for smaller screens too */
    }

    .header-section-wrapper {
        width: 100%; /* Take full width */
    }

    .logo-top-bar, .top-language-bar {
        width: 100%; /* Revert to full width */
        right: 0; /* Reset shift */
    }

    .page-content-wrapper {
        margin: 15px; /* Adjust margin for mobile */
        padding: 15px; /* Adjust padding for mobile */
        /* max-width: 100%; will now apply within the reduced body width */
    }

    /* Detail content wrapper (ad and subcategories) will naturally stack due to flex-direction: column */
    .detail-content-wrapper {
        padding: 15px; /* Adjust padding for mobile */
    }

        .detail-content-wrapper .ad-image-wrapper {
            margin-bottom: 15px; /* Add margin below ad on mobile when stacked */
        }

        .detail-content-wrapper .subcategories-container {
            grid-template-columns: repeat(2, 1fr); /* Set to 2 columns for small devices */
        }

    .category-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); /* Adjusted for 2 columns on mobile */
        gap: 10px;
    }

    .category-item {
        padding: 8px;
    }

        .category-item img {
            width: 45px;
            height: 45px;
        }

    .top-language-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 10px;
        top: 60px;
    }

    .lang-buttons-wrapper {
        justify-content: center;
        width: 100%;
        margin-bottom: 10px;
    }

    .location-section {
        justify-content: center;
        width: 100%;
        height: auto;
        opacity: 1;
        visibility: visible;
    }
}

@media (max-width: 480px) {
    /* Adjust main content margin for very small screens */
    .main-content {
        margin-right: 120px;
    }

    .sidebar {
        width: 120px; /* Even smaller sidebar width for very small screens */
    }

    .category-grid {
        grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
        gap: 8px;
    }

    .category-item span {
        font-size: 0.8rem;
    }

    .subcategory-item {
        padding: 6px 8px;
        font-size: 0.75rem;
        min-width: 70px;
    }

        .subcategory-item img {
            width: 28px;
            height: 28px;
        }

    .state-selection-modal {
        padding: 15px;
    }

    .state-item {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    .promo-image, .ad-image {
        max-height: 400px; /* Further larger ad banner on very small screens */
    }
}
 
