/* === RESET & BASE === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4a90d9;
    --primary-dark: #357abd;
    --bg: #f5f5f5;
    --card-bg: #ffffff;
    --text: #333333;
    --text-muted: #666666;
    --border: #e0e0e0;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --radius: 12px;
}

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

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

/* === HEADER === */
.header {
    text-align: center;
    padding: 40px 20px;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.header p {
    color: var(--text-muted);
}

/* === UPLOAD SECTION === */
.upload-section {
    margin-bottom: 40px;
}

.upload-box {
    border: 3px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    background: var(--card-bg);
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-box:hover,
.upload-box.dragover {
    border-color: var(--primary);
    background: rgba(74, 144, 217, 0.05);
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.upload-btn {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 12px 30px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    margin: 15px 0;
    transition: background 0.3s;
}

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

.upload-hint {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Progress */
.progress-container {
    margin-top: 20px;
    text-align: center;
}

.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    max-width: 400px;
    margin: 0 auto;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.3s;
}

.progress-text {
    margin-top: 10px;
    color: var(--text-muted);
}

/* === BOOKS SECTION === */
.books-section h2 {
    margin-bottom: 20px;
    font-size: 1.5rem;
}

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

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

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

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

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

.book-cover-placeholder {
    font-size: 64px;
    opacity: 0.8;
}

.book-info {
    padding: 15px;
}

.book-title {
    font-size: 1.1rem;
    margin-bottom: 5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-author {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.book-format {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.book-actions {
    padding: 15px;
    display: flex;
    gap: 10px;
    border-top: 1px solid var(--border);
}

.btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    text-align: center;
    text-decoration: none;
}

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

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

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

.btn-delete:hover {
    background: #fecaca;
}

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

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    opacity: 0;
    transition: all 0.3s;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.error {
    background: #dc2626;
}

.toast.success {
    background: #16a34a;
}

/* === READER PAGE === */
.reader-body {
    background: #faf8f5;
    overflow: hidden;
}

/* Reader Themes */
.reader-body.theme-light {
    --reader-bg: #ffffff;
    --reader-text: #333333;
}

.reader-body.theme-sepia {
    --reader-bg: #f4ecd8;
    --reader-text: #5b4636;
}

.reader-body.theme-dark {
    --reader-bg: #1a1a1a;
    --reader-text: #d4d4d4;
}

/* Reader Header */
.reader-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--card-bg);
    display: flex;
    align-items: center;
    padding: 0 15px;
    box-shadow: var(--shadow);
    z-index: 100;
    transition: transform 0.3s;
}

.reader-header.hidden {
    transform: translateY(-100%);
}

.back-btn {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
}

.reader-title {
    flex: 1;
    text-align: center;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0 15px;
}

.settings-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
}

/* Settings Panel */
.settings-panel {
    position: fixed;
    top: 56px;
    right: 0;
    width: 300px;
    max-width: 90vw;
    background: var(--card-bg);
    box-shadow: var(--shadow);
    transform: translateX(100%);
    transition: transform 0.3s;
    z-index: 99;
    max-height: calc(100vh - 56px);
    overflow-y: auto;
}

.settings-panel.open {
    transform: translateX(0);
}

.settings-content {
    padding: 20px;
}

.settings-content h3 {
    margin-bottom: 20px;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-muted);
}

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

.size-btn {
    width: 40px;
    height: 40px;
    border: 2px solid var(--border);
    background: var(--card-bg);
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
}

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

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

.theme-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid var(--border);
    background: var(--card-bg);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

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

#fontFamily {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
}

#lineWidth {
    width: 100%;
}

/* TOC Panel */
.toc-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 300px;
    max-width: 85vw;
    height: 100vh;
    background: var(--card-bg);
    box-shadow: var(--shadow);
    transform: translateX(-100%);
    transition: transform 0.3s;
    z-index: 101;
    display: flex;
    flex-direction: column;
}

.toc-panel.open {
    transform: translateX(0);
}

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

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

.toc-list {
    flex: 1;
    overflow-y: auto;
    list-style: none;
}

.toc-list li {
    border-bottom: 1px solid var(--border);
}

.toc-list a {
    display: block;
    padding: 15px 20px;
    color: var(--text);
    text-decoration: none;
    transition: background 0.3s;
}

