/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2b3044; /* Dark blue/gray for buttons and text */
    --secondary-color: #fca5a5; /* Soft red for discount/out of stock */
    --bg-color: #f0f0f4; /* Light grey background for the app */
    --surface-color: #ffffff; /* White cards */
    --text-main: #333333;
    --text-muted: #888888;
    --brand-bg: #e5d9c5; /* Sand color for brand logos */
    --border-color: #eaeaea;
    --nav-bg: #e1d3c1; /* Bottom nav background color in screenshot */
}

body {
    font-family: 'Tajawal', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body.en-mode {
    font-family: 'Inter', 'Roboto', sans-serif; /* Use suitable LTR font */
}

/* Fix direction-specific alignments for LTR */
body[dir="ltr"] .product-rating {
    flex-direction: row-reverse;
}
body[dir="ltr"] .add-to-cart-btn i,
body[dir="ltr"] .nav-item i {
    margin-right: 5px;
    margin-left: 0;
}
body[dir="ltr"] .out-of-stock-overlay {
    direction: ltr;
}

/* Typography Helpers */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    font-family: inherit;
    border: none;
    background: none;
    cursor: pointer;
}

img {
    max-width: 100%;
    display: block;
}

/* Header */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: var(--bg-color);
}

.icon-btn {
    font-size: 1.2rem;
    color: var(--primary-color);
}

.logo {
    font-size: 1.5rem;
    color: var(--primary-color);
}

/* Category Navigation */
.category-nav {
    padding: 0 15px 10px;
    background-color: var(--bg-color);
    border-bottom: 2px solid #ddd;
    margin-bottom: 15px;
}

.category-nav ul {
    list-style: none;
    display: flex;
    overflow-x: auto;
    gap: 20px;
    padding-bottom: 5px;
    scrollbar-width: none; /* Firefox */
}

.category-nav ul::-webkit-scrollbar {
    display: none; /* Chrome, Safari */
}

.category-nav li {
    white-space: nowrap;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-muted);
}

.category-nav li.active {
    color: var(--primary-color);
    font-weight: 700;
    position: relative;
}

.category-nav li.active::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--primary-color);
    border-radius: 3px;
}

/* Content Area */
.content-area {
    padding: 0 15px;
}

/* Hero Section */
.hero-section {
    margin-bottom: 5px;
    position: relative;
}

.hero-slider {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    scroll-behavior: smooth;
    border-radius: 15px;
}

.hero-slider::-webkit-scrollbar {
    display: none;
}

.hero-slide {
    min-width: 100%;
    flex: 0 0 100%;
    scroll-snap-align: center;
}

.hero-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 15px;
}

/* Slider Dots */
.slider-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
    margin-bottom: 15px;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: #d1d5db;
    border-radius: 50%;
    transition: background-color 0.3s ease;
    cursor: pointer;
}

.dot.active {
    background-color: var(--primary-color);
    width: 15px;
    border-radius: 4px;
}

/* Brands Section */
.brands-section {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 25px;
}

