/* ========================================
   مكتبة المعلمين - اختبارات نهائية
   الأنماط الرئيسية
======================================== */

:root {
    /* Colors - مطابقة لمتجر سلة */
    --primary-color: #1e3a5f;
    --secondary-color: #0d9488;
    --accent-color: #0ea5e9;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --text-dark: #212529;
    --text-muted: #6c757d;
    --border-color: #dee2e6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.15);

    /* Transitions */
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Cairo', 'Tajawal', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
    direction: rtl;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ========================================
   Header
======================================== */

.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #1a365d 50%, #2c5282 100%);
    color: white;
    padding: 35px 0 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(13, 148, 136, 0.15) 0%, transparent 70%);
    border-radius: 50%;
}

.header-content {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 40px;
    position: relative;
    z-index: 1;
}

.logo-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.logo-img {
    width: 90px;
    height: 90px;
    border-radius: 16px;
    object-fit: contain;
    background: white;
    padding: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

.logo-img:hover {
    transform: scale(1.08);
}

.logo-name {
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    opacity: 0.95;
    letter-spacing: 0.3px;
}

.header-tagline {
    text-align: center;
    margin-top: 15px;
    position: relative;
    z-index: 1;
}

.site-tagline {
    font-size: 0.95rem;
    color: white;
    background: linear-gradient(135deg, var(--secondary-color), #0ea5e9);
    display: inline-block;
    padding: 6px 25px;
    border-radius: 25px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* ========================================
   شريط الملازم المتحرك (Exams Ticker)
======================================== */

.exams-ticker {
    background: linear-gradient(135deg, var(--secondary-color) 0%, #0ea5e9 100%);
    padding: 25px 0;
    overflow: hidden;
    position: relative;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    direction: ltr; /* Force LTR for stable animation math */
}

.ticker-track {
    display: flex;
    flex-wrap: nowrap;
    width: max-content;
    gap: 20px; /* Modern flex gap */
    animation: scroll-horizontal 40s linear infinite;
    will-change: transform;
}

.ticker-track:hover {
    animation-play-state: paused;
}

.ticker-card {
    flex-shrink: 0;
    width: 200px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.ticker-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
    background: white;
}

.ticker-placeholder {
    width: 100%;
    height: 100px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ticker-card-content {
    padding: 15px 10px;
    text-align: center;
}

.ticker-text {
    font-weight: 800;
    color: var(--primary-color);
    font-size: 0.95rem;
    margin: 0;
    line-height: 1.4;
}

@keyframes scroll-horizontal {
    0% { transform: translateX(0); }
    100% { transform: translateX(var(--scroll-width)); }
}

/* ========================================
   Hero Section
======================================== */

.hero {
    background: linear-gradient(135deg, rgba(30, 58, 95, 0.05) 0%, rgba(13, 148, 136, 0.05) 100%);
    padding: 40px 0;
    text-align: center;
}

.hero-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 15px;
    line-height: 1.3;
}

/* Typing Animation */
.hero-title.typing-animation {
    display: inline-block;
    overflow: hidden;
    white-space: nowrap;
    border-left: 3px solid var(--secondary-color);
    animation: typing 3.5s steps(40, end) forwards, blink-caret 0.75s step-end infinite;
    max-width: 0;
}

.hero-title.typing-animation.typing-active {
    max-width: 100%;
}

@keyframes typing {
    from { max-width: 0; }
    to { max-width: 100%; }
}

@keyframes blink-caret {
    from, to { border-color: transparent; }
    50% { border-color: var(--secondary-color); }
}

.hero-description {
    font-size: 1.05rem;
    color: var(--text-muted);
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.7;
}

/* Lord Icon Sizing */
lord-icon {
    width: 48px;
    height: 48px;
}

lord-icon.icon-large {
    width: 80px;
    height: 80px;
}

lord-icon.icon-xlarge {
    width: 120px;
    height: 120px;
}

/* ========================================
   Smart Search Bar
======================================== */
.smart-search-container {
    max-width: 800px;
    margin: 0 auto 25px auto;
    width: 100%;
}
.search-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-white);
    border: 2px solid #e2e8f0;
    border-radius: 50px;
    padding: 12px 20px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
}
.search-input-wrapper:focus-within {
    border-color: var(--secondary-color);
    box-shadow: 0 8px 30px rgba(13, 148, 136, 0.15);
    transform: translateY(-2px);
}
.search-input-wrapper lord-icon {
    margin-left: 15px;
    flex-shrink: 0;
}
#smartSearchInput {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    background: transparent;
    font-family: inherit;
    width: 100%;
}
#smartSearchInput::placeholder {
    color: #94a3b8;
    font-weight: 600;
}

