/* ═══════════════════════════════════════════════════
   AI Examiner — Shared Styles
   Live grading widget for AQA & IB exam pages
   ═══════════════════════════════════════════════════ */

/* ── Container ── */
.ai-grader {
    margin-top: 1.25rem;
    padding: 1.25rem;
    background: linear-gradient(135deg, rgba(20, 184, 166, .03) 0%, rgba(99, 102, 241, .03) 100%);
    border: 1px solid rgba(20, 184, 166, .18);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    transition: border-color .3s ease, box-shadow .3s ease;
}

.ai-grader:focus-within {
    border-color: rgba(20, 184, 166, .35);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, .08);
}

/* ── Header ── */
.ai-grader__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .75rem;
    flex-wrap: wrap;
    gap: .5rem;
}

.ai-grader__badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    background: linear-gradient(135deg, #14b8a6, #0d9488);
    color: #fff;
    padding: 5px 14px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
}

.ai-grader__badge svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.ai-grader__powered {
    font-size: .7rem;
    color: var(--color-text-muted, #94a3b8);
    font-weight: 500;
    letter-spacing: .02em;
}

/* ── Textarea ── */
.ai-grader__textarea {
    width: 100%;
    min-height: 100px;
    max-height: 300px;
    padding: .85rem 1rem;
    border: 1px solid rgba(15, 23, 42, .1);
    border-radius: 8px;
    background: #fff;
    font-family: inherit;
    font-size: .9rem;
    line-height: 1.6;
    color: var(--color-navy, #0f172a);
    resize: vertical;
    transition: border-color .2s ease, box-shadow .2s ease;
    box-sizing: border-box;
}

.ai-grader__textarea::placeholder {
    color: #94a3b8;
    font-style: italic;
}

.ai-grader__textarea:focus {
    outline: none;
    border-color: #14b8a6;
    box-shadow: 0 0 0 3px rgba(20, 184, 166, .1);
}

/* ── Actions Row ── */
.ai-grader__actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: .65rem;
    gap: .75rem;
    flex-wrap: wrap;
}

.ai-grader__char-count {
    font-size: .75rem;
    color: #94a3b8;
    font-weight: 500;
    transition: color .2s;
}

.ai-grader__char-count--active {
    color: #14b8a6;
}

/* ── Submit Button ── */
.ai-grader__btn {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .6rem 1.4rem;
    background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: .85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .2s ease;
    position: relative;
    overflow: hidden;
}

.ai-grader__btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(20, 184, 166, .35);
    background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
}

.ai-grader__btn:active:not(:disabled) {
    transform: translateY(0);
}

.ai-grader__btn:disabled {
    opacity: .6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.ai-grader__btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ── Loading Spinner ── */
.ai-grader__spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, .3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ai-grader-spin .6s linear infinite;
    flex-shrink: 0;
}

@keyframes ai-grader-spin {
    to { transform: rotate(360deg); }
}

/* ── Feedback Panel ── */
.ai-grader__feedback {
    margin-top: .85rem;
    padding: 0;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height .4s ease, opacity .3s ease, padding .3s ease;
}

.ai-grader__feedback--visible {
    max-height: 500px;
    opacity: 1;
    padding: 1rem 1.1rem;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, .08);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .04);
}

.ai-grader__feedback-label {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: .6rem;
    color: #14b8a6;
}

.ai-grader__feedback-text {
    font-size: .9rem;
    line-height: 1.7;
    color: var(--color-navy, #1e293b);
    word-wrap: break-word;
}

.ai-grader__feedback-text strong {
    color: #0f172a;
    font-weight: 700;
}

/* Score badge within feedback */
.ai-grader__score {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .35rem .85rem;
    border-radius: 999px;
    font-size: .85rem;
    font-weight: 800;
    margin-bottom: .65rem;
}

.ai-grader__score--great {
    background: rgba(16, 185, 129, .12);
    color: #065f46;
}

.ai-grader__score--ok {
    background: rgba(245, 158, 11, .12);
    color: #92400e;
}

.ai-grader__score--needs-work {
    background: rgba(239, 68, 68, .1);
    color: #991b1b;
}

/* ── Cooldown state ── */
.ai-grader__cooldown {
    font-size: .75rem;
    color: #94a3b8;
    font-style: italic;
}

/* ── Error state ── */
.ai-grader__feedback--error {
    border-color: rgba(239, 68, 68, .2);
}

.ai-grader__feedback--error .ai-grader__feedback-label {
    color: #ef4444;
}

/* ═══════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════ */
@media (max-width: 600px) {
    .ai-grader {
        padding: 1rem;
    }

    .ai-grader__textarea {
        min-height: 80px;
        font-size: .85rem;
    }

    .ai-grader__actions {
        flex-direction: column;
        align-items: stretch;
    }

    .ai-grader__btn {
        justify-content: center;
        width: 100%;
    }

    .ai-grader__char-count {
        text-align: center;
    }
}

/* ═══════════════════════════════════════════════════
   Print — hide completely
   ═══════════════════════════════════════════════════ */
@media print {
    .ai-grader {
        display: none !important;
    }
}

/* ═══════════════════════════════════════════════════
   Dark Mode
   ═══════════════════════════════════════════════════ */
[data-theme="dark"] .ai-grader {
    background: linear-gradient(135deg, rgba(20, 184, 166, .04) 0%, rgba(99, 102, 241, .04) 100%);
    border-color: rgba(45, 212, 191, .15);
}

[data-theme="dark"] .ai-grader__textarea {
    background: rgba(255, 255, 255, .04);
    border-color: rgba(255, 255, 255, .1);
    color: #e2e8f0;
}

[data-theme="dark"] .ai-grader__textarea::placeholder {
    color: #64748b;
}

[data-theme="dark"] .ai-grader__textarea:focus {
    border-color: #2dd4bf;
    box-shadow: 0 0 0 3px rgba(45, 212, 191, .1);
}

[data-theme="dark"] .ai-grader__feedback--visible {
    background: rgba(255, 255, 255, .03);
    border-color: rgba(255, 255, 255, .08);
}

[data-theme="dark"] .ai-grader__feedback-text {
    color: #cbd5e1;
}

[data-theme="dark"] .ai-grader__feedback-text strong {
    color: #f1f5f9;
}

[data-theme="dark"] .ai-grader__score--great {
    background: rgba(16, 185, 129, .15);
    color: #6ee7b7;
}

[data-theme="dark"] .ai-grader__score--ok {
    background: rgba(245, 158, 11, .15);
    color: #fcd34d;
}

[data-theme="dark"] .ai-grader__score--needs-work {
    background: rgba(239, 68, 68, .15);
    color: #fca5a5;
}

[data-theme="dark"] .ai-grader__char-count {
    color: #64748b;
}

[data-theme="dark"] .ai-grader__powered {
    color: #64748b;
}
