/* ============================================
   诵英学堂 - 全局样式
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ============================================
   登录页样式
   ============================================ */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-box {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo h1 {
    font-size: 28px;
    color: #667eea;
    margin-bottom: 8px;
}

.login-logo p {
    color: #888;
    font-size: 14px;
}

.login-tabs {
    display: flex;
    margin-bottom: 25px;
    border-bottom: 2px solid #eee;
}

.login-tab {
    flex: 1;
    text-align: center;
    padding: 12px;
    cursor: pointer;
    color: #888;
    font-size: 15px;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.3s;
}

.login-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-size: 14px;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.3s;
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #667eea;
}

.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 100%;
    padding: 14px;
    font-size: 16px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-warning {
    background: #f59e0b;
    color: white;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-outline {
    background: white;
    border: 1.5px solid #667eea;
    color: #667eea;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

/* ============================================
   布局样式
   ============================================ */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: #1e293b;
    color: white;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #334155;
}

.sidebar-header h2 {
    font-size: 20px;
    color: #667eea;
}

.sidebar-menu {
    padding: 15px 0;
}

.menu-item {
    display: block;
    padding: 12px 20px;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.3s;
    border-left: 3px solid transparent;
}

.menu-item:hover,
.menu-item.active {
    background: #334155;
    color: white;
    border-left-color: #667eea;
}

.menu-item .icon {
    margin-right: 10px;
    width: 20px;
    display: inline-block;
}

.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 20px;
}

