/* ==========================================================================
   نظام تحدي المدارس — أنماط التصميم المؤسسي الموحد
   ========================================================================== */

/* 1. شبكة بلوكات التحديات في صفحة الأحداث */
.challenges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.challenge-card {
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 15px rgba(27, 43, 94, 0.05);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    position: relative;
}

.challenge-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(27, 43, 94, 0.12);
    border-color: #C8A951;
}

.challenge-card-header {
    padding: 18px 20px;
    background: linear-gradient(135deg, #152247 0%, #1B2B5E 100%);
    color: #ffffff;
    position: relative;
    border-bottom: 3px solid #C8A951;
}

.challenge-card-header.gold {
    background: linear-gradient(135deg, #92400e 0%, #d97706 100%);
    border-bottom-color: #fef08a;
}
.challenge-card-header.teal {
    background: linear-gradient(135deg, #115e59 0%, #0f766e 100%);
    border-bottom-color: #2dd4bf;
}
.challenge-card-header.purple {
    background: linear-gradient(135deg, #581c87 0%, #7e22ce 100%);
    border-bottom-color: #d8b4fe;
}

.challenge-card-title {
    font-size: 1.15rem;
    font-weight: 800;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #ffffff;
}

.challenge-card-desc {
    font-size: 0.78rem;
    opacity: 0.9;
    line-height: 1.4;
}

.challenge-card-body {
    padding: 18px 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* إحصائيات سريعة للبطاقة */
.ch-stats-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    background: #f8fafc;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #edf2f7;
    text-align: center;
}

.ch-stat-val {
    font-size: 1.35rem;
    font-weight: 900;
    color: #1B2B5E;
    line-height: 1.1;
}

.ch-stat-lbl {
    font-size: 0.7rem;
    color: #64748b;
    font-weight: 600;
    margin-top: 4px;
}

/* شريط المستهدف */
.ch-target-bar-wrap {
    margin-top: 4px;
}

.ch-target-bar-head {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: #334155;
}

.ch-target-bar {
    height: 9px;
    background: #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
}

.ch-target-fill {
    height: 100%;
    background: linear-gradient(90deg, #0f766e, #C8A951);
    border-radius: 6px;
    transition: width 0.4s ease;
}

/* بطاقة المدرسة الأولى في الصدارة */
.ch-top-school {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 1px solid #fde68a;
    border-radius: 10px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.ch-top-badge {
    font-size: 0.72rem;
    font-weight: 800;
    color: #92400e;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* تاريخ آخر تحديث */
.ch-update-info {
    font-size: 0.72rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 6px;
    border-top: 1px dashed #e2e8f0;
    padding-top: 10px;
    margin-top: auto;
}

/* أزرار الإجراءات */
.challenge-card-footer {
    padding: 14px 20px;
    background: #f8fafc;
    border-top: 1px solid #f1f5f9;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.ch-btn-view {
    flex: 1;
    background: #1B2B5E;
    color: #ffffff;
    font-weight: 700;
    font-size: 0.8rem;
    padding: 8px 14px;
    border-radius: 8px;
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.ch-btn-view:hover {
    background: #0F766E;
    color: #ffffff;
}

.ch-btn-upload {
    background: #0f766e;
    color: #ffffff;
    font-weight: 700;
    font-size: 0.8rem;
    padding: 8px 12px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.ch-btn-upload:hover {
    background: #115e59;
}

.ch-btn-edit {
    background: #e2e8f0;
    color: #334155;
    font-size: 0.8rem;
    padding: 8px 10px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ch-btn-edit:hover {
    background: #cbd5e1;
    color: #0f172a;
}

/* ==========================================================================
   2. مؤشرات التقدم والأسهم (Delta Indicators)
   ========================================================================== */
.delta-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 12px;
    white-space: nowrap;
}

.delta-tag.up {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.delta-tag.down {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.delta-tag.same {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.delta-tag.new {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fde68a;
}

/* ==========================================================================
   3. منصة الشرف الثلاثية (Podium) في صفحة التحدي
   ========================================================================== */
.view-podium-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.podium-box {
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    padding: 20px 16px;
    text-align: center;
    position: relative;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.podium-box.rank-1 {
    border-top: 5px solid #C8A951;
    background: linear-gradient(180deg, #fffdf0 0%, #ffffff 100%);
    box-shadow: 0 8px 25px rgba(200, 169, 81, 0.15);
    order: 2;
}

.podium-box.rank-2 {
    border-top: 5px solid #94a3b8;
    order: 1;
}

.podium-box.rank-3 {
    border-top: 5px solid #f97316;
    order: 3;
}

.podium-badge-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 10px;
}

.rank-1 .podium-badge-icon {
    background: linear-gradient(135deg, #fef08a 0%, #C8A951 100%);
    color: #78350f;
    box-shadow: 0 4px 12px rgba(200, 169, 81, 0.4);
}
.rank-2 .podium-badge-icon {
    background: linear-gradient(135deg, #f1f5f9 0%, #cbd5e1 100%);
    color: #334155;
    box-shadow: 0 4px 12px rgba(148, 163, 184, 0.4);
}
.rank-3 .podium-badge-icon {
    background: linear-gradient(135deg, #ffedd5 0%, #f97316 100%);
    color: #7c2d12;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
}

.podium-school-title {
    font-size: 1rem;
    font-weight: 800;
    color: #1e293b;
    margin-bottom: 4px;
}

.podium-count-big {
    font-size: 2rem;
    font-weight: 900;
    line-height: 1.1;
    margin: 8px 0;
}

/* ==========================================================================
   4. جدول لوحة الصدارة في صفحة التحدي
   ========================================================================== */
.ch-table-wrap {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.ch-leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.84rem;
}

.ch-leaderboard-table thead tr {
    background: linear-gradient(135deg, #152247 0%, #1B2B5E 100%);
    color: #ffffff;
    border-bottom: 2px solid #C8A951;
}

.ch-leaderboard-table th {
    padding: 14px 12px;
    font-weight: 800;
    font-size: 0.8rem;
    color: #ffffff;
    text-align: center;
}

.ch-leaderboard-table th:first-child,
.ch-leaderboard-table th:nth-child(2) {
    text-align: right;
}

.ch-leaderboard-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    text-align: center;
}

.ch-leaderboard-table td:first-child,
.ch-leaderboard-table td:nth-child(2) {
    text-align: right;
}

.ch-leaderboard-table tbody tr:hover {
    background: #f8fafc;
}

/* شريط تصفية تفاعلي */
.view-filter-bar {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 16px 20px;
    margin-bottom: 22px;
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
}

.view-filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.view-filter-group label {
    font-size: 0.76rem;
    font-weight: 700;
    color: #475569;
}

.view-filter-select {
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    font-size: 0.78rem;
    font-family: inherit;
    color: #1e293b;
    background: #fff;
}

.view-search-input {
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    font-size: 0.78rem;
    font-family: inherit;
    min-width: 220px;
}

/* ==========================================================================
   5. أنماط الطباعة والتصدير كـ PDF
   ========================================================================== */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
        margin: 0 !important;
        padding: 10px !important;
    }

    .admin-sidebar,
    .admin-header-bar,
    .theme-toggle,
    .events-tabs,
    .view-filter-bar,
    .btn-print-hide,
    [data-noprint] {
        display: none !important;
    }

    .admin-main-content {
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
    }

    .ch-print-header {
        display: block !important;
        border-bottom: 2px solid #1B2B5E;
        padding-bottom: 12px;
        margin-bottom: 18px;
        text-align: center;
    }

    .ch-leaderboard-table {
        font-size: 10pt !important;
    }

    .ch-leaderboard-table th {
        background: #1B2B5E !important;
        color: #ffffff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .podium-box {
        break-inside: avoid;
    }
}

@media (max-width: 768px) {
    .challenges-grid {
        grid-template-columns: 1fr;
    }
    .view-podium-grid {
        grid-template-columns: 1fr;
    }
    .podium-box.rank-1 { order: 1; }
    .podium-box.rank-2 { order: 2; }
    .podium-box.rank-3 { order: 3; }
}