/* ==========================================================================
   style.css — خدلك كبسولة | تصميم احترافي متجاوب
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&display=swap');

/* ==========================================================================
   1. المتغيرات
   ========================================================================== */
:root {
    /* الألوان الأساسية */
    --primary:          #0284c7;
    --primary-dark:     #0369a1;
    --primary-light:    #e0f2fe;
    --accent:           #10b981;
    --accent-light:     #d1fae5;
    --secondary:        #6366f1;
    --secondary-light:  rgba(99,102,241,0.1);
    --danger:           #ef4444;
    --warning:          #f59e0b;

    /* الخلفيات */
    --bg:               #f0f7ff;
    --bg-alt:           #e8f4fd;
    --card-bg:          rgba(255,255,255,0.9);
    --card-solid:       #ffffff;
    --header-bg:        linear-gradient(135deg, #060d1f 0%, #0f172a 40%, #1e1b4b 75%, #1e3a8a 100%);

    /* النصوص */
    --text:             #0f172a;
    --text-muted:       #64748b;
    --text-light:       #94a3b8;

    /* الحدود والظلال */
    --border:           rgba(2,132,199,0.15);
    --border-soft:      rgba(226,232,240,0.8);
    --shadow-xs:        0 1px 3px rgba(0,0,0,0.06);
    --shadow-sm:        0 4px 12px rgba(2,132,199,0.08);
    --shadow-md:        0 8px 24px rgba(2,132,199,0.12);
    --shadow-lg:        0 20px 40px rgba(0,0,0,0.1);
    --shadow-card:      0 2px 8px rgba(2,132,199,0.06), 0 0 0 1px rgba(2,132,199,0.08);
    --selection-bg:     rgba(2,132,199,0.18);

    /* الأشكال */
    --radius-sm:        8px;
    --radius-md:        14px;
    --radius-lg:        22px;
    --radius-xl:        32px;
    --radius-pill:      999px;

    /* التأثيرات */
    --blur:             blur(16px);
    --transition:       all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast:  all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

    /* ── aliases للتوافق مع index.html ── */
    --primary-color:    var(--primary);
    --accent-color:     var(--accent);
    --secondary-color:  var(--secondary);
    --bg-color:         var(--bg);
    --text-color:       var(--text);
    --border-color:     var(--border);
    --card-color:       var(--card-bg);
}

[data-theme="dark"] {
    --bg:               #070c18;
    --bg-alt:           #0d1525;
    --card-bg:          rgba(15, 23, 42, 0.85);
    --card-solid:       #0f172a;
    --text:             #f1f5f9;
    --text-muted:       #94a3b8;
    --text-light:       #64748b;
    --border:           rgba(56,189,248,0.28);
    --border-soft:      rgba(100,116,139,0.55);
    --primary:          #38bdf8;
    --primary-dark:     #0ea5e9;
    --primary-light:    rgba(56,189,248,0.1);
    --shadow-xs:        0 1px 3px rgba(0,0,0,0.35);
    --shadow-sm:        0 4px 12px rgba(0,0,0,0.3);
    --shadow-md:        0 8px 24px rgba(0,0,0,0.35);
    --shadow-lg:        0 20px 40px rgba(0,0,0,0.45);
    --shadow-card:      0 2px 8px rgba(0,0,0,0.2), 0 0 0 1px rgba(56,189,248,0.08);
    --selection-bg:     rgba(56,189,248,0.25);
    --accent:           #10b981;
    --accent-light:     #d1fae5;
    --secondary:        #818cf8;
    --secondary-light:  rgba(129,140,248,0.12);
    --header-bg:        linear-gradient(135deg, #020408 0%, #060d1f 40%, #0f0e2e 75%, #0c1a4a 100%);
    /* aliases dark mode */
    --primary-color:    var(--primary);
    --accent-color:     var(--accent);
    --secondary-color:  var(--secondary);
    --bg-color:         var(--bg);
    --text-color:       var(--text);
    --border-color:     var(--border);
    --card-color:       var(--card-bg);
}

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

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.7;
    max-width: 100%;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
    -webkit-font-smoothing: antialiased;
    position: relative;
}

img { max-width: 100%; display: block; }

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

:focus-visible {
    outline: 2.5px solid var(--primary);
    outline-offset: 3px;
    border-radius: 4px;
}

::selection {
    background: var(--selection-bg);
    color: var(--text);
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary), var(--secondary));
    border-radius: 20px;
    border: 2px solid var(--bg);
}

/* ==========================================================================
   3. شريط التقدم العلوي
   ========================================================================== */
#progressBar {
    position: fixed;
    top: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--primary), var(--secondary));
    width: 0%;
    z-index: 10000;
    border-radius: 0 2px 2px 0;
    transition: width 0.1s linear;
    pointer-events: none;
}

/* ==========================================================================
   4. الهيدر
   ========================================================================== */
header {
    background: var(--header-bg);
    padding: 0 4%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 20px rgba(0,0,0,0.3);
    gap: 12px;
    height: 64px;
    min-height: 64px;
}

/* يسار: هامبرجر + براند */
.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 1;
    min-width: 0;
}

.header-brand {
    display: flex;
    flex-direction: column;
    gap: 1px;
    line-height: 1.2;
    min-width: 0;
    overflow: hidden;
}

.header-username {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255,255,255,0.75);
    font-family: 'Cairo', sans-serif;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: none;
    background: rgba(255,255,255,0.08);
    padding: 1px 7px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.12);
}
.header-username.visible { display: block; }

header .logo {
    font-size: 20px;
    font-weight: 900;
    color: #ffffff;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: 0.3px;
    text-shadow: 0 2px 8px rgba(2,132,199,0.4);
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 100%;
}

/* shimmer للنقاط */
@keyframes shimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(200%); }
}

/* أزرار الأيقونة في الهيدر */
.hdr-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    color: rgba(255,255,255,0.8);
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}
.hdr-icon-btn:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

/* أفاتار البروفايل */
.hdr-avatar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: rgba(255,255,255,0.1);
    border: 1.5px solid rgba(255,255,255,0.25);
    border-radius: 50%;
    color: #fff;
    font-size: 19px;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    flex-shrink: 0;
}
.hdr-avatar-btn:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.5);
}

/* أيقونات الـ nav */
.nav-icon {
    width: 18px;
    text-align: center;
    opacity: 0.7;
    font-size: 13px;
}

#headerPoints:hover {
    background: linear-gradient(135deg,rgba(251,191,36,0.3),rgba(245,158,11,0.25)) !important;
    border-color: rgba(251,191,36,0.8) !important;
    box-shadow: 0 0 16px rgba(251,191,36,0.35),0 4px 12px rgba(0,0,0,0.3) !important;
    transform: scale(1.04);
}

/* السوشيال داخل القايمة على موبايل */
.nav-social-row {
    display: none;
    gap: 10px;
    padding: 16px 16px 4px;
    width: 100%;
    border-top: 1px solid rgba(255,255,255,0.08);
    margin-top: 8px;
}
.nav-social-row a {
    color: rgba(255,255,255,0.65);
    font-size: 14px;
    width: 36px; height: 36px;
    background: rgba(255,255,255,0.07);
    display: flex; justify-content: center; align-items: center;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.1);
    transition: var(--transition);
    flex-shrink: 0;
}
.nav-social-row a:hover { color: #fff; transform: scale(1.1); }

/* زر البروفايل دائرة */
#profileNavBtn:hover {
    background: rgba(255,255,255,0.22) !important;
}

