:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #f1f5f9;
    --secondary-hover: #e2e8f0;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --bg-white: #ffffff;
    --bg-light: #f8fafc;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 10px 20px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
}

body {
    background-color: var(--bg-light);
    color: var(--text-primary);
    line-height: 1.6;
}

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

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

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

.logo-icon {
    font-size: 2.2rem;
    color: var(--primary-color);
}

.logo-text h1 {
    font-size: 1.8rem;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.logo-text p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.user-actions {
    display: flex;
    gap: 15px;
}

.btn {
    padding: 10px 20px;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

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

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

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

.search-section {
    background-color: var(--bg-white);
    padding: 25px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.search-bar {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.search-input {
    flex: 1;
    position: relative;
}

.search-input input {
    width: 100%;
    padding: 14px 20px 14px 45px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: all 0.3s;
}

.search-input input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.filter-group select {
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background-color: var(--bg-white);
}

.books-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.books-count {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.view-options {
    display: flex;
    gap: 10px;
}

.view-btn {
    padding: 8px 12px;
    border-radius: 6px;
    background-color: var(--secondary-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
}

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

/* 网格视图样式 */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
}

.book-card {
    background-color: var(--bg-white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
}

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

.book-cover {
    height: 200px;
    background-color: var(--secondary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    position: relative;
    overflow: hidden;
}

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

.book-info {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.book-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.4;
}

.book-author {
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-size: 0.95rem;
}

.book-meta {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.book-category {
    background-color: var(--secondary-color);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    display: inline-block;
    margin-bottom: 15px;
    align-self: flex-start;
}

.book-actions {
    display: flex;
    gap: 10px;
    margin-top: auto;
}

.action-btn {
    flex: 1;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
}

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

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

.delete-btn {
    background-color: #fef2f2;
    color: var(--danger-color);
}

.delete-btn:hover {
    background-color: #fee2e2;
}

/* 列表视图样式 */
.books-table {
    width: 100%;
    background-color: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: none;
}

.books-table.active {
    display: table;
}

.books-grid.active {
    display: grid;
}

.books-grid:not(.active) {
    display: none;
}

.table-header {
    display: grid;
    grid-template-columns: 80px 1fr 1fr 120px 100px 100px 120px;
    gap: 15px;
    padding: 15px 20px;
    background-color: var(--bg-light);
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.table-row {
    display: grid;
    grid-template-columns: 80px 1fr 1fr 120px 100px 100px 120px;
    gap: 15px;
    padding: 15px 20px;
    border-bottom: 1px solid var(--secondary-color);
    transition: all 0.3s;
}

.table-row:hover {
    background-color: var(--bg-light);
}

.table-cell {
    display: flex;
    align-items: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-available {
    background-color: #d1fae5;
    color: #065f46;
}

.status-borrowed {
    background-color: #fef3c7;
    color: #92400e;
}

.status-reserved {
    background-color: #dbeafe;
    color: #1e40af;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 20px;
    color: #cbd5e1;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--text-secondary);
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .table-header, .table-row {
        grid-template-columns: 80px 1fr 1fr 120px 100px 120px;
    }

    .table-header .hide-on-large,
    .table-row .hide-on-large {
        display: none;
    }
}

@media (max-width: 992px) {
    .table-header, .table-row {
        grid-template-columns: 80px 1fr 120px 100px 120px;
    }

    .table-header .hide-on-medium,
    .table-row .hide-on-medium {
        display: none;
    }

    .search-bar {
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }

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

    .table-header, .table-row {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 10px;
    }

    .table-header .hide-on-small,
    .table-row .hide-on-small {
        display: none;
    }

    .user-actions {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 576px) {
    .container {
        padding: 10px;
    }

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

    .table-header, .table-row {
        grid-template-columns: 1fr 1fr;
    }

    .view-options {
        flex-direction: column;
    }

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

/* 添加视图切换样式 */
.view-switcher {
    margin-bottom: 15px;
    text-align: right;
}

.view-btn {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 6px 12px;
    cursor: pointer;
    margin-left: 5px;
}

.view-btn.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

/* 网格视图 */
#booksGrid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    padding: 20px;
}

#booksGrid.active {
    display: grid;
}

/* 表格视图 */
#booksTable {
    display: none;
}

#booksTable.active {
    display: block;
}

/* 空状态样式 */
.empty-state {
    text-align: center;
    padding: 40px;
    color: #6c757d;
    grid-column: 1 / -1;
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 15px;
    color: #adb5bd;
}

/* 加载状态 */
select.loading {
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px 16px;
    padding-right: 35px;
}

/* 错误状态 */
select.error {
    border-color: #dc3545;
    background-color: #fff5f5;
}

/* 禁用状态 */
select:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
}

/* 分组样式 */
optgroup {
    font-weight: bold;
    font-style: normal;
    color: #495057;
}

optgroup option {
    font-weight: normal;
    padding-left: 20px;
}