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

:root {
    --primary-gradient: linear-gradient(135deg, #6c5ce7, #a29bfe);
    --secondary-gradient: linear-gradient(135deg, #ff7675, #fd79a8);
    --success-gradient: linear-gradient(135deg, #00b894, #55efc4);
    --danger-gradient: linear-gradient(135deg, #d63031, #ff7675);
    
    --bg-dark: #0f0c1b;
    --bg-light: #16122d;
    --bg-card: rgba(26, 21, 51, 0.65);
    --border-card: rgba(108, 92, 231, 0.25);
    
    --text-main: #f8f9fa;
    --text-muted: #b2bec3;
    --text-highlight: #fd79a8;
    
    --shadow-glow: 0 8px 32px 0 rgba(108, 92, 231, 0.3);
    --shadow-button: 0 4px 15px 0 rgba(0, 0, 0, 0.25);
    --radius-lg: 20px;
    --radius-md: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Cairo', 'Tajawal', sans-serif;
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 10% 20%, rgba(108, 92, 231, 0.15) 0px, transparent 50%),
        radial-gradient(at 90% 80%, rgba(253, 121, 168, 0.15) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    direction: rtl;
    text-align: right;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

header {
    width: 100%;
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(15, 12, 27, 0.85);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #a29bfe, #fd79a8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    cursor: pointer;
}

.heart-pulse {
    display: inline-block;
    color: #e84393;
    animation: heartBeat 1.5s infinite;
}

.love-badge {
    background: var(--secondary-gradient);
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: 50px;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(253, 121, 168, 0.3);
    display: flex;
    align-items: center;
    gap: 5px;
}

main {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    padding: 30px;
    box-shadow: var(--shadow-glow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Animations */
@keyframes heartBeat {
    0% { transform: scale(1); }
    14% { transform: scale(1.15); }
    28% { transform: scale(1); }
    42% { transform: scale(1.15); }
    70% { transform: scale(1); }
}

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

@keyframes glow {
    0% { box-shadow: 0 0 5px rgba(108, 92, 231, 0.2); }
    50% { box-shadow: 0 0 20px rgba(108, 92, 231, 0.6); }
    100% { box-shadow: 0 0 5px rgba(108, 92, 231, 0.2); }
}

/* Welcome Screen */
.welcome-container {
    text-align: center;
    max-width: 700px;
    margin: 40px auto;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.welcome-title h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 10px;
    line-height: 1.3;
}

.welcome-title span {
    background: linear-gradient(135deg, #a29bfe, #fd79a8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-desc {
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1.6;
}

/* Mode Switch Tabs */
.tabs-container {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px;
    border-radius: 50px;
    width: fit-content;
    margin: 15px auto;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 10px 24px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: var(--shadow-button);
}

/* Category Grid */
.category-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    text-align: right;
    margin-top: 15px;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 10px;
}

.category-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 24px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.category-card:hover {
    background: rgba(108, 92, 231, 0.1);
    border-color: rgba(108, 92, 231, 0.35);
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

.category-card.selected {
    background: rgba(108, 92, 231, 0.2);
    border-color: #6c5ce7;
    box-shadow: 0 0 15px rgba(108, 92, 231, 0.3);
}

.category-icon {
    font-size: 2rem;
    color: #fd79a8;
}

.category-card h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
}

.category-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.btn-start {
    background: var(--primary-gradient);
    color: #fff;
    border: none;
    padding: 16px 40px;
    font-size: 1.15rem;
    font-weight: 700;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-button);
    width: fit-content;
    margin: 20px auto 0;
}

.btn-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.55);
}

.btn-start:active {
    transform: translateY(1px);
}

/* Quiz Interface */
.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.quiz-info-badge {
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.category-badge {
    background: rgba(108, 92, 231, 0.2);
    border: 1px solid rgba(108, 92, 231, 0.3);
    color: #a29bfe;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.9rem;
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timer-badge {
    background: rgba(255, 118, 117, 0.15);
    border: 1px solid rgba(255, 118, 117, 0.3);
    color: #ff7675;
    font-weight: 700;
}

.progress-container {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    height: 8px;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 30px;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #fd79a8, #6c5ce7);
    border-radius: 10px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(108, 92, 231, 0.5);
}

.question-text {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.6;
    margin-bottom: 25px;
    color: var(--text-main);
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.option-btn {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: var(--radius-md);
    padding: 18px 24px;
    text-align: right;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Cairo', sans-serif;
}

.option-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateX(-5px);
}

.option-btn.selected {
    background: rgba(108, 92, 231, 0.15);
    border-color: #6c5ce7;
}

.option-btn.correct {
    background: rgba(0, 184, 148, 0.15);
    border-color: #00b894;
    color: #55efc4;
}

.option-btn.incorrect {
    background: rgba(214, 48, 49, 0.15);
    border-color: #d63031;
    color: #ff7675;
}

.option-indicator {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: all 0.25s ease;
}

.option-btn.correct .option-indicator {
    border-color: #00b894;
    background: #00b894;
    color: #fff;
}

.option-btn.incorrect .option-indicator {
    border-color: #d63031;
    background: #d63031;
    color: #fff;
}

.explanation-card {
    background: rgba(108, 92, 231, 0.08);
    border: 1px dashed rgba(108, 92, 231, 0.3);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 25px;
    line-height: 1.5;
    font-size: 0.95rem;
    display: none;
    animation: fadeIn 0.4s ease;
}

.explanation-card.show {
    display: block;
}

.explanation-title {
    font-weight: 700;
    color: #a29bfe;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.quiz-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.btn-nav {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 28px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-nav:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-submit {
    background: var(--primary-gradient);
    border: none;
    color: #fff;
}

.btn-submit:hover {
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
}

/* Result Dashboard */
.result-container {
    text-align: center;
    max-width: 600px;
    margin: 20px auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
}

.result-ring-wrapper {
    position: relative;
    width: 180px;
    height: 180px;
    margin: 10px 0;
}

.result-ring-svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.result-ring-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.04);
    stroke-width: 12;
}

.result-ring-progress {
    fill: none;
    stroke: url(#resultGrad);
    stroke-width: 12;
    stroke-linecap: round;
    stroke-dasharray: 502;
    stroke-dashoffset: 502;
    transition: stroke-dashoffset 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.result-ring-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.2rem;
    font-weight: 800;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.result-ring-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.result-title {
    font-size: 1.8rem;
    font-weight: 800;
}

.result-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    width: 100%;
    margin-top: 10px;
}

.stat-box {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    padding: 16px;
}

.stat-val {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-val.success { color: #55efc4; }
.stat-val.danger { color: #ff7675; }
.stat-val.highlight { color: #a29bfe; }

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.result-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 15px;
    flex-wrap: wrap;
}

/* Study Section */
.study-accordion {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 10px;
}

.accordion-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all 0.3s ease;
}

.accordion-header {
    padding: 20px 24px;
    background: rgba(255, 255, 255, 0.01);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-weight: 700;
    font-size: 1.1rem;
    user-select: none;
    transition: background 0.3s ease;
}

.accordion-header:hover {
    background: rgba(255, 255, 255, 0.04);
}

.accordion-header::after {
    content: '\25BC';
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

.accordion-item.active {
    border-color: rgba(108, 92, 231, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.accordion-item.active .accordion-header::after {
    transform: rotate(180deg);
    color: #6c5ce7;
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0 24px;
}

.accordion-item.active .accordion-content {
    max-height: 1200px;
    padding: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
}

.study-article {
    line-height: 1.7;
    font-size: 1rem;
    color: #e2e8f0;
}

.study-article p {
    margin-bottom: 15px;
}

.study-article ul, .study-article ol {
    margin-right: 25px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.study-article li strong {
    color: #a29bfe;
}

/* Modal Popup Dialog (Motivational Alerts) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 12, 27, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    box-shadow: var(--shadow-glow);
    border-radius: var(--radius-lg);
    padding: 40px;
    text-align: center;
    max-width: 450px;
    width: 90%;
    transform: scale(0.85);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.show .modal-box {
    transform: scale(1);
}

.modal-icon {
    font-size: 3.5rem;
    margin-bottom: 20px;
    animation: heartBeat 1.2s infinite;
}

.modal-title {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #a29bfe, #fd79a8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-text {
    font-size: 1.05rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 25px;
}

.modal-btn {
    background: var(--primary-gradient);
    color: #fff;
    border: none;
    padding: 12px 36px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    transition: all 0.3s ease;
}

.modal-btn:hover {
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.45);
}

/* Footer Section */
footer {
    padding: 30px;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(15, 12, 27, 0.65);
    color: var(--text-muted);
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.love-tag {
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    header {
        padding: 15px 20px;
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    .logo {
        font-size: 1.25rem;
    }
    .love-badge {
        font-size: 0.75rem;
        padding: 4px 10px;
    }
    main {
        padding: 15px 10px;
        gap: 20px;
    }
    .glass-card {
        padding: 20px 15px;
        border-radius: var(--radius-md);
    }
    .welcome-title h1 {
        font-size: 1.7rem;
    }
    .welcome-desc {
        font-size: 0.95rem;
    }
    .category-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .category-card {
        padding: 16px;
    }
    .quiz-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .category-badge {
        max-width: 100%;
        text-align: center;
    }
    .question-text {
        font-size: 1.15rem;
        margin-bottom: 20px;
    }
    .option-btn {
        padding: 14px 18px;
        font-size: 0.95rem;
        line-height: 1.5;
    }
    .result-stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .study-accordion {
        gap: 10px;
    }
    .accordion-header {
        padding: 15px 18px;
        font-size: 0.95rem;
    }
    .accordion-item.active .accordion-content {
        padding: 16px;
    }
    .study-article {
        font-size: 0.9rem;
    }
    .modal-box {
        padding: 25px 20px;
    }
    .modal-icon {
        font-size: 2.8rem;
        margin-bottom: 12px;
    }
    .modal-title {
        font-size: 1.3rem;
    }
    .modal-text {
        font-size: 0.95rem;
        margin-bottom: 15px;
    }
}

@media (max-width: 480px) {
    .tabs-container {
        flex-direction: column;
        border-radius: var(--radius-md);
        width: 100%;
        gap: 4px;
    }
    .tab-btn {
        width: 100%;
        padding: 8px 12px;
        font-size: 0.9rem;
        border-radius: var(--radius-md);
    }
    .quiz-footer {
        flex-direction: column-reverse;
        gap: 12px;
        width: 100%;
    }
    .btn-nav {
        width: 100%;
        justify-content: center;
        padding: 12px;
    }
    .btn-start {
        width: 100%;
        padding: 14px 20px;
    }
    .result-actions {
        flex-direction: column;
        width: 100%;
    }
}

/* Utility classes to hide/show screen sections */
.d-none {
    display: none !important;
}

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

.fade-in {
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