header nav {
    display: flex;
    gap: 2px;
    align-items: center;
    justify-content: center;
    flex: 1;
}

header nav a {
    color: rgba(255,255,255,0.78);
    font-weight: 600;
    font-size: 13px;
    padding: 7px 11px;
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
    white-space: nowrap;
    position: relative;
}

header nav a::after {
    content: '';
    position: absolute;
    bottom: 3px; left: 50%;
    transform: translateX(-50%);
    width: 0; height: 2px;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.25s ease;
}

header nav a:hover {
    color: #ffffff;
    background: rgba(255,255,255,0.1);
}

header nav a:hover::after { width: 60%; }

.social-icons {
    display: flex;
    gap: 5px;
    align-items: center;
    flex-shrink: 0;
}

.social-icons a {
    color: rgba(255,255,255,0.65);
    font-size: 13px;
    width: 32px; height: 32px;
    background: rgba(255,255,255,0.05);
    display: flex; justify-content: center; align-items: center;
    border-radius: 50%;
    transition: var(--transition);
    border: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.social-icons a:hover { color: #fff; transform: translateY(-3px) scale(1.1); }
.ico-facebook:hover  { background: #1877f2 !important; border-color: #1877f2 !important; }
.ico-instagram:hover { background: linear-gradient(45deg,#f09433,#e6683c,#dc2743,#cc2366,#bc1888) !important; border-color: #e6683c !important; }
.ico-threads:hover   { background: #000 !important; border-color: #333 !important; }
.ico-tiktok:hover    { background: #000 !important; border-color: #333 !important; }
.ico-youtube:hover   { background: #ff0000 !important; border-color: #ff0000 !important; }

#headerAuthActions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

/* ==========================================================================
   5. الأزرار
   ========================================================================== */
.btn-primary, .btn-main, .btn-dark-mode {
    padding: 9px 16px;
    border-radius: var(--radius-pill);
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transition: var(--transition);
    white-space: nowrap;
    line-height: 1.4;
}

.btn-primary {
    background: rgba(255,255,255,0.95);
    color: var(--primary-dark);
    box-shadow: var(--shadow-xs);
}
.btn-primary:hover {
    background: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255,255,255,0.15);
}

.btn-dark-mode {
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.85);
    border: 1px solid rgba(255,255,255,0.12);
}
.btn-dark-mode:hover {
    background: rgba(255,255,255,0.14);
    color: #fff;
    transform: translateY(-2px);
}

.btn-main {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: #ffffff;
    font-size: 17px;
    font-weight: 800;
    padding: 15px 48px;
    border-radius: var(--radius-pill);
    box-shadow: 0 8px 24px rgba(2,132,199,0.3);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: none;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    transition: var(--transition-bounce);
    position: relative;
    overflow: hidden;
}

.btn-main::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.btn-main:hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 16px 36px rgba(2,132,199,0.4);
}
.btn-main:hover::before { opacity: 1; }

.btn-main:active { transform: translateY(-1px) scale(0.99); }

.input-error {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 3px rgba(239,68,68,0.15) !important;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* ==========================================================================
   6. Hero
   ========================================================================== */
.hero {
    background: var(--bg);
    padding: 90px 8% 80px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: -120px; left: 50%;
    transform: translateX(-50%);
    width: 800px; height: 800px;
    background: radial-gradient(circle, rgba(2,132,199,0.08) 0%, transparent 70%);
    pointer-events: none;
}

.hero-text h1 {
    font-size: 42px;
    font-weight: 900;
    color: var(--text);
    margin-bottom: 18px;
    line-height: 1.45;
    min-height: 64px;
    background: linear-gradient(135deg, var(--primary-dark), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-text p {
    font-size: 17px;
    color: var(--text-muted);
    max-width: 660px;
    margin: 0 auto 38px;
    line-height: 1.8;
}

.main-btn-container {
    position: relative;
    display: inline-block;
}

.btn-ping-effect {
    position: absolute;
    inset: -8px;
    border-radius: var(--radius-pill);
    background: var(--primary);
    opacity: 0.15;
    animation: ping 2.2s cubic-bezier(0, 0, 0.2, 1) infinite;
    pointer-events: none;
}

/* عداد الكبسولات */
.capsule-tracker {
    position: fixed;
    top: 80px; left: 24px;
    background: var(--card-solid);
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
    border: 1px solid var(--border);
    padding: 10px 20px;
    border-radius: var(--radius-pill);
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 700;
    font-size: 13px;
    color: var(--primary);
    box-shadow: var(--shadow-md);
    z-index: 900;
    transition: var(--transition);
}

[data-theme="dark"] .capsule-tracker {
    background: rgba(15,23,42,0.95);
}

.capsule-tracker i {
    animation: pulse 2.5s infinite ease-in-out;
    color: var(--secondary);
    font-size: 15px;
}

/* ==========================================================================
   7. معلومة اليوم
   ========================================================================== */
#tip-of-day {
    background: linear-gradient(135deg, rgba(2,132,199,0.07) 0%, rgba(99,102,241,0.05) 100%);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 44px 8%;
    display: none;
}

#tip-of-day > div {
    max-width: 720px;
    margin: 0 auto;
    text-align: center;
}

/* ==========================================================================
   8. الكروت والأقسام
   ========================================================================== */
.cards-section, .tools-section, .contact-section {
    padding: 70px 6%;
}

.cards-section {
    background: var(--bg);
}

.tools-section {
    background: var(--bg-alt);
}

[data-theme="dark"] .tools-section {
    background: var(--bg-alt);
}

.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
    margin-top: 40px;
}

.tools-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    margin-top: 40px;
}

.card, .tool-box {
    background: var(--card-bg);
    border: 1px solid var(--border-soft);
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    text-align: center;
    cursor: pointer;
    box-shadow: var(--shadow-card);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    opacity: 0;
    transition: opacity 0.3s;
}

.card:hover::before { opacity: 1; }

.card:hover, .tool-box:hover {
    background: var(--card-solid);
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border);
}

.tool-box { cursor: default; }
.tool-box:hover { transform: translateY(-4px); }

.card-icon {
    font-size: 32px;
    color: var(--primary);
    background: var(--primary-light);
    width: 70px; height: 70px;
    display: flex; justify-content: center; align-items: center;
    border-radius: var(--radius-md);
    margin: 0 auto 20px;
    transition: var(--transition-bounce);
}

.card:hover .card-icon {
    transform: scale(1.12) rotate(-5deg);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
}

.card h3, .tool-box h3 {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 10px;
    color: var(--text);
}

.card p, .tool-box p {
    color: var(--text-muted);
    font-size: 13.5px;
    line-height: 1.7;
}

h2 {
    font-size: 30px;
    font-weight: 900;
    text-align: center;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--primary-dark), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ==========================================================================
   9. النماذج والمدخلات
   ========================================================================== */
.form-input {
    width: 100%;
    padding: 12px 16px;
    margin: 7px 0;
    border: 1.5px solid var(--border-soft);
    background: var(--bg);
    color: var(--text);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    outline: none;
    transition: var(--transition);
    font-family: 'Cairo', sans-serif;
    display: block;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(2,132,199,0.12);
    background: var(--card-solid);
}

.form-input::placeholder { color: var(--text-light); font-weight: 500; }
.form-input:disabled { opacity: 0.55; cursor: not-allowed; }

select.form-input { appearance: none; -webkit-appearance: none; }

input[type="checkbox"] {
    accent-color: var(--accent);
    width: 17px; height: 17px;
    cursor: pointer;
    border-radius: 4px;
}

/* شريط الماء */
.water-progress-container {
    background: rgba(2,132,199,0.10);
    border: 1.5px solid var(--primary);
    border-radius: 20px;
    height: 22px;
    position: relative;
    overflow: hidden;
    margin: 14px 0;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.04);
}

[data-theme="dark"] .water-progress-container {
    background: rgba(56,189,248,0.12);
}

.water-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #38bdf8, #0077b6);
    width: 0%;
    border-radius: 20px;
    transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.water-progress-bar::after {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: waterShine 2s infinite;
}

.water-progress-text {
    position: absolute;
    width: 100%; text-align: center;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    font-weight: 800;
    color: var(--text);
    pointer-events: none;
    z-index: 1;
}

/* ==========================================================================
   10. المودالات
   ========================================================================== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(7, 12, 24, 0.55);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 5000;
    padding: 16px;
}

/* ✅ إصلاح: مودال التعليقات بيتفتح فوق مودال الكبسولة من غير ما يقفله
   (زرار "💬 التعليقات والآراء" جوه capsuleModal)، فلازم z-index أعلى
   عشان يظهر فعلاً قدام مودال الكبسولة مش وراه */
#commentsModal {
    z-index: 5001;
}

.modal-content {
    background: var(--card-solid);
    border: 1px solid var(--border);
    padding: 40px 32px;
    border-radius: var(--radius-xl);
    max-width: 500px;
    width: 100%;
    position: relative;
    box-shadow: 0 32px 64px rgba(0,0,0,0.2);
    text-align: center;
    animation: scaleUp 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: 92vh;
    overflow-y: auto;
}

.modal-content h3 {
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 6px;
}

.close-btn {
    position: absolute;
    top: 16px; right: 20px;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    background: none;
    border: none;
    padding: 6px;
    border-radius: 8px;
    transition: var(--transition-fast);
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
}
.close-btn:hover { color: var(--danger); background: rgba(239,68,68,0.08); }

/* روابط التواصل */
.contact-links-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.contact-modal-btn {
    padding: 14px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 14px;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-family: 'Cairo', sans-serif;
    gap: 8px;
}
.contact-modal-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.25);
    filter: brightness(1.08);
}
.btn-modal-whatsapp { background: linear-gradient(135deg,#25d366,#128c7e); }
.btn-modal-facebook { background: linear-gradient(135deg,#1877f2,#1557b0); }
.btn-modal-tiktok   { background: linear-gradient(135deg,#333,#000); }

/* ==========================================================================
   11. Toast
   ========================================================================== */
.toast-notification {
    position: fixed;
    bottom: 28px; left: 28px;
    background: var(--accent);
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
    color: #ffffff;
    padding: 14px 24px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 14px;
    font-family: 'Cairo', sans-serif;
    box-shadow: 0 12px 32px rgba(0,0,0,0.15);
    z-index: 9998;
    transform: translateY(200%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-width: 340px;
    word-break: break-word;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 10px;
}
.toast-notification.show { transform: translateY(0); }

/* ==========================================================================
   12. الفوتر
   ========================================================================== */
footer {
    background: #060d1f;
    color: rgba(255,255,255,0.5);
    padding: 28px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    border-top: 1px solid rgba(255,255,255,0.06);
}
footer .highlight { color: var(--primary); font-weight: 800; }

/* ==========================================================================
   13. العودة للأعلى
   ========================================================================== */
#backToTop {
    position: fixed;
    bottom: 28px; right: 28px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    border: none;
    width: 46px; height: 46px;
    border-radius: 50%;
    font-size: 17px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    display: none;
    z-index: 999;
    transition: var(--transition-bounce);
    font-family: 'Cairo', sans-serif;
    align-items: center;
    justify-content: center;
}
#backToTop:hover {
    transform: translateY(-5px) scale(1.08);
    box-shadow: var(--shadow-lg);
}

/* ==========================================================================
   14. عناصر متفرقة
   ========================================================================== */
#registerOnlyFields {
    overflow: hidden;
    transition: all 0.3s ease;
}

.contact-section {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg);
}

/* تحسين قسم الأدوية والمفضلة */
#medListContainer, #favListContainer {
    border-radius: var(--radius-md);
    overflow: hidden;
}

/* لوحة الالتزام */
#checkupList label {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}
#checkupList label:hover {
    background: var(--primary-light);
}

/* ==========================================================================
   15. Keyframes
   ========================================================================== */
@keyframes ping {
    75%, 100% { transform: scale(1.4); opacity: 0; }
}

@keyframes scaleUp {
    from { transform: scale(0.88) translateY(10px); opacity: 0; }
    to   { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%       { transform: scale(1.1); opacity: 0.8; }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-10px); }
}

