/* ==========================================================================
   1. المتغيرات العامة والألوان الأساسية للموقع
   ========================================================================== */
:root {
    --navbar-bg: #6b0f37;
    --primary-blue: #0077b6;
    --dark-blue: #03045e;
    --light-blue: #00b4d8;
    --soft-blue: #caf0f8;
    --light-bg: #f4f9fc;
    --icon-light-blue: #00b4d8;
    --icon-soft-blue: #90e0ef;
    --icon-white: #ffffff;
    --primary-maroon: #5c1a2e;
    --primary-green: #007a3d;
}

/* ==========================================================================
   2. إعدادات التجاوب ومنع التمرير الأفقي وضبط الصفحة العامة
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    max-width: 100% !important;
    overflow-x: hidden !important;
    position: relative;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: #ffffff;
    color: #2b2b2b;
    font-size: 16px;
}

/* ==========================================================================
   3. تخصيص شريط التنقل الرئيسي (Navbar)
   ========================================================================== */
.navbar-custom {
    background-color: var(--navbar-bg);
}

.navbar-custom .nav-link, 
.navbar-custom .navbar-brand {
    color: #ffffff !important;
}

.navbar-custom .fa-user-doctor {
    color: var(--icon-soft-blue) !important;
}

/* ==========================================================================
   4. القسم الرئيسي (Hero Section) مع خلفية الصور المتحركة
   ========================================================================== */
/* ==========================================================================
   قسم الهيرو الرئيسي والتحكم في خلفية الصور المتحركة (Hero Section & Slider)
   ========================================================================== */

/* الحاوية الرئيسية لقسم الهيرو */
.hero-section {
    position: relative;
    width: 100%;
    min-height: 500px;
    padding: 100px 0;
    color: #ffffff;
    overflow: hidden;
}

/* طبقة التظليل الشفافة فوق الصور لضمان وضوح النصوص وقراءتها بسهولة */
.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1;
}

/* الحاوية الحاضنة لصور الخلفية المتحركة */
.hero-bg-slider {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* تنسيق الشرائح الفردية (الصور) مع تطبيق أنيميشن التلاشي التلقائي */
.hero-bg-slider .slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    opacity: 0;
    /* تم ضبط مدة الأنيميشن الإجمالية لتناسب الصور الستة بانتظام */
    animation: imageFade 42s infinite;
}

/* التوقيت الزمني (Delay) لكل صورة من الصور الستة لكي تعمل بالتتابع بدقة */
.hero-bg-slider .slide:nth-child(1) { animation-delay: 0s; }
.hero-bg-slider .slide:nth-child(2) { animation-delay: 5s; }
.hero-bg-slider .slide:nth-child(3) { animation-delay: 10s; }
.hero-bg-slider .slide:nth-child(4) { animation-delay: 15s; }
.hero-bg-slider .slide:nth-child(5) { animation-delay: 20s; }
.hero-bg-slider .slide:nth-child(6) { animation-delay: 25s; }

/* تصميم العنوان الرئيسي داخل الهيرو مع تأثير الظل لبروز أفضل */
.hero-title {
    color: #f3efef;
    font-weight: 800;
    font-size: 2.5rem;
    line-height: 1.2;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* تنسيق لون أيقونة الهاتف داخل قسم الهيرو */
.hero-section .fa-phone {
    color: var(--icon-soft-blue) !important;
}

/* ==========================================================================
   حركة التلاشي الخاصة بالصور المتحركة (Keyframes)
   ========================================================================== */
/* ==========================================================================
   حركة التلاشي الخاصة بالصور المتحركة (Keyframes لـ 6 صور بدقة)
   ========================================================================== */
@keyframes imageFade {
    0% { 
        opacity: 0; 
        transform: scale(1); 
    }
    4% { 
        opacity: 1; 
    }
    16% { 
        opacity: 1; 
    }
    20% { 
        opacity: 0; 
        transform: scale(1.05); 
    }
    100% { 
        opacity: 0; 
    }
}
/* ==========================================================================
   5. بطاقات الخدمات العامة والأيقونات
   ========================================================================== */
.custom-card {
    border: 2px solid #e0f2fe;
    border-radius: 12px;
    background-color: #ffffff;
    transition: all 0.3s ease;
}

.custom-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-blue);
    box-shadow: 0 10px 20px rgba(0, 119, 182, 0.12);
}

