/**
 * @file
 * =================================================================================
 * City4Market - ملف الأنماط الرئيسي (index-style.css)
 * =================================================================================
 *
 * @version 5.0 - (29 يوليو 2025)
 * @author Gemini
 *
 * @description
 * هذا الملف يحتوي على جميع الأنماط الخاصة بصفحة المنتج الرئيسية (index.html).
 * تم إعادة هيكلته وتصحيحه بالكامل لتحقيق أعلى معايير الأداء، إمكانية الوصول،
 * والتصميم المتجاوب.
 *
 * @enhancements
 * - **تحسين الأداء**: تعديل آلية إظهار وإخفاء الأزرار العائمة لتجنب إعادة حساب تخطيط الصفحة.
 * - **إمكانية الوصول**: ضمان حجم أهداف اللمس (48px)، وتحسين حالات التركيز (:focus-visible).
 * - **التنظيم والتوثيق**: إعادة تقسيم الملف إلى أقسام مرقمة مع تعليقات عربية شاملة.
 * - **تصميم متجاوب**: تحسينات طفيفة على نقاط التجاوب لضمان التوافق الكامل.
 */

/* --- 1. متغيرات عامة وإعادة الضبط (Global Variables & Reset) --- */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #1abc9c;
    --accent-color: #f1c40f;
    --danger-color: #e74c3c;
    --success-color: #2ecc71;
    --text-color: #34495e;
    --text-light: #7f8c8d;
    --bg-light: #ecf0f1;
    --bg-white: #ffffff;
    --border-color: #bdc3c7;
    --border-light: #e0e0e0;
    --focus-ring-color: rgba(26, 188, 156, 0.4);

    --border-radius-md: 10px;
    --border-radius-lg: 15px;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 5px 15px rgba(0,0,0,0.1);
    --gradient-primary: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 100%;
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-color);
    line-height: 1.7;
    font-size: 1rem;
    overflow-x: hidden; /* منع التمرير الأفقي غير المرغوب فيه */
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

.visually-hidden {
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    white-space: nowrap;
    border: 0;
    margin: -1px;
}

/* --- 2. شاشة التحميل الأولية (Page Loader) --- */
.page-loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-light);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--border-color);
    border-top-color: var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* --- 3. الحاوية والتخطيط العام (Container & Layout) --- */
.container {
    max-width: 750px;
    margin: 1.5rem auto;
    padding: 1.5rem 2rem;
    padding-bottom: 120px; /* ترك مساحة للأزرار العائمة في الأسفل */
    background-color: var(--bg-white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
}

/* --- 4. الرأس والعداد التنازلي (Header & Countdown) --- */
.header {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    background: var(--gradient-primary);
    color: var(--bg-white);
    text-align: center;
    border-radius: var(--border-radius-md);
}

.header h1 {
    font-size: 1.6rem;
    font-weight: 700;
}

.countdown-box {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    margin: 1.5rem 0;
    background-color: var(--accent-color);
    color: var(--primary-color);
    border-radius: var(--border-radius-md);
    font-size: 1.2rem;
    font-weight: 700;
}

.countdown-box #timer {
    padding: 0.5rem 1rem;
    background-color: var(--primary-color);
    color: var(--bg-white);
    border-radius: var(--border-radius-md);
    font-size: 1.3rem;
}

/* --- 5. معرض الصور (Swiper Slider) --- */
.slider-section {
    margin-bottom: 2rem;
}

.swiper {
    width: 100%;
    aspect-ratio: 1 / 1; /* ضمان نسبة أبعاد ثابتة للصور ومنع تغير التخطيط */
    background-color: #f0f0f0;
    border-radius: var(--border-radius-lg);
    overflow: hidden;
}

.swiper-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* التأكد من تغطية الصورة للمساحة */
}

.swiper-pagination-bullet-active {
    background-color: var(--secondary-color) !important;
}

.swiper-button-next, .swiper-button-prev {
    width: 48px;  /* حجم أكبر لسهولة اللمس */
    height: 48px; /* حجم أكبر لسهولة اللمس */
    color: var(--primary-color);
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.2s ease;
}

.swiper-button-next:focus-visible, .swiper-button-prev:focus-visible {
    outline: 4px solid var(--focus-ring-color);
    outline-offset: 2px;
}

.swiper-button-next::after, .swiper-button-prev::after {
    font-size: 1.2rem;
    font-weight: bold;
}

/* --- 6. الشعار الترويجي والمميزات (Promo & Features) --- */
.promo-slogan {
    padding: 1.5rem;
    margin: 2rem 0;
    background-color: #f8f9fa;
    border: 2px dashed var(--secondary-color);
    border-radius: var(--border-radius-lg);
    text-align: center;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary-color);
}

.features-title {
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 3px solid var(--secondary-color);
    text-align: center;
    font-size: 1.8rem;
    color: var(--primary-color);
}