@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes waterShine {
    0%   { left: -100%; }
    100% { left: 200%; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   16. Utilities
   ========================================================================== */
.skeleton {
    background: linear-gradient(90deg, var(--border-soft) 25%, var(--card-bg) 50%, var(--border-soft) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border-width: 0;
}

.text-center { text-align: center; }
.mt-10 { margin-top: 10px; }
.mt-15 { margin-top: 15px; }

/* ==========================================================================
   17. Responsive — Large Desktop (1440px+)
   ========================================================================== */
@media (min-width: 1440px) {
    header { padding: 0 6%; }
    .cards-section, .tools-section, .contact-section { padding: 80px 10%; }
    .hero { padding: 110px 12% 90px; }
    .hero-text h1 { font-size: 50px; }
    .hero-text p  { font-size: 18px; }
    .cards-container  { grid-template-columns: repeat(5, 1fr); gap: 28px; }
    .tools-container  { grid-template-columns: repeat(3, 1fr); gap: 28px; }
}

/* ==========================================================================
   HAMBURGER BUTTON
   ========================================================================== */
.hamburger-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.12);
    border: 1.5px solid rgba(255,255,255,0.3);
    border-radius: 10px;
    cursor: pointer;
    padding: 9px;
    flex-shrink: 0;
    transition: background 0.2s;
}
.hamburger-btn:hover { background: rgba(255,255,255,0.22); }
.hamburger-btn span {
    display: block;
    height: 2.5px;
    background: #ffffff;
    border-radius: 3px;
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform-origin: center;
    box-shadow: 0 0 4px rgba(255,255,255,0.4);
}
/* X animation */
.hamburger-btn.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.active span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger-btn.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Overlay */
.nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.55);
    z-index: 998;
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.3s;
}
.nav-overlay.active {
    display: block;
    opacity: 1;
}

