/**
 * Dar Al Waqar Storefront - Main Stylesheet
 * Consolidated CSS for the entire storefront
 * Production-ready, responsive, RTL/LTR compatible
 */

/* ============================================
   CSS Variables & Root Styles
   ============================================ */
:root {
    --primary-color: #8B4513;
    --secondary-color: #D2691E;
    --accent-color: #A0522D;
    --light-color: #FAF3E0;
    --dark-color: #5D4037;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --info-color: #3498db;
    --gold-color: #c6a25e;
    --brown-dark: #4b3a1e;
    --light-brown: #f5e6d3;
}

/* RTL/LTR Support */
[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

[dir="ltr"] {
    direction: ltr;
    text-align: left;
}

/* ============================================
   Base Styles
   ============================================ */
body {
    font-family: 'Cairo', 'Tajawal', sans-serif;
    background-color: #f9f5f0;
    color: #333;
    line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
}

.btn {
    border-radius: 10px;
    font-weight: 500;
    transition: all 0.3s ease;
}

/* ============================================
   Header & Topbar
   ============================================ */
.header-top {
    background: linear-gradient(135deg, #fffaf4 0%, #ffffff 100%);
    color: white;
    padding: 8px 0;
    font-size: 14px;
    border-bottom: 2px solid var(--gold-color);
}

.top-links a {
    color: #5a4200;
    text-decoration: none;
    margin-left: 20px;
    transition: all 0.3s;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.top-links a:hover {
    color: var(--gold-color);
    transform: translateY(-1px);
}

.header-main {
    background-color: white;
    box-shadow: 0 4px 15px rgba(139, 69, 19, 0.1);
    padding: 15px 0;
    border-bottom: 3px solid var(--primary-color);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--primary-color);
    transition: all 0.3s;
}

.logo:hover {
    transform: translateY(-2px);
    color: var(--dark-color);
}

.logo img {
    max-height: 55px;
    width: auto;
    border-radius: 8px;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-main {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary-color);
    line-height: 1.1;
}

.logo-sub {
    font-size: 13px;
    color: var(--accent-color);
    font-weight: 500;
}

/* Search Box */
.search-box {
    max-width: 500px;
    margin: 0 auto;
}

.search-input {
    border-radius: 25px 0 0 25px;
    border: 2px solid var(--gold-color);
    padding: 12px 20px;
    font-size: 15px;
    background-color: white;
    transition: all 0.3s;
}

[dir="rtl"] .search-input {
    border-radius: 0 25px 25px 0;
}

.search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(198, 162, 94, 0.25);
}

.search-btn {
    border-radius: 0 25px 25px 0;
    background: linear-gradient(135deg, var(--gold-color) 0%, var(--accent-color) 100%);
    color: white;
    border: none;
    padding: 12px 25px;
    transition: all 0.3s;
    font-weight: 600;
}

[dir="rtl"] .search-btn {
    border-radius: 25px 0 0 25px;
}

.search-btn:hover {
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--primary-color) 100%);
    transform: translateY(-1px);
}

/* Header Icons */
.header-icons {
    display: flex;
    gap: 25px;
    justify-content: flex-end;
    align-items: center;
}

[dir="rtl"] .header-icons {
    justify-content: flex-start;
    float: left;
}

