/**
 * 公共样式 - 响应式设计
 */

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

:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --secondary: #764ba2;
    --success: #48bb78;
    --warning: #ed8936;
    --danger: #f56565;
    --dark: #2d3748;
    --gray: #718096;
    --light-gray: #e2e8f0;
    --bg: #f7fafc;
    --white: #ffffff;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-lg: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--dark);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 按钮 */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: var(--white);
}

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

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: var(--white);
}

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

.btn-block {
    width: 100%;
    padding: 14px;
    font-size: 16px;
}

/* 导航 */
.navbar {
    background: var(--white);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.logo img {
    height: 40px;
}

.logo-text {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-link {
    color: var(--dark);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.nav-link:hover {
    color: var(--primary);
}

/* 搜索区域 */
.hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    padding: 60px 0;
    text-align: center;
    color: var(--white);
}

.hero-title {
    font-size: 42px;
    margin-bottom: 15px;
}

.hero-subtitle {
    font-size: 18px;
    opacity: 0.9;
    margin-bottom: 30px;
}

.search-box {
    display: flex;
    max-width: 600px;
    margin: 0 auto;
    background: var(--white);
    border-radius: 50px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.search-input {
    flex: 1;
    padding: 16px 24px;
    border: none;
    font-size: 16px;
    outline: none;
}

.search-btn {
    padding: 16px 30px;
    background: var(--dark);
    color: var(--white);
    border: none;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.search-btn:hover {
    background: #1a202c;
}

/* 分类 */
.categories {
    background: var(--white);
    padding: 20px 0;
    border-bottom: 1px solid var(--light-gray);
}

.category-list {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.category-item {
    padding: 8px 18px;
    border-radius: 20px;
    background: var(--bg);
    color: var(--gray);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.3s;
}

.category-item:hover,
.category-item.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: var(--white);
}

/* 书籍列表 */
.books-section {
    padding: 40px 0;
}

.section-title {
    font-size: 24px;
    margin-bottom: 25px;
    color: var(--dark);
}

.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
}

.book-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s;
}

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.book-cover {
    height: 180px;
    overflow: hidden;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
}

.book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-cover-placeholder {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 64px;
    color: var(--white);
    opacity: 0.8;
}

.book-info {
    padding: 20px;
}

.book-title {
    font-size: 17px;
    margin-bottom: 6px;
    color: var(--dark);
}

.book-author {
    font-size: 13px;
    color: var(--gray);
    margin-bottom: 8px;
}

.book-category {
    display: inline-block;
    padding: 3px 10px;
    background: #edf2f7;
    color: var(--primary);
    font-size: 12px;
    border-radius: 12px;
    margin-bottom: 10px;
}

.book-desc {
    font-size: 13px;
    color: var(--gray);
    margin-bottom: 15px;
    line-height: 1.5;
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 40px;
}

.page-item {
    padding: 8px 16px;
    border-radius: var(--radius);
    background: var(--white);
    color: var(--dark);
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: all 0.3s;
}

.page-item:hover,
.page-item.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: var(--white);
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray);
}

/* 认证页面 */
.auth-page {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-box {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header h1 {
    font-size: 26px;
    color: var(--dark);
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--gray);
}

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

.auth-form label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--dark);
}

.auth-form input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--light-gray);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color 0.3s;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary);
}

.auth-footer {
    text-align: center;
    margin-top: 25px;
    color: var(--gray);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
}

/* 提示框 */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-error {
    background: #fff5f5;
    color: #c53030;
    border: 1px solid #feb2b2;
}

.alert-success {
    background: #f0fff4;
    color: #276749;
    border: 1px solid #9ae6b4;
}

/* 个人中心 */
.profile-page {
    padding: 30px 0;
}

.profile-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 30px;
}

.profile-sidebar {
    position: sticky;
    top: 84px;
    height: fit-content;
}

.profile-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 30px;
    text-align: center;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin: 0 auto 15px;
}

.profile-name {
    font-size: 20px;
    margin-bottom: 5px;
}

.profile-email {
    font-size: 13px;
    color: var(--gray);
    margin-bottom: 10px;
}