.icon-box {
    background: linear-gradient(135deg, var(--light-blue), var(--primary-blue));
    color: var(--icon-white);
    width: 80px;
    height: 80px;
    margin: 0 auto 15px auto;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 180, 216, 0.3);
    transition: transform 0.3s ease;
}

.custom-card:hover .icon-box {
    transform: scale(1.1);
}

/* ==========================================================================
   6. كاروسيل الأطباء (Doctor Carousel) وتنسيق الصور والحاويات
   ========================================================================== */
.carousel-container {
    max-width: 950px;
    margin: 0 auto;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    width: 100%;
}

.carousel-track {
    position: relative;
    width: 100%;
    height: 380px;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1000px;
}

.doctor-card {
    position: absolute;
    width: 300px;
    padding: 20px;
    background-color: #ffffff;
    border-radius: 16px;
    transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
    opacity: 0;
    pointer-events: none;
    transform: scale(0.7) translateX(0);
    z-index: 0;
}

.doctor-card.active {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1) translateX(0);
    z-index: 3;
    box-shadow: 0 12px 30px rgba(0, 119, 182, 0.18) !important;
}

.doctor-card.prev {
    opacity: 0.6;
    transform: scale(0.82) translateX(230px);
    z-index: 2;
}

.doctor-card.next {
    opacity: 0.6;
    transform: scale(0.82) translateX(-230px);
    z-index: 2;
}

/* حاوية صورة الطبيب الدائرية الثابتة (تحل مشكلة التمدد والتشوه) */
.doctor-avatar-wrapper {
    width: 100px;
    height: 100px;
    margin: 0 auto 15px auto;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--soft-blue);
    border: 3px solid #ffffff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

/* تنسيق الصورة الشخصية للطبيب لملء الدائرة باحترافية */
.doctor-img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important; /* يمنع تمدد الصورة ويقوم بقص الزوائد بانتظام */
    object-position: center top !important; /* يركز على منطقة الوجه تماماً */
    display: block;
}

/* الأيقونة الافتراضية في حال لم تتوفر صورة للطبيب */
.doctor-avatar, .default-avatar-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--soft-blue);
    color: var(--primary-blue);
    font-size: 2.5rem;
}

.carousel-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--primary-blue);
    color: #ffffff;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.carousel-nav-btn:hover {
    background-color: var(--dark-blue);
    transform: translateY(-50%) scale(1.1);
}

.prev-btn { right: 0; }
.next-btn { left: 0; }

/* ==========================================================================
   7. عناوين الأقسام العامة (Section Titles)
   ========================================================================== */
.section-title {
    color: var(--dark-blue);
    font-weight: 700;
    position: relative;
    margin-bottom: 40px;
}

.section-title::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background-color: var(--light-blue);
    margin: 10px auto 0;
    border-radius: 2px;
}

/* ==========================================================================
   8. الشريط الإخباري المتحرك (News Ticker)
   ========================================================================== */
.news-ticker-container {
    background-color: var(--dark-blue);
    color: #ffffff;
    font-size: 0.95rem;
    direction: rtl;
    border-bottom: 2px solid var(--primary-blue);
    width: 100%;
    overflow: hidden !important;
}

.ticker-title {
    background-color: var(--primary-blue);
    white-space: nowrap;
    z-index: 2;
    font-size: 0.9rem;
}

.ticker-title i {
    color: #ffffff !important;
}

.ticker-content {
    position: relative;
    white-space: nowrap;
    overflow: hidden;
}

.ticker-text {
    white-space: nowrap;
    display: inline-block;
    animation: tickerAnimation 25s linear infinite;
}

.news-ticker-container:hover .ticker-text {
    animation-play-state: paused;
}

.ticker-item {
    margin-left: 50px;
    display: inline-block;
}

.ticker-item i {
    color: var(--icon-soft-blue) !important;
}

/* ==========================================================================
   9. جدول العيادات والمواعيد (Clinic Table & Management)
   ========================================================================== */
.clinic-container {
    width: 100%;
    max-width: 1200px;
    background-color: #ffffff;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    border-top: 5px solid var(--primary-maroon);
    margin: 0 auto;
}

