/*
 * Zlix Default Theme — Responsive UI
 * Version: 2.0.0
 */

:root {
    --primary: #ea580c;
    --primary-dark: #c2410c;
    --primary-light: #ffedd5;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --danger: #ef4444;
    --success: #16a34a;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.1);
    --header-h: 64px;
    --font: Vazirmatn, Tahoma, 'Segoe UI', system-ui, sans-serif;
    --max-w: 1140px;
    --transition: 0.2s ease;
}

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

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    direction: rtl;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

button, input, select, textarea {
    font-family: inherit;
    font-size: 15px;
}

/* ========== Layout ========== */
.container {
    width: 100%;
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 16px;
}

@media (min-width: 768px) {
    .container {
        padding: 0 24px;
    }
}

.page-main {
    flex: 1;
    padding: 24px 0 48px;
}

@media (min-width: 768px) {
    .page-main {
        padding: 32px 0 64px;
    }
}

/* ========== Header ========== */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: 0 1px 0 rgba(0,0,0,0.03);
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--header-h);
    gap: 12px;
}

.site-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
    flex-shrink: 0;
}

.site-logo:hover {
    color: var(--primary-dark);
}

/* Mobile menu toggle */
.nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    flex-shrink: 0;
}

.nav-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text);
    position: relative;
    transition: var(--transition);
}

.nav-toggle span::before,
.nav-toggle span::after {
    content: '';
    position: absolute;
    left: 0;
    width: 20px;
    height: 2px;
    background: var(--text);
    transition: var(--transition);
}

.nav-toggle span::before { top: -6px; }
.nav-toggle span::after { top: 6px; }

.nav-toggle[aria-expanded="true"] span {
    background: transparent;
}
.nav-toggle[aria-expanded="true"] span::before {
    top: 0;
    transform: rotate(45deg);
}
.nav-toggle[aria-expanded="true"] span::after {
    top: 0;
    transform: rotate(-45deg);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0 10px;
    color: var(--text);
    font-size: 14px;
    border-radius: var(--radius-sm);
}

.cart-link:hover {
    background: var(--bg);
    color: var(--primary);
}

.cart-badge {
    position: absolute;
    top: 4px;
    left: 2px;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 99px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

/* Nav drawer */
.site-nav {
    display: none;
    flex-direction: column;
    gap: 0;
    padding: 8px 0 16px;
    border-top: 1px solid var(--border);
}

.site-nav.is-open {
    display: flex;
}

.site-nav a {
    display: block;
    padding: 12px 4px;
    color: var(--text);
    font-size: 15px;
    border-radius: var(--radius-sm);
}

.site-nav a:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.header-search {
    display: none;
    padding: 0 0 14px;
}

.header-search.is-open,
.site-nav.is-open + .header-search,
.header-search-always {
    display: block;
}

.search-form {
    display: flex;
    gap: 8px;
    width: 100%;
}

.search-form input {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    outline: none;
    transition: border-color var(--transition);
}

.search-form input:focus {
    border-color: var(--primary);
    background: #fff;
}

@media (min-width: 900px) {
    .nav-toggle {
        display: none;
    }

    .header-top {
        gap: 24px;
    }

    .site-nav {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 4px;
        flex: 1;
        padding: 0;
        border: none;
        margin-right: 16px;
    }

    .site-nav a {
        padding: 8px 12px;
        font-size: 14px;
        white-space: nowrap;
    }

    .header-search {
        display: block;
        padding: 0;
        max-width: 280px;
        flex: 0 1 280px;
        order: 0;
    }

    .header-search .search-form input {
        padding: 9px 12px;
        font-size: 13px;
    }

    .header-layout {
        display: flex;
        align-items: center;
        gap: 16px;
        width: 100%;
    }
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--primary);
    color: #fff !important;
    padding: 12px 22px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
    text-align: center;
    min-height: 44px;
    line-height: 1.2;
}

.btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3);
}

.btn:active {
    transform: translateY(0);
}

.btn-outline {
    background: transparent;
    color: var(--primary) !important;
    border: 1.5px solid var(--primary);
}

.btn-outline:hover {
    background: var(--primary-light);
    box-shadow: none;
}

.btn-ghost {
    background: var(--surface);
    color: var(--text) !important;
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg);
    box-shadow: none;
}

.btn-danger {
    background: var(--danger);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 13px;
    min-height: 36px;
}

.btn-hero {
    background: #fff;
    color: var(--primary-dark) !important;
}

.btn-hero:hover {
    background: #f0fdfa;
    color: var(--primary-dark) !important;
}

/* ========== Hero ========== */
.hero {
    background: linear-gradient(135deg, #c2410c 0%, #ea580c 50%, #fb923c 100%);
    color: #fff;
    padding: 48px 16px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.12), transparent 50%);
    pointer-events: none;
}

.hero .container {
    position: relative;
    z-index: 1;
}

.hero h1 {
    font-size: clamp(1.5rem, 5vw, 2.25rem);
    margin-bottom: 12px;
    font-weight: 700;
    line-height: 1.3;
}

.hero p {
    opacity: 0.92;
    font-size: clamp(0.9rem, 2.5vw, 1.05rem);
    max-width: 480px;
    margin: 0 auto 24px;
    line-height: 1.7;
}

@media (min-width: 768px) {
    .hero {
        padding: 72px 24px;
    }
}

/* ========== Products ========== */
.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 20px;
}

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

@media (min-width: 600px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
}

@media (min-width: 900px) {
    .products-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }
}

