/* Existing History result styles, scoped to the shared TOEFL Review page. */
.toefl-review-history, #results-modal-root {
    --primary: var(--mr-accent);
    --primary-dark: var(--mr-accent);
    --primary-light: var(--mr-tint);
    --primary-border: var(--mr-border);
    --text-primary: var(--mr-text);
    --text-secondary: var(--mr-secondary);
    --border-primary: var(--mr-border);
    --text-muted: var(--mr-muted);
    --bg-cream: var(--mr-bg);
    --bg-white: var(--mr-card);
    color: var(--mr-text);
}

/* History uses the same quiet rows and controls as the Review collection. */
.toefl-history-controls { margin: 26px 0 20px; }
.toefl-history-count { color: var(--mr-muted); font-size: 11px; }
.toefl-history-test-link { display: inline-flex; gap: 5px; color: var(--mr-secondary); font-size: 12px; text-decoration: none; }
.toefl-history-test-link:hover { color: var(--mr-highlight); text-decoration: underline; }
.toefl-history-score { min-width: 58px; text-align: right; flex-shrink: 0; }
.toefl-history-score span { display: block; color: var(--mr-muted); font-size: 10px; margin-bottom: 3px; }
.toefl-history-score strong { font-size: 15px; font-weight: 600; color: var(--mr-text); }
.toefl-history-examples { margin: 5px 0 0; font-size: 11px; color: var(--mr-muted); }
.toefl-review-history .pagination { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 26px; }
.toefl-review-history .page-btn { min-height: 40px; padding: 8px 13px; background: var(--mr-card); color: var(--mr-secondary); border: 1px solid var(--mr-border); border-radius: 8px; font: inherit; font-size: 12px; cursor: pointer; }
.toefl-review-history .page-btn.active { background: var(--mr-raised); color: var(--mr-text); border-color: var(--mr-muted); }
.toefl-review-history .page-btn:disabled { opacity: .45; cursor: default; }
.toefl-review-history :is(.empty-state, .unauth-state, .error-state) { padding: 48px 24px; border: 1px dashed var(--mr-border); border-radius: 12px; text-align: center; color: var(--mr-secondary); }
.toefl-review-history .empty-title { font-size: 18px; font-weight: 600; color: var(--mr-text); margin: 0 0 8px; }
.toefl-review-history .empty-text { font-size: 13px; margin: 0 0 20px; }
.toefl-review-history .empty-icon { width: 30px; height: 30px; margin: 0 auto 16px; color: var(--mr-highlight); }
.toefl-review-history .loading-state { padding: 40px 20px; text-align: center; font-size: 13px; }
.toefl-review-history .loading-spinner { width: 24px; height: 24px; margin: 0 auto 14px; border: 2px solid var(--mr-border); border-top-color: var(--mr-highlight); border-radius: 50%; animation: toefl-review-spin 1s linear infinite; }
@keyframes toefl-review-spin { to { transform: rotate(360deg); } }
@media (max-width: 600px) {
    .toefl-review-history .mr-controls { display: flex; gap: 16px; }
    .toefl-review-history .mr-filters { flex: 0 1 auto; }
    .toefl-review-history .mr-item { align-items: flex-end; }
    .toefl-history-score { text-align: left; margin-right: auto; }
    .toefl-review-history .view-results-btn { margin-left: auto; }
    .toefl-review-history .page-btn { padding: 8px 11px; }
}
@media (prefers-reduced-motion: reduce) {
    .toefl-review-history *, #results-modal-root .animate-spin { animation: none; transition: none; }
}

/* Results Modal Styles */
#results-modal-root {
    --results-modal-primary: #5C6F5C;
    --results-modal-primary-light: rgba(92, 111, 92, 0.08);
    --results-modal-border: #E8E3DA;
    --results-modal-bg-cream: #F7F4EF;
    --results-modal-bg-white: #FEFEFE;
    --results-modal-text-primary: #1A1816;
    --results-modal-text-secondary: #3A3633;
    --results-modal-text-muted: #9E9689;
}

.results-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.results-modal-container {
    position: relative;
    background: var(--results-modal-bg-white);
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 1200px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.results-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--results-modal-border);
    background: var(--results-modal-bg-cream);
}

.results-modal-header .close-button {
    background: transparent;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--results-modal-text-muted);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.results-modal-header .close-button:hover {
    background: var(--results-modal-primary-light);
    color: var(--results-modal-primary);
}

.results-modal-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.results-modal-body .attempts-list {
    width: 300px;
    flex-shrink: 0;
    border-right: 1px solid var(--results-modal-border);
    background: var(--results-modal-bg-cream);
    overflow-y: auto;
}

.results-modal-body .detail-pane {
    flex: 1;
    overflow-y: auto;
    background: var(--results-modal-bg-white);
}

@media (max-width: 640px) {
    .results-modal-body {
        flex-direction: column;
    }

    .results-modal-body .attempts-list {
        width: 100%;
        max-height: 150px;
        border-right: none;
        border-bottom: 1px solid var(--results-modal-border);
    }
}