.brand-item {
    flex: 1;
    background-color: var(--brand-bg);
    border-radius: 12px;
    overflow: hidden;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.brand-item img {
    max-height: 80%;
    max-width: 80%;
    object-fit: contain;
    mix-blend-mode: multiply; /* Helps blend white bg logos if any */
}

/* Products Section */
.products-section {
    margin-bottom: 30px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.section-title {
    font-size: 1.1rem;
    color: var(--primary-color);
}

.view-all {
    font-size: 0.85rem;
    color: var(--primary-color);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.horizontal-scroll {
    display: flex;
    overflow-x: auto;
    gap: 12px;
    padding-bottom: 10px;
    scrollbar-width: none;
    scroll-snap-type: x mandatory;
}
.horizontal-scroll::-webkit-scrollbar {
    display: none;
}
.horizontal-scroll .product-card {
    min-width: 160px;
    max-width: 160px;
    flex: 0 0 auto;
    scroll-snap-align: start;
}

.product-card {
    background-color: var(--surface-color);
    border-radius: 15px;
    padding: 10px;
    position: relative;
    display: flex;
    flex-direction: column;
}

.product-card.out-of-stock {
    opacity: 0.7;
}

.product-image {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
    background-color: #f9f9f9;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-image img {
    max-height: 90%;
    object-fit: contain;
}

.out-of-stock-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--secondary-color);
    color: white;
    padding: 5px 15px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.85rem;
    z-index: 2;
    white-space: nowrap;
}

.product-info {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    justify-content: space-between;
}

.product-title-rating {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    gap: 5px;
}

.product-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-rating {
    font-size: 0.75rem;
    color: #eab308; /* Star yellow */
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 2px;
    white-space: nowrap;
}

.product-pricing {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.price-old-new {
    display: flex;
    flex-direction: column;
}

.new-price {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-main);
}

.new-price small {
    font-size: 0.7rem;
    font-weight: 400;
}

.old-price {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: line-through;
}

.discount-badge {
    background-color: var(--secondary-color);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 6px;
    border-radius: 6px;
    direction: ltr; /* Keeps -50% formatting */
}

.product-actions {
    display: flex;
    gap: 8px;
}

.add-to-cart-btn {
    flex-grow: 1;
    background-color: var(--primary-color);
    color: white;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 8px;
    padding: 8px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: background-color 0.2s;
}

.add-to-cart-btn:disabled {
    background-color: #a0a0a0;
    cursor: not-allowed;
}

.favorite-btn {
    width: 35px;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: color 0.2s, border-color 0.2s;
}

/* Banner Section */
.banner-section {
    margin-bottom: 25px;
}

.banner-image {
    width: 100%;
    border-radius: 15px;
    object-fit: cover;
    height: 150px;
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--nav-bg);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 15px 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    z-index: 10;
}

.nav-item {
    color: var(--primary-color);
    font-size: 1.3rem;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.nav-item.active {
    opacity: 1;
}

.nav-item.active::after {
    content: '';
    position: absolute;
    bottom: -8px;
    width: 6px;
    height: 6px;
    background-color: var(--primary-color);
    border-radius: 50%;
}

/* Media Query for larger screens relative to mobile */
@media (min-width: 500px) {
    .product-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 768px) {
    .content-area {
        max-width: 600px;
        margin: 0 auto;
    }
    
    .category-nav ul {
        justify-content: center;
    }
    
    .bottom-nav {
        max-width: 600px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 20px 20px 0 0;
    }
}

/* Cart Badge */
.cart-badge {
    position: absolute;
    top: -5px;
    right: -10px;
    background-color: var(--secondary-color);
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Cart Details */
.cart-item {
    display: flex;
    background: white;
    margin-bottom: 15px;
    border-radius: 12px;
    padding: 12px;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.cart-item img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 8px;
    background: #f9f9f9;
}
.cart-item-info {
    flex-grow: 1;
}
.cart-item-title {
    font-size: 0.95rem;
    margin-bottom: 5px;
    color: var(--text-main);
}
.cart-item-price {
    font-weight: 800;
    color: var(--primary-color);
}
.cart-item-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.remove-btn {
    color: var(--secondary-color);
    font-size: 1.2rem;
    transition: transform 0.2s;
}
.remove-btn:active {
    transform: scale(0.9);
}
.cart-item-count {
    font-weight: bold;
    background: #f0f0f4;
    padding: 5px 12px;
    border-radius: 8px;
}
.checkout-btn {
    background-color: var(--primary-color);
    color: white;
    width: 100%;
    padding: 15px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: bold;
    margin-top: 20px;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s;
}
.checkout-btn:hover {
    opacity: 0.9;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--surface-color);
    width: 90%;
    max-width: 400px;
    border-radius: 15px;
    padding: 25px;
    position: relative;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close-modal {
    position: absolute;
    top: 15px;
    left: 20px;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-content h3 {
    margin-bottom: 20px;
    color: var(--primary-color);
    text-align: center;
}

/* Form Styles */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    font-size: 0.9rem;
    color: var(--text-main);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.whatsapp-btn {
    background-color: #25D366; /* WhatsApp Green */
    color: white;
    width: 100%;
    padding: 15px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: bold;
    margin-top: 10px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background-color 0.2s;
}

.whatsapp-btn:hover {
    background-color: #1ebe57;
}

.whatsapp-btn:disabled {
    background-color: #9cdbaf;
    cursor: not-allowed;
}

/* Product Details Page */
.product-gallery {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.main-gallery-img {
    grid-column: 1 / -1;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 15px;
    background-color: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.sub-gallery-img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 8px;
    background-color: white;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.sub-gallery-img:hover {
    border-color: var(--primary-color);
}