.profile-role {
    display: inline-block;
    padding: 4px 12px;
    background: #edf2f7;
    color: var(--primary);
    font-size: 12px;
    border-radius: 12px;
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.stat-item {
    background: var(--white);
    border-radius: var(--radius);
    padding: 15px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-num {
    display: block;
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 12px;
    color: var(--gray);
}

.profile-main {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 30px;
    box-shadow: var(--shadow);
}

.tabs {
    display: flex;
    gap: 20px;
    border-bottom: 2px solid var(--light-gray);
    margin-bottom: 25px;
}

.tab {
    padding: 12px 0;
    color: var(--gray);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

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

/* 问题列表 */
.question-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.question-item {
    border: 1px solid var(--light-gray);
    border-radius: var(--radius);
    padding: 20px;
    transition: box-shadow 0.3s;
}

.question-item:hover {
    box-shadow: var(--shadow);
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.question-title {
    font-size: 16px;
    color: var(--dark);
    flex: 1;
}

.question-status {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-pending {
    background: #fffaf0;
    color: var(--warning);
}

.status-solved {
    background: #f0fff4;
    color: var(--success);
}

.question-meta {
    display: flex;
    gap: 15px;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--gray);
}

.meta-tag {
    color: var(--primary);
}

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

.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--light-gray);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 3px;
    transition: width 0.3s;
}

.progress-text {
    font-size: 12px;
    color: var(--gray);
    white-space: nowrap;
}

.question-actions {
    display: flex;
    gap: 10px;
}

/* 学习页面 */
.learn-page {
    padding: 20px 0;
}

.learn-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
}

.learn-sidebar {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    height: fit-content;
    position: sticky;
    top: 84px;
}

.book-info-small {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--light-gray);
}

.book-info-small h3 {
    font-size: 16px;
    margin-bottom: 5px;
}

.book-info-small p {
    font-size: 13px;
    color: var(--gray);
}

.learn-main {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 30px;
    box-shadow: var(--shadow);
}

.question-input-area {
    margin-bottom: 30px;
}

.question-input-area textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--light-gray);
    border-radius: var(--radius);
    font-size: 15px;
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

.question-input-area textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.step-container {
    margin-bottom: 25px;
}

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

.step-badge {
    padding: 6px 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: var(--white);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.step-title-text {
    font-size: 20px;
    color: var(--dark);
}

.step-content {
    line-height: 1.8;
}

.step-section {
    margin-bottom: 24px;
}

.step-section h4 {
    font-size: 16px;
    color: var(--primary);
    margin-bottom: 12px;
    padding-left: 12px;
    border-left: 4px solid var(--primary);
}

.step-section p {
    color: var(--dark);
    margin-bottom: 10px;
}

.step-section ul {
    padding-left: 20px;
    color: var(--dark);
}

.step-section li {
    margin-bottom: 6px;
}

.code-block {
    background: #2d3748;
    color: #e2e8f0;
    padding: 16px;
    border-radius: var(--radius);
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    line-height: 1.6;
}

.code-block code {
    color: #68d391;
}

.tips-box {
    background: #fffaf0;
    border-left: 4px solid var(--warning);
    padding: 15px;
    border-radius: 0 var(--radius) var(--radius) 0;
}

.tips-box h4 {
    color: var(--warning);
    margin-bottom: 8px;
}

.tips-box p {
    color: #744210;
    font-size: 14px;
}

.step-actions {
    display: flex;
    gap: 12px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--light-gray);
}

/* 页脚 */
.footer {
    background: var(--white);
    border-top: 1px solid var(--light-gray);
    padding: 20px 0;
    text-align: center;
    color: var(--gray);
    font-size: 14px;
    margin-top: 40px;
}

/* 响应式 */
@media (max-width: 768px) {
    .hero-title {
        font-size: 28px;
    }

    .search-box {
        flex-direction: column;
        border-radius: var(--radius-lg);
    }

    .search-btn {
        border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    }

    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 16px;
    }

    .profile-layout {
        grid-template-columns: 1fr;
    }

    .profile-sidebar {
        position: static;
    }

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

    .learn-layout {
        grid-template-columns: 1fr;
    }

    .learn-sidebar {
        position: static;
    }

    .question-header {
        flex-direction: column;
        gap: 8px;
    }

    .step-actions {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .nav-container {
        height: 56px;
    }

    .logo-text {
        font-size: 18px;
    }

    .nav-right {
        gap: 12px;
    }

    .nav-link {
        font-size: 14px;
    }

    .hero {
        padding: 40px 0;
    }

    .hero-subtitle {
        font-size: 15px;
    }

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

    .auth-box {
        padding: 25px;
    }
}