/* ========================================
   Filtering System
======================================== */

.filters-section {
    background: #f8fafc;
    padding: 40px 0;
    border-bottom: 1px solid var(--border-color);
}

/* Terms Tabs */
.terms-tabs-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
    background: white;
    padding: 8px;
    border-radius: 50px;
    box-shadow: var(--shadow-sm);
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}
.term-tab {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 40px;
    background: transparent;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
}
.term-tab:hover {
    color: var(--primary-color);
}
.term-tab.active {
    background: linear-gradient(135deg, var(--secondary-color) 0%, #0ea5e9 100%);
    color: white;
    box-shadow: var(--shadow-sm);
}

/* Compact Filters Container */
.compact-filters-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background: white;
    padding: 25px;
    border-radius: 20px;
    box-shadow: var(--shadow-sm);
}
.compact-filter-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 180px;
    flex: 1;
}
.compact-filter-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    color: var(--primary-color);
    font-size: 0.95rem;
}
.compact-select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    color: #475569;
    background-color: #f8fafc;
    cursor: pointer;
    transition: var(--transition);
    appearance: none; /* remove default arrow */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 15px center;
    background-size: 15px;
}
.compact-select:focus, .compact-select:hover {
    border-color: var(--secondary-color);
    outline: none;
    background-color: white;
}

/* Custom Select Wrapper */
.custom-select-wrapper {
    position: relative;
    user-select: none;
    width: 100%;
}
.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: #f8fafc;
    color: #475569;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}
.custom-select-trigger:hover, .custom-select-wrapper.open .custom-select-trigger {
    border-color: var(--secondary-color);
    background: white;
}
.custom-select-trigger::after {
    content: '';
    width: 14px; height: 14px;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230d9488' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.custom-select-wrapper.open .custom-select-trigger::after {
    transform: rotate(180deg);
}
.custom-options {
    position: absolute;
    top: 100%; left: 0; right: 0;
    margin-top: 8px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 100;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}
.custom-select-wrapper.open .custom-options {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}
.custom-option {
    padding: 12px 15px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.95rem;
    color: #475569;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f8fafc;
}
.custom-option:last-child { border-bottom: none; }
.custom-option:hover {
    background: #f1f5f9;
    color: var(--primary-color);
    padding-right: 20px;
}
.custom-option.selected {
    background: #f0fdf4;
    color: var(--secondary-color);
    padding-right: 20px;
    border-right: 4px solid var(--secondary-color);
}

/* ========================================
   Exams Section
======================================== */

.exams-section {
    padding: 60px 0;
    background: white;
}

.section-title {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 50px;
    text-align: center;
    position: relative;
    padding-bottom: 15px;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: var(--secondary-color);
    border-radius: 2px;
}

.no-exams {
    text-align: center;
    padding: 60px 20px;
    background: #f8fafc;
    border-radius: 20px;
    border: 2px dashed #e2e8f0;
    animation: fadeIn 0.8s ease;
}

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

.no-exams-icon {
    margin-bottom: 25px;
}

.no-exams-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: #1e293b;
    margin-bottom: 12px;
}

.no-exams-subtitle {
    font-size: 1.1rem;
    color: #64748b;
    max-width: 400px;
    margin: 0 auto;
}
.exams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 25px;
}

.exam-card {
    background: var(--bg-white);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid #f1f5f9;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.exam-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
    border-color: #cbd5e1;
}

.exam-header {
    width: 100%;
    height: 220px;
    position: relative;
    background: #f8fafc;
    overflow: hidden;
}

/* Blurred Background Cover for vertical images */
.exam-cover-image {
    position: absolute;
    top: -10%; left: -10%; right: -10%; bottom: -10%;
    background-size: cover;
    background-position: center top;
    filter: blur(20px);
    opacity: 0.4;
    z-index: 2;
}

/* The actual image */
.exam-image-contain {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 10px;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
    z-index: 3;
}

