/* math-grader-public.css */

.mg-result-wrapper { background: #fff; border: 1px solid #e2e8f0; border-radius: 1.5rem; padding: 2rem; margin-top: 1rem; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05); font-family: sans-serif; animation: mg-fade-in 0.5s ease; }
.mg-ai-content { color: #334155; line-height: 1.7; font-size: 1.05rem; margin-bottom: 1.5rem; }
.mg-ai-content p { margin-bottom: 1rem; }
.mg-ai-content strong { color: #0f172a; font-weight: 700; }
.mg-bridge-loader { text-align: center; padding: 2.2rem 1rem; border: 2px dashed #e2e8f0; border-radius: 16px; background: #f8fafc; }
.mg-loader-user { border-color: #e2e8f0; background: #f8fafc; }
.mg-loader-guest { border-color: #e2e8f0; background: #f8fafc; }
.mg-spinner { width: 40px; height: 40px; border: 4px solid #e2e8f0; border-top: 4px solid #2271b1; border-radius: 50%; margin: 0 auto 15px auto; animation: mg-spin 1s linear infinite; }
.mg-loading-text { font-weight: 700; color: #334155; font-size: 1.02rem; }
.mg-tortoise-wrap { width: 64px; height: 64px; margin: 0 auto 15px auto; position: relative; }
.mg-tortoise-ring { width: 64px; height: 64px; border: 4px solid #e2e8f0; border-top-color: #b45309; border-radius: 50%; animation: mg-spin 1s linear infinite; }
.mg-tortoise-icon { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 30px; line-height: 1; }
.mg-thunder-wrap { width: 64px; height: 64px; margin: 0 auto 15px auto; position: relative; }
.mg-thunder-ring { width: 64px; height: 64px; border: 4px solid #dcfce7; border-top-color: #22c55e; border-radius: 50%; animation: mg-spin 1s linear infinite; }
.mg-thunder-icon { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 30px; line-height: 1; }
.mg-guest-note { margin-top: 10px; font-size: 0.85rem; color: #64748b; background: #fff; display: inline-block; padding: 5px 12px; border-radius: 20px; border: 1px solid #e2e8f0; }
.mg-guest-note a { color: #2271b1; font-weight: bold; text-decoration: none; }
.mg-guest-note a:hover { text-decoration: underline; }
.mg-priority-badge { font-size: 0.75rem; color: #166534; background: #dcfce7; padding: 4px 8px; border-radius: 99px; font-weight: bold; text-transform: uppercase; letter-spacing: 0.5px; }
.mg-loader-steps-vertical { margin: 14px auto 0; max-width: 420px; text-align: left; display: grid; gap: 8px; }
.mg-step-line { display: block; font-size: 0.83rem; color: #6b7280; padding: 8px 10px; border-radius: 8px; background: #ffffff; border: 1px solid #e2e8f0; transition: all 0.2s ease; }

.mg-step-line.is-active { color: var(--mg-step-active-text, #374151); border-color: var(--mg-step-active-border, #9ca3af); background: var(--mg-step-active-bg, #f3f4f6); font-weight: 600; }
.mg-step-line.is-done { color: var(--mg-step-done-text, #166534); border-color: var(--mg-step-done-border, #86efac); background: var(--mg-step-done-bg, #f0fdf4); font-weight: 600; }
.mg-swap { transition: opacity 0.2s ease, transform 0.2s ease; }
.mg-swap.is-fading { opacity: 0; transform: translateY(4px); }
@keyframes mg-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes mg-fade-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.mg-fb-actions { display: flex; gap: 0.75rem; border-top: 1px solid #f1f5f9; padding-top: 1.5rem; margin-top: 1.5rem; align-items: center; flex-wrap: wrap; }
.mg-btn-vote { background: #f1f5f9 !important; border: 1px solid #d1d5db !important; color: #4b5563 !important; padding: 0.55rem 0.95rem; border-radius: 9999px; cursor: pointer; font-size: 0.84rem; font-weight: 700; display: inline-flex; align-items: center; gap: 0.4rem; line-height: 1; }
.mg-btn-vote:hover, .mg-btn-vote:focus { background: #e5e7eb !important; border-color: #9ca3af !important; color: #374151 !important; outline: none; box-shadow: none; }
.mg-btn-vote:active, .mg-btn-vote.is-selected { background: #d1d5db !important; border-color: #6b7280 !important; color: #1f2937 !important; }
.mg-vote-icon { width: 14px; height: 14px; display: inline-flex; align-items: center; justify-content: center; color: #4b5563; }
.mg-vote-icon svg { width: 14px; height: 14px; display: block; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mg-btn-vote:hover .mg-vote-icon, .mg-btn-vote.is-selected .mg-vote-icon { color: #1f2937; }
.mg-fb-msg { color: #166534; font-weight: bold; font-size: 0.9rem; display: none; margin-left: auto; }
.mg-tags-container { width: 100%; display: none; gap: 8px; margin-top: 12px; flex-wrap: wrap; background: #f8fafc; border: 1px solid #e2e8f0; padding: 10px; border-radius: 10px; }
.mg-tag-btn { background: #f3f4f6 !important; border: 1px solid #d1d5db !important; color: #475569 !important; padding: 7px 12px; border-radius: 999px; font-size: 0.8rem; cursor: pointer; font-weight: 600; }
.mg-tag-btn:hover, .mg-tag-btn:focus { background: #e5e7eb !important; color: #334155 !important; border-color: #9ca3af !important; outline: none; box-shadow: none; }
.mg-input-area { width: 100%; display: none; margin-top: 10px; }
.mg-input-area textarea { width: 100%; padding: 8px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 0.9rem; background: #fff; color: #334155; }
.mg-submit-btn { margin-top: 6px; background: #9ca3af !important; color: #fff !important; border: none; padding: 7px 13px; border-radius: 8px; cursor: pointer; font-size: 0.8rem; font-weight: 700; }
.mg-submit-btn:hover, .mg-submit-btn:focus { background: #6b7280 !important; color: #fff !important; outline: none; box-shadow: none; }

.mg-limit-overlay { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; padding: 16px; z-index: 100000; }
.mg-limit-overlay.is-open { display: flex; }
.mg-limit-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(3px); }
.mg-limit-dialog { position: relative; width: min(95vw, 700px); background: #fff; border-radius: 20px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); overflow: hidden; border: 1px solid rgba(255,255,255,0.5); transform: scale(1); }
.mg-limit-close { position: absolute; top: 10px; right: 10px; z-index: 5; width: 34px; height: 34px; border-radius: 999px; border: none; background: rgba(255,255,255,0.75); color: #0F172A; cursor: pointer; font-size: 18px; line-height: 1; }
.mg-limit-grid { display: flex; flex-direction: column; }
.mg-limit-left { width: 100%; background: #E6F8F2; padding: 30px; display: flex; align-items: center; justify-content: center; min-height: 220px; position: relative; overflow: hidden; }
.mg-limit-left::before { content: ""; position: absolute; top: -70px; left: -70px; width: 170px; height: 170px; border-radius: 999px; background: rgba(0,201,133,0.1); filter: blur(12px); }
.mg-limit-left::after { content: ""; position: absolute; bottom: -55px; right: -55px; width: 135px; height: 135px; border-radius: 999px; background: rgba(0,201,133,0.2); filter: blur(10px); }
.mg-limit-left-inner { position: relative; z-index: 1; text-align: center; }
.mg-limit-icon-circle { width: 80px; height: 80px; border-radius: 999px; background: #fff; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 10px 25px rgba(0,0,0,0.08); margin-bottom: 14px; font-size: 32px; color: #00C985; }
.mg-limit-left-title { margin: 0; color: #0F172A; font-size: 24px; font-weight: 800; }
.mg-limit-left-stars { margin: 8px 0 0; font-size: 14px; letter-spacing: 1px; color: #facc15; }
.mg-limit-left-subtitle { margin: 8px 0 0; color: rgba(15,23,42,.7); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

.mg-limit-right { width: 100%; padding: 32px 30px; display: flex; flex-direction: column; }
.mg-limit-title { margin: 0 0 8px; font-size: 34px; line-height: 1.15; color: #0F172A; font-weight: 800; }
.mg-limit-subtitle { margin: 0 0 18px; color: rgba(15,23,42,.62); font-size: 16px; font-weight: 600; }
.mg-limit-list { margin: 0 0 24px; padding: 0; list-style: none; display: grid; gap: 14px; }
.mg-limit-list li { display: flex; align-items: flex-start; gap: 12px; color: #0F172A; font-size: 16px; line-height: 1.45; font-weight: 500; }
.mg-limit-list li span { margin-top: 2px; width: 18px; height: 18px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; background: rgba(0,201,133,.12); color: #00C985; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.mg-limit-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: auto; }

.mg-limit-btn-main { background: #00C985; color: #fff; border: none; border-radius: 16px; padding: 14px 18px; font-weight: 800; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; cursor: pointer; width: 100%; box-shadow: 0 10px 20px rgba(0,201,133,0.22); }
.mg-limit-btn-main:hover { background: #00b074; }
.mg-limit-footer { margin: 14px 0 0; color: #94a3b8; font-size: 10px; text-align: center; }

@media (min-width: 768px) {
    .mg-limit-grid { flex-direction: row; min-height: 370px; }
    .mg-limit-left { width: 42%; min-height: auto; }
    .mg-limit-right { width: 58%; padding: 34px; display: flex; flex-direction: column; justify-content: center; }
}

.mg-drag-active {
    border: 2px dashed #00C985 !important;
    background-color: #E6F8F2 !important;
    transition: all 0.2s ease;
}

/* ============================================================
   AI FEEDBACK SECTION CARDS
   Three colour-coded cards: green (good), amber (mistakes), blue (next).
   ============================================================ */
.mg-ai-content .mg-section {
    border-radius: 14px;
    padding: 18px 22px 18px 22px;
    margin: 14px 0;
    border-left: 4px solid;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.mg-ai-content .mg-section:first-child { margin-top: 0; }
.mg-ai-content .mg-section:last-child  { margin-bottom: 0; }

.mg-ai-content .mg-section-title {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 12px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.01em;
    line-height: 1.3;
}
.mg-ai-content .mg-section-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
    line-height: 1;
}

/* What You Did Well — green */
.mg-ai-content .mg-section-good {
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    border-left-color: #22c55e;
}
.mg-ai-content .mg-section-good .mg-section-title { color: #166534; }
.mg-ai-content .mg-section-good .mg-section-icon { background: #22c55e; }

/* Where You Might Have Gone Wrong — amber */
.mg-ai-content .mg-section-wrong {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border-left-color: #f59e0b;
}
.mg-ai-content .mg-section-wrong .mg-section-title { color: #92400e; }
.mg-ai-content .mg-section-wrong .mg-section-icon { background: #f59e0b; }

/* Next Steps — blue */
.mg-ai-content .mg-section-next {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-left-color: #3b82f6;
}
.mg-ai-content .mg-section-next .mg-section-title { color: #1e40af; }
.mg-ai-content .mg-section-next .mg-section-icon { background: #3b82f6; }

/* Other (fallback) — neutral grey */
.mg-ai-content .mg-section-other {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-left-color: #94a3b8;
}
.mg-ai-content .mg-section-other .mg-section-title { color: #334155; }
.mg-ai-content .mg-section-other .mg-section-icon { background: #94a3b8; }

/* Bullet list inside sections */
.mg-ai-content .mg-section-list {
    margin: 0;
    padding-left: 8px;
    list-style: none;
}
.mg-ai-content .mg-section-list li {
    position: relative;
    padding-left: 18px;
    margin: 0 0 8px 0;
    font-size: 14px;
    line-height: 1.65;
    color: #1f2937;
}
.mg-ai-content .mg-section-list li:last-child { margin-bottom: 0; }
.mg-ai-content .mg-section-list li::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 9px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.35;
}

/* Bold inside cards — subtle emphasis without going too dark */
.mg-ai-content .mg-section strong {
    color: #0f172a;
    font-weight: 700;
}

/* Inline code-style for things the AI quotes */
.mg-ai-content .mg-section code {
    background: rgba(15, 23, 42, 0.05);
    padding: 1px 6px;
    border-radius: 5px;
    font-size: 0.9em;
    font-family: inherit;
    color: #0f172a;
}

/* Paragraphs outside sections (rare — fallback) */
.mg-ai-content > p {
    font-size: 14px;
    line-height: 1.65;
    color: #334155;
    margin: 8px 0;
}

/* Refusal blockquote (when image isn't valid maths) */
.mg-ai-content .mg-refusal {
    background: #fef2f2;
    border-left: 4px solid #ef4444;
    padding: 14px 18px;
    border-radius: 10px;
    margin: 8px 0;
    color: #991b1b;
    font-size: 14px;
    line-height: 1.6;
    font-weight: 500;
}

/* Math equation spacing inside cards */
.mg-ai-content .mg-section .MathJax,
.mg-ai-content .mg-section mjx-container {
    margin: 2px 0;
}

/* ============================================================
   SEHAJ CHAT-BUBBLE CARD
   Renders the conversational "Sehaj: ..." response as a warm,
   personal chat bubble (replaces the old 3-section layout).
   ============================================================ */
.mg-ai-content .mg-sehaj-card {
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    border-left: 4px solid #22c55e;
    border-radius: 14px;
    padding: 20px 22px;
    margin: 0;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.mg-ai-content .mg-sehaj-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(34, 197, 94, 0.15);
}

.mg-ai-content .mg-sehaj-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: #fff;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(34, 197, 94, 0.35);
    flex-shrink: 0;
}

.mg-ai-content .mg-sehaj-name {
    font-size: 15px;
    font-weight: 700;
    color: #166534;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.mg-ai-content .mg-sehaj-message {
    font-size: 15px;
    line-height: 1.75;
    color: #1f2937;
}

.mg-ai-content .mg-sehaj-message p {
    margin: 0 0 10px 0;
    padding: 0;
}

.mg-ai-content .mg-sehaj-message p:last-child {
    margin-bottom: 0;
}

/* Math equations inside the Sehaj card — small breathing room */
.mg-ai-content .mg-sehaj-message .MathJax,
.mg-ai-content .mg-sehaj-message mjx-container {
    margin: 2px 0;
}

/* Optional: subtle hover lift to feel more "alive" */
.mg-ai-content .mg-sehaj-card:hover {
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
    transition: box-shadow 0.2s ease;
}

/* Bullets inside the Sehaj card — clean green dots, easy to scan */
.mg-ai-content .mg-sehaj-message .mg-sehaj-list {
    margin: 8px 0 0 0;
    padding: 0;
    list-style: none;
}
.mg-ai-content .mg-sehaj-message .mg-sehaj-list li {
    position: relative;
    padding: 6px 0 6px 22px;
    margin: 0;
    font-size: 14.5px;
    line-height: 1.65;
    color: #1f2937;
}
.mg-ai-content .mg-sehaj-message .mg-sehaj-list li::before {
    content: "";
    position: absolute;
    left: 6px;
    top: 14px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.18);
}
.mg-ai-content .mg-sehaj-message .mg-sehaj-list li + li {
    border-top: 1px solid rgba(34, 197, 94, 0.12);
}

/* The opener paragraph just before the bullets — slightly bolder so it leads the eye */
.mg-ai-content .mg-sehaj-message p:has(+ .mg-sehaj-list) {
    font-weight: 600;
    color: #14532d;
    margin-bottom: 4px;
}
