/**
 * Client Site Styles - RTL/LTR Support
 */

/* ============ Variables ============ */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #64748b;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;

    --text: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    --bg: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;

    --border: #e2e8f0;
    --border-dark: #cbd5e1;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);

    --radius: 8px;
    --radius-lg: 12px;

    --transition: all 0.2s ease;
}

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

/* ============ Base ============ */
html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body.rtl {
    font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, sans-serif;
    direction: rtl;
}

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

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

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

input, textarea, select {
    font: inherit;
}

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

/* ============ Sidebar Menu ============ */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

.categories-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    max-width: 85vw;
    height: 100vh;
    background: #334155;
    z-index: 201;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

/* Sidebar always opens from right (where menu button is) */
.rtl .categories-sidebar {
    right: 0;
    left: auto;
    transform: translateX(100%);
}

.categories-sidebar.active {
    transform: translateX(0);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: #1e293b;
    color: white;
    font-size: 1.125rem;
    font-weight: 600;
}

.sidebar-close {
    color: white;
    padding: 0.5rem;
    border-radius: var(--radius);
    transition: var(--transition);
}

.sidebar-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    color: white;
    font-size: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: var(--transition);
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-link-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.sidebar-link-icon-placeholder {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

/* Menu Button */
.menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    color: var(--text);
    background: transparent;
    border: none;
    border-radius: 0.5rem;
    transition: var(--transition);
    cursor: pointer;
}

.menu-btn:hover {
    background: var(--bg-secondary);
    color: var(--primary);
}

.menu-btn svg {
    width: 24px;
    height: 24px;
}

.desktop-only {
    display: flex;
}

@media (max-width: 768px) {
    .desktop-only {
        display: none;
    }
}

/* ============ Header ============ */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    gap: 1rem;
}

/* Keep header LTR even in RTL pages */
.rtl .header-content {
    direction: ltr;
}

.rtl .header-actions {
    direction: ltr;
}

.rtl .nav {
    direction: ltr;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
}

.logo-img {
    height: 40px;
    width: auto;
    max-width: 150px;
    object-fit: contain;
}

.nav {
    display: flex;
    gap: 1.5rem;
}

.nav-link {
    color: var(--text-muted);
    font-weight: 500;
    transition: var(--transition);
}

.nav-link:hover {
    color: var(--primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.lang-switch {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-weight: 500;
    transition: var(--transition);
}

.lang-switch:hover {
    background: var(--bg-secondary);
}

.cart-icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    transition: var(--transition);
}

.cart-icon:hover {
    background: var(--bg-secondary);
}

.cart-count {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 50%;
}

.rtl .cart-count {
    right: auto;
    left: -4px;
}

/* ============ Main ============ */
.main {
    flex: 1;
    padding: 2rem 0;
}

/* ============ Buttons ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: var(--radius);
    transition: var(--transition);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--border);
}

/* ============ Product Page ============ */
.product-page {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    background: white;
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

@media (max-width: 768px) {
    .product-page {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: 1rem;
    }
}

/* Gallery */
.product-gallery {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.gallery-main {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-secondary);
    box-shadow: var(--shadow-sm);
}

.main-image, .main-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-main:hover .main-image {
    transform: scale(1.02);
}

.video-container {
    position: absolute;
    inset: 0;
}

.gallery-thumbs {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.thumb {
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    background: white;
}

.thumb:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.thumb.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumb-video {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

/* Product Info */
.product-info {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.product-category {
    display: inline-block;
    padding: 0.375rem 1rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 50px;
    width: fit-content;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.product-name {
    font-size: 1.875rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text);
}

.product-price {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
}

.price-current {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
}

.price-compare {
    font-size: 1.25rem;
    color: var(--text-light);
    text-decoration: line-through;
}

.price-discount {
    padding: 0.375rem 0.75rem;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    font-size: 0.875rem;
    font-weight: 700;
    border-radius: 50px;
}

.product-stock {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    width: fit-content;
}

.product-stock.in-stock {
    color: #059669;
    background: #d1fae5;
}

.product-stock.out-of-stock {
    color: #dc2626;
    background: #fee2e2;
}

/* Delivery Info */
.delivery-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1.25rem;
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    border-radius: var(--radius-lg);
    border: 1px solid #bae6fd;
}

.delivery-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: #0369a1;
}

.delivery-item svg {
    flex-shrink: 0;
    color: var(--primary);
}

.delivery-item strong {
    color: #0c4a6e;
}

/* Product Actions */
.product-actions {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.quantity-selector {
    display: flex;
    align-items: center;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: white;
}

.qty-btn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: var(--transition);
    background: transparent;
    border: none;
    cursor: pointer;
}

.qty-btn:hover {
    background: var(--primary);
    color: white;
}

.quantity-selector input {
    width: 60px;
    height: 48px;
    text-align: center;
    border: none;
    border-left: 2px solid var(--border);
    border-right: 2px solid var(--border);
    font-size: 1.125rem;
    font-weight: 600;
}

.rtl .quantity-selector input {
    border-left: 2px solid var(--border);
    border-right: 2px solid var(--border);
}

.btn-add-to-cart {
    flex: 1;
    height: 52px;
    font-size: 1rem;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

.btn-add-to-cart:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

.btn-buy-now {
    width: 100%;
    margin-top: 0.75rem;
    height: 52px;
    font-size: 1rem;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
}

.btn-buy-now:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-2px);
}

/* Description */
.product-description {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.product-description h2,
.product-description h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.product-description h3::before {
    content: '';
    width: 4px;
    height: 20px;
    background: var(--primary);
    border-radius: 2px;
}

.description-content {
    color: var(--text-muted);
    line-height: 1.8;
    font-size: 0.95rem;
}

/* SEO Content */
.product-seo-h2 {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--primary);
    margin-top: 0.5rem;
}

.product-seo-description {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.product-seo-description h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.seo-content {
    color: var(--text);
    line-height: 1.8;
}

.seo-content .seo-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.seo-content .seo-link:hover {
    text-decoration: underline;
}

.seo-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.keyword-tag {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 0.85rem;
    border-radius: var(--radius);
}

.product-description h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text);
}

/* ============ Cart Page ============ */
.cart-page {
    max-width: 900px;
    margin: 0 auto;
}

.page-title {
    font-size: 1.5rem;
    margin-bottom: 2rem;
}

.empty-cart {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 3rem;
    text-align: center;
    color: var(--text-muted);
}

.cart-items {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.cart-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
}

.cart-item-image {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius);
}

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-size: 1rem;
    font-weight: 600;
}

