/* إشعار الأوسمة المجمّع — badge-toast.js */
.sm-badge-toast {
    position: fixed;
    inset-inline-end: 20px;
    bottom: 20px;
    z-index: 2000;
    width: min(320px, calc(100vw - 32px));
    background: #fff;
    color: #1f2937;
    border: 1px solid #fde68a;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .18);
    padding: 12px 14px;
    animation: sm-badge-in .25s ease-out;
}
.sm-badge-toast-leaving { opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.sm-badge-toast-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.sm-badge-toast-trophy { font-size: 20px; }
.sm-badge-toast-title { flex: 1; font-size: 15px; color: #92400e; }
.sm-badge-toast-close { border: 0; background: transparent; font-size: 20px; line-height: 1; color: #9ca3af; cursor: pointer; padding: 0 4px; }
.sm-badge-toast-close:hover { color: #374151; }
.sm-badge-toast-list { list-style: none; margin: 0; padding: 0; }
.sm-badge-toast-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 14px; border-top: 1px solid #f3f4f6; }
.sm-badge-toast-row:first-child { border-top: 0; }
.sm-badge-toast-icon { font-size: 18px; }
.sm-badge-toast-name { font-weight: 600; }
.sm-badge-toast-badge { color: #6b7280; margin-inline-start: auto; }
.sm-badge-toast-more { font-size: 13px; color: #6b7280; padding-top: 4px; }

@keyframes sm-badge-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* بطاقة الطالب الذي أخذ وساماً في هذه الحصة */
.student-card.has-new-badge { border: 2px solid #f59e0b !important; box-shadow: 0 0 0 3px rgba(245, 158, 11, .15); }
.student-card.has-new-badge.badge-just-earned { animation: sm-badge-pulse 1.2s ease-out 2; }
.student-new-badges { display: inline-flex; gap: 2px; font-size: 16px; margin-inline-start: 6px; }
@keyframes sm-badge-pulse { 0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, .55); } 100% { box-shadow: 0 0 0 14px rgba(245, 158, 11, 0); } }

/* لحظة التتويج */
.badge-celebration-overlay {
    position: fixed; inset: 0; z-index: 1990;
    background: rgba(15, 23, 42, .72);
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
.badge-celebration {
    background: #fff; border-radius: 20px; width: min(960px, 100%); max-height: 92vh; overflow: auto;
    padding: 24px; text-align: center; animation: sm-badge-in .3s ease-out;
}
.badge-celebration h2 { font-size: 30px; font-weight: 800; color: #92400e; margin-bottom: 4px; }
.badge-celebration-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin: 20px 0; }
.badge-celebration-card { background: #fffbeb; border: 1px solid #fde68a; border-radius: 16px; padding: 16px 12px; }
.badge-celebration-card .icons { font-size: 40px; line-height: 1.2; }
.badge-celebration-card .name { font-size: 20px; font-weight: 700; margin: 6px 0 2px; color: #1f2937; }
.badge-celebration-card .badges { font-size: 14px; color: #92400e; }
.badge-celebration-footer { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; border-top: 1px solid #f3f4f6; padding-top: 14px; }
.badge-celebration-footer select { width: auto; }

@media (prefers-reduced-motion: reduce) {
    .sm-badge-toast, .badge-celebration, .student-card.has-new-badge.badge-just-earned { animation: none; }
    .sm-badge-toast-leaving { transition: none; }
}

/* ختام الحصة: نافذة تحمل البطاقة، والبطاقة نفسها هي الصورة التي تُشارك (lesson-card.js) */
.lesson-closing-dialog {
    position: relative; background: #fff; border-radius: 20px; width: min(980px, 100%); max-height: 94vh; overflow: auto;
    padding: 16px; animation: sm-badge-in .3s ease-out;
}
.lesson-closing-x { position: absolute; top: 10px; inset-inline-start: 12px; z-index: 2; border: 0; background: rgba(255, 255, 255, .9); width: 34px; height: 34px; border-radius: 50%; font-size: 22px; line-height: 1; color: #334155; }
.lesson-closing-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 4px 8px; }

.closing-card { direction: rtl; background: #fff; border: 1px solid #e2e8f0; border-radius: 18px; overflow: hidden; color: #0f172a; text-align: center; }
.closing-card-head { background: #1e3a8a; color: #fff; padding: 22px 20px 18px; }
.closing-card-kicker { font-size: 14px; opacity: .85; }
.closing-card-head h2 { color: #fff; font-size: clamp(24px, 4vw, 36px); font-weight: 800; margin: 4px 0 6px; }
.closing-card-meta { color: #fde68a; font-weight: 700; font-size: clamp(15px, 2.2vw, 20px); }
.closing-card-sub { font-size: 13px; opacity: .85; margin-top: 6px; }
.closing-card-empty { color: #64748b; font-size: 17px; padding: 28px 20px; margin: 0; }

.closing-podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 14px; padding: 24px 24px 0; border-bottom: 4px solid #e2e8f0; margin: 0 16px; }
.closing-podium-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; min-width: 0; }
.closing-podium-medal { font-size: 40px; line-height: 1; }
.closing-podium-names { font-size: clamp(15px, 2vw, 19px); font-weight: 800; margin: 6px 2px; line-height: 1.35; overflow-wrap: anywhere; }
.closing-podium-points { font-size: 14px; font-weight: 700; color: #475569; margin-bottom: 8px; }
.closing-podium-step { width: 100%; border: 3px solid; border-bottom: 0; border-radius: 14px 14px 0 0; font-size: 34px; font-weight: 900; padding-top: 6px; }
.closing-podium .place-1 .closing-podium-step { height: 120px; background: #fef3c7; border-color: #f59e0b; color: #92400e; }
.closing-podium .place-2 .closing-podium-step { height: 88px; background: #f1f5f9; border-color: #94a3b8; color: #334155; }
.closing-podium .place-3 .closing-podium-step { height: 66px; background: #ffedd5; border-color: #fb923c; color: #9a3412; }

.closing-stars { padding: 20px 20px 4px; text-align: start; }
.closing-stars h3 { font-size: 18px; font-weight: 800; color: #92400e; margin: 0 0 12px; }
.closing-stars-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.closing-star { display: flex; align-items: center; gap: 10px; background: #fffbeb; border: 1px solid #fde68a; border-radius: 14px; padding: 10px 12px; }
.closing-star-icons { font-size: 26px; flex-shrink: 0; }
.closing-star-name { display: block; font-weight: 800; font-size: 16px; }
.closing-star-badges { display: block; font-size: 13px; color: #92400e; }

.closing-card-foot { background: #f8fafc; border-top: 1px solid #e2e8f0; padding: 14px 16px; margin-top: 18px; color: #475569; font-size: 14px; }
.closing-card-participants { font-weight: 800; color: #1e3a8a; font-size: 16px; margin-bottom: 2px; }

/* الجوال: المنصة عمودية ضيقة. في الصورة (capture-mode) يبقى التخطيط ثابتاً مهما كان الجهاز. */
@media (max-width: 576px) {
    .closing-card:not(.capture-mode) .closing-podium { gap: 6px; padding: 16px 8px 0; margin: 0 6px; }
    .closing-card:not(.capture-mode) .closing-podium-medal { font-size: 30px; }
    .closing-card:not(.capture-mode) .closing-podium-step { font-size: 24px; }
    .closing-card:not(.capture-mode) .place-1 .closing-podium-step { height: 84px; }
    .closing-card:not(.capture-mode) .place-2 .closing-podium-step { height: 62px; }
    .closing-card:not(.capture-mode) .place-3 .closing-podium-step { height: 46px; }
    .closing-card:not(.capture-mode) .closing-stars-grid { grid-template-columns: 1fr; }
}
.closing-card.capture-mode { border: 0; border-radius: 0; }
.closing-card.capture-mode .closing-card-head h2 { font-size: 36px; }
.closing-card.capture-mode .closing-card-meta { font-size: 20px; }
.closing-card.capture-mode .closing-podium-names { font-size: 19px; }
