@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800&display=swap');

:root {
    --color-bg:          #f4f7f2;
    --color-surface:     #ffffff;
    --color-primary:     #1e4d2b;
    --color-primary-mid: #2d6a3f;
    --color-primary-soft:#e8f0e9;
    --color-text:        #0f1f13;
    --color-text-muted:  #5a7060;
    --color-border:      #dde8de;
    --color-danger:      #c0392b;
    --color-warning:     #b7791f;
    --color-success:     #1e4d2b;
    --font: 'Cairo', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
    direction: rtl;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; transition: color 150ms ease; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: var(--font); border: none; background: none; }
input, textarea, select { font-family: var(--font); }
ul, ol { list-style: none; }

/* ── Container ── */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 28px;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    border: none;
    transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
    line-height: 1;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}
.btn-primary:hover { background: var(--color-primary-mid); }

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--color-primary);
    color: var(--color-primary);
}
.btn-outline:hover { background: var(--color-primary); color: #fff; }

.btn-ghost {
    background: var(--color-primary-soft);
    color: var(--color-primary);
}
.btn-ghost:hover { background: var(--color-primary); color: #fff; }

.btn-sm { padding: 8px 18px; font-size: 13px; }
.btn-lg { padding: 14px 36px; font-size: 16px; }
.btn-full { width: 100%; }

/* ── Cards ── */
.card {
    background: var(--color-surface);
    border-radius: 20px;
    border: 1px solid var(--color-border);
    padding: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    transition: transform 150ms ease, border-color 150ms ease;
}
.card:hover {
    transform: translateY(-2px);
    border-color: var(--color-primary);
}

/* ── Product Card ── */
.product-card {
    background: var(--color-surface);
    border-radius: 20px;
    border: 1px solid var(--color-border);
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    transition: transform 150ms ease, border-color 150ms ease;
    position: relative;
}
.product-card:hover {
    transform: translateY(-2px);
    border-color: var(--color-primary);
}
.product-card .card-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 16px 16px 0 0;
    background: var(--color-primary-soft);
}
.product-card .card-body { padding: 14px; }
.product-card .card-category {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}
.product-card .card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.product-card .card-price {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.product-card .price-current {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-primary);
}
.product-card .price-old {
    font-size: 13px;
    color: var(--color-text-muted);
    text-decoration: line-through;
}
.product-card .badge-discount {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--color-danger);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
}

/* ── Category Chip ── */
.chip {
    display: inline-flex;
    align-items: center;
    background: var(--color-primary-soft);
    color: var(--color-primary);
    border-radius: 999px;
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease;
    border: none;
    font-family: var(--font);
}
.chip:hover, .chip.active {
    background: var(--color-primary);
    color: #fff;
}

/* ── Forms ── */
.form-group { margin-bottom: 20px; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--color-border);
    border-radius: 14px;
    font-size: 15px;
    font-family: var(--font);
    color: var(--color-text);
    background: var(--color-surface);
    transition: border-color 150ms ease;
    direction: rtl;
}
.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
}
.form-control::placeholder { color: var(--color-text-muted); }

.form-error { font-size: 13px; color: var(--color-danger); margin-top: 4px; }

/* ── Alerts ── */
.alert {
    padding: 14px 18px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 16px;
}
.alert-success { background: var(--color-primary-soft); color: var(--color-primary); border: 1px solid var(--color-border); }
.alert-danger  { background: #fdecea; color: var(--color-danger); border: 1px solid #f5c6c2; }
.alert-warning { background: #fef9ec; color: var(--color-warning); border: 1px solid #f5e4b0; }

/* ── Section ── */
.section { padding: 56px 0; }
.section-sm { padding: 32px 0; }

.section-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 24px;
}

/* ── Products Grid ── */
.products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

/* ── Header ── */
.site-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 68px;
    gap: 16px;
}
.site-logo {
    font-size: 20px;
    font-weight: 800;
    color: var(--color-primary);
    letter-spacing: -0.5px;
}
.site-nav {
    display: flex;
    align-items: center;
    gap: 24px;
}
.site-nav a {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-muted);
    padding: 4px 0;
    border-bottom: 2px solid transparent;
    transition: color 150ms ease, border-color 150ms ease;
}
.site-nav a:hover, .site-nav a.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    color: var(--color-text);
    transition: background 150ms ease, color 150ms ease;
    background: none;
    border: none;
    cursor: pointer;
}
.icon-btn:hover { background: var(--color-primary-soft); color: var(--color-primary); }
.icon-btn svg { width: 20px; height: 20px; }
.badge-count {
    position: absolute;
    top: 2px;
    left: 2px;
    background: var(--color-primary);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 17px;
    height: 17px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

/* ── Footer ── */
.site-footer {
    background: var(--color-text);
    color: rgba(255,255,255,0.65);
    padding: 48px 0 24px;
    margin-top: 64px;
}
.footer-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
    margin-bottom: 32px;
}
.site-footer h4 {
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 12px;
}
.site-footer a { color: rgba(255,255,255,0.55); font-size: 14px; }
.site-footer a:hover { color: #fff; }
.site-footer ul li { margin-bottom: 8px; }
.footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 20px;
    text-align: center;
    font-size: 13px;
    color: rgba(255,255,255,0.35);
}