.product-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: box-shadow var(--transition), transform var(--transition);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.product-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
}

.product-card__img {
    aspect-ratio: 1;
    background: var(--border);
    overflow: hidden;
}

.product-card__img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.35s ease;
}

.product-card:hover .product-card__img img {
    transform: scale(1.04);
}

.product-card__placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 13px;
    background: linear-gradient(145deg, #f1f5f9, #e2e8f0);
}

.product-card__body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 8px;
}

@media (min-width: 600px) {
    .product-card__body {
        padding: 14px;
    }
}

.product-card h3 {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (min-width: 600px) {
    .product-card h3 {
        font-size: 14px;
    }
}

.product-card h3 a {
    color: var(--text);
}

.product-card h3 a:hover {
    color: var(--primary);
}

.product-card .price {
    color: var(--primary);
    font-weight: 700;
    font-size: 14px;
    margin-top: auto;
}

.product-card .price-old {
    color: var(--muted);
    font-size: 12px;
    text-decoration: line-through;
    font-weight: 400;
    margin-left: 6px;
}

.product-card .btn {
    width: 100%;
    padding: 10px;
    font-size: 12px;
    min-height: 40px;
}

@media (min-width: 600px) {
    .product-card .btn {
        font-size: 13px;
    }
}

/* Category chips */
.category-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    border-radius: 99px;
    font-size: 13px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    transition: var(--transition);
    min-height: 36px;
}

.chip:hover,
.chip.is-active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ========== Product single ========== */
.product-detail {
    display: grid;
    gap: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

@media (min-width: 768px) {
    .product-detail {
        grid-template-columns: 1fr 1fr;
        gap: 40px;
        padding: 28px;
    }
}

.product-gallery__main {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius-sm);
    background: var(--border);
}

.product-gallery__thumbs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.product-gallery__thumbs img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid var(--border);
    transition: border-color var(--transition);
}

.product-gallery__thumbs img:hover,
.product-gallery__thumbs img.is-active {
    border-color: var(--primary);
}

.product-meta {
    font-size: 13px;
    color: var(--primary);
    margin-bottom: 8px;
}

.product-detail h1 {
    font-size: clamp(1.25rem, 3vw, 1.75rem);
    margin-bottom: 12px;
    line-height: 1.3;
}

.product-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 12px;
}

.stock-ok { color: var(--success); font-size: 13px; margin-bottom: 16px; }
.stock-out { color: var(--danger); font-size: 13px; margin-bottom: 16px; }

.product-desc {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.8;
    margin-bottom: 24px;
}

.qty-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.qty-form input[type="number"] {
    width: 88px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
    min-height: 44px;
}

/* ========== Cards / Forms ========== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

@media (min-width: 768px) {
    .card {
        padding: 28px;
    }
}

.form-group {
    margin-bottom: 16px;
}

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

.form-control {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
    min-height: 44px;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

.auth-box {
    max-width: 420px;
    margin: 0 auto;
}

.auth-box h1 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.35rem;
}

.auth-links {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: var(--muted);
}

/* ========== Alerts ========== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

/* ========== Cart & Checkout ========== */
.two-col {
    display: grid;
    gap: 24px;
}

@media (min-width: 768px) {
    .two-col {
        grid-template-columns: 1fr 1fr;
        gap: 32px;
        align-items: start;
    }
}

.cart-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
}

.cart-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 480px;
}

.cart-table th,
.cart-table td {
    padding: 14px 12px;
    text-align: right;
    border-bottom: 1px solid var(--border);
}

.cart-table th {
    background: var(--bg);
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
}

.cart-table tr:last-child td {
    border-bottom: none;
}

.cart-table input[type="number"] {
    width: 70px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-align: center;
}

.cart-summary {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

@media (min-width: 600px) {
    .cart-summary {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
}

.summary-row.total {
    font-size: 18px;
    font-weight: 700;
    border-top: 1px solid var(--border);
    padding-top: 14px;
    margin-top: 8px;
}

.summary-row.total span:last-child {
    color: var(--primary);
}

.payment-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color var(--transition);
    min-height: 48px;
}

.payment-option:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-light);
}

.empty-state {
    text-align: center;
    padding: 48px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--muted);
}

.empty-state .btn {
    margin-top: 16px;
}

/* ========== Footer ========== */
.site-footer {
    background: #0f172a;
    color: #94a3b8;
    padding: 40px 16px 28px;
    margin-top: auto;
    font-size: 13px;
}

.site-footer .container {
    text-align: center;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 20px;
    margin-bottom: 16px;
}

.site-footer a {
    color: #fdba74;
}

.site-footer a:hover {
    color: #99f6e4;
}

/* ========== Utilities ========== */
.page-title {
    font-size: clamp(1.25rem, 3vw, 1.5rem);
    margin-bottom: 20px;
    font-weight: 700;
}

.text-muted { color: var(--muted); }
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

/* 404 */
.error-404 {
    text-align: center;
    padding: 64px 20px;
}

.error-404 h1 {
    font-size: clamp(3rem, 15vw, 5rem);
    color: var(--primary);
    margin-bottom: 12px;
}

/* Order success */
.success-box {
    max-width: 480px;
    margin: 0 auto;
    text-align: center;
    padding: 40px 24px;
}

.success-box .icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #dcfce7;
    color: var(--success);
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

/* Radio fallback for older browsers */
@supports not selector(:has(*)) {
    .payment-option input:checked {
        accent-color: var(--primary);
    }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
