/**
 * 全局样式
 * 图书分享系统 - 主样式表
 */

/* ============================================
   重置样式
   ============================================ */

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

/* ============================================
   基础样式
   ============================================ */

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.5;
}

.app-container {
    max-width: 640px;
    margin: 0 auto;
    background: #f5f5f5;
    min-height: 100vh;
    position: relative;
}

/* ============================================
   分类标签栏
   ============================================ */

.category-tabs {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid #e5e5e5;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.category-tab {
    padding: 6px 16px;
    background: #f5f5f5;
    border-radius: 20px;
    font-size: 14px;
    color: #666;
    text-decoration: none;
    transition: all 0.2s;
    flex-shrink: 0;
}

.category-tab.active {
    background: #007aff;
    color: white;
}

.category-tab:active {
    opacity: 0.7;
    transform: scale(0.96);
}

/* ============================================
   图书列表
   ============================================ */

.book-list {
    padding: 12px;
}

/* 图书卡片 */
.book-card {
    background: white;
    border-radius: 12px;
    margin-bottom: 12px;
    padding: 14px;
    display: flex;
    gap: 12px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.book-card:active {
    transform: scale(0.98);
}

.book-cover {
    width: 80px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    background: #f0f0f0;
    flex-shrink: 0;
}

.book-info {
    flex: 1;
    overflow: hidden;
}

.book-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #333;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.book-author {
    font-size: 13px;
    color: #666;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.book-publisher {
    font-size: 12px;
    color: #999;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.book-status {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.status-available {
    background: #e8f5e9;
    color: #4caf50;
}

.status-borrowed {
    background: #fff3e0;
    color: #ff9800;
}

.status-reserved {
    background: #e3f2fd;
    color: #2196f3;
}

.book-meta {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 8px;
}

.book-owner {
    font-size: 12px;
    color: #999;
}

/* ============================================
   按钮样式
   ============================================ */

.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: opacity 0.2s, transform 0.2s;
    background: #f5f5f5;
    color: #333;
}

.btn:active {
    opacity: 0.7;
    transform: scale(0.98);
}

.btn-primary {
    background: #007aff;
    color: white;
}

.btn-success {
    background: #34c759;
    color: white;
}

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

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

.btn-block {
    display: block;
    width: 100%;
}

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

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

/* ============================================
   表单样式
   ============================================ */

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

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

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: #007aff;
    box-shadow: 0 0 0 3px rgba(0,122,255,0.1);
}

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

.form-input.error,
.form-textarea.error,
.form-select.error {
    border-color: #ff3b30;
}

.field-error {
    color: #ff3b30;
    font-size: 12px;
    margin-top: 4px;
}

/* ============================================
   分页样式
   ============================================ */

.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    flex-wrap: wrap;
}

.page-link {
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    text-decoration: none;
    color: #007aff;
    transition: all 0.2s;
}

.page-link.active {
    background: #007aff;
    color: white;
}

.page-link:active {
    opacity: 0.7;
}

/* ============================================
   空状态样式
   ============================================ */

.empty-state {
    text-align: center;
    padding: 80px 20px;
}

.empty-icon {
    font-size: 80px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-text {
    font-size: 16px;
    color: #999;
}

/* ============================================
   演示卡片样式
   ============================================ */

.demo-books {
    padding: 20px;
}

.demo-message {
    text-align: center;
    padding: 40px 20px;
    background: white;
    border-radius: 16px;
    margin-bottom: 20px;
}

.demo-icon {
    font-size: 60px;
    margin-bottom: 15px;
}

.demo-text {
    font-size: 16px;
    color: #666;
    margin-bottom: 10px;
}

.demo-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.demo-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.demo-card:active {
    transform: scale(0.98);
}

.demo-card-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.demo-card-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 5px;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.demo-card-author {
    font-size: 12px;
    color: #999;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.demo-card-status {
    display: inline-block;
    padding: 4px 8px;
    background: #e8f5e9;
    color: #4caf50;
    border-radius: 4px;
    font-size: 11px;
}

/* ============================================
   暗色模式
   ============================================ */

@media (prefers-color-scheme: dark) {
    body {
        background: #000;
    }
    
    .app-container {
        background: #000;
    }
    
    .category-tabs {
        background: #1c1c1e;
        border-bottom-color: #3a3a3c;
    }
    
    .category-tab {
        background: #2c2c2e;
        color: #8e8e93;
    }
    
    .category-tab.active {
        background: #0a84ff;
        color: white;
    }
    
    .book-card {
        background: #1c1c1e;
    }
    
    .book-title {
        color: #fff;
    }
    
    .book-author,
    .book-publisher {
        color: #8e8e93;
    }
    
    .demo-card {
        background: #1c1c1e;
    }
    
    .demo-card-title {
        color: #fff;
    }
    
    .demo-card-author {
        color: #8e8e93;
    }
    
    .demo-message {
        background: #1c1c1e;
    }
    
    .demo-text {
        color: #8e8e93;
    }
    
    .form-input,
    .form-textarea,
    .form-select {
        background: #2c2c2e;
        border-color: #3a3a3c;
        color: #fff;
    }
    
    .form-label {
        color: #fff;
    }
    
    .form-input:focus,
    .form-textarea:focus,
    .form-select:focus {
        border-color: #0a84ff;
        box-shadow: 0 0 0 3px rgba(10,132,255,0.1);
    }
    
    .btn {
        background: #2c2c2e;
        color: #fff;
    }
    
    .btn-primary {
        background: #0a84ff;
    }
    
    .page-link {
        background: #2c2c2e;
        color: #0a84ff;
    }
    
    .page-link.active {
        background: #0a84ff;
        color: white;
    }
    
    .empty-text {
        color: #666;
    }
}

/* ============================================
   工具类
   ============================================ */

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

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mt-30 { margin-top: 30px; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }
.mb-30 { margin-bottom: 30px; }
.ml-10 { margin-left: 10px; }
.mr-10 { margin-right: 10px; }

.p-10 { padding: 10px; }
.p-20 { padding: 20px; }

.hidden {
    display: none;
}

.clearfix::after {
    content: "";
    display: table;
    clear: both;
}