/* ==========================================================================
   18. Responsive — Tablet (1024px)
   ========================================================================== */
@media (max-width: 1024px) {
    header {
        height: auto;
        min-height: 56px;
        flex-wrap: wrap;
        padding: 10px 4%;
    }

    header nav { flex-wrap: wrap; justify-content: center; }
    header nav a { font-size: 12px; padding: 6px 9px; }

    .social-icons { display: none; }

    .hero { padding: 70px 6% 60px; }
    .hero-text h1 { font-size: 36px; }

    .cards-container { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
    .tools-container { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

    .capsule-tracker { top: auto; bottom: 90px; left: 16px; }
}

/* ==========================================================================
   19. Responsive — Mobile (768px)
   ========================================================================== */
@media (max-width: 768px) {
    /* ═══ الهيدر — صف واحد نظيف ═══ */
    header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 0 4%;
        gap: 8px;
        height: 58px;
        min-height: 58px;
        flex-wrap: nowrap;
    }

    .header-left { gap: 8px; }
    .logo { font-size: 15px; }
    .header-username { font-size: 10px; max-width: 90px; }

    /* إظهار زر الهامبرجر */
    .hamburger-btn { display: flex; }

    /* القايمة — Drawer من الشمال، كامل الارتفاع */
    header nav {
        position: fixed;
        top: 58px;
        left: 0;
        width: min(280px, 82vw);
        height: calc(100vh - 58px);
        background: linear-gradient(160deg, #060d1f 0%, #0f172a 55%, #1e1b4b 100%);
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
        padding: 16px 12px 24px;
        z-index: 999;
        transform: translateX(-100%);
        transition: transform 0.32s cubic-bezier(0.4,0,0.2,1);
        box-shadow: 4px 0 28px rgba(0,0,0,0.5);
        overflow-y: auto;
    }

    header nav.open {
        transform: translateX(0);
    }

    header nav a {
        font-size: 15px;
        padding: 13px 16px;
        width: 100%;
        border-radius: 12px;
        border-bottom: 1px solid rgba(255,255,255,0.05);
        display: flex;
        align-items: center;
        gap: 12px;
    }
    header nav a:last-of-type { border-bottom: none; }

    /* السوشيال جوه القايمة */
    .nav-social-row { display: flex; }

    /* ─── Auth ─── */
    #headerAuthActions {
        justify-content: flex-end;
        flex-wrap: nowrap;
        gap: 6px;
        flex-shrink: 1;
        min-width: 0;
    }

    /* إخفاء السوشيال في الهيدر على الموبايل */
    .social-icons { display: none !important; }

    /* أزرار الأيقونة */
    .hdr-icon-btn { width: 36px; height: 36px; font-size: 14px; border-radius: 9px; }
    .hdr-avatar-btn { width: 36px; height: 36px; font-size: 17px; }

    /* زر تسجيل الدخول */
    #authActionBtn { padding: 7px 12px; font-size: 12px; }

    /* النقاط */
    #headerPoints {
        padding: 5px 8px !important;
        font-size: 11px !important;
        border-radius: 14px !important;
        gap: 4px !important;
    }

    /* ─── جرس الإشعارات ─── */
    #notifBellWrap button {
        padding: 5px 8px !important;
        font-size: 17px !important;
    }

    /* ─── زر FCM ─── */
    #fcmPushBtn {
        padding: 5px 8px !important;
        font-size: 12px !important;
    }
    #fcmPushBtn span { display: none; }

    /* Hero */
    .hero { padding: 40px 5% 44px; }
    .hero::before { display: none; }
    .hero-text h1 { font-size: 24px; min-height: auto; }
    .hero-text p  { font-size: 14px; margin-bottom: 28px; }
    .btn-main { font-size: 15px; padding: 13px 30px; }

    /* عداد الكبسولات — مخفي على الموبايل */
    .capsule-tracker { display: none; }

    /* الأقسام */
    .cards-section, .tools-section, .contact-section { padding: 44px 4%; }
    h2 { font-size: 22px; }

    .cards-container  { grid-template-columns: 1fr 1fr; gap: 14px; }
    .tools-container  { grid-template-columns: 1fr; gap: 16px; }

    .card { padding: 22px 16px; }
    .card-icon { width: 58px; height: 58px; font-size: 26px; }
    .card h3 { font-size: 15px; }
    .card p  { font-size: 12px; }
    .tool-box { padding: 24px 18px; }

    /* المودال */
    .modal { padding: 12px; }
    .modal-content { padding: 28px 20px; border-radius: var(--radius-lg); }
    .modal-content h3 { font-size: 18px; }

    /* Toast */
    .toast-notification {
        left: 10px; right: 10px; bottom: 12px;
        max-width: unset; font-size: 13px; padding: 12px 16px;
    }

    /* لوحة الإشعارات */
    #notifPanel {
        width: calc(100vw - 16px) !important;
        left: 50% !important;
        transform: translateX(-50%) translateY(-8px) !important;
    }
    #notifPanel.open {
        transform: translateX(-50%) translateY(0) !important;
    }

    /* Back to top */
    #backToTop { bottom: 16px; right: 16px; width: 42px; height: 42px; font-size: 15px; }
}

/* ==========================================================================
   19b. Responsive — Header fit fix for real phones (≤600px)
   الهيدر كان بيعمل overflow حقيقي على موبايلات كتير (الهامبرجر بيتقطع
   بره الشاشة) لأن كل عناصره flex-shrink:0. الحل: تصغير أحجام العناصر
   عشان تتظبط في صف واحد من غير ما تخرج بره حدود الشاشة.
   ========================================================================== */
@media (max-width: 600px) {
    header { padding: 0 3%; gap: 6px; }
    .header-left { gap: 6px; }

    .hamburger-btn { width: 34px; height: 34px; padding: 7px; }
    header .logo { font-size: 14px; }
    .header-username { max-width: 72px; font-size: 9.5px; padding: 1px 5px; }

    #headerAuthActions #userMenuContainer { gap: 5px !important; }

    /* زرار جرس الصوت مكرر مع جرس الإشعارات (notifBellWrap) — نخفيه على
       الموبايل عشان نوفر مساحة، الوظيفة لسه موجودة على الديسكتوب */
    #audioMasterToggle { display: none !important; }

    .hdr-icon-btn { width: 32px; height: 32px; font-size: 13px; }
    .hdr-avatar-btn { width: 32px; height: 32px; font-size: 15px; }

    #headerPoints {
        padding: 4px 6px !important;
        font-size: 10px !important;
        gap: 3px !important;
    }
    #headerPoints .pts-sep { margin: 0 1px; }

    /* الجرس اللي بيتحقن بالجافاسكريبت (app-bundle.js) — كان ناسي أظبطه */
    #notifBellWrap { flex-shrink: 0; }
    #notifBellWrap button {
        padding: 4px 6px !important;
        font-size: 15px !important;
    }
    #fcmPushBtn { padding: 4px 6px !important; font-size: 11px !important; }
}

