/* ===========================================
   SCHOOL TASK SOLVER - FRONTEND STYLES
   =========================================== */

/* Основные переменные */
:root {
    --sts-primary: #3b82f6;
    --sts-primary-dark: #2563eb;
    --sts-secondary: #64748b;
    --sts-success: #10b981;
    --sts-warning: #f59e0b;
    --sts-error: #ef4444;
    --sts-bg: #ffffff;
    --sts-bg-secondary: #f8fafc;
    --sts-text: #1e293b;
    --sts-text-secondary: #64748b;
    --sts-border: #e2e8f0;
    --sts-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --sts-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --sts-radius: 0.5rem;
    --sts-radius-lg: 0.75rem;
    --sts-transition: all 0.2s ease-in-out;
}

/* Темная тема */
.sts-theme-dark {
    --sts-bg: #0f172a;
    --sts-bg-secondary: #1e293b;
    --sts-text: #f1f5f9;
    --sts-text-secondary: #94a3b8;
    --sts-border: #334155;
}

/* Основной контейнер */
.sts-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    background: var(--sts-bg);
    border-radius: var(--sts-radius-lg);
    box-shadow: var(--sts-shadow-lg);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--sts-text);
}

/* Заголовок */
.sts-header {
    text-align: center;
    margin-bottom: 2rem;
}

.sts-title {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    color: var(--sts-text);
}

.sts-icon {
    font-size: 2.5rem;
    margin-right: 0.5rem;
    vertical-align: middle;
}

.sts-subtitle {
    font-size: 1.1rem;
    color: var(--sts-text-secondary);
    margin: 0;
}

/* Область загрузки */
.sts-upload-area {
    border: 2px dashed var(--sts-border);
    border-radius: var(--sts-radius);
    padding: 3rem 2rem;
    text-align: center;
    background: var(--sts-bg-secondary);
    transition: var(--sts-transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.sts-upload-area:hover {
    border-color: var(--sts-primary);
    background: rgba(59, 130, 246, 0.05);
}

.sts-upload-area.dragover {
    border-color: var(--sts-primary);
    background: rgba(59, 130, 246, 0.1);
    transform: scale(1.02);
}

.sts-upload-content {
    position: relative;
    z-index: 2;
}

.sts-upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.7;
}

.sts-upload-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    color: var(--sts-text);
}

.sts-upload-subtitle {
    color: var(--sts-text-secondary);
    margin: 0 0 1.5rem 0;
}

.sts-upload-formats {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.sts-format-tag {
    background: var(--sts-primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.sts-upload-btn {
    background: var(--sts-primary);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: var(--sts-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--sts-transition);
}

.sts-upload-btn:hover {
    background: var(--sts-primary-dark);
    transform: translateY(-1px);
}

/* Предварительный просмотр */
.sts-preview-area {
    background: var(--sts-bg-secondary);
    border-radius: var(--sts-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--sts-border);
}

.sts-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.sts-preview-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: var(--sts-text);
}

.sts-remove-btn {
    background: var(--sts-error);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--sts-radius);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--sts-transition);
}

.sts-remove-btn:hover {
    background: #dc2626;
}

.sts-preview-content {
    text-align: center;
}

.sts-preview-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--sts-radius);
    box-shadow: var(--sts-shadow);
}

.sts-image-info {
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--sts-text-secondary);
}

/* Настройки */
.sts-settings {
    background: var(--sts-bg-secondary);
    border-radius: var(--sts-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--sts-border);
}

.sts-settings-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 1.5rem 0;
    color: var(--sts-text);
}

.sts-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.sts-setting-group {
    display: flex;
    flex-direction: column;
}

.sts-setting-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--sts-text);
}

.sts-setting-select,
.sts-setting-input {
    padding: 0.75rem;
    border: 1px solid var(--sts-border);
    border-radius: var(--sts-radius);
    background: var(--sts-bg);
    color: var(--sts-text);
    font-size: 1rem;
    transition: var(--sts-transition);
}

.sts-setting-select:focus,
.sts-setting-input:focus {
    outline: none;
    border-color: var(--sts-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.sts-setting-description {
    font-size: 0.875rem;
    color: var(--sts-text-secondary);
    margin: 0.5rem 0 0 0;
}

.sts-setting-range {
    width: 100%;
    margin: 0.5rem 0;
}

.sts-range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--sts-text-secondary);
    margin-top: 0.25rem;
}

/* Дополнительные настройки */
.sts-advanced-settings {
    margin-top: 1rem;
}

.sts-toggle-advanced {
    background: none;
    border: none;
    color: var(--sts-primary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--sts-transition);
}

