/**
 * RoSH Custom Features - Frontend Styles
 * ملف التنسيقات الاحترافي للواجهة الأمامية
 * Version: 1.0.0
 */

/* =============== متغيرات CSS العامة =============== */
:root {
    --rosh-primary-color: #ff3d00;
    --rosh-primary-dark: #d32f2f;
    --rosh-primary-light: #ff6333;
    --rosh-secondary-color: #2196f3;
    --rosh-success-color: #4caf50;
    --rosh-warning-color: #ff9800;
    --rosh-error-color: #f44336;
    --rosh-text-primary: #333333;
    --rosh-text-secondary: #666666;
    --rosh-text-muted: #999999;
    --rosh-background-light: #ffffff;
    --rosh-background-gray: #f8f9fa;
    --rosh-border-color: #e0e0e0;
    --rosh-border-radius: 12px;
    --rosh-border-radius-small: 6px;
    --rosh-border-radius-large: 20px;
    --rosh-shadow-small: 0 2px 8px rgba(0, 0, 0, 0.1);
    --rosh-shadow-medium: 0 4px 16px rgba(0, 0, 0, 0.15);
    --rosh-shadow-large: 0 8px 32px rgba(0, 0, 0, 0.2);
    --rosh-transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --rosh-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* =============== البحث المتقدم - التصميم الحديث =============== */

/* الحاوية الرئيسية للبحث المتقدم */
.rosh-advanced-search-container {
    position: relative;
    margin: 30px auto;
    max-width: 700px;
    width: 95%;
    font-family: var(--rosh-font-family);
    direction: rtl;
}

/* نموذج البحث */
.rosh-search-form {
    display: flex;
    align-items: stretch;
    background: var(--rosh-background-light);
    border: 2px solid var(--rosh-primary-color);
    border-radius: var(--rosh-border-radius-large);
    overflow: hidden;
    box-shadow: var(--rosh-shadow-medium);
    transition: var(--rosh-transition);
    position: relative;
}

.rosh-search-form:hover {
    box-shadow: var(--rosh-shadow-large);
    transform: translateY(-2px);
}

.rosh-search-form:focus-within {
    border-color: var(--rosh-primary-dark);
    box-shadow: 0 0 0 4px rgba(255, 61, 0, 0.1), var(--rosh-shadow-large);
}

/* حاوية البحث */
.rosh-search-wrapper {
    display: flex;
    align-items: stretch;
    width: 100%;
    min-height: 56px;
}

/* حاوية حقل الإدخال */
.rosh-search-input-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

/* حقل البحث */
.rosh-search-input {
    width: 100%;
    border: none;
    outline: none;
    padding: 16px 50px 16px 20px;
    font-size: 16px;
    font-weight: 400;
    color: var(--rosh-text-primary);
    background: transparent;
    font-family: inherit;
    line-height: 1.5;
}

.rosh-search-input::placeholder {
    color: var(--rosh-text-muted);
    font-weight: 400;
    transition: var(--rosh-transition);
}

.rosh-search-input:focus::placeholder {
    opacity: 0.7;
    transform: translateX(10px);
}

/* أيقونة البحث داخل الحقل */
.rosh-search-icon {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--rosh-text-muted);
    font-size: 18px;
    pointer-events: none;
    transition: var(--rosh-transition);
}

.rosh-search-input:focus + .rosh-search-icon {
    color: var(--rosh-primary-color);
    transform: translateY(-50%) scale(1.1);
}

/* حاوية القائمة المنسدلة */
.rosh-category-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    border-right: 2px solid var(--rosh-border-color);
    background: #333333 !important; /* خلفية سوداء */
    min-width: 180px;
}

/* القائمة المنسدلة */
.rosh-category-select {
    appearance: none;
    border: none;
    outline: none;
    padding: 16px 40px 16px 20px;
    font-size: 15px;
    font-weight: 500;
    color: #ffffff !important; /* نص أبيض */
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    width: 100%;
    transition: var(--rosh-transition);
}

