/* ==========================================
   Chapter Reading Page Styles
   ========================================== */

/* Reading Container */
.reading-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
}
.container {
    padding: 0px!important;
}

/* Chapter Header */
.chapter-header {
    background: var(--bg-color);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
    text-align: center;
}

.chapter-header h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.chapter-header .story-link {
    color: var(--text-light);
    font-size: 1.125rem;
}

.chapter-header .story-link:hover {
    color: var(--primary-color);
}

/* Chapter Navigation */
.chapter-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
}

.nav-btn {
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    flex: 1;
    max-width: 200px;
}

.nav-btn:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: scale(1.05);
}

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

.chapter-select-wrapper {
    flex: 2;
    position: relative;
}

.chapter-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    background: var(--bg-color);
    cursor: pointer;
    transition: var(--transition);
}

.chapter-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Settings Panel */
.settings-toggle {
    position: fixed;
    left: 1rem;
    bottom: 1rem;
    width: 56px;
    height: 56px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
    z-index: 999;
}

.settings-toggle:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

.settings-panel {
    position: fixed;
    right: -400px;
    top: 0;
    width: 400px;
    height: 100vh;
    background: var(--bg-color);
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.1);
    padding: 2rem;
    overflow-y: auto;
    transition: right 0.3s ease;
    z-index: 1000;
}

.settings-panel.active {
    right: 0;
}

.settings-panel h3 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.setting-group {
    margin-bottom: 2rem;
}

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

/* Theme Buttons */
.theme-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.theme-btn {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
}

.theme-btn.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.theme-light {
    background: #ffffff;
    color: #1f2937;
}

.theme-dark {
    background: #1f2937;
    color: #ffffff;
}

.theme-sepia {
    background: #f4ecd8;
    color: #5c4b37;
}

/* Font Family Buttons */
.font-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.font-btn {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-color);
}

.font-btn.active {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.05);
}

/* Range Inputs */
.range-input {
    width: 100%;
    margin-top: 0.5rem;
}

.range-value {
    display: inline-block;
    margin-left: 1rem;
    font-weight: 600;
    color: var(--primary-color);
}

