/* 思悟数学 - 现代化设计系统 */

/* ==================== CSS变量定义 ==================== */
:root {
    /* 主色调 - 柔和的Indigo */
    --color-primary: #6366F1;
    --color-primary-light: #818CF8;
    --color-primary-dark: #4F46E5;
    --color-primary-50: #EEF2FF;
    --color-primary-100: #E0E7FF;

    /* 辅助色 */
    --color-success: #10B981;
    --color-success-light: #34D399;
    --color-warning: #F59E0B;
    --color-warning-light: #FBBF24;
    --color-error: #EF4444;
    --color-error-light: #F87171;
    --color-info: #3B82F6;
    --color-info-light: #60A5FA;

    /* 中性色 */
    --color-gray-50: #F9FAFB;
    --color-gray-100: #F3F4F6;
    --color-gray-200: #E5E7EB;
    --color-gray-300: #D1D5DB;
    --color-gray-400: #9CA3AF;
    --color-gray-500: #6B7280;
    --color-gray-600: #4B5563;
    --color-gray-700: #374151;
    --color-gray-800: #1F2937;
    --color-gray-900: #111827;

    /* 字体大小 */
    --text-xs: 0.75rem;
    /* 12px */
    --text-sm: 0.875rem;
    /* 14px */
    --text-base: 1rem;
    /* 16px */
    --text-lg: 1.125rem;
    /* 18px */
    --text-xl: 1.25rem;
    /* 20px */
    --text-2xl: 1.5rem;
    /* 24px */
    --text-3xl: 1.875rem;
    /* 30px */
    --text-4xl: 2.25rem;
    /* 36px */
    --text-5xl: 3rem;
    /* 48px */

    /* 间距 */
    --spacing-1: 0.25rem;
    /* 4px */
    --spacing-2: 0.5rem;
    /* 8px */
    --spacing-3: 0.75rem;
    /* 12px */
    --spacing-4: 1rem;
    /* 16px */
    --spacing-5: 1.25rem;
    /* 20px */
    --spacing-6: 1.5rem;
    /* 24px */
    --spacing-8: 2rem;
    /* 32px */
    --spacing-10: 2.5rem;
    /* 40px */
    --spacing-12: 3rem;
    /* 48px */
    --spacing-16: 4rem;
    /* 64px */

    /* 圆角 */
    --radius-sm: 0.375rem;
    /* 6px */
    --radius-md: 0.5rem;
    /* 8px */
    --radius-lg: 0.75rem;
    /* 12px */
    --radius-xl: 1rem;
    /* 16px */
    --radius-2xl: 1.5rem;
    /* 24px */
    --radius-full: 9999px;

    /* 阴影 */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

    /* 过渡 */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================== 基础样式重置 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
        'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    min-height: 100vh;
    color: var(--color-gray-900);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==================== 容器 ==================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-6);
}

/* ==================== 头部样式 ==================== */
.header {
    text-align: center;
    margin-bottom: var(--spacing-12);
    color: white;
    animation: fadeInDown 0.6s ease-out;
}

.header h1 {
    font-size: var(--text-4xl);
    font-weight: 700;
    margin-bottom: var(--spacing-3);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    letter-spacing: -0.02em;
}

.header p {
    font-size: var(--text-lg);
    opacity: 0.95;
    font-weight: 400;
}

/* ==================== 卡片样式 ==================== */
.card {
    background: white;
    border-radius: var(--radius-2xl);
    padding: var(--spacing-8);
    margin-bottom: var(--spacing-6);
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-base);
    border: 1px solid var(--color-gray-100);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: var(--color-primary-100);
}

/* ==================== 按钮样式 ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-2);
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: white;
    border: none;
    padding: var(--spacing-3) var(--spacing-6);
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-size: var(--text-base);
    font-weight: 500;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left var(--transition-slow);
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-success), var(--color-success-light));
}

.btn-secondary {
    background: linear-gradient(135deg, var(--color-info), var(--color-info-light));
}

.btn-danger {
    background: linear-gradient(135deg, var(--color-error), var(--color-error-light));
}

.btn-warning {
    background: linear-gradient(135deg, var(--color-warning), var(--color-warning-light));
}

/* ==================== 表单样式 ==================== */
.form-group {
    margin-bottom: var(--spacing-5);
}