/* Results Modal Content Styles */
#results-modal-root .text-xs { font-size: 0.75rem; }
#results-modal-root .text-sm { font-size: 0.875rem; }
#results-modal-root .text-base { font-size: 1rem; }
#results-modal-root .text-lg { font-size: 1.125rem; }
#results-modal-root .text-xl { font-size: 1.25rem; }
#results-modal-root .text-2xl { font-size: 1.5rem; }

#results-modal-root .font-medium { font-weight: 500; }
#results-modal-root .font-semibold { font-weight: 600; }
#results-modal-root .font-bold { font-weight: 700; }

#results-modal-root .text-gray-400 { color: #9ca3af; }
#results-modal-root .text-gray-500 { color: #6b7280; }
#results-modal-root .text-gray-600 { color: #4b5563; }
#results-modal-root .text-gray-700 { color: #374151; }
#results-modal-root .text-gray-800 { color: #1f2937; }
#results-modal-root .text-gray-900 { color: #111827; }
#results-modal-root .text-green-600 { color: #16a34a; }
#results-modal-root .text-green-700 { color: #15803d; }
#results-modal-root .text-green-800 { color: #166534; }
#results-modal-root .text-green-900 { color: #14532d; }
#results-modal-root .text-red-600 { color: #dc2626; }
#results-modal-root .text-red-700 { color: #b91c1c; }
#results-modal-root .text-amber-700 { color: #b45309; }
#results-modal-root .text-amber-800 { color: #92400e; }
#results-modal-root .text-amber-900 { color: #78350f; }
#results-modal-root .text-blue-600 { color: #2563eb; }
#results-modal-root .text-blue-700 { color: #1d4ed8; }
#results-modal-root .text-purple-600 { color: #9333ea; }
#results-modal-root .text-purple-700 { color: #7c3aed; }
#results-modal-root .text-indigo-600 { color: #4f46e5; }
#results-modal-root .text-indigo-700 { color: #4338ca; }

#results-modal-root .bg-gray-50 { background-color: #f9fafb; }
#results-modal-root .bg-gray-100 { background-color: #f3f4f6; }
#results-modal-root .bg-green-50 { background-color: #f0fdf4; }
#results-modal-root .bg-green-100 { background-color: #dcfce7; }
#results-modal-root .bg-red-50 { background-color: #fef2f2; }
#results-modal-root .bg-red-100 { background-color: #fee2e2; }
#results-modal-root .bg-amber-50 { background-color: #fffbeb; }
#results-modal-root .bg-blue-50 { background-color: #eff6ff; }
#results-modal-root .bg-purple-50 { background-color: #faf5ff; }
#results-modal-root .bg-indigo-50 { background-color: #eef2ff; }
#results-modal-root .bg-emerald-50\/60 { background-color: rgba(236, 253, 245, 0.6); }
#results-modal-root .bg-amber-50\/60 { background-color: rgba(255, 251, 235, 0.6); }
#results-modal-root .bg-white { background-color: white; }

#results-modal-root .border { border-width: 1px; }
#results-modal-root .border-b { border-bottom-width: 1px; }
#results-modal-root .border-l-2 { border-left-width: 2px; }
#results-modal-root .border-gray-100 { border-color: #f3f4f6; }
#results-modal-root .border-gray-200 { border-color: #e5e7eb; }
#results-modal-root .border-gray-300 { border-color: #d1d5db; }
#results-modal-root .border-green-100 { border-color: #dcfce7; }
#results-modal-root .border-green-200 { border-color: #bbf7d0; }
#results-modal-root .border-green-600 { border-color: #16a34a; }
#results-modal-root .border-red-200 { border-color: #fecaca; }
#results-modal-root .border-red-600 { border-color: #dc2626; }
#results-modal-root .border-amber-100 { border-color: #fef3c7; }
#results-modal-root .border-amber-200 { border-color: #fde68a; }
#results-modal-root .border-blue-200 { border-color: #bfdbfe; }
#results-modal-root .border-purple-200 { border-color: #e9d5ff; }
#results-modal-root .border-indigo-200 { border-color: #c7d2fe; }
#results-modal-root .border-emerald-100 { border-color: #d1fae5; }
#results-modal-root .border-yellow-600 { border-color: #ca8a04; }

#results-modal-root .rounded-full { border-radius: 9999px; }
#results-modal-root .rounded { border-radius: 0.25rem; }
#results-modal-root .rounded-lg { border-radius: 0.5rem; }
#results-modal-root .rounded-md { border-radius: 0.375rem; }

#results-modal-root .px-1 { padding-left: 0.25rem; padding-right: 0.25rem; }
#results-modal-root .px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
#results-modal-root .px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
#results-modal-root .px-4 { padding-left: 1rem; padding-right: 1rem; }
#results-modal-root .px-5 { padding-left: 1.25rem; padding-right: 1.25rem; }
#results-modal-root .px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
#results-modal-root .py-0\.5 { padding-top: 0.125rem; padding-bottom: 0.125rem; }
#results-modal-root .py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
#results-modal-root .py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
#results-modal-root .py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
#results-modal-root .py-5 { padding-top: 1.25rem; padding-bottom: 1.25rem; }
#results-modal-root .py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
#results-modal-root .py-8 { padding-top: 2rem; padding-bottom: 2rem; }
#results-modal-root .pt-4 { padding-top: 1rem; }
#results-modal-root .pb-2 { padding-bottom: 0.5rem; }
#results-modal-root .p-2 { padding: 0.5rem; }
#results-modal-root .p-3 { padding: 0.75rem; }
#results-modal-root .pl-2 { padding-left: 0.5rem; }
#results-modal-root .pl-4 { padding-left: 1rem; }