.toc-list a:hover,
.toc-list a.active {
    background: rgba(74, 144, 217, 0.1);
}

.toc-list a.active {
    color: var(--primary);
    font-weight: 600;
}

/* Reader Content */
.reader-content {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 50px;
    overflow-y: auto;
    background: var(--reader-bg, #ffffff);
    transition: background 0.3s;
}

.chapter-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 30px 20px;
    font-size: 18px;
    line-height: 1.8;
    color: var(--reader-text, #333);
    transition: all 0.3s;
}

.chapter-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 20px auto;
}

.chapter-content h1,
.chapter-content h2,
.chapter-content h3 {
    margin: 1.5em 0 0.5em;
    line-height: 1.3;
}

.chapter-content p {
    margin-bottom: 1em;
    text-align: justify;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.mobi-notice {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 20px;
}

.mobi-notice ul {
    margin: 10px 0 0 20px;
}

/* Reader Footer */
.reader-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    z-index: 100;
    transition: transform 0.3s;
}

.reader-footer.hidden {
    transform: translateY(100%);
}

.nav-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
}

.nav-btn:disabled {
    background: var(--border);
    cursor: not-allowed;
}

.toc-btn {
    background: none;
    border: 2px solid var(--border);
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
}

.chapter-progress {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Overlay */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 98;
}

.overlay.show {
    opacity: 1;
    pointer-events: auto;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .header {
        padding: 30px 15px;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }
    
    .upload-box {
        padding: 30px 20px;
    }
    
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 15px;
    }
    
    .book-cover {
        height: 160px;
    }
    
    .chapter-content {
        padding: 20px 15px;
        font-size: 16px;
    }
    
    .reader-title {
        font-size: 0.9rem;
    }
    
    .nav-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .books-grid {
        grid-template-columns: 1fr;
    }
    
    .settings-panel {
        width: 100%;
    }
}
/* ===== ADMIN KEY BOX ===== */
.admin-key-box {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

/* Input */
#adminKey {
    width: 220px;
    max-width: 90%;
    padding: 8px 12px;
    font-size: 14px;
    border-radius: 8px;
    border: 1px solid #ccc;
    outline: none;
    transition: all 0.2s ease;
    text-align: center;
    background: #f9f9f9;
}

/* Focus */
#adminKey:focus {
    border-color: #4CAF50;
    background: #fff;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

/* Placeholder */
#adminKey::placeholder {
    color: #999;
    font-size: 13px;
}

/* Khi nhập đúng (nếu bạn muốn thêm class JS) */
#adminKey.valid {
    border-color: #4CAF50;
    background: #eaffea;
}

/* Khi sai */
#adminKey.invalid {
    border-color: #f44336;
    background: #ffecec;
}
.header-top{display:flex;gap:10px}
#menuBtn{font-size:20px;border:none;background:none}

.side-menu{
position:fixed;left:-200px;top:0;width:200px;height:100%;
background:#fff;transition:.3s;padding:20px
}
.side-menu.open{left:0}

#searchInput{
width:100%;padding:8px;margin-top:10px;
border-radius:8px;border:1px solid #ccc
}

.hidden-delete{display:none}

.book-card{
padding:10px;margin:10px;border:1px solid #ddd;border-radius:10px
}
/* ===== AUTO NEXT ===== */
.next-loader {
    text-align: center;
    padding: 20px;
    color: #888;
    display: none;
}

/* Smooth scroll */
html {
    scroll-behavior: smooth;
}

/* Tối ưu mobile đọc */
.reader-content {
    max-width: 800px;
    margin: auto;
}

/* Dark mode đẹp hơn */
.theme-dark {
    background: #111;
    color: #ddd;
}
.book-card {
    background: #111;
    border-radius: 12px;
    padding: 12px;
    margin: 10px;
    color: #fff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

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

.format {
    font-size: 12px;
    opacity: 0.6;
}

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

.upload-box {
    cursor: pointer;
}

.btn {
    padding: 6px 10px;
    border-radius: 6px;
    text-decoration: none;
    display: inline-block;
    margin: 2px;
}

.btn-read {
    background: #1890ff;
    color: #fff;
}

.btn-download {
    background: #52c41a;
    color: #fff;
}

.btn-delete {
    background: #ff4d4f;
    color: #fff;
    border: none;
}