/* Chapter Content */
.chapter-content {
    background: var(--reader-bg, #ffffff);
    color: var(--reader-color, #1f2937);
    padding: 3rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    font-family: var(--reader-font, Georgia, serif);
    font-size: var(--reader-size, 18px);
    line-height: var(--reader-line-height, 1.8);
    min-height: 500px;
    transition: all 0.3s ease;
}

.chapter-content p {
    margin-bottom: 1.5em;
    text-align: justify;
    text-indent: 2em;
}

.chapter-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1.5em auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.chapter-content b,
.chapter-content strong {
    font-weight: 700;
    color: var(--reader-color, #1f2937);
}

.chapter-content i,
.chapter-content em {
    font-style: italic;
}

.chapter-content u {
    text-decoration: underline;
}

/* Loading State */
.chapter-content.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Close Settings Button */
.close-settings {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 32px;
    height: 32px;
    background: var(--bg-gray);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.close-settings:hover {
    background: var(--border-color);
}

/* Theme Overlays */
body[data-theme="dark"] {
    --bg-color: #1f2937;
    --bg-gray: #111827;
    --text-color: #f9fafb;
    --text-light: #9ca3af;
    --border-color: #374151;
}

body[data-theme="sepia"] {
    --bg-color: #f4ecd8;
    --bg-gray: #e8dcc4;
    --text-color: #5c4b37;
    --text-light: #8b7355;
    --border-color: #d4c4a8;
}

/* Keyboard Shortcuts Hint */
.shortcuts-hint {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    padding: 0.75rem 1.25rem;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.shortcuts-hint.show {
    opacity: 1;
}

/* Responsive */
@media (max-width: 768px) {
    .reading-container {
        padding: 1rem 0.5rem;
    }

    .chapter-content {
        padding: 0.5rem;
    }

    .settings-panel {
        width: 100%;
        right: -100%;
    }

    .chapter-nav {
        flex-direction: column;
    }

    .nav-btn {
        max-width: none;
        width: 100%;
    }

    .settings-toggle {
        right: 1rem;
        bottom: 1rem;
        width: 48px;
        height: 48px;
    }
}

/* ==========================================
   Chapter List Modal Styles
   ========================================== */

/* Modal Overlay */
.chapter-list-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
    padding: 1rem;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Modal Container */
.chapter-list-modal {
    background: var(--bg-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
    overflow: hidden;
}

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

/* Modal Header */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 2px solid var(--border-color);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: white;
    font-weight: 700;
}

.modal-close {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    line-height: 1;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Modal Body */
.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    min-height: 300px;
    max-height: 60vh;
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    gap: 1rem;
}

.loading-state p {
    color: var(--text-light);
    font-size: 1rem;
    margin: 0;
}

/* Chapter List Table */
.chapter-list {
    width: 100%;
}

.chapter-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.chapter-table thead {
    background: var(--bg-gray);
    position: sticky;
    top: 0;
    z-index: 10;
}

.chapter-table th {
    padding: 0.875rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-color);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.chapter-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.chapter-table tbody tr:hover {
    background: var(--bg-gray);
    transform: scale(1.01);
}

.chapter-table tbody tr.current-chapter {
    background: rgba(59, 130, 246, 0.1);
    border-left: 4px solid var(--primary-color);
}

.chapter-table tbody tr.current-chapter:hover {
    background: rgba(59, 130, 246, 0.15);
}

.chapter-table td {
    padding: 0.875rem 1rem;
}

.chapter-number {
    font-weight: 700;
    color: var(--primary-color);
    white-space: nowrap;
    width: 80px;
}

.chapter-title {
    color: var(--text-color);
    max-width: 350px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chapter-views {
    color: var(--text-light);
    font-size: 0.875rem;
    text-align: right;
    width: 100px;
}

/* Modal Footer */
.modal-footer {
    border-top: 2px solid var(--border-color);
    padding: 1.5rem;
    background: var(--bg-gray);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Pagination Controls */
.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.pagination-btn {
    padding: 0.75rem 1.25rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.pagination-btn:disabled {
    background: var(--border-color);
    color: var(--text-light);
    cursor: not-allowed;
    opacity: 0.6;
}

.chapter-info {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.95rem;
    white-space: nowrap;
}

/* Quick Navigation */
.quick-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.quick-nav label {
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
    font-size: 0.95rem;
}

.quick-nav input {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    background: var(--bg-color);
    transition: var(--transition);
}

.quick-nav input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.quick-nav-btn {
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.quick-nav-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chapter-list-modal {
        max-width: 100%;
        max-height: 95vh;
        margin: 0;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-header h3 {
        font-size: 1.25rem;
    }

    .modal-body {
        padding: 1rem;
        max-height: 50vh;
    }

    .modal-footer {
        padding: 1rem;
    }

    .chapter-table {
        font-size: 0.875rem;
    }

    .chapter-table th,
    .chapter-table td {
        padding: 0.625rem 0.5rem;
    }

    .hide-mobile {
        display: none;
    }

    .chapter-title {
        max-width: 200px;
    }

    .pagination-controls {
        flex-wrap: wrap;
    }

    .pagination-btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    .quick-nav {
        flex-wrap: wrap;
    }

    .quick-nav label {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .quick-nav input {
        flex: 1;
        min-width: 0;
    }

    .quick-nav-btn {
        padding: 0.75rem 1.25rem;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .chapter-number {
        width: 60px;
    }

    .chapter-title {
        max-width: 150px;
    }

    .pagination-btn span {
        font-size: 0.8rem;
    }

    .chapter-info {
        font-size: 0.875rem;
    }
}