.form-group label {
    display: block;
    margin-bottom: var(--spacing-2);
    font-weight: 500;
    color: var(--color-gray-700);
    font-size: var(--text-sm);
}

.form-control {
    width: 100%;
    padding: var(--spacing-3) var(--spacing-4);
    border: 2px solid var(--color-gray-200);
    border-radius: var(--radius-lg);
    font-size: var(--text-base);
    transition: all var(--transition-base);
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-50);
}

.form-control:hover {
    border-color: var(--color-gray-300);
}

/* ==================== 动画定义 ==================== */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ==================== 工具类 ==================== */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.font-bold {
    font-weight: 700;
}

.font-semibold {
    font-weight: 600;
}

.font-medium {
    font-weight: 500;
}

.text-primary {
    color: var(--color-primary);
}

.text-success {
    color: var(--color-success);
}

.text-warning {
    color: var(--color-warning);
}

.text-error {
    color: var(--color-error);
}

.text-gray {
    color: var(--color-gray-500);
}

.bg-primary {
    background-color: var(--color-primary);
}

.bg-success {
    background-color: var(--color-success);
}

.bg-warning {
    background-color: var(--color-warning);
}

.bg-error {
    background-color: var(--color-error);
}

.rounded-sm {
    border-radius: var(--radius-sm);
}

.rounded-md {
    border-radius: var(--radius-md);
}

.rounded-lg {
    border-radius: var(--radius-lg);
}

.rounded-xl {
    border-radius: var(--radius-xl);
}

.rounded-2xl {
    border-radius: var(--radius-2xl);
}

.rounded-full {
    border-radius: var(--radius-full);
}

.shadow-sm {
    box-shadow: var(--shadow-sm);
}

.shadow-md {
    box-shadow: var(--shadow-md);
}

.shadow-lg {
    box-shadow: var(--shadow-lg);
}

.shadow-xl {
    box-shadow: var(--shadow-xl);
}

.mb-2 {
    margin-bottom: var(--spacing-2);
}

.mb-4 {
    margin-bottom: var(--spacing-4);
}

.mb-6 {
    margin-bottom: var(--spacing-6);
}

.mb-8 {
    margin-bottom: var(--spacing-8);
}

.mt-2 {
    margin-top: var(--spacing-2);
}

.mt-4 {
    margin-top: var(--spacing-4);
}

.mt-6 {
    margin-top: var(--spacing-6);
}

.mt-8 {
    margin-top: var(--spacing-8);
}

.p-4 {
    padding: var(--spacing-4);
}

.p-6 {
    padding: var(--spacing-6);
}

.p-8 {
    padding: var(--spacing-8);
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: var(--spacing-2);
}

.gap-4 {
    gap: var(--spacing-4);
}