.header-icon {
    position: relative;
    color: var(--dark-color);
    font-size: 22px;
    text-decoration: none;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.header-icon:hover {
    color: var(--primary-color);
    transform: translateY(-3px);
}

.cart-count, .wishlist-count, .orders-count {
    position: absolute;
    top: -8px;
    background-color: var(--danger-color);
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border: 2px solid white;
}

[dir="rtl"] .cart-count,
[dir="rtl"] .wishlist-count,
[dir="rtl"] .orders-count {
    left: -5px;
}

[dir="ltr"] .cart-count,
[dir="ltr"] .wishlist-count,
[dir="ltr"] .orders-count {
    right: -5px;
}

.bounce-animation {
    animation: bounce 0.3s ease;
}

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* ============================================
   Mobile Menu
   ============================================ */
.mobile-menu {
    position: fixed;
    top: 0;
    width: 300px;
    height: 100vh;
    background: white;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

[dir="rtl"] .mobile-menu {
    right: 0;
    transform: translateX(100%);
}

[dir="ltr"] .mobile-menu {
    left: 0;
}

.mobile-menu.active {
    transform: translateX(0);
}

.mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   Cart Page
   ============================================ */
.cart-item {
    border-radius: 15px;
    transition: all 0.3s ease;
}

.cart-item:hover {
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.product-thumbnail {
    position: relative;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    border-radius: 12px;
    padding: 5px;
}

.quantity-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 8px;
}

.quantity-btn:hover {
    background: #f8f9fa;
}

.quantity-input {
    width: 60px;
    text-align: center;
    border: none;
    font-weight: bold;
}

.update-btn {
    display: none;
}

.update-btn:not(.d-none) {
    display: inline-block;
}

/* ============================================
   Checkout Page – تصميم متكامل
   ============================================ */
.checkout-page {
    background: linear-gradient(180deg, #faf8f5 0%, #f5f0e8 50%, #f0ebe3 100%);
    min-height: 100vh;
    padding-bottom: 3rem;
}

.checkout-page .container {
    max-width: 1200px;
}

/* خطوات الطلب */
.checkout-steps {
    margin-bottom: 2rem;
    padding: 1rem 0;
}

.steps-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.step-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #6c757d;
}

.step.active .step-label {
    color: var(--primary-color);
}

.step-icon {
    width: 52px;
    height: 52px;
    background: #e9ecef;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #6c757d;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.step.active .step-icon {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    color: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.25);
}

.step-line {
    flex: 1;
    height: 3px;
    background: #e9ecef;
    max-width: 80px;
    border-radius: 2px;
}

.step-line.active {
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
}

/* البطاقات */
.checkout-card {
    border-radius: 16px;
    border: 1px solid rgba(139, 69, 19, 0.08);
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

.checkout-card:hover {
    box-shadow: 0 8px 24px rgba(139, 69, 19, 0.1);
}

.checkout-card-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--brown-dark) 100%) !important;
    color: #fff !important;
    border: none !important;
    padding: 1rem 1.25rem !important;
    font-weight: 600;
}

.checkout-card-header .card-title {
    color: #fff !important;
    font-size: 1.05rem;
}

.checkout-card-header.payment-header {
    background: linear-gradient(135deg, #495057 0%, #343a40 100%) !important;
}

.checkout-card .card-body {
    background: #fff;
    padding: 1.5rem 1.5rem !important;
}

.checkout-section {
    animation: fadeIn 0.5s ease;
}

/* النماذج */
.checkout-form .form-label {
    color: #2c3e50;
    font-size: 0.95rem;
    margin-bottom: 0.35rem;
}

.checkout-form .form-control,
.checkout-form .form-select {
    border-radius: 10px;
    border: 1px solid #dee2e6;
    padding: 0.6rem 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.checkout-form .form-control:focus,
.checkout-form .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(139, 69, 19, 0.15);
}

.checkout-form .form-text {
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 0.25rem;
}

/* مدة التوصيل */
#delivery_duration_display {
    border-radius: 12px;
    border: 1px solid rgba(13, 110, 253, 0.2);
}

#delivery_duration_display small {
    font-size: 0.75rem;
    opacity: 0.9;
}

/* طريقة الدفع */
.payment-option {
    margin-bottom: 0;
}

.payment-label {
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: all 0.25s ease;
    background: #fff;
}

.payment-label:hover {
    border-color: var(--primary-color);
    background: #fefcf9;
}

.payment-radio:checked + .payment-label,
.payment-label.selected {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #fefcf9 0%, #faf5ee 100%);
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.12);
}

.payment-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--primary-color);
    flex-shrink: 0;
}

.payment-radio:checked + .payment-label .payment-icon,
.payment-label.selected .payment-icon {
    background: rgba(139, 69, 19, 0.1);
}

.payment-details {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex-grow: 1;
}

.payment-title {
    font-weight: 600;
    color: #2c3e50;
    font-size: 1rem;
}

.payment-desc {
    font-size: 0.8rem;
    color: #6c757d;
}

.payment-check {
    font-size: 1.25rem;
    color: #dee2e6;
    transition: color 0.2s;
}

.payment-radio:checked + .payment-label .payment-check,
.payment-label.selected .payment-check {
    color: var(--success-color);
}

/* ملخص الطلب */
.order-summary-wrapper {
    position: sticky;
    top: 1rem;
}

.order-summary {
    border-radius: 16px;
    overflow: hidden;
}

.order-items-title {
    color: var(--primary-color);
    font-size: 1rem;
}

.order-items-list {
    max-height: 280px;
    overflow-y: auto;
}

.order-items-list::-webkit-scrollbar {
    width: 6px;
}

.order-items-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.order-items-list::-webkit-scrollbar-thumb {
    background: var(--light-brown);
    border-radius: 10px;
}

.order-item {
    transition: background 0.2s;
}

.order-item:hover {
    background: #fafafa;
}

.order-item .item-image {
    border-radius: 10px;
    overflow: hidden;
}

.order-item .item-image img {
    border-radius: 10px;
}