@media (max-width: 360px) {
    header { padding: 0 2.5%; gap: 4px; }
    .header-left { gap: 5px; }

    .hamburger-btn { width: 32px; height: 32px; padding: 6px; }
    header .logo { font-size: 13px; }
    .header-username { display: none !important; }

    #headerAuthActions #userMenuContainer { gap: 4px !important; }

    .hdr-icon-btn { width: 30px; height: 30px; font-size: 12px; }
    .hdr-avatar-btn { width: 30px; height: 30px; font-size: 14px; }

    #headerPoints {
        padding: 3px 5px !important;
        font-size: 9.5px !important;
        gap: 2px !important;
    }

    /* الجرس اللي بيتحقن بالجافاسكريبت (app-bundle.js) */
    #notifBellWrap { flex-shrink: 0; }
    #notifBellWrap button {
        padding: 3px 5px !important;
        font-size: 14px !important;
    }
    #fcmPushBtn { padding: 3px 5px !important; font-size: 10px !important; }
}

/* ==========================================================================
   20. Responsive — Small Mobile (480px)
   ========================================================================== */
@media (max-width: 480px) {
    .hero-text h1 { font-size: 21px; }
    .hero-text p  { font-size: 13px; }
    .btn-main     { font-size: 14px; padding: 12px 24px; }
    h2            { font-size: 20px; }

    .cards-container { grid-template-columns: 1fr; gap: 12px; }

    .modal-content { padding: 24px 16px; }

    .form-input { font-size: 13px; padding: 11px 14px; }
}

/* ==========================================================================
   21. Responsive — XS Mobile (360px)
   ========================================================================== */
@media (max-width: 360px) {
    header .logo { font-size: 13px; }
    .hero-text h1 { font-size: 19px; }
    .btn-main { font-size: 13px; padding: 11px 20px; }
    h2 { font-size: 18px; }
}
/* === كبسولة الاستشارة الطبية === */
.card-consultation {
    border: 1.5px solid rgba(16, 185, 129, 0.25);
    position: relative;
    overflow: hidden;
}
.card-consultation::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(16,185,129,0.04), rgba(5,150,105,0.02));
    pointer-events: none;
}
.card-consultation:hover {
    border-color: rgba(16, 185, 129, 0.6) !important;
    box-shadow: 0 8px 32px rgba(16,185,129,0.18), 0 0 0 1px rgba(16,185,129,0.2) !important;
    transform: translateY(-4px);
}
.card-consultation:hover .card-icon {
    background: linear-gradient(135deg, rgba(16,185,129,0.25), rgba(5,150,105,0.15)) !important;
}

/* textarea في المودال */
textarea.form-input {
    font-family: 'Cairo', sans-serif;
    line-height: 1.7;
}

/* === كبسولة الاستشارة الطبية === */
.card-consultation {
    border: 1.5px solid rgba(16, 185, 129, 0.25);
    position: relative;
    overflow: hidden;
}
.card-consultation::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(16,185,129,0.04), rgba(5,150,105,0.02));
    pointer-events: none;
}
.card-consultation:hover {
    border-color: rgba(16, 185, 129, 0.6) !important;
    box-shadow: 0 8px 32px rgba(16,185,129,0.18), 0 0 0 1px rgba(16,185,129,0.2) !important;
    transform: translateY(-4px);
}
.card-consultation:hover .card-icon {
    background: linear-gradient(135deg, rgba(16,185,129,0.25), rgba(5,150,105,0.15)) !important;
}
textarea.form-input {
    font-family: 'Cairo', sans-serif;
    line-height: 1.7;
}

/* ================================================================
   ✅ الميزات الجديدة — بحث + تعليقات + بروفايل + نقاط + سجل صحي
   ================================================================ */

/* شريط البحث */
#capsuleSearchInput {
    text-align: right;
    direction: rtl;
    transition: box-shadow 0.2s;
}
#capsuleSearchInput:focus {
    box-shadow: 0 0 0 3px rgba(2,132,199,0.15);
}

/* زر النقاط والبروفايل في الهيدر */
#headerPoints,
#profileNavBtn {
    transition: background 0.2s, transform 0.1s;
}
#headerPoints:hover,
#profileNavBtn:hover {
    background: rgba(255,255,255,0.25) !important;
    transform: scale(1.04);
}

/* أعمدة الرسم البياني الصحي */
#healthChartContainer > div > div:hover > div[style*="background:var(--primary-color)"] {
    opacity: 0.8;
    cursor: default;
}

/* مودال التعليقات */
#commentsList {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}
#commentsList > div:last-child {
    border-bottom: none;
}
#commentInput {
    font-family: Cairo, sans-serif;
    direction: rtl;
    text-align: right;
}

/* مودال البروفايل */
#profileModal .modal-content,
#pointsModal  .modal-content,
#commentsModal .modal-content {
    text-align: center;
}

/* بطاقات النقاط */
#pointsModal [style*="border-radius:14px"] {
    min-width: 110px;
}

/* ─── 640px: ضغط إضافي ─── */
@media (max-width: 640px) {
    header .logo { font-size: 15px; }

    #headerUserName { max-width: 60px !important; font-size: 11px !important; }

    #headerPoints {
        padding: 4px 7px !important;
        font-size: 10px !important;
    }
    #profileNavBtn {
        padding: 4px 7px !important;
        font-size: 10px !important;
    }
}

/* ─── 480px: أصغر موبايل ─── */
@media (max-width: 480px) {
    header { padding: 0 3%; }
    header .logo { font-size: 14px; }

    #headerAuthActions { gap: 4px; }

    .btn-dark-mode { padding: 7px; font-size: 13px; min-width: 34px; width: 34px; height: 34px; }
    #authActionBtn { padding: 6px 10px; font-size: 11px; }
}

/* ─── زر الخروج: إخفاء النص على الموبايل ─── */
@media (max-width: 768px) {
    .btn-logout-text { display: none; }
    #logoutBtn { min-width: 34px; justify-content: center; padding: 7px 10px !important; }
}



/* ════════════════════════════════════════════════════════════
   ⚡ LAUNCH ANIMATIONS — خدلك كبسولة
   احترافي طبي: clean + subtle
   ════════════════════════════════════════════════════════════ */

/* ── Splash Screen ── */
#kh-splash {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
    flex-direction: column;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    gap: 18px;
    background: linear-gradient(160deg, #0284c7 0%, #0369a1 60%, #075985 100%);
    -webkit-transition: opacity 0.55s cubic-bezier(0.4, 0, 0.2, 1),
                -webkit-transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
    transition: opacity 0.55s cubic-bezier(0.4, 0, 0.2, 1),
                transform  0.55s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: opacity, transform;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
#kh-splash.kh-splash--exit {
    opacity: 0;
    transform: scale(1.04);
    pointer-events: none;
}

/* لوجو الـ splash */
.kh-splash__icon {
    width: 80px;
    height: 80px;
    background: rgba(255,255,255,0.15);
    border: 2px solid rgba(255,255,255,0.35);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: #fff;
    animation: kh-splash-icon-in 0.6s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}