.rosh-category-select:hover {
    background: rgba(255, 255, 255, 0.1) !important; /* تأثير تمرير خفيف */
}

.rosh-category-select:focus {
    background: rgba(255, 255, 255, 0.15) !important; /* تأثير تركيز */
}

/* خيارات القائمة المنسدلة */
.rosh-category-select option {
    background: #333333 !important; /* خلفية سوداء للخيارات */
    color: #ffffff !important; /* نص أبيض للخيارات */
    padding: 10px;
}

/* سهم القائمة المنسدلة */
.rosh-select-arrow {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #ffffff !important; /* سهم أبيض */
    font-size: 14px;
    pointer-events: none;
    transition: var(--rosh-transition);
}

.rosh-category-select:focus + .rosh-select-arrow {
    color: #ffffff !important; /* يبقى أبيض عند التركيز */
    transform: translateY(-50%) rotate(180deg);
}

/* زر البحث */
.rosh-search-button {
    background: linear-gradient(135deg, var(--rosh-primary-color) 0%, var(--rosh-primary-dark) 100%);
    color: var(--rosh-background-light);
    border: none;
    padding: 0 24px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 120px;
    transition: var(--rosh-transition);
    position: relative;
    overflow: hidden;
}

.rosh-search-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.rosh-search-button:hover::before {
    left: 100%;
}

.rosh-search-button:hover {
    background: linear-gradient(135deg, var(--rosh-primary-dark) 0%, #b71c1c 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(255, 61, 0, 0.3);
}

.rosh-search-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(255, 61, 0, 0.3);
}

.rosh-search-button i {
    font-size: 18px;
    transition: var(--rosh-transition);
}

.rosh-search-button:hover i {
    transform: scale(1.1);
}

/* مؤشر التحميل */
.rosh-search-loading {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--rosh-background-light);
    padding: 12px 20px;
    border-radius: var(--rosh-border-radius);
    box-shadow: var(--rosh-shadow-medium);
    font-size: 14px;
    color: var(--rosh-text-secondary);
    z-index: 1000;
}

.rosh-loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--rosh-border-color);
    border-top: 2px solid var(--rosh-primary-color);
    border-radius: 50%;
    animation: rosh-spin 1s linear infinite;
}

@keyframes rosh-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* =============== نتائج البحث الحي =============== */

/* حاوية النتائج */
.rosh-search-results {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    right: 0;
    background: var(--rosh-background-light);
    border: 1px solid var(--rosh-border-color);
    border-radius: var(--rosh-border-radius);
    box-shadow: var(--rosh-shadow-large);
    z-index: 9999;
    max-height: 500px;
    overflow-y: auto;
    animation: rosh-slideDown 0.3s ease-out;
}

@keyframes rosh-slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* قائمة النتائج */
.live-search-list {
    list-style: none;
    margin: 0;
    padding: 8px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--rosh-primary-color) transparent;
}

.live-search-list::-webkit-scrollbar {
    width: 6px;
}

.live-search-list::-webkit-scrollbar-track {
    background: transparent;
}

.live-search-list::-webkit-scrollbar-thumb {
    background: var(--rosh-primary-color);
    border-radius: 3px;
}

.live-search-list::-webkit-scrollbar-thumb:hover {
    background: var(--rosh-primary-dark);
}

/* عنصر النتيجة */
.live-search-item {
    margin: 0;
    transition: var(--rosh-transition);
}

.live-search-item:not(:last-child) {
    border-bottom: 1px solid var(--rosh-border-color);
}

.live-search-item:hover {
    background: linear-gradient(90deg, rgba(255, 61, 0, 0.05) 0%, transparent 100%);
    transform: translateX(-2px);
}

.live-search-item a {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    text-decoration: none;
    color: #333333 !important; /* لون النص الأساسي */
    transition: var(--rosh-transition);
}

.live-search-item a:hover {
    color: #333333 !important;
    text-decoration: none;
}