.features ul {
    list-style: none;
    padding: 0;
}

.features li {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.features li i {
    color: var(--secondary-color);
    font-size: 1.4em;
    margin-top: 5px;
}

/* --- 7. قسم السعر (Price Section) --- */
.price-section {
    padding: 1.5rem;
    margin: 2.5rem 0;
    background-color: #fdfefe;
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-lg);
    text-align: center;
}

.price-wrapper {
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 15px;
    margin-bottom: 0.5rem;
}

.main-price {
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--danger-color);
}

.old-price {
    font-size: 1.6rem;
    color: var(--text-light);
    text-decoration: line-through;
}

.shipping-info {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--secondary-color);
}

/* --- 8. نموذج الطلب (Order Form) --- */
.order-form-section {
    margin-top: 2rem;
}

.order-form-title {
    margin-bottom: 2rem;
    text-align: center;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
}

.form-row {
    display: flex;
    flex-wrap: wrap; /* ضمان التجاوب في الصفوف */
    gap: 1.5rem;
    margin-bottom: 1.25rem;
}

.form-group {
    flex: 1;
    min-width: 250px;
}

.form-group.full-width {
    flex-basis: 100%;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 1rem;
}

.form-group input, .form-group select {
    width: 100%;
    min-height: 48px; /* هدف لمس بحجم مناسب */
    padding: 0.9rem;
    background-color: #fdfdfd;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 4px var(--focus-ring-color);
}

.error-message {
    min-height: 1.2em; /* حجز مساحة لرسالة الخطأ لمنع تغير التخطيط */
    margin-top: 0.5rem;
    display: block;
    color: var(--danger-color);
    font-size: 0.875rem;
    font-weight: 600;
}

.input-error {
    border-color: var(--danger-color) !important;
    background-color: #fffafa !important;
}

.input-error-shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* --- 9. محددات اللون والمقاس (Selectors) --- */
.details-section {
    margin-top: 2.5rem;
}

.section-title {
    margin-bottom: 1.5rem;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.color-selector, .size-selector {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
}

.color-selector label, .size-selector label {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px; /* هدف لمس بحجم مناسب */
    padding: 10px 15px;
    background-color: var(--bg-white);
    border: 2px solid var(--border-light);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.3s ease;
}

.color-selector label:focus-within, .size-selector label:focus-within {
    box-shadow: 0 0 0 4px var(--focus-ring-color);
}

.color-selector label.selected, .size-selector label.selected {
    border-color: var(--secondary-color);
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(26, 188, 156, 0.2);
}

.color-selector label {
    gap: 10px;
}

.color-box {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
}

.size-selector label {
    flex-direction: column;
    min-width: 100px;
    padding: 15px;
}

.size-name {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary-color);
}

.size-range {
    font-size: 0.9rem;
    color: var(--text-light);
}

/* --- 10. جدول الملخص وزر التأكيد (Summary & Submit) --- */
.summary-container {
    margin: 2rem 0;
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.summary-title {
    padding: 1rem;
    background-color: var(--primary-color);
    color: var(--bg-white);
    text-align: center;
    font-size: 1.5rem;
}

.summary-table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--bg-white);
}

.summary-table tr:not(:last-child) {
    border-bottom: 1px solid var(--border-light);
}

.summary-table td {
    padding: 1rem 1.25rem;
}

.summary-table td:first-child {
    font-weight: 700;
    color: var(--text-light);
}

.total-row {
    background-color: #f8f9fa;
    font-size: 1.3rem;
    font-weight: 700;
}

.total-row td {
    color: var(--danger-color);
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 56px; /* هدف لمس كبير وواضح */
    padding: 1.1rem;
    margin-top: 1.5rem;
    background: var(--success-color);
    color: var(--bg-white);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 1.4rem;
    font-weight: 700;
    transition: all 0.3s ease;
}

.action-btn:hover:not(:disabled) {
    background-color: #27ae60;
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(46, 204, 113, 0.4);
}

.action-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--focus-ring-color);
}

.action-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: translateY(0);
    box-shadow: none;
}

/* --- 11. أقسام المعلومات الإضافية (Info, FAQ) --- */
.info-section, .reviews-section, .faq-section {
    padding-top: 2rem;
    margin-top: 2rem;
    border-top: 1px solid var(--border-light);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.info-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    padding: 1.5rem;
    background-color: #f8f9fa;
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-lg);
    text-align: center;
    transition: all 0.3s ease;
}

.info-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    border-color: var(--secondary-color);
}

.info-card .icon {
    margin-bottom: 1rem;
    font-size: 2.8rem;
    color: var(--secondary-color);
}

.info-card .text {
    font-size: 1rem;
    font-weight: 700;
}

.faq-title {
    margin-bottom: 2rem;
    text-align: center;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
}

