/* 全局重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 页面全屏布局 */
html, body {
    height: 100%;
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4eaf5 100%);
    overflow: hidden;
    position: relative;
}

/* 应用主容器 - 全屏分栏 */
.app-container {
    display: flex;
    height: calc(100vh - 60px - 5px);
    width: 100%;
    padding: 0;
    margin: 0;
    position: fixed;
    top: 40px;  /*用户信息栏的高度*/
    left: 0;
    right: 0;
    overflow: hidden;
}

/* 左侧侧边栏 - 固定宽度，占满高度 */
.sidebar {
    width: 280px;
    flex-shrink: 0;
    background-color: white;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 15px;
    overflow-y: auto; /* 菜单过多时滚动 */
}

/* 侧边栏头部 */
.sidebar-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
}

/* 模块菜单 - 文字居中显示 */
.module-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.module-btn {
    padding: 12px 15px;
    background-color: #f1f5f9;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    text-align: center; /* 模块名称居中 */
    transition: all 0.2s ease;
    color: #475569;
}

.module-btn.active {
    background-color: #2563eb;
    color: white;
}

.module-btn:hover:not(.active) {
    background-color: #e2e8f0;
}

/* 模块控制区 */
.module-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex-grow: 1;
}

/* 右侧主内容区 - 占满剩余空间 */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 20px;
    overflow: hidden;
}

/* 主内容头部 */
.main-header {
    margin-bottom: 8px;
    text-align: center;
}

.main-header h1 {
    font-size: 100px;
    color: #1e293b;
    font-weight: 600;
}

/* 题目包装器 - 占满剩余高度 */
.problems-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: calc(100% - 40px);
}

/* 题目容器 - 全屏利用空间 */
.problems-container {
    flex-grow: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 20px;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    overflow-y: auto;
    align-content: flex-start; /* 顶部对齐 */
}

/* 控制按钮样式 */
.controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.controls button {
    background-color: #2563eb;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
}

.controls button:hover {
    background-color: #1d4ed8;
}

/* 选项区样式 */
.options {
    padding: 12px;
    background-color: #f1f5f9;
    border-radius: 8px;
}

/* 横式/竖式选项横向排列 */
.format-options {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 10px;
}

.options label {
    display: block;
    margin-bottom: 8px;
    font-size: 15px;
    color: #334155;
    text-align: center; /* 选项文字居中 */
}

.options input[type="number"] {
    width: 100%;
    padding: 8px;
    font-size: 15px;
    text-align: center;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    margin-top: 5px;
}

.options input[type="number"]:focus {
    border-color: #2563eb;
    outline: none;
}

/* 输入区域样式 */
.input-area {
    padding: 15px;
    background-color: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.input-area p {
    margin-bottom: 10px;
    font-size: 15px;
    color: #334155;
    text-align: center; /* 提示文字居中 */
}

.answer-input {
    width: 100%;
    padding: 10px;
    font-size: 16px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    margin-bottom: 10px;
    text-align: center; /* 输入框文字居中 */
}

.answer-input:focus {
    border-color: #2563eb;
    outline: none;
}

/* 反馈信息 */
.feedback {
    padding: 8px;
    border-radius: 4px;
    text-align: center;
    font-weight: 500;
}

.feedback.success {
    background-color: #dcfce7;
    color: #166534;
}

.feedback.error {
    background-color: #fee2e2;
    color: #991b1b;
}

/* 题目卡片样式 */
.problem {
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 20px;
    min-width: 180px;
    flex: 1;
    flex-basis: calc(20% - 15px); /* 每行5个题目，充分利用宽度 */
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease;
}

.problem:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.07);
}

/* 题目序号 */
.problem-number {
    position: absolute;
    top: 8px;
    left: 10px;
    font-size: 14px;
    color: #94a3b8;
    font-weight: bold;
}

/* 横式题目 */
.horizontal {
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 10px;
}

/* 竖式题目 - 标准竖式结构 */
.vertical {
    font-family: 'Courier New', 'Consolas', monospace;
    font-size: 28px;
    font-weight: bold;
    text-align: right;
    margin-bottom: 10px;
    display: inline-block;
    min-width: 120px;
    position: relative;
    line-height: 1.4;
}

.vertical .top-number {
    text-align: right;
    display: block;
    white-space: pre;
}

.vertical .bottom-number {
    text-align: right;
    display: block;
    white-space: pre;
}

/* 竖式运算符 - 精确定位 */
.vertical .operator {
    display: inline-block;
    width: 1.2em;
    text-align: center;
    margin-right: 0.2em;
}

/* 竖式横线 - 使用实线字符 */
.vertical .line {
    border-top: 2px solid #333;
    margin: 2px 0;
    width: 100%;
}

