/* ============================================
   LightNovel - Main Stylesheet
   Organized by component for easy maintenance
   ============================================ */

/* ============================================
   1. CSS Variables (Theme)
   ============================================ */
:root {
    --primary: #007bff;
    --primary-dark: #0056b3;
    --secondary: #6c757d;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --dark: #2c3e50;
    --light: #f8f9fa;
    
    --bg-gradient-start: #f5f7fa;
    --bg-gradient-end: #c3cfe2;
    
    --card-radius: 15px;
    --card-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    --card-shadow-hover: 0 15px 35px rgba(0, 0, 0, 0.15);
    
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.4s ease;
}

/* Dark mode variables */
[data-bs-theme="dark"] {
    --bg-gradient-start: #1a1a2e;
    --bg-gradient-end: #16213e;
    --card-bg: #343a40;
    --text-primary: #f8f9fa;
    --text-secondary: #adb5bd;
}

/* ============================================
   2. Base Styles
   ============================================ */
body {
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
}

/* Navbar spacer for fixed header */
.navbar-spacer {
    height: 80px;
}

@media (max-width: 991.98px) {
    .navbar-spacer {
        height: 70px;
    }
}

/* ============================================
   3. Hero Section
   ============================================ */
.hero-section {
    background: white;
    border-radius: 20px;
    padding: 3rem 2rem;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    animation: fadeInUp 0.6s ease-out;
}

.hero-section h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 1rem;
}

.hero-section p {
    font-size: 1.2rem;
    color: var(--secondary);
    max-width: 600px;
    margin: 0 auto;
}

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

/* ============================================
   4. Search Form
   ============================================ */
.search-form {
    background: white;
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.search-form .form-control,
.search-form .form-select {
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 0.75rem 1rem;
    transition: all var(--transition-normal);
    background: #f8f9fa;
}

.search-form .form-control:focus,
.search-form .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    background: white;
    transform: translateY(-2px);
}

.search-form .btn {
    border-radius: 12px;
    padding: 0.75rem 2rem;
    font-weight: 600;
    transition: all var(--transition-normal);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
}

.search-form .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 123, 255, 0.3);
}

/* ============================================
   5. Horizontal Scroll (Novel Cards)
   ============================================ */
.horizontal-scroll {
    position: relative;
    overflow: hidden;
    border-radius: var(--card-radius);
    background: white;
    box-shadow: var(--card-shadow);
    margin-bottom: 2rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    font-weight: 700;
    color: var(--dark);
}

.section-title {
    font-size: 1.5rem;
}

.novels-scroller {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 1.5rem;
    padding: 1.5rem;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.novels-scroller::-webkit-scrollbar {
    display: none;
}

/* Novel Card */
.novel-card {
    background: white;
    border: none;
    border-radius: var(--card-radius);
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: all var(--transition-slow) cubic-bezier(0.175, 0.885, 0.32, 1.275);
    flex: 0 0 250px;
    scroll-snap-align: start;
    position: relative;
}

.novel-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--card-shadow-hover);
}

.novel-card .card-img-top {
    height: 250px;
    object-fit: cover;
    transition: transform var(--transition-slow);
    width: 100%;
}

.novel-card:hover .card-img-top {
    transform: scale(1.05);
}

.novel-card .card-body {
    padding: 1rem;
}

.novel-card .card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 0.5rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.novel-card .categories {
    color: var(--secondary);
    font-size: 0.8rem;
}

.card-img-placeholder {
    height: 250px;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary);
    font-size: 3rem;
}

/* Scroll Arrows */
.scroll-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 10;
    backdrop-filter: blur(10px);
}