/* صورة المنتج */
.live-search-thumb {
    width: 60px;
    height: 60px;
    border-radius: var(--rosh-border-radius-small);
    object-fit: cover;
    margin-left: 16px;
    border: 2px solid var(--rosh-border-color);
    transition: var(--rosh-transition);
    flex-shrink: 0;
}

.live-search-item:hover .live-search-thumb {
    border-color: var(--rosh-primary-color);
    transform: scale(1.05);
}

/* تفاصيل المنتج */
.live-search-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.live-search-details h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50 !important; /* لون العنوان */
    line-height: 1.4;
    transition: var(--rosh-transition);
}

.live-search-item:hover .live-search-details h4 {
    color: var(--rosh-primary-color) !important;
}

/* السعر */
.live-search-price {
    font-size: 15px;
    font-weight: 700;
    color: #27ae60 !important; /* لون السعر */
    display: flex;
    align-items: center;
    gap: 4px;
}

/* التقييم */
.live-search-rating {
    font-size: 14px;
    color: #f39c12 !important; /* لون النجوم */
    display: flex;
    align-items: center;
    gap: 4px;
}

.live-search-rating .fas,
.live-search-rating .far {
    color: #f39c12 !important;
}

.live-search-rating .rating-count {
    color: #7f8c8d !important;
    font-size: 12px;
}

.live-search-rating::before {
    content: '⭐';
    font-size: 12px;
}

/* قسم عرض جميع النتائج */
.live-search-footer {
    border-top: 2px solid var(--rosh-border-color);
    padding: 16px 20px;
    text-align: center;
    background: var(--rosh-background-gray);
}

.view-all-results {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--rosh-primary-color);
    color: var(--rosh-background-light);
    padding: 12px 24px;
    border-radius: var(--rosh-border-radius-large);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    transition: var(--rosh-transition);
    border: 2px solid var(--rosh-primary-color);
}

.view-all-results:hover {
    background: var(--rosh-background-light);
    color: var(--rosh-primary-color);
    transform: translateY(-2px);
    box-shadow: var(--rosh-shadow-medium);
}

.view-all-results::after {
    content: '←';
    font-size: 16px;
    transition: var(--rosh-transition);
}

.view-all-results:hover::after {
    transform: translateX(-3px);
}

/* رسالة عدم وجود نتائج */
.no-results-found {
    text-align: center;
    padding: 40px 20px;
    color: var(--rosh-text-secondary);
    font-size: 16px;
    background: var(--rosh-background-gray);
    border-radius: var(--rosh-border-radius);
    margin: 10px;
}

.no-results-found::before {
    content: '🔍';
    display: block;
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* =============== البحث البسيط =============== */

.rosh-simple-search-container {
    position: relative;
    margin: 20px auto;
    max-width: 500px;
    width: 95%;
    font-family: var(--rosh-font-family);
    direction: rtl;
}

.rosh-simple-search-form {
    display: flex;
    background: var(--rosh-background-light);
    border: 2px solid var(--rosh-border-color);
    border-radius: var(--rosh-border-radius-large);
    overflow: hidden;
    transition: var(--rosh-transition);
}

.rosh-simple-search-form:focus-within {
    border-color: var(--rosh-primary-color);
    box-shadow: 0 0 0 3px rgba(255, 61, 0, 0.1);
}

.rosh-simple-search-wrapper {
    display: flex;
    align-items: stretch;
    width: 100%;
}

.rosh-simple-search-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 14px 20px;
    font-size: 16px;
    color: var(--rosh-text-primary);
    background: transparent;
    font-family: inherit;
}

.rosh-simple-search-input::placeholder {
    color: var(--rosh-text-muted);
}

.rosh-simple-search-button {
    background: var(--rosh-primary-color);
    color: var(--rosh-background-light);
    border: none;
    padding: 0 20px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--rosh-transition);
}

.rosh-simple-search-button:hover {
    background: var(--rosh-primary-dark);
}

/* =============== معلومات المخزون =============== */