.kh-splash__title {
    font-family: Cairo, sans-serif;
    font-size: 26px;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.5px;
    animation: kh-fade-up 0.5s 0.15s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.kh-splash__subtitle {
    font-family: Cairo, sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,0.75);
    animation: kh-fade-up 0.5s 0.25s cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* نبضة الـ ECG */
.kh-splash__ecg {
    width: 160px;
    height: 36px;
    animation: kh-fade-up 0.5s 0.3s ease both;
}
.kh-splash__ecg path {
    stroke: rgba(255,255,255,0.85);
    stroke-width: 2.2;
    fill: none;
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    animation: kh-ecg-draw 1.1s 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ── Page Elements In-Animation ── */

/* body مخفي الأول */
body.kh-loading > *:not(#kh-splash) {
    opacity: 0;
}

/* header — لا نحرك الـ header نفسه (يكسر position:fixed على nav في أندرويد)
   بدله نحرك العناصر الداخلية بس */
header.kh-animate .header-left {
    animation: kh-slide-down 0.5s 0.05s cubic-bezier(0.4, 0, 0.2, 1) both;
}
header.kh-animate #headerAuthActions {
    animation: kh-slide-down 0.5s 0.1s cubic-bezier(0.4, 0, 0.2, 1) both;
}
header.kh-animate #socialIconsHeader {
    animation: kh-fade-in 0.5s 0.15s ease both;
}

/* progress bar */
#progressBar.kh-animate {
    animation: kh-fade-in 0.4s 0.1s ease both;
}

/* capsule tracker */
.capsule-tracker.kh-animate {
    animation: kh-slide-down 0.5s 0.12s cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* hero section */
.hero.kh-animate .hero-text h1 {
    animation: kh-fade-up 0.6s 0.18s cubic-bezier(0.4, 0, 0.2, 1) both;
}
.hero.kh-animate .hero-text p {
    animation: kh-fade-up 0.6s 0.27s cubic-bezier(0.4, 0, 0.2, 1) both;
}
.hero.kh-animate .main-btn-container {
    animation: kh-fade-up 0.6s 0.36s cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* cards — stagger واحدة ورا التانية */
.cards-container.kh-animate .card,
.cards-container.kh-animate .tool-box {
    opacity: 0;
    animation: kh-card-in 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}
/* كل card ليها delay بناءً على --card-index */
.cards-container.kh-animate .card:nth-child(1)  { animation-delay: calc(0.35s + 0 * 0.07s); }
.cards-container.kh-animate .card:nth-child(2)  { animation-delay: calc(0.35s + 1 * 0.07s); }
.cards-container.kh-animate .card:nth-child(3)  { animation-delay: calc(0.35s + 2 * 0.07s); }
.cards-container.kh-animate .card:nth-child(4)  { animation-delay: calc(0.35s + 3 * 0.07s); }
.cards-container.kh-animate .card:nth-child(5)  { animation-delay: calc(0.35s + 4 * 0.07s); }
.cards-container.kh-animate .card:nth-child(6)  { animation-delay: calc(0.35s + 5 * 0.07s); }
.cards-container.kh-animate .card:nth-child(7)  { animation-delay: calc(0.35s + 6 * 0.07s); }
.cards-container.kh-animate .card:nth-child(8)  { animation-delay: calc(0.35s + 7 * 0.07s); }
.cards-container.kh-animate .card:nth-child(9)  { animation-delay: calc(0.35s + 8 * 0.07s); }
.cards-container.kh-animate .card:nth-child(10) { animation-delay: calc(0.35s + 9 * 0.07s); }

/* sections التانية */
#tip-of-day.kh-animate,
#capsules > h2.kh-animate,
#tools.kh-animate {
    animation: kh-fade-up 0.55s 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* ── @keyframes ── */
@keyframes kh-splash-icon-in {
    from { opacity: 0; transform: scale(0.7) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes kh-fade-up {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes kh-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes kh-slide-down {
    from { opacity: 0; transform: translateY(-20px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes kh-card-in {
    from { opacity: 0; transform: translateY(22px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes kh-ecg-draw {
    to { stroke-dashoffset: 0; }
}

/* ── تعطيل الأنيميشن لمن يفضل تقليل الحركة ── */
@media (prefers-reduced-motion: reduce) {
    #kh-splash { transition: none; }
    #kh-splash * { animation: none !important; }
    body.kh-loading > *:not(#kh-splash) { opacity: 1; }
    header.kh-animate,
    .hero.kh-animate .hero-text h1,
    .hero.kh-animate .hero-text p,
    .hero.kh-animate .main-btn-container,
    .capsule-tracker.kh-animate,
    .cards-container.kh-animate .card { animation: none !important; opacity: 1 !important; }
}

/* ════════════════════════════════════════════════════════════════
   ✨ STYLE UPGRADES v2 — خدلك كبسولة
   تحسينات بصرية شاملة: كروت، هيدر، بوتونات، أنيميشن
   ════════════════════════════════════════════════════════════════ */

/* ── 1. تحسين الكروت: Glass Morphism + Gradient Border ── */
.card {
    background: var(--card-bg);
    border: 1px solid transparent;
    background-clip: padding-box;
    position: relative;
    transition: transform 0.35s cubic-bezier(0.34,1.2,0.64,1),
                box-shadow 0.35s ease,
                background 0.3s ease;
}

/* Hover glow via box-shadow (no pseudo conflict) ── */

.card:hover {
    transform: translateY(-10px) scale(1.013);
    box-shadow: 0 24px 48px rgba(2,132,199,0.16),
                0 8px 16px rgba(0,0,0,0.08);
}

/* أيقونة الكرت — تأثير glow ── */
.card-icon {
    transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1),
                box-shadow 0.3s ease,
                background 0.3s ease;
    box-shadow: 0 4px 12px rgba(2,132,199,0.10);
}

.card:hover .card-icon {
    transform: scale(1.18) rotate(-6deg);
    box-shadow: 0 8px 24px rgba(2,132,199,0.28);
    background: linear-gradient(135deg, var(--primary), var(--secondary)) !important;
    color: #fff !important;
}

/* ── 2. Badge "جديد" على الكروت — يستخدم span.card-badge داخل الـ HTML ── */
/* (badge via .card-badge class لتجنب تعارض ::before مع top-stripe) */
.card-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: linear-gradient(135deg, var(--accent), #059669);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    padding: 3px 9px;
    border-radius: var(--radius-pill);
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(16,185,129,0.35);
    z-index: 2;
    pointer-events: none;
}

/* ── 3. تحسين Hero: Animated Gradient Background ── */
.hero {
    background: var(--bg);
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: -200px; left: 50%;
    transform: translateX(-50%);
    width: 1000px; height: 1000px;
    background: radial-gradient(circle at 30% 40%,
        rgba(2,132,199,0.10) 0%,
        rgba(99,102,241,0.06) 40%,
        transparent 70%);
    animation: heroGlow 8s ease-in-out infinite alternate;
    pointer-events: none;
}

.hero::after {
    content: '';
    position: absolute;
    bottom: -100px; right: -100px;
    width: 500px; height: 500px;
    background: radial-gradient(circle,
        rgba(16,185,129,0.07) 0%,
        transparent 70%);
    animation: heroGlow 6s 2s ease-in-out infinite alternate-reverse;
    pointer-events: none;
}

@keyframes heroGlow {
    0%   { transform: translateX(-50%) scale(1);   opacity: 0.8; }
    100% { transform: translateX(-50%) scale(1.15); opacity: 1;   }
}

/* ── 4. تحسين الـ Hero Title: animated gradient ── */
.hero-text h1 {
    background-size: 200% auto;
    animation: gradientShift 5s linear infinite;
}

@keyframes gradientShift {
    0%   { background-position: 0%   center; }
    50%  { background-position: 100% center; }
    100% { background-position: 0%   center; }
}

/* ── 5. تحسين الـ btn-main: Shimmer effect ── */
.btn-main {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
}

.btn-main::after {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255,255,255,0.22) 50%,
        transparent 100%);
    animation: btnShimmer 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes btnShimmer {
    0%   { left: -100%; }
    40%  { left: 150%;  }
    100% { left: 150%;  }
}

/* ── 6. تحسين الـ tool-box ── */
.tool-box {
    border: 1px solid var(--border-soft);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    position: relative;
    overflow: hidden;
}

.tool-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--primary), var(--secondary));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tool-box:hover::before { opacity: 1; }

.tool-box:hover {
    transform: translateY(-6px);
    box-shadow: 0 16px 36px rgba(2,132,199,0.14);
    border-color: var(--primary);
}

/* ── 7. Section Headings: عنوان مع خط تزييني ── */
.cards-section > h2,
.tools-section > h2 {
    position: relative;
    padding-bottom: 18px;
    margin-bottom: 6px;
}

.cards-section > h2::after,
.tools-section > h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: var(--radius-pill);
}

/* ── 8. تحسين الـ Form Inputs ── */
.form-input {
    transition: border-color 0.25s ease,
                box-shadow 0.25s ease,
                background 0.25s ease,
                transform 0.2s ease;
}

.form-input:focus {
    transform: translateY(-1px);
    box-shadow: 0 0 0 3.5px rgba(2,132,199,0.14),
                0 4px 12px rgba(2,132,199,0.08);
}

/* ── 9. تحسين الـ modal-content: أنيميشن أحسن ── */
.modal-content {
    animation: modalIn 0.38s cubic-bezier(0.34, 1.4, 0.64, 1);
}

@keyframes modalIn {
    from { transform: scale(0.85) translateY(20px); opacity: 0; }
    to   { transform: scale(1)    translateY(0);    opacity: 1; }
}

/* border علوي ملوّن للمودال ── */
.modal-content::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

/* ── 10. تحسين الـ Toast ── */
.toast-notification {
    border-radius: var(--radius-md);
    border-right: 4px solid rgba(255,255,255,0.35);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.toast-notification.toast-error {
    background: var(--danger);
}
.toast-notification.toast-warning {
    background: var(--warning);
    color: #1a1a1a;
}
.toast-notification.toast-info {
    background: var(--primary);
}

/* ── 11. تحسين الـ header nav active state ── */
header nav a.active {
    background: rgba(255,255,255,0.14);
    color: #ffffff;
}

header nav a.active::after {
    width: 60%;
}

/* ── 12. تحسين الـ scrollbar — أجمل ── */
::-webkit-scrollbar { width: 7px; }
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary), var(--secondary));
    border-radius: 20px;
    border: 2px solid var(--bg);
    transition: background 0.3s;
}
::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--secondary), var(--accent));
}

/* ── 13. تحسين الـ back-to-top button ── */
#backToTop {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    box-shadow: 0 8px 20px rgba(2,132,199,0.35);
    transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1),
                box-shadow 0.3s ease,
                opacity 0.3s ease;
}