.clinic-container .header {
    text-align: center;
    padding: 30px 20px;
    background: linear-gradient(135deg, #fff 0%, #fdfbfb 100%);
    border-bottom: 1px solid #eee;
}

.clinic-container .header h5 {
    color: var(--primary-maroon);
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.clinic-container .toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 20px;
    background-color: #fcfcfc;
    border-bottom: 1px solid #eee;
    align-items: center;
    justify-content: space-between;
}

.clinic-container .search-box {
    position: relative;
    flex: 1;
    min-width: 250px;
}

.clinic-container .search-box input {
    width: 100%;
    padding: 12px 40px 12px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: 'Cairo', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

.clinic-container .search-box input:focus {
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(0, 122, 61, 0.1);
}

.clinic-container .filter-buttons {
    display: flex;
    gap: 8px;
}

.clinic-container .filter-btn {
    padding: 10px 20px;
    border: 1px solid #ddd;
    background-color: #ffffff;
    border-radius: 8px;
    font-family: 'Cairo', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #333333;
}

.clinic-container .filter-btn:hover {
    border-color: var(--primary-maroon);
    color: var(--primary-maroon);
}

.clinic-container .filter-btn.active {
    background-color: var(--primary-maroon);
    color: #ffffff;
    border-color: var(--primary-maroon);
}

.clinic-container table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 900px;
}

.clinic-container th {
    background-color: var(--primary-maroon);
    color: #ffffff;
    padding: 18px 15px;
    text-align: right;
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
}

.clinic-container td {
    padding: 16px 15px;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    vertical-align: middle;
}

.clinic-container tr:hover {
    background-color: #fcf8f9;
}

.clinic-container .period-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
}

.clinic-container .period-morning {
    background-color: #fff3e0;
    color: #e65100;
}

.clinic-container .period-evening {
    background-color: #e3f2fd;
    color: #1565c0;
}

.clinic-container .btn-book {
    background-color: var(--primary-green);
    color: #ffffff;
    border: 1px solid var(--primary-green);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s ease;
    text-decoration: none;
}

.clinic-container .btn-book:hover {
    background-color: #005f2e;
    color: #ffffff;
    box-shadow: 0 4px 8px rgba(0, 122, 61, 0.3);
}

.clinic-container .btn-consult {
    background-color: transparent;
    color: var(--primary-maroon);
    border: 1px solid var(--primary-maroon);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s ease;
    text-decoration: none;
}

.clinic-container .btn-consult:hover {
    background-color: var(--primary-maroon);
    color: #ffffff;
    box-shadow: 0 4px 8px rgba(92, 26, 46, 0.3);
}

.clinic-container .table i {
    color: var(--primary-blue) !important;
}

/* ==========================================================================
   10. شبكة شركاء التأمين والتحليل التفاعلي (Isolated Section Wrapper)
   ========================================================================== */
.hfs-section-wrapper {
    --hfs-primary-blue: #1976d2;
    --hfs-light-blue: #e3f2fd;
    --hfs-text-main: #0d47a1;
    --hfs-text-muted: #546e7a;

    width: 100%;
    max-width: 1000px;
    margin: 40px auto;
    padding: 50px 20px;
    background-color: #ffffff;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(25, 118, 210, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    direction: rtl;
}

.hfs-title {
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--hfs-text-main);
    text-align: center;
    margin-top: 0;
    margin-bottom: 30px;
    letter-spacing: 1px;
    animation: hfsFadeIn 1.5s ease-in-out;
}

@keyframes hfsFadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.hfs-ear-wrapper {
    position: relative;
    width: 300px;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 40px;
}

.hfs-ring {
    position: absolute;
    border: 2px solid var(--hfs-light-blue);
    border-radius: 50%;
}

.hfs-ring-1 { width: 160px; height: 160px; }
.hfs-ring-2 { width: 220px; height: 220px; border-color: #bbdefb; }
.hfs-ring-3 { width: 280px; height: 280px; border-color: #e3f2fd; }

.hfs-glow-circle {
    position: absolute;
    width: 120px;
    height: 120px;
    background: var(--hfs-primary-blue);
    border-radius: 50%;
    box-shadow: 0 10px 30px rgba(25, 118, 210, 0.3);
    animation: hfsBreathe 3s ease-in-out infinite alternate;
}

@keyframes hfsBreathe {
    0% { transform: scale(0.95); box-shadow: 0 10px 20px rgba(25, 118, 210, 0.2); }
    100% { transform: scale(1.05); box-shadow: 0 15px 40px rgba(25, 118, 210, 0.4); }
}

.hfs-ear-svg {
    position: relative;
    z-index: 10;
    width: 60px;
    height: 60px;
    fill: #ffffff;
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.15));
    animation: hfsFloat 3s ease-in-out infinite;
}