/* Gradient wrapper for icon when no image */
.exam-icon-wrapper {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, var(--primary-color) 0%, #1e40af 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

/* Floating Stage Badge */
.stage-chip {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 10;
    padding: 6px 14px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 800;
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.stage-chip.stage-ابتدائي { background: rgba(16, 185, 129, 0.95); }
.stage-chip.stage-متوسط { background: rgba(59, 130, 246, 0.95); }
.stage-chip.stage-ثانوي { background: rgba(139, 92, 246, 0.95); }

.exam-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.exam-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 15px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.exam-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.exam-tag {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f1f5f9;
    color: #475569;
}
.exam-tag.term-tag { background: #e0e7ff; color: #4338ca; }
.exam-tag.type-tag { background: #fce7f3; color: #be185d; }
.exam-tag.subject-tag { background: #dcfce7; color: #15803d; }
.exam-tag.level-tag { background: #f3f4f6; color: #4b5563; }

.exam-footer {
    padding: 0 20px 20px;
    margin-top: auto;
}

.exam-action-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    background: linear-gradient(135deg, var(--secondary-color) 0%, #0ea5e9 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 800;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.2);
}

.exam-card:hover .exam-action-btn {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(13, 148, 136, 0.4);
    background: var(--primary-color);
}

/* ========================================
   Custom Requests Section
======================================== */

.custom-requests {
    background: linear-gradient(135deg, var(--primary-color) 0%, #2c5282 100%);
    padding: 60px 0;
    margin-top: 40px;
}

.custom-requests-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 50px;
    text-align: center;
    color: white;
}

.custom-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.custom-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 15px;
}

.custom-description {
    font-size: 1.2rem;
    line-height: 1.8;
    margin-bottom: 30px;
    opacity: 0.9;
}

.custom-btns-container {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 25px;
}

.custom-btn {
    display: inline-block;
    background: var(--secondary-color);
    color: white;
    text-decoration: none;
    padding: 15px 30px;
    border-radius: 50px;
    font-weight: 700;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
    min-width: 220px; /* Equal width for both */
    text-align: center;
}

.custom-btn:hover {
    background: #0d9488;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    color: white;
}

/* ========================================
   Footer
======================================== */

.footer {
    background: var(--primary-color);
    color: white;
    padding: 40px 0 20px;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.footer-section h4 {
    font-size: 1.3rem;
    margin-bottom: 15px;
}

.footer-link {
    color: var(--secondary-color);
    text-decoration: none;
    transition: var(--transition);
}

.footer-link:hover {
    color: white;
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px;
    text-align: center;
    opacity: 0.8;
}

/* ========================================
   Responsive Design
======================================== */

@media (max-width: 768px) {
    .header {
        padding: 20px 0 15px;
    }

    .header-content {
        flex-direction: row; /* Keep side by side but smaller */
        gap: 20px;
        flex-wrap: wrap;
    }

    .logo-block {
        gap: 5px;
        flex: 1; /* Equal space */
        min-width: 120px;
    }

    .logo-img {
        width: 65px;
        height: 65px;
        border-radius: 12px;
    }

    .logo-name {
        font-size: 0.9rem;
        line-height: 1.2;
    }

    .header-tagline {
        margin-top: 10px;
    }

    .site-tagline {
        font-size: 0.8rem;
        padding: 4px 15px;
    }

    .hero {
        padding: 30px 0;
    }

    .hero-title {
        font-size: 1.4rem;
        margin-bottom: 10px;
    }

    /* Fix typing animation on mobile — allow text wrapping */
    .hero-title.typing-animation {
        white-space: normal;
        border-right: none;
        animation: fadeInUp 1s ease forwards;
        max-width: 100%;
        overflow: visible;
    }

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

    .hero-description {
        font-size: 0.95rem;
    }

    .filters-section {
        padding: 20px 0;
    }

    .terms-tabs-container {
        flex-direction: row;
        justify-content: space-between;
        padding: 6px;
        border-radius: 50px;
        gap: 8px;
        width: 100%;
        overflow: hidden;
    }
    .term-tab {
        flex: 1;
        padding: 12px 5px;
        font-size: 0.95rem;
        text-align: center;
        white-space: nowrap;
    }
    .compact-filters-container {
        padding: 15px;
        gap: 15px;
    }
    .compact-filter-box {
        min-width: 100%;
    }

    .exams-section {
        padding: 40px 0;
    }

    .section-title {
        font-size: 1.6rem;
        margin-bottom: 30px;
    }

    .exams-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .custom-requests {
        padding: 40px 0;
    }

    .custom-requests-card {
        padding: 30px 20px;
    }

    .custom-title {
        font-size: 1.4rem;
    }

    .custom-description {
        font-size: 0.95rem;
    }

    .custom-btn {
        min-width: 100%; /* Stack on small mobile */
    }

    .ticker-card {
        width: 160px;
    }

    .ticker-placeholder {
        height: 90px;
    }
}

@media (max-width: 480px) {
    .header-content {
        gap: 15px;
    }

    .logo-img {
        width: 55px;
        height: 55px;
    }

    .logo-name {
        font-size: 0.8rem;
    }

    .hero-title {
        font-size: 1.25rem;
    }

    .no-exams-title {
        font-size: 1.2rem;
    }

    .no-exams-subtitle {
        font-size: 0.9rem;
    }
}