#backToTop:hover {
    transform: translateY(-7px) scale(1.12);
    box-shadow: 0 16px 32px rgba(2,132,199,0.45);
}

/* ── 14. تحسين الـ hdr-icon-btn بضوء hover ── */
.hdr-icon-btn {
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.hdr-icon-btn:hover {
    background: rgba(255,255,255,0.18) !important;
    transform: scale(1.08);
    box-shadow: 0 0 12px rgba(255,255,255,0.12);
}

/* ── 15. Skeleton Loading — أحسن ── */
.skeleton {
    background: linear-gradient(90deg,
        rgba(148,163,184,0.12) 25%,
        rgba(148,163,184,0.22) 50%,
        rgba(148,163,184,0.12) 75%);
    background-size: 400% 100%;
    animation: skeletonLoad 1.8s ease infinite;
}

@keyframes skeletonLoad {
    0%   { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

/* ── 16. Progress bar — أجمل + نابض ── */
#progressBar {
    background: linear-gradient(90deg,
        var(--accent) 0%,
        var(--primary) 50%,
        var(--secondary) 100%);
    box-shadow: 0 0 8px rgba(2,132,199,0.5);
    height: 3.5px;
}

/* ── 17. Section subtitle style ── */
.section-subtitle,
.cards-section > p,
.tools-section > p {
    text-align: center;
    color: var(--text-muted);
    font-size: 14.5px;
    max-width: 560px;
    margin: 0 auto 36px;
    line-height: 1.75;
}

/* ── 18. Hover glow on social icons ── */
.social-icons a,
.nav-social-row a {
    transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1),
                background 0.2s ease,
                box-shadow 0.2s ease;
}

.social-icons a:hover,
.nav-social-row a:hover {
    transform: translateY(-4px) scale(1.12);
    box-shadow: 0 8px 16px rgba(0,0,0,0.25);
}

/* ── 19. Card أنيميشن عند الظهور (Intersection Observer) ── */
.card.card-visible {
    animation: cardReveal 0.5s cubic-bezier(0.4,0,0.2,1) both;
}

@keyframes cardReveal {
    from { opacity: 0; transform: translateY(28px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ── 20. تحسين dark mode cards ── */
[data-theme="dark"] .card {
    background: rgba(15,23,42,0.75);
    border-color: rgba(56,189,248,0.10);
}

[data-theme="dark"] .card:hover {
    background: rgba(15,23,42,0.95);
    border-color: rgba(56,189,248,0.22);
    box-shadow: 0 24px 48px rgba(0,0,0,0.4),
                0 0 0 1px rgba(56,189,248,0.15);
}

[data-theme="dark"] .tool-box {
    background: rgba(15,23,42,0.75);
}

[data-theme="dark"] .tool-box:hover {
    background: rgba(15,23,42,0.95);
    border-color: rgba(56,189,248,0.3);
}

/* ── 21. تحسين footer ── */
footer {
    background: linear-gradient(135deg, #040a14, #060d1f);
    border-top: 1px solid rgba(2,132,199,0.12);
    position: relative;
    overflow: hidden;
}

footer::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg,
        transparent,
        rgba(2,132,199,0.4) 30%,
        rgba(99,102,241,0.4) 70%,
        transparent);
}

/* ── 22. تحسين focus-visible عام ── */
:focus-visible {
    outline: 2.5px solid var(--primary);
    outline-offset: 3px;
    border-radius: 6px;
    box-shadow: 0 0 0 5px rgba(2,132,199,0.12);
}



/* ── 24. تحسين progress bar على الماء ── */
.water-progress-bar {
    background: linear-gradient(90deg, #38bdf8 0%, #0ea5e9 50%, #0077b6 100%);
    box-shadow: inset 0 1px 3px rgba(255,255,255,0.2);
}

/* ── 25. Responsive: تحسينات إضافية للموبايل ── */
@media (max-width: 768px) {
    .card:hover {
        transform: translateY(-4px);
    }

    .hero::before,
    .hero::after {
        display: none;
    }

    .cards-section > h2::after,
    .tools-section > h2::after {
        width: 44px;
        height: 3px;
    }
}

/* ════════════════════════════════════════════════════════════════
   END STYLE UPGRADES v2
   ════════════════════════════════════════════════════════════════ */

/* ─── In-Header Language Switcher ─── */
#kh-lang-switcher {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.12);
    border-radius: 50px;
    padding: 3px 4px;
    gap: 2px;
    border: 1px solid rgba(255,255,255,0.18);
    flex-shrink: 0;
}
#kh-lang-switcher .kh-lb {
    background: transparent;
    color: rgba(255,255,255,0.8);
    border: none;
    border-radius: 50px;
    padding: 4px 11px;
    font-size: 12px;
    font-weight: 700;
    font-family: 'Cairo', sans-serif;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background .15s, color .15s;
    white-space: nowrap;
    line-height: 1;
}
#kh-lang-switcher .kh-lb:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}
#kh-lang-switcher .kh-lb.kh-active {
    background: #fff;
    color: #0284c7;
    font-weight: 800;
}
#kh-lang-switcher .kh-sep {
    width: 1px;
    height: 16px;
    background: rgba(255,255,255,0.2);
    flex-shrink: 0;
}
@media (max-width: 380px) {
    #kh-lang-switcher .kh-lb { padding: 3px 8px; font-size: 11px; }
    #kh-lang-switcher .kh-lb span:first-child { display: none; }
}