.cart-item-price {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.cart-item-quantity {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cart-item-total {
    font-weight: 600;
    min-width: 100px;
    text-align: right;
}

.rtl .cart-item-total {
    text-align: left;
}

.cart-item-remove {
    padding: 0.5rem;
    color: var(--danger);
    border-radius: var(--radius);
    transition: var(--transition);
}

.cart-item-remove:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Cart Summary */
.cart-summary {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.summary-row.total {
    border-bottom: none;
    font-size: 1.25rem;
    font-weight: 700;
    padding-top: 1rem;
}

.cart-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.cart-actions .btn {
    flex: 1;
}

/* ============ Checkout Page ============ */
.checkout-grid {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
}

@media (max-width: 768px) {
    .checkout-grid {
        grid-template-columns: 1fr;
    }

    .checkout-summary {
        order: -1;
    }
}

.checkout-form-container h2,
.checkout-summary h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
}

/* Form */
.checkout-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
}

.form-group input,
.form-group textarea {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.error-message {
    color: var(--danger);
    font-size: 0.875rem;
}

.promo-input {
    display: flex;
    gap: 0.5rem;
}

.promo-input input {
    flex: 1;
}

.promo-message {
    font-size: 0.875rem;
}

.promo-message.success {
    color: var(--success);
}

.promo-message.error {
    color: var(--danger);
}

.btn-place-order {
    margin-top: 1rem;
}

/* Order Summary */
.checkout-summary {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    height: fit-content;
    position: sticky;
    top: 80px;
}

.order-items {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.order-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.order-item-image {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: var(--radius);
}

.order-item-info {
    flex: 1;
}

.order-item-info h4 {
    font-size: 0.875rem;
    font-weight: 500;
}

.order-item-info p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.order-item-total {
    font-weight: 600;
}

.order-totals {
    display: flex;
    flex-direction: column;
}

/* Success Message */
.success-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 3rem;
    text-align: center;
    color: var(--success);
}

.success-message h2 {
    color: var(--text);
}

/* ============ Footer ============ */
.footer {
    margin-top: auto;
    padding: 2rem 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

.footer-content {
    text-align: center;
    color: var(--text-muted);
}

/* ============ Notification ============ */
.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    background: var(--text);
    color: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: var(--transition);
    z-index: 1000;
}

.rtl .notification {
    right: auto;
    left: 20px;
}

.notification.show {
    transform: translateY(0);
    opacity: 1;
}

/* ============ Responsive ============ */
@media (max-width: 640px) {
    .header-content {
        flex-wrap: wrap;
        height: auto;
        padding: 0.75rem 0;
    }

    .nav {
        display: none;
    }

    .product-name {
        font-size: 1.5rem;
    }

    .product-actions {
        flex-direction: column;
    }

    .cart-item {
        flex-wrap: wrap;
    }

    .cart-item-image {
        width: 60px;
        height: 60px;
    }

    .cart-actions {
        flex-direction: column;
    }
}
