/* Math problem solver (scoped) — page chrome lives in tools-page.css */

/* Math solver block */
.lms-math-root {
    --math-primary: #2563eb;
    --math-primary-dark: #1e40af;
    --math-secondary: #10b981;
    --math-surface: #ffffff;
    --math-text: #0f172a;
    --math-muted: #64748b;
    --math-border: #e2e8f0;
    --math-error: #ef4444;
    font-family: 'DM Sans', system-ui, sans-serif;
    color: var(--math-text);
    padding-bottom: var(--space-16);
}

.lms-math-hero {
    text-align: center;
    margin-bottom: var(--space-8);
}

.lms-math-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.95);
    padding: 12px 24px;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    margin-bottom: var(--space-5);
}

.lms-math-hero-badge strong {
    font-size: 1.25rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.lms-math-hero h2 {
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    font-weight: 700;
    margin-bottom: var(--space-2);
    color: var(--text-primary);
}

.lms-math-hero p {
    color: var(--text-secondary);
    max-width: 36rem;
    margin: 0 auto;
}

.lms-math-card {
    background: var(--math-surface);
    border-radius: 24px;
    padding: clamp(1.5rem, 4vw, 2.5rem);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    max-width: 1000px;
    margin: 0 auto;
}

.lms-math-tabs {
    display: flex;
    gap: 12px;
    margin-bottom: var(--space-8);
    border-bottom: 2px solid var(--math-border);
    flex-wrap: wrap;
}

.lms-math-tab {
    background: none;
    border: none;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 600;
    color: var(--math-muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    font-family: inherit;
    transition: color 0.2s, border-color 0.2s;
}

.lms-math-tab:hover {
    color: var(--math-primary);
}

.lms-math-tab.is-active {
    color: var(--math-primary);
    border-bottom-color: var(--math-primary);
}

.lms-math-label {
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-2);
    display: block;
    color: var(--math-text);
}

.lms-math-textarea {
    width: 100%;
    min-height: 120px;
    padding: 16px;
    border: 2px solid var(--math-border);
    border-radius: 12px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 15px;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.lms-math-textarea:focus {
    outline: none;
    border-color: var(--math-primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.lms-math-chips {
    margin-top: var(--space-3);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.lms-math-chip {
    background: var(--bg-secondary);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    color: var(--math-muted);
    cursor: pointer;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    border: 1px solid var(--math-border);
    transition: background 0.2s, color 0.2s;
}

.lms-math-chip:hover {
    background: var(--math-primary);
    color: #fff;
    border-color: var(--math-primary);
}

.lms-math-upload {
    border: 2px dashed var(--math-border);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    background: var(--bg-secondary);
    position: relative;
    transition: border-color 0.2s, background 0.2s;
}

.lms-math-upload:hover,
.lms-math-upload.is-dragover {
    border-color: var(--math-primary);
    background: rgba(37, 99, 235, 0.06);
}

.lms-math-upload-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-2);
}

.lms-math-preview {
    position: relative;
    max-width: 100%;
}

.lms-math-preview img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
}

.lms-math-remove-img {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--math-error);
    color: #fff;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lms-math-solve {
    width: 100%;
    margin-top: var(--space-6);
    padding: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.35);
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.lms-math-solve:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(102, 126, 234, 0.45);
}

.lms-math-solve:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.lms-math-loading {
    display: none;
    text-align: center;
    padding: var(--space-10);
}

.lms-math-loading.is-visible {
    display: block;
}

.lms-math-spinner {
    border: 4px solid var(--math-border);
    border-top-color: var(--math-primary);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: lms-math-spin 0.9s linear infinite;
    margin: 0 auto var(--space-4);
}

@keyframes lms-math-spin {
    to { transform: rotate(360deg); }
}

.lms-math-error {
    display: none;
    background: rgba(239, 68, 68, 0.1);
    border: 2px solid var(--math-error);
    padding: var(--space-5);
    border-radius: 12px;
    color: var(--math-error);
    margin-top: var(--space-6);
}

.lms-math-error.is-visible {
    display: block;
}

.lms-math-solution {
    display: none;
    margin-top: var(--space-8);
}

.lms-math-solution.is-visible {
    display: block;
}

.lms-math-solution h3 {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-4);
    border-bottom: 2px solid var(--math-border);
}

.lms-math-step {
    background: var(--bg-secondary);
    padding: var(--space-5);
    border-radius: 12px;
    margin-bottom: var(--space-4);
    border-left: 4px solid var(--math-primary);
}

.lms-math-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--math-primary);
    color: #fff;
    border-radius: 50%;
    font-weight: 700;
    font-size: 14px;
    margin-right: 12px;
}

.lms-math-step h4 {
    display: inline;
    font-size: 1rem;
    font-weight: 600;
}

.lms-math-step-body {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 14px;
    line-height: 1.75;
    color: var(--math-muted);
    margin-top: var(--space-2);
    padding-left: 40px;
    white-space: pre-wrap;
}

.lms-math-final {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.12) 0%, rgba(16, 185, 129, 0.05) 100%);
    padding: var(--space-6);
    border-radius: 12px;
    border: 2px solid var(--math-secondary);
    margin-top: var(--space-5);
}

.lms-math-final-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--math-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-2);
}

.lms-math-final-value {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 1.35rem;
    font-weight: 700;
    white-space: pre-wrap;
}

.lms-math-pane[hidden] {
    display: none !important;
}