/* 答案区域 */
.answer-section {
    margin-top: 10px;
    padding: 10px;
    background-color: #e7f3ff;
    border-radius: 6px;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* 答案文本 */
.answer {
    font-size: 20px;
    font-weight: bold;
    color: #d9534f;
}

/* 进位/借位信息 */
.carry-info {
    font-size: 16px;
    margin-top: 5px;
}

.carry-yes {
    color: #ef4444;
    font-weight: bold;
}

.carry-no {
    color: #10b981;
    font-weight: bold;
}

/* 结果占位符 */
.result-placeholder {
    display: inline-block;
    width: 40px;
    border-bottom: 2px solid #333;
    margin: 0 5px;
}

/* 爱心动画 - 丝滑出现/消失，放大一倍 */
.heart {
    position: fixed;
    font-size: 60px; /* 原30px放大一倍 */
    color: #ec4899;
    z-index: 9999;
    pointer-events: none;
    animation: fall 3s ease-in-out forwards;
    top: -50px; /* 初始位置在屏幕外，避免显示一半 */
    opacity: 0; /* 初始透明 */
}

/* 爱心动画关键帧 - 丝滑过渡 */
@keyframes fall {
    0% { 
        transform: translateY(0) rotate(0deg) scale(0); /* 初始：缩小到0 */
        opacity: 0; /* 完全透明 */
    }
    10% {
        transform: translateY(20px) rotate(30deg) scale(1); /* 快速放大到正常大小 */
        opacity: 1; /* 完全显示 */
    }
    90% {
        transform: translateY(calc(100vh - 100px)) rotate(690deg) scale(1); /* 接近底部保持大小 */
        opacity: 1; /* 保持显示 */
    }
    100% { 
        transform: translateY(100vh) rotate(720deg) scale(0.8); /* 最后轻微缩小 */
        opacity: 0; /* 完全透明消失 */
    }
}

/* 响应式适配 */
@media (max-width: 1200px) {
    .problem {
        flex-basis: calc(25% - 15px); /* 每行4个 */
    }
}

@media (max-width: 992px) {
    .problem {
        flex-basis: calc(33.33% - 15px); /* 每行3个 */
    }
    
    .sidebar {
        width: 240px;
    }
}

/* 平板设备适配 */
@media (max-width: 768px) {
    html, body {
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .app-container {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 60px - 42px);
        position: relative;
        top: auto;
        bottom: auto;
        margin-top: 60px;
        margin-bottom: 42px;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: none;
        position: relative;
        overflow-y: visible;
    }
    
    .main-content {
        height: auto;
        min-height: calc(100vh - 60px - 42px);
        padding: 15px;
    }
    
    .problems-wrapper {
        height: auto;
        min-height: 400px;
    }
    
    .problems-container {
        height: auto;
        min-height: 300px;
    }
    
    .problem {
        flex-basis: calc(50% - 15px); /* 每行2个 */
    }
}

/* 手机设备适配 */
@media (max-width: 480px) {
    .problem {
        flex-basis: 100%; /* 每行1个 */
    }
    
    .main-header h1 {
        font-size: 18px;
    }
    
    .sidebar {
        padding: 10px;
    }
    
    .main-content {
        padding: 10px;
    }
    
    .problems-container {
        padding: 15px;
        gap: 10px;
    }
}
/* ���ֶ�����ʽ */
.points-animation {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    font-weight: bold;
    color: #f59e0b;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    animation: pointsFloat 2s ease-out forwards;
    pointer-events: none;
    z-index: 9999;
}

@keyframes pointsFloat {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -60%) scale(1.2);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -100%) scale(1);
        opacity: 0;
    }
}

/* 用户信息包装器样式 */
.user-info-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 1px 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    transition: all 0.3s ease;
    line-height: 1;
    height: 24px;
}

.user-info-wrap:hover {
    background: rgba(255, 255, 255, 0.15);
}

.user-points {
    font-size: 13px;
    font-weight: 600;
    color: #fbbf24;
    position: relative;
    white-space: nowrap;
    line-height: 1;
    display: flex;
    align-items: center;
}

.user-name {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1;
    display: flex;
    align-items: center;
}

#logoutBtn {
    padding: 3px 8px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.3s;
    white-space: nowrap;
    font-weight: 500;
    line-height: 1;
    height: 20px;
    display: inline-flex;
    align-items: center;
}

#logoutBtn:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

#trainingStatsBtn {
    padding: 3px 8px;
    background: rgba(59, 130, 246, 0.9);
    color: white;
    border: none;
    border-radius: 3px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    font-weight: 500;
    line-height: 1;
    height: 20px;
    box-sizing: border-box;
}

#trainingStatsBtn:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

#dataManagerLink {
    padding: 3px 8px;
    background: rgba(16, 185, 129, 0.9);
    color: white;
    border-radius: 3px;
    font-size: 11px;
    text-decoration: none;
    transition: all 0.3s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    font-weight: 500;
    line-height: 1;
    height: 20px;
    box-sizing: border-box;
}

#dataManagerLink:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

/* 移动端优化 - 竖屏模式 */
@media (max-width: 767px) and (orientation: portrait) {
    .user-info-wrap {
        display: flex !important;
        flex-wrap: wrap;
        height: auto !important;
        min-height: 24px;
        padding: 4px 8px;
        gap: 4px;
    }
    
    .user-info-wrap > * {
        flex: 0 0 auto;
    }
    
    .user-points, .user-name {
        font-size: 11px !important;
    }
    
    #trainingStatsBtn, #vipStatusBtn {
        font-size: 10px !important;
        padding: 2px 6px !important;
        height: auto !important;
    }
}

/* 移动端优化 - 横屏模式 */
@media (max-width: 767px) and (orientation: landscape) {
    /* 统计窗口在横屏模式下优化 */
    #statsWindow {
        width: 95% !important;
        height: 90% !important;
        max-width: none !important;
    }
    
    #statsWindow.help-window {
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
    }
}