.sts-toggle-advanced:hover {
    color: var(--sts-primary-dark);
}

.sts-toggle-icon {
    transition: var(--sts-transition);
}

.sts-toggle-advanced.active .sts-toggle-icon {
    transform: rotate(180deg);
}

.sts-advanced-content {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--sts-border);
}

/* Секция решения */
.sts-solve-section {
    text-align: center;
    padding-top: 1rem;
    border-top: 1px solid var(--sts-border);
}

.sts-solve-btn {
    background: var(--sts-success);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: var(--sts-radius);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--sts-transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.sts-solve-btn:hover:not(:disabled) {
    background: #059669;
    transform: translateY(-1px);
}

.sts-solve-btn:disabled {
    background: var(--sts-secondary);
    cursor: not-allowed;
    opacity: 0.6;
}

.sts-solve-icon {
    font-size: 1.25rem;
}

.sts-solve-note {
    font-size: 0.875rem;
    color: var(--sts-text-secondary);
    margin: 0.5rem 0 0 0;
}

/* Прогресс-бар */
.sts-progress {
    background: var(--sts-bg-secondary);
    border-radius: var(--sts-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--sts-border);
}

.sts-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--sts-border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.sts-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--sts-primary), var(--sts-success));
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
    animation: progress-pulse 2s ease-in-out infinite;
}

@keyframes progress-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.sts-progress-text {
    text-align: center;
    font-weight: 600;
    color: var(--sts-text);
}

/* Результат */
.sts-result {
    background: var(--sts-bg-secondary);
    border-radius: var(--sts-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--sts-border);
}

.sts-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.sts-result-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: var(--sts-text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sts-result-icon {
    font-size: 1.5rem;
}

.sts-result-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.sts-copy-btn,
.sts-export-btn {
    background: var(--sts-primary);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--sts-radius);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--sts-transition);
}

.sts-copy-btn:hover,
.sts-export-btn:hover {
    background: var(--sts-primary-dark);
}

.sts-result-content {
    background: var(--sts-bg);
    border-radius: var(--sts-radius);
    padding: 1.5rem;
    border: 1px solid var(--sts-border);
    line-height: 1.7;
}