.scroll-arrow:hover {
    background: white;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.scroll-arrow-left { left: 10px; }
.scroll-arrow-right { right: 10px; }

.scroll-arrow i {
    font-size: 1.2rem;
    color: var(--primary);
}

/* ============================================
   6. Novel List (Grid View)
   ============================================ */
.novel-list-section {
    margin-bottom: 2rem;
}

.novel-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.novel-card-list {
    background: white;
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    transition: all var(--transition-normal);
    display: flex;
    flex-direction: row;
}

.novel-card-list:hover {
    transform: translateY(-3px);
    box-shadow: var(--card-shadow-hover);
}

.novel-cover {
    width: 100px;
    min-width: 100px;
    max-height: 220px;
    object-fit: cover;
    flex-shrink: 0;
}

.novel-cover-placeholder {
    width: 100px;
    min-width: 100px;
    height: 220px;
    background: #bdc3c7;
    flex-shrink: 0;
}

.novel-content {
    padding: 18px;
    flex-grow: 1;
}

.novel-title {
    font-size: 1.5em;
    font-weight: 700;
    margin: 0 0 10px 0;
    color: var(--dark);
}

.novel-title a {
    text-decoration: none;
    color: inherit;
    transition: color var(--transition-normal);
}

.novel-title a:hover {
    color: var(--primary);
}

.novel-meta {
    margin-bottom: 8px;
    font-size: 0.9em;
}

.status {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: 500;
    text-transform: uppercase;
}

.status.ongoing { background-color: var(--success); color: white; }
.status.completed { background-color: #9b59b6; color: white; }
.status.draft { background-color: var(--warning); color: white; }

.last-chapter {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #ecf0f1;
}

.last-chapter a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.last-chapter a:hover {
    text-decoration: underline;
}

/* Mobile: Horizontal scroll for novel list */
@media (max-width: 768px) {
    .novel-grid {
        overflow-x: auto;
        gap: 15px;
        padding-bottom: 10px;
    }
    
    .novel-card-list {
        flex-shrink: 0;
        width: 100%;
    }
    
    .novel-content {
        padding: 15px;
        font-size: 10px;
    }
    
    .novel-cover, .novel-cover-placeholder {
        width: 80px;
        min-width: 80px;
    }
}

/* ============================================
   7. Fantasy Section
   ============================================ */
.fantasy-section {
    margin-top: 40px;
}

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

.fantasy-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: all var(--transition-normal);
}

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

.fantasy-cover img {
    width: 100%;
    height: 260px;
    object-fit: cover;
}

.fantasy-title {
    padding: 12px;
    font-weight: 600;
    font-size: 1rem;
}

.fantasy-full-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

@media (max-width: 768px) {
    .fantasy-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .fantasy-cover img {
        height: 180px;
    }
    
    .fantasy-title {
        padding: 8px;
        font-size: 0.9rem;
        text-align: center;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

/* ============================================
   8. Novel Detail Page
   ============================================ */
.novel-header {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    animation: fadeInUp 0.6s ease-out;
}

.novel-cover {
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    transition: transform var(--transition-normal);
    max-height: 400px;
    object-fit: cover;
}

.novel-cover:hover {
    transform: scale(1.02);
}

.stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-item {
    background: var(--light);
    padding: 0.75rem 1.25rem;
    border-radius: 25px;
    display: flex;
    align-items: center;
    font-weight: 600;
    transition: all var(--transition-normal);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.stat-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.stat-item i {
    margin-right: 0.5rem;
    color: var(--primary);
}

.stat-rating {
    color: var(--warning);
}

.novel-desc {
    color: #495057;
    line-height: 1.6;
    margin-bottom: 2rem;
}

.bookmark-btn {
    border-radius: 25px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    transition: all var(--transition-normal);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
}

.bookmark-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 123, 255, 0.3);
}

/* ============================================
   9. Chapters Section
   ============================================ */
.chapters-section {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.chapters-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

@media (min-width: 768px) {
    .chapters-grid {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }
}

.chapter-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    background: var(--light);
    border-radius: 10px;
    transition: all var(--transition-normal);
    gap: 10px;
}

.chapter-item:hover {
    background: #e9ecef;
    transform: translateX(5px);
}

.chapter-number {
    font-weight: 600;
    color: var(--primary);
    min-width: 80px;
}

.chapter-link {
    flex-grow: 1;
    text-decoration: none;
    color: var(--dark);
    font-weight: 500;
}

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

.chapter-date {
    font-size: 0.85em;
    color: var(--secondary);
    white-space: nowrap;
}

/* Pagination */
.pagination-wrapper {
    margin-top: 2rem;
}

.pagination .page-link {
    border-radius: 8px;
    margin: 0 0.25rem;
    transition: all var(--transition-normal);
    color: var(--primary);
}

.pagination .page-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.2);
}