@keyframes hfsFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.hfs-cards-container {
    display: flex;
    gap: 20px;
    width: 100%;
    justify-content: center;
    flex-wrap: nowrap;
    z-index: 10;
}

.hfs-card {
    background: #ffffff;
    border: none;
    border-radius: 15px;
    padding: 25px 15px;
    flex: 1;
    max-width: 250px;
    text-align: center;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.03);
}

.hfs-card:hover {
    transform: translateY(-5px);
    border-color: var(--hfs-primary-blue);
    box-shadow: 0 10px 25px rgba(25, 118, 210, 0.15);
}

.hfs-card-number {
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--hfs-primary-blue);
    margin-bottom: 5px;
}

.hfs-card-text {
    font-size: 1.1rem;
    color: var(--hfs-text-muted);
    font-weight: 700;
}

/* ==========================================================================
   11. شاشة التحميل (Preloader)
   ========================================================================== */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.preloader-logo {
    max-width: 110px;
    height: auto;
    animation: pulse-logo 1.5s infinite ease-in-out;
}

@keyframes pulse-logo {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.8; }
}

/* ==========================================================================
   12. الحركات والتأثيرات العامة (Animations & Keyframes)
   ========================================================================== */
@keyframes tickerAnimation {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

@keyframes imageFade {
    0% { opacity: 0; transform: scale(1); }
    10% { opacity: 1; }
    33% { opacity: 1; }
    43% { opacity: 0; transform: scale(1.05); }
    100% { opacity: 0; }
}

/* ==========================================================================
   13. التجاوب مع الأجهزة المحمولة والشاشات المختلفة (Media Queries)
   ========================================================================== */
@media (max-width: 992px) {
    body { font-size: 15px; }
    .hero-section { min-height: 450px; padding: 80px 0; }
    .hero-title { font-size: 2rem; }
    .carousel-container { max-width: 100%; min-height: 380px; }
    .carousel-track { height: 360px; }
    .doctor-card { width: 270px; padding: 16px; }
    .doctor-card.prev { transform: scale(0.78) translateX(200px); }
    .doctor-card.next { transform: scale(0.78) translateX(-200px); }
    .section-title { font-size: 1.5rem; margin-bottom: 30px; }
    .clinic-container .header h5 { font-size: 22px; }
}

@media (max-width: 768px) {
    body { font-size: 14px; }
    .hero-section { padding: 50px 15px; min-height: 380px; }
    .hero-title { font-size: 1.6rem !important; }
    .carousel-container { min-height: 340px; }
    .carousel-track { height: 320px; }
    .doctor-card { width: 240px; padding: 14px; }
    .doctor-card.prev { transform: scale(0.7) translateX(100px) !important; }
    .doctor-card.next { transform: scale(0.7) translateX(-100px) !important; }
    
    .clinic-container .toolbar {
        flex-direction: column;
        padding: 15px;
        gap: 10px;
    }
    .clinic-container .search-box { width: 100%; min-width: 100%; }
    .clinic-container .filter-buttons { width: 100%; justify-content: center; flex-wrap: wrap; }

    .hfs-section-wrapper { padding: 30px 10px; margin: 20px 10px; }
    .hfs-title { font-size: 1.2rem; margin-bottom: 20px; white-space: nowrap; }
    .hfs-ear-wrapper { width: 200px; height: 200px; margin-bottom: 25px; }
    .hfs-cards-container { flex-direction: row; flex-wrap: nowrap; gap: 8px; width: 100%; }
    .hfs-card { flex: 1 1 33.33%; padding: 12px 4px; }
    .hfs-card-number { font-size: 1.3rem; }
    .hfs-card-text { font-size: 0.7rem; }
}

@media (max-width: 576px) {
    body { font-size: 13.5px; }
    .hero-section { padding: 40px 10px; min-height: 340px; }
    .hero-title { font-size: 1.35rem !important; }
    .doctor-card { width: 210px; padding: 12px; }
    .doctor-card.prev { transform: scale(0.6) translateX(70px) !important; opacity: 0.4; }
    .doctor-card.next { transform: scale(0.6) translateX(-70px) !important; opacity: 0.4; }
}

@media (hover: none) and (pointer: coarse) {
    .custom-card:hover { transform: none; }
    #latest-news .card:hover { transform: none; }
    .carousel-nav-btn:hover { transform: translateY(-50%); }
}