#results-modal-root .mt-1 { margin-top: 0.25rem; }
#results-modal-root .mt-0\.5 { margin-top: 0.125rem; }
#results-modal-root .mb-1 { margin-bottom: 0.25rem; }
#results-modal-root .mb-2 { margin-bottom: 0.5rem; }

#results-modal-root .space-y-1 > * + * { margin-top: 0.25rem; }
#results-modal-root .space-y-2 > * + * { margin-top: 0.5rem; }
#results-modal-root .space-y-4 > * + * { margin-top: 1rem; }
#results-modal-root .gap-2 { gap: 0.5rem; }
#results-modal-root .gap-3 { gap: 0.75rem; }
#results-modal-root .gap-4 { gap: 1rem; }

#results-modal-root .flex { display: flex; }
#results-modal-root .inline-flex { display: inline-flex; }
#results-modal-root .grid { display: grid; }
#results-modal-root .grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#results-modal-root .grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#results-modal-root .align-top { vertical-align: top; }
#results-modal-root .flex-1 { flex: 1 1 0%; }
#results-modal-root .items-center { align-items: center; }
#results-modal-root .items-baseline { align-items: baseline; }
#results-modal-root .justify-between { justify-content: space-between; }
#results-modal-root .justify-center { justify-content: center; }
#results-modal-root .text-center { text-align: center; }
#results-modal-root .text-left { text-align: left; }
#results-modal-root .text-right { text-align: right; }

#results-modal-root .uppercase { text-transform: uppercase; }
#results-modal-root .whitespace-pre-wrap { white-space: pre-wrap; }
#results-modal-root .whitespace-pre-line { white-space: pre-line; }
#results-modal-root .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#results-modal-root .overflow-y-auto { overflow-y: auto; }
#results-modal-root .overflow-x-auto { overflow-x: auto; }
#results-modal-root .max-h-48 { max-height: 12rem; }
#results-modal-root .max-h-56 { max-height: 14rem; }
#results-modal-root .max-h-64 { max-height: 16rem; }
#results-modal-root .max-w-none { max-width: none; }

#results-modal-root .w-4 { width: 1rem; }
#results-modal-root .w-5 { width: 1.25rem; }
#results-modal-root .w-20 { width: 5rem; }
#results-modal-root .w-full { width: 100%; }
#results-modal-root .h-4 { height: 1rem; }
#results-modal-root .h-5 { height: 1.25rem; }
#results-modal-root .h-20 { height: 5rem; }
#results-modal-root .h-full { height: 100%; }

#results-modal-root .list-disc { list-style-type: disc; }
#results-modal-root .leading-7 { line-height: 1.75rem; }
#results-modal-root .line-through { text-decoration: line-through; }
#results-modal-root .font-mono { font-family: ui-monospace, SFMono-Regular, monospace; }

#results-modal-root .tracking-\[0\.2em\] { letter-spacing: 0.2em; }
#results-modal-root .tracking-\[0\.25em\] { letter-spacing: 0.25em; }

#results-modal-root .absolute { position: absolute; }
#results-modal-root .inset-0 { inset: 0; }

#results-modal-root .animate-spin {
    animation: toefl-review-spin 1s linear infinite;
}

/* Attempt list button styles */
#results-modal-root .attempts-list button {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

#results-modal-root .attempts-list button:hover {
    background-color: white;
}

#results-modal-root {
    --results-modal-primary: var(--mr-highlight);
    --results-modal-primary-light: var(--mr-tint);
    --results-modal-border: var(--mr-border);
    --results-modal-bg-cream: var(--mr-bg);
    --results-modal-bg-white: var(--mr-card);
    --results-modal-text-primary: var(--mr-text);
    --results-modal-text-secondary: var(--mr-secondary);
    --results-modal-text-muted: var(--mr-muted);
    font-family: 'Plus Jakarta Sans', sans-serif;
    overflow-wrap: anywhere;
}
#results-modal-root .detail-pane { min-width: 0; }
#results-modal-root .attempts-list button:hover { background-color: var(--mr-raised); }
[data-theme="dark"] #results-modal-root :is(.bg-white,.bg-gray-50,.bg-gray-100) { background-color: var(--mr-card); }
[data-theme="dark"] #results-modal-root :is(.text-gray-700,.text-gray-800,.text-gray-900) { color: var(--mr-text); }
[data-theme="dark"] #results-modal-root :is(.text-gray-400,.text-gray-500,.text-gray-600) { color: var(--mr-secondary); }
[data-theme="dark"] #results-modal-root :is(.border-gray-100,.border-gray-200,.border-gray-300) { border-color: var(--mr-border); }