.pagination .page-item.active .page-link {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-color: var(--primary);
}

/* ============================================
   10. Chapter Reading Page
   ============================================ */
.chapter-article {
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.chapter-header {
    padding: 2rem;
    border-bottom: 1px solid #e9ecef;
}

.chapter-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--dark);
    margin: 1rem 0;
}

.chapter-meta {
    color: var(--secondary);
    font-size: 0.9rem;
}

.chapter-content {
    padding: 2rem;
    line-height: 1.8;
    font-size: 1.1rem;
}

.chapter-content p {
    margin-bottom: 1.5rem;
}

.chapter-navigation {
    padding: 2rem;
    border-top: 1px solid #e9ecef;
}

.btn-chapter {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 1rem 1.5rem;
    background: var(--light);
    border-radius: 12px;
    text-decoration: none;
    color: var(--dark);
    transition: all var(--transition-normal);
}

.btn-chapter:hover {
    background: #e9ecef;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    color: var(--primary);
}

.btn-chapter i {
    font-size: 1.2rem;
}

.btn-chapter small {
    display: block;
    color: var(--secondary);
    font-size: 0.8rem;
}

/* ============================================
   11. Empty States
   ============================================ */
.empty-state, .empty-chapters {
    text-align: center;
    padding: 3rem;
    color: var(--secondary);
    background: white;
    border-radius: 15px;
    box-shadow: var(--card-shadow);
}

.empty-state i, .empty-chapters i {
    font-size: 4rem;
    margin-bottom: 1rem;
    color: var(--primary);
}

/* ============================================
   12. Error Pages
   ============================================ */
.error-card {
    text-align: center;
    padding: 3rem;
}

.error-icon {
    font-size: 5rem;
    color: var(--danger);
    margin-bottom: 1rem;
}

.error-title {
    font-size: 4rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 0.5rem;
}

.error-heading {
    font-size: 1.5rem;
    color: var(--secondary);
    margin-bottom: 1rem;
}

/* ============================================
   13. Dark Mode
   ============================================ */
[data-bs-theme="dark"] .hero-section,
[data-bs-theme="dark"] .search-form,
[data-bs-theme="dark"] .horizontal-scroll,
[data-bs-theme="dark"] .novel-card,
[data-bs-theme="dark"] .novel-card-list,
[data-bs-theme="dark"] .novel-header,
[data-bs-theme="dark"] .chapters-section,
[data-bs-theme="dark"] .chapter-article,
[data-bs-theme="dark"] .fantasy-card {
    background: #343a40 !important;
    color: #f8f9fa;
}

[data-bs-theme="dark"] .novel-title,
[data-bs-theme="dark"] .chapter-title,
[data-bs-theme="dark"] .section-title {
    color: #f8f9fa;
}

[data-bs-theme="dark"] .novel-desc,
[data-bs-theme="dark"] .chapter-content {
    color: #ced4da;
}

[data-bs-theme="dark"] .chapter-item {
    background: #495057;
}

[data-bs-theme="dark"] .chapter-item:hover {
    background: #6c757d;
}

[data-bs-theme="dark"] .btn-chapter {
    background: #495057;
    color: #f8f9fa;
}

/* ============================================
   14. Utility Classes
   ============================================ */
.text-gradient {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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