:root {
    --primary: #8b5a2b;
    --primary-hover: #6d4620;
    --bg: #f5f0e6;
    --card: #fffbf5;
    --text: #3d3229;
    --text-muted: #8b7355;
    --border: #e8e0d0;
    --success: #6b8e4e;
    --warning: #c9a227;
    --error: #b85450;
    --shadow: 0 1px 3px rgba(61,50,41,0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-muted);
}

section {
    background: var(--card);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
}

/* Load Section */
.file-drop-zone {
    border: 3px dashed var(--border);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
}

.file-drop-zone:hover, .file-drop-zone.drag-over {
    border-color: var(--primary);
    background: #eff6ff;
}

.drop-content .icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

.drop-content p {
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.drop-content .or {
    font-size: 0.875rem;
    text-transform: uppercase;
    margin: 1rem 0;
}

.hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 1rem;
}

/* Buttons */
button {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover {
    background: #a04542;
}

/* Toolbar */
.toolbar {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    align-items: center;
}

.search-box {
    flex: 1;
    min-width: 250px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 0.625rem 2.5rem 0.625rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
}

#clearSearch {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    display: none;
}

.filters {
    display: flex;
    gap: 0.5rem;
}

.filters select {
    padding: 0.625rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    font-size: 0.875rem;
    min-width: 150px;
}

/* Stats Bar */
.stats-bar {
    padding: 0.75rem 0;
    color: var(--text-muted);
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

.divider {
    margin: 0 0.5rem;
}

/* Table */
.table-container {
    overflow-x: auto;
    margin-bottom: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

th {
    text-align: left;
    padding: 0.75rem;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

th:hover {
    background: var(--bg);
}

.sort-icon {
    color: var(--text-muted);
    margin-left: 0.25rem;
}

th.asc .sort-icon::after { content: "↑"; }
th.desc .sort-icon::after { content: "↓"; }

td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

tr:hover {
    background: var(--bg);
}

td:last-child {
    white-space: nowrap;
}

.book-title {
    font-weight: 500;
}

.book-author {
    color: var(--text-muted);
}

.book-isbn {
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.no-results {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

/* Action Buttons */
.action-btn {
    padding: 0.25rem 0.5rem;
    margin-right: 0.25rem;
    font-size: 0.75rem;
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
}

.action-btn:hover {
    background: var(--bg);
}

.action-btn.edit { color: var(--primary); }
.action-btn.delete { color: var(--error); }

/* Read Toggle Button */
.read-toggle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: white;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--text-muted);
}

.read-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.read-toggle.read {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.read-toggle.read:hover {
    background: var(--error);
    border-color: var(--error);
}

/* Read book row styling */
tr.book-read {
    opacity: 0.6;
}

tr.book-read .book-title {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
    border-top: 1px solid var(--border);
}

#pageInfo {
    color: var(--text-muted);
    font-size: 0.875rem;
}

#perPage {
    margin-left: auto;
    padding: 0.375rem;
    border: 1px solid var(--border);
    border-radius: 4px;
}

/* Export Bar */
.export-bar {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Data Management Bar */
.data-bar {
    display: flex;
    justify-content: center;
    padding-top: 1rem;
    margin-top: 1rem;
}

/* Import Stats */
#importStats {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    text-align: center;
}

.stat-added {
    color: var(--success);
    font-weight: 600;
    margin-right: 1rem;
}

.stat-dup {
    color: var(--text-muted);
}

/* Backup Reminder */
.backup-reminder {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.reminder-icon {
    font-size: 1.25rem;
}

.reminder-text {
    flex: 1;
    color: #856404;
}

.reminder-close {
    background: none;
    border: none;
    color: #856404;
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1rem;
    line-height: 1;
}

.reminder-close:hover {
    color: #5a3d03;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}

.modal-content h3 {
    margin-bottom: 1rem;
}

.modal-content label {
    display: block;
    margin: 1rem 0 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.modal-content input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* Footer */
footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 2rem;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .filters select {
        width: 100%;
    }
    
    th, td {
        padding: 0.5rem;
    }
    
    .book-isbn {
        display: none; /* Hide ISBN on mobile */
    }
}

/* Hamburger Menu */
.hamburger {
    position: fixed;
    top: 1rem;
    right: 1rem;
    width: 44px;
    height: 44px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    z-index: 1100;
    box-shadow: var(--shadow);
    padding: 0;
}

.hamburger span {
    width: 20px;
    height: 2px;
    background: var(--text);
    transition: all 0.3s;
    border-radius: 2px;
}

.mobile-nav {
    position: fixed;
    top: 0;
    right: -280px;
    width: 280px;
    height: 100vh;
    background: var(--card);
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    z-index: 1200;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.mobile-nav.open {
    right: 0;
}

.nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.nav-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.close-nav {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.25rem;
    width: auto;
}

.mobile-nav ul {
    list-style: none;
    padding: 1rem 0;
    margin: 0;
}

.mobile-nav li a {
    display: block;
    padding: 1rem 1.5rem;
    color: var(--text);
    text-decoration: none;
    transition: background 0.2s;
    font-size: 0.95rem;
}

.mobile-nav li a:hover {
    background: var(--bg);
}

.nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1150;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.nav-overlay.open {
    opacity: 1;
    visibility: visible;
}