.rosh-stock-info {
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
    color: var(--rosh-error-color);
    padding: 8px 12px;
    border-radius: var(--rosh-border-radius-small);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    margin-top: 8px;
    border: 1px solid rgba(244, 67, 54, 0.2);
    animation: rosh-pulse 2s infinite;
}

@keyframes rosh-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

/* =============== الاستجابة للشاشات المختلفة =============== */

/* الأجهزة اللوحية */
@media screen and (max-width: 768px) {
    .rosh-advanced-search-container {
        max-width: 100%;
        margin: 20px auto;
    }
    
    .rosh-search-wrapper {
        flex-direction: column;
        min-height: auto;
    }
    
    .rosh-search-input-wrapper {
        order: 1;
    }
    
    .rosh-category-wrapper {
        order: 2;
        border-right: none;
        border-top: 2px solid var(--rosh-border-color);
        min-width: auto;
    }
    
    .rosh-search-button {
        order: 3;
        min-width: auto;
        justify-content: center;
        padding: 16px;
    }
    
    .rosh-search-form {
        border-radius: var(--rosh-border-radius);
    }
}

/* الهواتف المحمولة */
@media screen and (max-width: 480px) {
    .rosh-advanced-search-container {
        width: 100%;
        margin: 15px 0;
        padding: 0 10px;
    }
    
    .rosh-search-input {
        padding: 14px 45px 14px 15px;
        font-size: 15px;
    }
    
    .rosh-category-select {
        padding: 14px 35px 14px 15px;
        font-size: 14px;
    }
    
    .rosh-search-button {
        padding: 14px 20px;
        font-size: 15px;
    }
    
    .rosh-search-button span {
        display: none;
    }
    
    .live-search-thumb {
        width: 50px;
        height: 50px;
        margin-left: 12px;
    }
    
    .live-search-details h4 {
        font-size: 15px;
    }
    
    .live-search-price {
        font-size: 14px;
    }
    
    .live-search-item a {
        padding: 12px 15px;
    }
}

/* الشاشات الصغيرة جداً */
@media screen and (max-width: 320px) {
    .rosh-search-input {
        padding: 12px 40px 12px 12px;
        font-size: 14px;
    }
    
    .rosh-category-select {
        padding: 12px 30px 12px 12px;
        font-size: 13px;
    }
    
    .rosh-search-button {
        padding: 12px 16px;
        min-width: 60px;
    }
}

/* =============== الوضع المظلم =============== */

@media (prefers-color-scheme: dark) {
    :root {
        --rosh-text-primary: #ffffff;
        --rosh-text-secondary: #cccccc;
        --rosh-text-muted: #999999;
        --rosh-background-light: #1a1a1a;
        --rosh-background-gray: #2d2d2d;
        --rosh-border-color: #404040;
    }
    
    .rosh-search-form {
        background: var(--rosh-background-light);
        border-color: var(--rosh-border-color);
    }
    
    .rosh-category-wrapper {
        background: var(--rosh-background-gray);
        border-color: var(--rosh-border-color);
    }
    
    .rosh-search-results {
        background: var(--rosh-background-light);
        border-color: var(--rosh-border-color);
    }
    
    .live-search-item:hover {
        background: linear-gradient(90deg, rgba(255, 61, 0, 0.1) 0%, transparent 100%);
    }
    
    .live-search-footer {
        background: var(--rosh-background-gray);
    }
    
    .no-results-found {
        background: var(--rosh-background-gray);
    }
}

/* =============== تحسينات الأداء =============== */

/* تحسين الرسوم المتحركة */
.rosh-advanced-search-container *,
.rosh-simple-search-container * {
    will-change: auto;
}

.rosh-search-form:hover,
.rosh-search-button:hover,
.live-search-item:hover {
    will-change: transform, box-shadow;
}