.gap-6 {
    gap: var(--spacing-6);
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    .container {
        padding: var(--spacing-4);
    }

    .header h1 {
        font-size: var(--text-3xl);
    }

    .header p {
        font-size: var(--text-base);
    }

    .card {
        padding: var(--spacing-6);
    }

    .btn {
        padding: var(--spacing-2) var(--spacing-4);
        font-size: var(--text-sm);
    }
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e5e9;
    border-radius: 10px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 文本区域 */
textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

/* 历史记录样式 */
.history-item {
    background: #f8f9fa;
    border-left: 4px solid #667eea;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 0 10px 10px 0;
    transition: background-color 0.3s ease;
}

.history-item:hover {
    background: #e9ecef;
}

.history-item .problem {
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.history-item .solution {
    color: #666;
    line-height: 1.6;
}

.history-item .meta {
    font-size: 0.9rem;
    color: #999;
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
}

/* 错题本样式 */
.error-item {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 0 10px 10px 0;
}

.error-item .category {
    background: #ffc107;
    color: white;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.8rem;
    display: inline-block;
    margin-bottom: 10px;
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header h1 {
        font-size: 2rem;
    }

    .card {
        padding: 15px;
    }

    .btn {
        padding: 10px 20px;
        font-size: 14px;
    }
}

/* 隐藏类 */
.hidden {
    display: none !important;
}

/* 显示类 */
.show {
    display: block !important;
}

/* 成功消息 */
.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

/* 错误消息 */
.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

/* 信息消息 */
.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

/* 现代化角色选择样式 */
.role-option-modern:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.role-option-modern:hover>div:last-child {
    transform: rotate(45deg) scale(1.2);
}

@media (max-width: 768px) {
    .role-option-modern {
        min-width: auto !important;
        width: 100% !important;
        max-width: 400px !important;
    }
}

/* 帮助模态框中的立即使用按钮 */
.btn-help-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    margin-top: 10px;
}

.btn-help-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
    filter: brightness(1.1);
}

.btn-help-action:active {
    transform: translateY(0);
}

.btn-help-action i {
    font-size: 0.9em;
}

/* ==================== 现代化加载动画 - 完全重写 ==================== */

.loading {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 60px 20px !important;
}

/* 旋转圆环容器 */
.loading-ring-container {
    position: relative !important;
    width: 120px !important;
    height: 120px !important;
    margin-bottom: 30px !important;
}

/* 外层圆环 - 只旋转圆环 */
.loading-ring-outer {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border: 6px solid #e5e7eb !important;
    border-top-color: #3b82f6 !important;
    border-right-color: #60a5fa !important;
    border-radius: 50% !important;
    animation: spinClean 1s linear infinite !important;
}

/* 内层圆环 - 删除 */
.loading-ring-inner {
    display: none !important;
}

/* 中心图标 - 绝对静止 */
.loading-icon {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    font-size: 3rem !important;
    color: #3b82f6 !important;
    animation: none !important;
}

/* 清洁的旋转动画 */
@keyframes spinClean {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* 加载文字 - 绝对静止 */
.loading p {
    font-size: 1.3rem !important;
    color: #1f2937 !important;
    font-weight: 700 !important;
    margin: 8px 0 !important;
    text-align: center !important;
    animation: none !important;
    transform: none !important;
}

/* 强制让 loading 中的任意 icon 静止，避免内联样式旋转 */
.loading i {
    animation: none !important;
    transform: none !important;
}


/* 删除旧版兼容 */
.loading i.fa-spinner {
    display: none !important;
}

/* === 智能解题：叠加模态加载遮罩（虚化背景，可中断） === */
.solve-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.6);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.solve-loading-card {
    background: #fff;
    border: 1px solid var(--color-gray-200);
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    padding: 18px 20px;
    width: 520px;
    max-width: 92%;
    display: flex;
    align-items: center;
    gap: 14px;
}

.solve-spinner-ring {
    width: 32px;
    height: 32px;
    border: 4px solid #e5e7eb;
    border-top-color: var(--color-info);
    border-right-color: var(--color-info-light);
    border-radius: 50%;
    animation: spinClean 1s linear infinite;
    flex: 0 0 auto;
}

.solve-loading-texts {
    flex: 1 1 auto;
    min-width: 0;
}

.solve-loading-text-main {
    font-size: 1.05rem;
    color: var(--color-gray-800);
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
}

.solve-loading-text-sub {
    margin-top: 4px;
    font-size: 0.9rem;
    color: var(--color-gray-500);
}

.solve-cancel-btn {
    flex: 0 0 auto;
    background: var(--color-error);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: filter var(--transition-fast);
}

.solve-cancel-btn:hover {
    filter: brightness(0.95);
}

/* 帮助模块功能跳转按钮 */
.btn-help-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white !important;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 20px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    text-decoration: none;
}

.btn-help-action:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
    filter: brightness(1.1);
}

.btn-help-action i {
    font-size: 1.2rem;
}