.top-bar {
    background: white;
    padding: 15px 25px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.top-bar h1 {
    font-size: 20px;
    color: #1e293b;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

.coins-badge {
    background: #fef3c7;
    color: #d97706;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

/* ============================================
   卡片样式
   ============================================ */
.card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.card-header h3 {
    font-size: 17px;
    color: #1e293b;
}

/* ============================================
   星级评分
   ============================================ */
.stars {
    display: inline-flex;
    gap: 2px;
}

.star {
    color: #ddd;
    font-size: 18px;
}

.star-filled {
    color: #fbbf24;
}

/* ============================================
   进度条
   ============================================ */
.progress-bar {
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* ============================================
   课文列表
   ============================================ */
.text-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.text-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.text-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    border-color: #667eea;
}

.text-card h4 {
    font-size: 16px;
    margin-bottom: 10px;
    color: #1e293b;
}

.text-card .meta {
    font-size: 13px;
    color: #888;
    margin-bottom: 12px;
}

.text-card .progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #666;
    margin-top: 10px;
}

/* ============================================
   训练页面
   ============================================ */
.train-container {
    max-width: 800px;
    margin: 0 auto;
}

.level-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.level-tab {
    padding: 10px 20px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.level-tab.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.level-tab.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.recite-area {
    background: white;
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 20px;
}

.text-display {
    font-size: 18px;
    line-height: 2;
    margin-bottom: 25px;
    color: #1e293b;
}

.text-display.hidden-text {
    color: #ccc;
}

.text-display .word {
    display: inline;
    transition: all 0.3s;
}

.control-bar {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.speed-control {
    display: flex;
    gap: 5px;
    align-items: center;
}

.speed-btn {
    padding: 6px 12px;
    border: 1px solid #e5e7eb;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.speed-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.audio-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.play-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   默写页面
   ============================================ */
.dictation-area textarea {
    width: 100%;
    min-height: 200px;
    padding: 15px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 16px;
    line-height: 1.8;
    resize: vertical;
    font-family: inherit;
}

.mode-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.mode-btn {
    padding: 10px 18px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

.mode-btn.active {
    border-color: #667eea;
    color: #667eea;
    background: #f0f4ff;
}

/* ============================================
   结果弹窗
   ============================================ */
.result-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.result-box {
    background: white;
    border-radius: 20px;
    padding: 35px;
    width: 90%;
    max-width: 450px;
    text-align: center;
}

.result-score {
    font-size: 56px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 15px 0;
}

.result-stars {
    font-size: 32px;
    margin-bottom: 20px;
}

.score-breakdown {
    text-align: left;
    background: #f8fafc;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.score-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
}

.coins-earned {
    background: #fef3c7;
    color: #d97706;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
}

/* ============================================
   排行榜
   ============================================ */
.ranking-list {
    list-style: none;
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.rank-num {
    width: 30px;
    text-align: center;
    font-weight: 600;
    color: #888;
}

.rank-num.top1 { color: #f59e0b; }
.rank-num.top2 { color: #9ca3af; }
.rank-num.top3 { color: #cd7c32; }

.rank-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e5e7eb;
    margin: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.rank-name {
    flex: 1;
}

.rank-score {
    font-weight: 600;
    color: #667eea;
}

/* ============================================
   商城
   ============================================ */
.shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.shop-item {
    background: white;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s;
}

.shop-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}

.item-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 12px;
    background: linear-gradient(135deg, #f0f4ff, #e0e7ff);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.item-name {
    font-weight: 500;
    margin-bottom: 6px;
}

.item-price {
    color: #f59e0b;
    font-weight: 600;
    margin-bottom: 12px;
}

/* ============================================
   打卡墙
   ============================================ */
.checkin-wall {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.checkin-post {
    background: white;
    border-radius: 12px;
    padding: 20px;
}

.post-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.post-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

.post-user {
    font-weight: 500;
}

.post-time {
    font-size: 12px;
    color: #999;
}

.post-content {
    margin-bottom: 12px;
    line-height: 1.7;
}

.post-actions {
    display: flex;
    gap: 20px;
    color: #888;
    font-size: 14px;
}

.post-actions span {
    cursor: pointer;
}

/* ============================================
   PK对战
   ============================================ */
.pk-arena {
    max-width: 700px;
    margin: 0 auto;
}

.pk-players {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.pk-player {
    text-align: center;
    flex: 1;
}

.pk-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: white;
}

.pk-player1 .pk-avatar {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

.pk-player2 .pk-avatar {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
}

.vs-text {
    font-size: 32px;
    font-weight: 700;
    color: #f59e0b;
    padding: 0 20px;
}

.pk-score {
    font-size: 28px;
    font-weight: 700;
    color: #1e293b;
}

/* ============================================
   数据仪表盘
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 5px;
}

.stat-label {
    color: #888;
    font-size: 14px;
}

.chart-container {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.chart-title {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 15px;
}

/* ============================================
   表格样式
   ============================================ */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}

.data-table th {
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
    font-size: 14px;
}

.data-table tr:hover {
    background: #f8fafc;
}

/* ============================================
   标签样式
   ============================================ */
.tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.tag-success {
    background: #d1fae5;
    color: #059669;
}

.tag-warning {
    background: #fef3c7;
    color: #d97706;
}

.tag-danger {
    background: #fee2e2;
    color: #dc2626;
}

.tag-info {
    background: #dbeafe;
    color: #2563eb;
}

/* ============================================
   AI聊天界面
   ============================================ */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 600px;
    background: white;
    border-radius: 12px;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8fafc;
}

.chat-message {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
}

.chat-message.user {
    flex-direction: row-reverse;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: white;
}

.chat-message.assistant .chat-avatar {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.chat-message.user .chat-avatar {
    background: #10b981;
}

.chat-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.6;
}

.chat-message.assistant .chat-bubble {
    background: white;
    border-top-left-radius: 4px;
}

.chat-message.user .chat-bubble {
    background: #667eea;
    color: white;
    border-top-right-radius: 4px;
}

.chat-input-area {
    padding: 15px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 10px;
}

.chat-input-area input {
    flex: 1;
    padding: 12px 16px;
    border: 1.5px solid #e5e7eb;
    border-radius: 25px;
    outline: none;
    font-size: 14px;
}

.chat-input-area input:focus {
    border-color: #667eea;
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #667eea;
    color: white;
    border: none;
    cursor: pointer;
}

/* ============================================
   家长端
   ============================================ */
.child-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.child-card {
    padding: 12px 20px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
}

.child-card.active {
    border-color: #667eea;
    background: #f0f4ff;
}

.daily-report-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 20px;
}

.daily-report-card h3 {
    margin-bottom: 15px;
    font-size: 18px;
}

.report-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.report-stat {
    text-align: center;
}

.report-stat .num {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.report-stat .label {
    font-size: 13px;
    opacity: 0.9;
}

/* ============================================
   响应式
   ============================================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 100;
        transition: transform 0.3s;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .text-grid {
        grid-template-columns: 1fr;
    }

    .report-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   工具类
   ============================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-10 { gap: 10px; }
.gap-15 { gap: 15px; }
.hidden { display: none; }