/* تحسين التمرير */
.live-search-list {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* منع تحديد النص غير المرغوب فيه */
.rosh-search-button,
.rosh-select-arrow,
.rosh-search-icon {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}


/* =============== إصلاحات إضافية للألوان =============== */

/* إصلاح ألوان النصوص في جميع حالات البحث */
.rosh-search-results * {
    color: inherit !important;
}

.live-search-item,
.live-search-item * {
    color: #333333 !important;
}

.live-search-details h4 {
    color: #2c3e50 !important;
}

.live-search-price {
    color: #27ae60 !important;
}

.live-search-rating,
.live-search-rating * {
    color: #f39c12 !important;
}

.live-search-rating .rating-count {
    color: #7f8c8d !important;
}

/* شارات المخزون */
.stock-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stock-badge.in-stock {
    background: #e8f5e8;
    color: #27ae60 !important;
    border: 1px solid #c8e6c9;
}

.stock-badge.out-of-stock {
    background: #ffebee;
    color: #e74c3c !important;
    border: 1px solid #ffcdd2;
}

.stock-badge.backorder {
    background: #fff3e0;
    color: #f39c12 !important;
    border: 1px solid #ffcc02;
}

/* تمييز نص البحث */
.search-highlight {
    background: linear-gradient(120deg, #ff3d00 0%, #ff6333 100%);
    color: #ffffff !important;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(255, 61, 0, 0.3);
}

/* رسائل عدم وجود نتائج */
.no-results-found {
    color: #7f8c8d !important;
}

.no-results-found p {
    color: #5a6c7d !important;
    font-weight: 600;
}

.no-results-found small {
    color: #95a5a6 !important;
}

/* رسائل الخطأ */
.search-error {
    color: #e74c3c !important;
    text-align: center;
    padding: 30px 20px;
}

.search-error p {
    color: #c0392b !important;
    font-weight: 600;
}

.search-error small {
    color: #e67e22 !important;
}

/* رابط عرض جميع النتائج */
.view-all-results {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    padding: 15px 20px !important;
    margin: 10px !important;
    background: #007cba !important; /* خلفية زرقاء */
    color: #ffffff !important; /* نص أبيض */
    text-decoration: none !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
    transition: all 0.3s ease !important;
}

.view-all-results:hover {
    background: #005a87 !important; /* أزرق أغمق عند التمرير */
    color: #ffffff !important;
    text-decoration: none !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 8px rgba(0, 124, 186, 0.3) !important;
}

.view-all-results i {
    color: #ffffff !important;
}

/* صورة افتراضية */
.live-search-no-image {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    color: #adb5bd !important;
    border: 2px dashed #dee2e6;
}

/* تحسينات للوضع المظلم */
@media (prefers-color-scheme: dark) {
    .live-search-item,
    .live-search-item * {
        color: #ecf0f1 !important;
    }
    
    .live-search-details h4 {
        color: #ffffff !important;
    }
    
    .rosh-search-results {
        background: #2c3e50 !important;
        border-color: #34495e !important;
    }
    
    .live-search-item {
        border-bottom-color: #34495e !important;
    }
    
    .live-search-footer {
        background: #34495e !important;
        border-top-color: #4a5f7a !important;
    }
    
    .no-results-found,
    .search-error {
        color: #bdc3c7 !important;
    }
}

/* إصلاح مشاكل التداخل مع القوالب */
.rosh-advanced-search-container .live-search-item a,
.rosh-advanced-search-container .live-search-item a:visited,
.rosh-advanced-search-container .live-search-item a:link {
    color: #333333 !important;
    text-decoration: none !important;
}

.rosh-advanced-search-container .live-search-details h4,
.rosh-advanced-search-container .live-search-details h4 a {
    color: #2c3e50 !important;
}

.rosh-advanced-search-container .live-search-price,
.rosh-advanced-search-container .live-search-price * {
    color: #27ae60 !important;
}

/* تأكيد أولوية الألوان */
.rosh-search-results .live-search-item {
    background: #ffffff !important;
}

.rosh-search-results .live-search-item:hover {
    background: linear-gradient(90deg, rgba(255, 61, 0, 0.05) 0%, rgba(255, 255, 255, 1) 100%) !important;
}