/* ── Toast ── */
.toast-wrap {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    pointer-events: none;
}
.toast {
    background: var(--color-text);
    color: #fff;
    padding: 12px 24px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: opacity 200ms ease, transform 200ms ease;
    transform: translateY(8px);
    white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--color-primary); }
.toast.error   { background: var(--color-danger); }

/* ── Spinner ── */
.spinner {
    width: 22px;
    height: 22px;
    border: 2.5px solid var(--color-primary-soft);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Skeleton ── */
.skeleton {
    background: var(--color-primary-soft);
    border-radius: 8px;
    animation: pulse 1.4s ease infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ── Modal ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--color-surface);
    border-radius: 24px;
    padding: 28px;
    max-width: 480px;
    width: 90%;
    position: relative;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .products-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
    .site-nav { display: none; }
    .header-inner { height: 60px; }
    .products-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
    .section { padding: 36px 0; }
    .container { padding: 0 16px; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
    @media (max-width: 480px) {
        .footer-grid { grid-template-columns: 1fr; }
    }
}
@media (max-width: 480px) {
    .products-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .footer-grid { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════
   RESPONSIVE - Mobile First
   ══════════════════════════════════════════════ */

/* Tablet: 768px */
@media (max-width: 768px) {

    /* Header */
    .site-nav { display: none; }
    .header-inner { height: 60px; }
    .site-logo { font-size: 18px; }

    /* Sections */
    .section { padding: 32px 0; }
    .section-sm { padding: 20px 0; }
    .container { padding: 0 16px; }

    /* Products grid */
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    /* Footer */
    .footer-grid {
        grid-template-columns: 1fr 1fr;
        gap: 24px;
    }

    /* Product show - stack columns */
    .product-show-grid {
        grid-template-columns: 1fr !important;
    }

    /* Checkout / Cart - stack */
    .two-col-grid {
        grid-template-columns: 1fr !important;
    }

    /* Account sidebar */
    .account-grid {
        grid-template-columns: 1fr !important;
    }

    /* Blog grid */
    .blog-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Services grid */
    .services-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Products index - hide sidebar */
    .products-layout {
        flex-direction: column !important;
    }
    .filters-sidebar {
        width: 100% !important;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    .filters-sidebar h3 { width: 100%; }
    .filters-sidebar > div {
        flex: 1;
        min-width: 140px;
    }

    /* Hero text */
    .hero-title { font-size: 28px !important; }

    /* Sticky summary - not sticky on mobile */
    .sticky-summary { position: static !important; }
}

/* Mobile: 480px */
@media (max-width: 480px) {

    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .footer-grid { grid-template-columns: 1fr; }

    .blog-grid { grid-template-columns: 1fr !important; }
    .services-grid { grid-template-columns: 1fr !important; }

    /* Card padding tighter */
    .card { padding: 14px; }

    /* Buttons full width in forms */
    .btn-form-full { width: 100%; }

    /* Hero */
    .hero-title { font-size: 24px !important; }
    .hero-btns {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    .hero-btns .btn { text-align: center; }

    /* Product show actions */
    .product-actions {
        flex-direction: column !important;
    }

    /* Auth cards */
    .auth-card { padding: 24px 20px !important; }

    /* Checkout grid */
    .checkout-form-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Mobile hamburger menu */
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 999px;
        background: none;
        border: none;
        cursor: pointer;
        color: var(--color-text);
    }
    .mobile-menu-btn:hover { background: var(--color-primary-soft); }

    .mobile-nav {
        display: none;
        position: fixed;
        inset: 0;
        background: var(--color-surface);
        z-index: 200;
        flex-direction: column;
        padding: 24px;
    }
    .mobile-nav.open { display: flex; }
    .mobile-nav a {
        font-size: 18px;
        font-weight: 600;
        color: var(--color-text);
        padding: 14px 0;
        border-bottom: 1px solid var(--color-border);
    }
    .mobile-nav a:hover { color: var(--color-primary); }
    .mobile-nav-close {
        align-self: flex-end;
        margin-bottom: 16px;
        background: none;
        border: none;
        font-size: 24px;
        cursor: pointer;
        color: var(--color-text);
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 999px;
    }
    .mobile-nav-close:hover { background: var(--color-primary-soft); }
}

@media (min-width: 769px) {
    .mobile-menu-btn { display: none; }
}