.sts-result-content h1,
.sts-result-content h2,
.sts-result-content h3,
.sts-result-content h4,
.sts-result-content h5,
.sts-result-content h6 {
    color: var(--sts-text);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.sts-result-content h1:first-child,
.sts-result-content h2:first-child,
.sts-result-content h3:first-child {
    margin-top: 0;
}

.sts-result-content p {
    margin-bottom: 1rem;
}

.sts-result-content ul,
.sts-result-content ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.sts-result-content li {
    margin-bottom: 0.5rem;
}

.sts-result-content code {
    background: var(--sts-bg-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
}

/* Математические формулы */
.sts-result-content .math-formula {
    font-family: 'Times New Roman', serif;
    font-size: 1.1rem;
    line-height: 1.6;
    margin: 0.5rem 0;
    padding: 0.5rem;
    background: var(--sts-bg-secondary);
    border-radius: 0.25rem;
    border-left: 3px solid var(--sts-primary);
    white-space: nowrap; /* Предотвращаем перенос формул */
    overflow-x: auto; /* Горизонтальная прокрутка при необходимости */
}

.sts-result-content .math-fraction {
    display: inline-block;
    text-align: center;
    vertical-align: middle;
    margin: 0 0.25rem;
}

.sts-result-content .math-fraction .numerator {
    display: block;
    border-bottom: 1px solid var(--sts-text);
    padding-bottom: 0.1rem;
    margin-bottom: 0.1rem;
}

.sts-result-content .math-fraction .denominator {
    display: block;
    padding-top: 0.1rem;
}

.sts-result-content .math-operation {
    font-weight: bold;
    color: var(--sts-primary);
    margin: 0 0.25rem;
}

.sts-result-content .math-equals {
    font-weight: bold;
    color: var(--sts-success);
    margin: 0 0.5rem;
}

.sts-result-content .math-step {
    margin: 0.75rem 0;
    padding: 0.5rem;
    background: rgba(59, 130, 246, 0.05);
    border-radius: 0.25rem;
    border-left: 3px solid var(--sts-primary);
}

.sts-result-content .math-step-number {
    font-weight: bold;
    color: var(--sts-primary);
    margin-right: 0.5rem;
}

/* Стили для арифметических операций в одну строку */
.sts-result-content .math-calculation {
    display: inline-block;
    font-family: 'Times New Roman', serif;
    font-size: 1.1rem;
    background: rgba(59, 130, 246, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    margin: 0.25rem 0;
    white-space: nowrap;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.sts-result-content .math-calculation .number {
    font-weight: 600;
    color: var(--sts-primary);
}

.sts-result-content .math-calculation .operator {
    font-weight: bold;
    color: var(--sts-secondary);
    margin: 0 0.5rem;
}

.sts-result-content .math-calculation .equals {
    font-weight: bold;
    color: var(--sts-success);
    margin: 0 0.5rem;
}

.sts-result-content .math-calculation .result {
    font-weight: 600;
    color: var(--sts-success);
}

.sts-result-content pre {
    background: var(--sts-bg-secondary);
    padding: 1rem;
    border-radius: var(--sts-radius);
    overflow-x: auto;
    margin-bottom: 1rem;
}

.sts-result-content pre code {
    background: none;
    padding: 0;
}

/* Ошибка */
.sts-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--sts-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.sts-error-content {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.sts-error-icon {
    font-size: 1.5rem;
    color: var(--sts-error);
    flex-shrink: 0;
}

.sts-error-text {
    flex: 1;
}

.sts-error-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    color: var(--sts-error);
}

.sts-error-message {
    color: #7f1d1d;
    margin: 0;
}

.sts-retry-btn {
    background: var(--sts-error);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--sts-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--sts-transition);
}

.sts-retry-btn:hover {
    background: #dc2626;
}

/* Статистика */
.sts-stats {
    background: var(--sts-bg-secondary);
    border-radius: var(--sts-radius);
    padding: 1.5rem;
    margin-top: 2rem;
    border: 1px solid var(--sts-border);
}

.sts-stats-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
    color: var(--sts-text);
    text-align: center;
}

.sts-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.sts-stat-item {
    text-align: center;
    padding: 1rem;
    background: var(--sts-bg);
    border-radius: var(--sts-radius);
    border: 1px solid var(--sts-border);
}

.sts-stat-number {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--sts-primary);
    margin-bottom: 0.5rem;
}

.sts-stat-label {
    font-size: 0.875rem;
    color: var(--sts-text-secondary);
    font-weight: 500;
}

/* Уведомления */
.sts-notifications {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sts-notification {
    background: var(--sts-bg);
    border: 1px solid var(--sts-border);
    border-radius: var(--sts-radius);
    padding: 1rem 1.5rem;
    box-shadow: var(--sts-shadow-lg);
    max-width: 400px;
    animation: notification-slide-in 0.3s ease-out;
}

.sts-notification.success {
    border-left: 4px solid var(--sts-success);
}

.sts-notification.error {
    border-left: 4px solid var(--sts-error);
}

.sts-notification.warning {
    border-left: 4px solid var(--sts-warning);
}

@keyframes notification-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Адаптивность */
@media (max-width: 768px) {
    .sts-container {
        padding: 1rem;
        margin: 1rem;
    }
    
    .sts-title {
        font-size: 1.5rem;
    }
    
    .sts-settings-grid {
        grid-template-columns: 1fr;
    }
    
    .sts-result-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .sts-result-actions {
        justify-content: center;
    }
    
    .sts-stats-grid {
        grid-template-columns: 1fr;
    }
    
    .sts-notifications {
        top: 1rem;
        right: 1rem;
        left: 1rem;
    }
    
    .sts-notification {
        max-width: none;
    }
}

@media (max-width: 480px) {
    .sts-upload-area {
        padding: 2rem 1rem;
    }
    
    .sts-upload-title {
        font-size: 1.25rem;
    }
    
    .sts-format-tag {
        font-size: 0.75rem;
        padding: 0.2rem 0.5rem;
    }
}

/* Анимации загрузки */
.sts-loading {
    position: relative;
    overflow: hidden;
}

.sts-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Улучшения доступности */
.sts-solve-btn:focus,
.sts-upload-btn:focus,
.sts-remove-btn:focus,
.sts-copy-btn:focus,
.sts-export-btn:focus,
.sts-retry-btn:focus {
    outline: 2px solid var(--sts-primary);
    outline-offset: 2px;
}

.sts-setting-select:focus,
.sts-setting-input:focus {
    outline: 2px solid var(--sts-primary);
    outline-offset: 2px;
}

/* Скрытие элементов */
.sts-hidden {
    display: none !important;
}

/* Утилиты */
.sts-text-center { text-align: center; }
.sts-text-left { text-align: left; }
.sts-text-right { text-align: right; }
.sts-mb-0 { margin-bottom: 0; }
.sts-mt-0 { margin-top: 0; }
