/* 基础变量 */
:root {
    --primary-color: #07c160;
    --primary-dark: #06ad56;
    --danger-color: #fa5151;
    --warning-color: #ffc300;
    --info-color: #10aeff;
    --text-primary: #333;
    --text-secondary: #666;
    --text-tertiary: #999;
    --bg-primary: #f5f5f5;
    --bg-white: #fff;
    --border-color: #e5e5e5;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

/* 重置样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

/* 应用容器 */
.app {
    max-width: 800px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: 32px;
}

/* 头部导航 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0 16px;
}

.header-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-add {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-add .icon {
    font-size: 18px;
    font-weight: 300;
}

/* 导入按钮 */
.btn-import {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--info-color);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    margin-right: 8px;
}

.btn-import:hover {
    background: #0a8fdb;
    transform: translateY(-1px);
}

.header-actions {
    display: flex;
    align-items: center;
}

/* 筛选组 */
.filter-group {
    margin-bottom: 12px;
}

.filter-group:last-child {
    margin-bottom: 0;
}

.filter-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: block;
}

/* 读者标签 */
.reader-tabs .filter-tab {
    font-size: 13px;
    padding: 6px 12px;
}

/* 二次阅读状态 */
.book-status-badge.rereading {
    background: #ff6b6b;
}

/* 读者标识 */
.book-reader {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 8px;
}

.book-reader.reader-male {
    background: #e3f2fd;
    color: #1976d2;
}

.book-reader.reader-female {
    background: #fce4ec;
    color: #c2185b;
}

.book-reader.reader-girl {
    background: #f3e5f5;
    color: #7b1fa2;
}

/* 统计面板 */
.stats-section {
    margin-bottom: 16px;
}

.stats-card {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    background: var(--bg-white);
    padding: 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.stat-number {
    font-size: 24px;
    font-weight: 600;
    color: var(--primary-color);
    line-height: 1.2;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* 筛选标签 */
.filter-section {
    margin-bottom: 16px;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-primary);
    padding: 8px 0;
}

.filter-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
}

.filter-tabs::-webkit-scrollbar {
    display: none;
}

.filter-tab {
    flex-shrink: 0;
    padding: 6px 16px;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.filter-tab:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.filter-tab.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* 图书列表 */
.books-section {
    min-height: 200px;
}

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

/* 图书卡片 */
.book-card {
    background: var(--bg-white);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
    cursor: pointer;
}

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

.book-cover {
    width: 100%;
    height: 160px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

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

.book-cover-placeholder {
    font-size: 48px;
    opacity: 0.3;
}

.book-status-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    color: white;
}

.book-status-badge.want {
    background: var(--info-color);
}

.book-status-badge.reserved {
    background: var(--warning-color);
    color: var(--text-primary);
}

.book-status-badge.reading {
    background: var(--primary-color);
}

.book-status-badge.finished {
    background: var(--text-tertiary);
}

.book-info {
    padding: 12px;
}

.book-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

/* 图书馆时间信息 */
.book-time {
    font-size: 11px;
    margin-bottom: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
}

.book-time.due-date {
    background: #e6f7ff;
    color: #1890ff;
}

.book-time.due-date.warning {
    background: #fff7e6;
    color: #fa8c16;
}

.book-time.due-date.urgent {
    background: #fff1f0;
    color: #f5222d;
    font-weight: 500;
}

.book-time.borrow-date {
    background: #f6ffed;
    color: #52c41a;
}

.book-time.reserve-date {
    background: #f9f0ff;
    color: #722ed1;
}

.book-time.want-date {
    background: #fff2e8;
    color: #fa541c;
}

/* 输入框带按钮 */
.input-with-btn {
    display: flex;
    gap: 8px;
}

.input-with-btn .form-input {
    flex: 1;
}

.btn-query {
    padding: 8px 16px;
    background: var(--info-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-query:hover {
    background: #0a8fdb;
}

.btn-query:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.book-desc {
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 12px;
}

.book-progress {
    margin-top: 8px;
}

.progress-bar {
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
    text-align: right;
}

.book-actions {
    display: flex;
    gap: 8px;
    padding: 0 12px 12px;
}

.btn-action {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-white);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-action:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-action.delete:hover {
    border-color: var(--danger-color);
    color: var(--danger-color);
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 48px 16px;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-text {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-subtext {
    font-size: 14px;
    color: var(--text-tertiary);
}

/* 弹窗 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    animation: modalSlideUp 0.3s ease;
}

.modal-small {
    max-width: 320px;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.btn-close {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    font-size: 24px;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-close:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

/* 表单 */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 15px;
    color: var(--text-primary);
    background: var(--bg-white);
    transition: all 0.2s;
}

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

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-range {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
}

.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.form-range::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* 封面上传 */
.cover-upload {
    position: relative;
}

.file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.cover-preview {
    width: 100%;
    height: 120px;
    background: var(--bg-primary);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

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

.cover-placeholder {
    color: var(--text-tertiary);
    font-size: 14px;
}

/* 按钮 */
.btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #e04040;
}

/* 确认文本 */
.confirm-text {
    font-size: 15px;
    color: var(--text-secondary);
    text-align: center;
    padding: 8px 0;
}

/* Toast 提示 */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}

.toast.active {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* 响应式适配 */
@media (max-width: 640px) {
    .app {
        padding: 12px;
    }

    .header-title {
        font-size: 20px;
    }

    .btn-add .text {
        display: none;
    }

    .btn-add {
        padding: 8px 12px;
    }

    .stats-card {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .stat-number {
        font-size: 22px;
    }

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

    .modal-content {
        max-height: 85vh;
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .books-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 隐藏进度条（非阅读中状态） */
.book-card:not([data-status="reading"]) .book-progress {
    display: none;
}

/* 状态颜色 */
.status-want { color: var(--info-color); }
.status-reserved { color: var(--warning-color); }
.status-reading { color: var(--primary-color); }
.status-finished { color: var(--text-tertiary); }