/* ─── Lang Switcher: hide from header on mobile, show in drawer ─── */
@media (max-width: 768px) {
    header > #kh-lang-switcher {
        display: none !important;
    }
}
@media (min-width: 769px) {
    .kh-drawer-lang-section,
    #kh-lang-switcher-drawer { display: none !important; }
}

/* ─── Drawer Lang Section ─── */
.kh-drawer-lang-section {
    margin: 6px 12px 12px;
    padding: 14px 16px;
    background: rgba(255,255,255,0.05);
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.08);
}
.kh-drawer-lang-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: rgba(255,255,255,0.45);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    font-family: 'Cairo', sans-serif;
}
#kh-lang-switcher-drawer {
    display: flex !important;
    gap: 8px;
    width: 100%;
}
#kh-lang-switcher-drawer .kh-lb {
    flex: 1;
    justify-content: center;
    background: rgba(255,255,255,0.07);
    color: rgba(255,255,255,0.65);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 10px 8px;
    font-size: 13px;
    font-weight: 700;
    font-family: 'Cairo', sans-serif;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 7px;
    transition: all .18s;
}
#kh-lang-switcher-drawer .kh-lb:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border-color: rgba(255,255,255,0.2);
}
#kh-lang-switcher-drawer .kh-lb.kh-active {
    background: linear-gradient(135deg, #0284c7, #0369a1);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 3px 12px rgba(2,132,199,0.4);
}
#kh-lang-switcher-drawer .kh-sep { display: none; }

/* ─── Hero Stats ─── */
.hero-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-top: 28px;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 20px;
    padding: 14px 24px;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(8px);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}
.hero-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 0 20px;
}
.hero-stat-num {
    font-size: 22px;
    font-weight: 900;
    color: #fff;
    line-height: 1;
    font-family: 'Cairo', sans-serif;
}
.hero-stat-label {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255,255,255,0.65);
    font-family: 'Cairo', sans-serif;
    white-space: nowrap;
}
.hero-stat-sep {
    width: 1px;
    height: 36px;
    background: rgba(255,255,255,0.2);
    flex-shrink: 0;
}
@media (max-width: 480px) {
    .hero-stats { padding: 12px 16px; }
    .hero-stat { padding: 0 14px; }
    .hero-stat-num { font-size: 18px; }
    .hero-stat-label { font-size: 10px; }
}

/* ══════════════════════════════════════════════════
   ✅ إصلاح: زر الوضع الداكن — focus واضح وآمن
══════════════════════════════════════════════════ */
.hdr-icon-btn:focus-visible {
    outline: 2px solid rgba(255,255,255,0.6);
    outline-offset: 2px;
    background: rgba(255,255,255,0.18) !important;
}
.hdr-icon-btn:focus:not(:focus-visible) {
    outline: none;
}
/* منع اختفاء الأيقونة عند أي حالة */
.hdr-icon-btn i {
    pointer-events: none;
    display: block;
    line-height: 1;
}

/* ==========================================================================
   🔥 Engagement: شارة النقاط/السلسلة + Onboarding + المشاركة
   ========================================================================== */
.hdr-points-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-soft, rgba(0,0,0,0.04));
    border: 1px solid var(--border-soft, rgba(0,0,0,0.08));
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-color, #222);
    cursor: pointer;
    line-height: 1;
    white-space: nowrap;
}
.hdr-points-btn .pts-sep { opacity: .4; margin: 0 2px; }
.hdr-points-btn .pts-flame, .hdr-points-btn .pts-coin { font-size: 13px; }

.kh-onboard-progress { display:flex; justify-content:center; gap:6px; margin-bottom:16px; }
.kh-onboard-progress .kh-dot { width:8px; height:8px; border-radius:50%; background:var(--border-soft, #ddd); transition:.2s; }
.kh-onboard-progress .kh-dot.active { background: var(--accent-color, #2563eb); width:20px; border-radius:5px; }

.kh-onboard-sub { color: var(--text-muted, #777); font-size: 13.5px; margin: 4px 0 14px; }
.kh-onboard-grid { display:grid; grid-template-columns: repeat(3, 1fr); gap:10px; }
.kh-onboard-grid-2 { grid-template-columns: repeat(2, 1fr); }
.kh-onboard-choice {
    background: var(--bg-soft, #f5f5f7);
    border: 2px solid transparent;
    border-radius: 14px;
    padding: 14px 6px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    color: var(--text-color, #222);
    transition: .15s;
    line-height: 1.6;
}
.kh-onboard-choice:hover { border-color: var(--accent-color, #2563eb); transform: translateY(-2px); }
.kh-onboard-choice.selected { border-color: var(--accent-color, #2563eb); background: rgba(37,99,235,.08); }
.kh-onboard-skip {
    display:block; width:100%; background:none; border:none;
    color: var(--text-muted, #888); font-size: 13px; margin-top:10px; cursor:pointer;
}
.kh-streak-flame { font-size: 48px; line-height:1; margin-bottom: 6px; }

@media (max-width: 480px) {
    .hdr-points-btn { font-size: 11.5px; padding: 4px 8px; }
}