.item-quantity-badge {
    position: absolute;
    bottom: -4px;
    right: -4px;
    background: var(--primary-color);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

[dir="rtl"] .item-quantity-badge {
    right: auto;
    left: -4px;
}

.order-total {
    color: var(--primary-color) !important;
    font-size: 1.5rem;
}

/* زر التأكيد */
.checkout-btn {
    border-radius: 12px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%) !important;
    border: none !important;
    color: #fff !important;
    transition: all 0.3s ease;
}

.checkout-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(139, 69, 19, 0.3);
    color: #fff !important;
}

.checkout-btn.loading {
    cursor: not-allowed;
    opacity: 0.85;
}

.checkout-security-note {
    font-size: 0.8rem;
}

/* الشروط والأحكام */
.terms-agreement .form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.terms-agreement .form-check-label a:hover {
    text-decoration: underline;
}

/* ميزات إضافية */
.features-card .card-body {
    background: linear-gradient(135deg, #fefcf9 0%, #faf5ee 100%);
    border-radius: 0 0 16px 16px;
}

.feature-item {
    background: #fff;
    border-radius: 12px;
    border: 1px solid rgba(139, 69, 19, 0.08);
    transition: all 0.25s ease;
}

.feature-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.1);
}

/* RTL – صفحة إتمام الشراء */
[dir="rtl"] .order-item .item-details {
    margin-inline-start: 0.75rem;
    margin-inline-end: 0;
}

/* ============================================
   Product Page
   ============================================ */
.product-title {
    background: linear-gradient(135deg, #212529 0%, #495057 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.colors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 20px;
}

.color-label {
    display: block;
    width: 70px;
    height: 70px;
    margin: 0 auto 8px;
    border-radius: 50%;
    border: 3px solid #f8f9fa;
    cursor: pointer;
    position: relative;
    transition: all 0.4s ease;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.color-label:hover {
    transform: scale(1.15) rotate(5deg);
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.color-radio:checked + .color-label {
    border-color: #0d6efd;
    transform: scale(1.2);
    box-shadow: 0 0 0 4px #fff, 0 0 0 7px #0d6efd, 0 10px 30px rgba(13, 110, 253, 0.4);
}

.sizes-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.size-label {
    display: block;
    min-width: 80px;
    padding: 15px 10px;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    background: white;
    text-align: center;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.4s ease;
}

.size-label:hover {
    border-color: #adb5bd;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}

.size-radio:checked + .size-label {
    border-color: #0d6efd;
    background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(13, 110, 253, 0.4);
}

/* ============================================
   Forms & Validation
   ============================================ */
.form-control:invalid {
    border-color: #dc3545;
}

.form-control:valid {
    border-color: #198754;
}

.invalid-feedback {
    font-size: 0.875rem;
    margin-top: 0.25rem;
    color: #dc3545;
}

/* ============================================
   Toast Notifications
   ============================================ */
.store-toast {
    position: fixed;
    top: 20px;
    z-index: 9999;
    min-width: 300px;
    animation: slideIn 0.3s ease;
}

[dir="rtl"] .store-toast {
    left: 20px;
}

[dir="ltr"] .store-toast {
    right: 20px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

[dir="rtl"] .fade-out {
    animation: fadeOutRTL 0.3s ease forwards;
}

@keyframes fadeOutRTL {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-100%);
    }
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    .steps-indicator {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .step-line {
        display: none;
    }
    
    .step {
        flex: 1;
        min-width: 70px;
    }
    
    .step-icon {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }
    
    .step-label {
        font-size: 0.75rem;
    }
    
    .order-summary-wrapper {
        position: static;
    }
    
    .order-summary {
        margin-top: 0;
    }
    
    .checkout-row {
        flex-direction: column-reverse;
    }
    
    .checkout-card .card-body {
        padding: 1.25rem !important;
    }
    
    .payment-label {
        padding: 0.85rem 1rem;
    }
    
    .payment-icon {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
    
    .header-icons {
        gap: 15px;
    }
    
    .logo-main {
        font-size: 18px;
    }
    
    .logo-sub {
        font-size: 11px;
    }
}

@media (max-width: 576px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .checkout-page .container {
        padding-top: 1rem !important;
        padding-bottom: 2rem !important;
    }
    
    .form-control-lg, .form-select-lg {
        font-size: 1rem;
        padding: 0.6rem 0.85rem;
    }
    
    .checkout-btn {
        font-size: 1rem;
        padding: 0.85rem 1rem;
    }
    
    .order-items-list {
        max-height: 220px;
    }
    
    .color-label {
        width: 60px;
        height: 60px;
    }
    
    .size-label {
        min-width: 70px;
        padding: 12px 8px;
    }
}

/* ============================================
   Utility Classes
   ============================================ */
.bg-light-brown {
    background-color: var(--light-brown) !important;
}

.text-primary-custom {
    color: var(--primary-color) !important;
}

.border-primary-custom {
    border-color: var(--primary-color) !important;
}