.faq-item {
    margin-bottom: 1rem;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
}

.faq-question {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    min-height: 48px;
    padding: 1.25rem;
    background: none;
    border: none;
    cursor: pointer;
    list-style: none; /* لإزالة السهم الافتراضي */
    font-family: inherit;
    font-size: 1.2rem;
    font-weight: 700;
    text-align: right;
    border-radius: var(--border-radius-md);
}
.faq-question::-webkit-details-marker {
    display: none;
}
.faq-question:focus-visible {
    outline: 4px solid var(--focus-ring-color);
}
.faq-question::after {
    content: '+';
    font-size: 1.8rem;
    color: var(--secondary-color);
    transition: transform 0.3s ease;
}

.faq-item[open] > .faq-question::after {
    transform: rotate(45deg);
}

.faq-answer {
    padding: 0 1.25rem 1.25rem;
    color: var(--text-light);
    line-height: 1.8;
}

.faq-answer a {
    color: var(--secondary-color);
    font-weight: 700;
    text-decoration: none;
}

.faq-answer a:hover, .faq-answer a:focus-visible {
    text-decoration: underline;
    outline: none;
}

/* --- 12. الفوتر والأزرار العائمة (Footer & Floating Buttons) --- */
.footer-text {
    padding-top: 1.5rem;
    margin-top: 2rem;
    border-top: 1px solid var(--border-light);
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-light);
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.footer-links a {
    color: var(--text-light);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.footer-links a:hover, .footer-links a:focus-visible {
    color: var(--secondary-color);
    text-decoration: underline;
    outline: none;
}

.floating-buttons-container {
    position: fixed;
    right: 20px;
    bottom: 80px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.floating-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 55px;
    height: 55px;
    color: var(--bg-white);
    background-color: var(--secondary-color); /* لون افتراضي */
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    text-decoration: none;
    font-size: 1.8rem;
    transition: all 0.3s ease;
}

.floating-btn:hover {
    transform: translateY(-3px) scale(1.1);
}

.floating-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--focus-ring-color);
}

.whatsapp-btn {
    background-color: #25d366;
}

.scroll-to-top {
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 1000;
    width: 55px;
    height: 55px;
    background-color: var(--primary-color);
    color: var(--bg-white);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.4s ease;
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-to-top:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--focus-ring-color);
}

/**
 * تحسين أداء زر "اطلب الآن" العائم:
 * بدلاً من تغيير `display`, نعتمد على `opacity` و `visibility` و `transform`.
 * هذا يمنع إعادة حساب تخطيط الصفحة (layout reflow) وهو أفضل للأداء.
 */
.floating-buy-now-btn {
    display: flex; /* العرض ثابت, التحكم بالظهور يتم عبر الخصائص الأخرى */
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    min-height: 56px;
    padding: 15px;
    background: linear-gradient(45deg, var(--success-color), #27ae60);
    color: white;
    border: none;
    text-decoration: none;
    text-align: center;
    font-size: 1.3rem;
    font-weight: 700;
    z-index: 1001;
    cursor: pointer;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.15);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    opacity: 0;
    visibility: hidden;
    transform: translateY(100%);
}

.floating-buy-now-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.floating-buy-now-btn i {
    margin-right: 10px; /* تعديل للهامش ليتناسب مع RTL */
    animation: bounceIcon 2s infinite;
}

.floating-buy-now-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(46, 204, 113, 0.4);
}

@keyframes bounceIcon {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-8px); }
    60% { transform: translateY(-4px); }
}

/* --- 13. التصميم المتجاوب (Responsive Adjustments) --- */
@media (max-width: 800px) {
    .container {
        padding: 1rem;
        margin: 0;
        border-radius: 0;
        max-width: 100%;
        padding-bottom: 120px;
    }

    .header h1, .promo-slogan, .features-title, .order-form-title {
        font-size: 1.5rem;
    }

    .main-price { font-size: 2.2rem; }
    .old-price { font-size: 1.3rem; }
    
    /* زر الشراء العائم يظهر فقط على الشاشات الصغيرة, وهذا يتم التحكم به عبر JavaScript بإضافة كلاس .visible */
    /* لذا لا نحتاج لتغيير display هنا */
}

@media (max-width: 600px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .form-group {
        margin-bottom: 1.25rem;
    }

    .countdown-box, .price-wrapper {
        flex-direction: column;
        gap: 5px;
    }

    /* إخفاء أزرار التنقل في Swiper على الشاشات الصغيرة جداً لتحسين المساحة */
    .swiper-button-next, .swiper-button-prev {
        display: none;
    }

    /* تعديل موضع الأزرار العائمة لتجنب التداخل مع زر "اطلب الآن" */
    .floating-buttons-container, .scroll-to-top {
        bottom: 85px;
    }
}