/* ========================================================================== */
/* Manga List (list and grid views, empty states)                              */
/* Load order: 6                                                               */
/* Styles for list rows, grid cards, toggles, and "no content" states.         */
/* ========================================================================== */
/* Manga List - header and toggle */
.manga-list-header {
    text-align: center;
    margin-top: 3rem;
    margin-bottom: 2rem;
    padding: 2rem 0;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    color: var(--text-primary);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

.library-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
    width: 100%;
    overflow-x: hidden;
}

.view-toggle {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.sort-controls,
.filter-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.filter-controls {
    gap: 20px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tag-filter-group {
    position: relative;
}

.tag-filter-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.tag-filter-toggle {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 150px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    max-width: 100%;
    box-sizing: border-box;
}

.tag-filter-toggle span:first-child {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tag-filter-toggle:hover {
    border-color: var(--accent-color);
    background: var(--bg-primary);
}

.tag-filter-count {
    background: var(--accent-color);
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

.tag-filter-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    min-width: 250px;
    max-width: 400px;
    max-height: 400px;
    overflow-y: auto;
    padding: 12px;
}

.tag-filter-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.tag-filter-action {
    flex: 1;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tag-filter-action:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
    border-color: var(--accent-color);
}

.tag-filter-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.tag-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease;
    user-select: none;
}

.tag-checkbox-label:hover {
    background: var(--bg-tertiary);
}

.tag-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-color);
}

.tag-checkbox-label span {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.control-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

.control-select {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 150px;
}

.control-select:hover {
    border-color: var(--accent-color);
    background: var(--bg-primary);
}

.control-select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(var(--accent-color-rgb), 0.1);
}

.filter-toggle {
    display: flex;
    justify-content: center;
    align-items: center;
}

.toggle-switch {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.toggle-switch input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: relative;
    width: 50px;
    height: 26px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 26px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    top: 2px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.toggle-switch input[type="checkbox"]:checked + .toggle-slider {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

.toggle-switch input[type="checkbox"]:checked + .toggle-slider::before {
    transform: translateX(24px);
    background-color: white;
}

.toggle-switch:hover .toggle-slider {
    border-color: var(--accent-color);
}

.toggle-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.view-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

.view-btn:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
    border-color: var(--accent-color);
}

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

.view-btn .icon {
    font-size: 1.1rem;
}

.view-btn .text {
    font-size: 0.9rem;
}

.manga-list-header h1 {
    margin: 0 0 0.5rem 0;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.manga-count {
    margin: 0;
    font-size: 1.1rem;
    opacity: 0.9;
    color: var(--text-secondary);
}

/* List View */
.manga-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 2rem;
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.manga-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    min-height: 70px;
    position: relative;
    overflow: hidden;
    width: 100%;
}

.manga-list-item:hover {
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
    border-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.manga-list-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(135deg, var(--accent-color), var(--primary-color));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.manga-list-item:hover::before {
    opacity: 1;
}

.manga-list-info {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 24px;
    padding-left: 8px;
    padding-right: 16px;
}

.manga-list-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 220px;
    max-width: 350px;
    letter-spacing: 0.3px;
}

.manga-list-right {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
}

.manga-list-stats {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.manga-list-status {
    color: var(--secondary-color);
    font-weight: 600;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-tertiary) 100%);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    border: 1px solid var(--secondary-color);
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.manga-list-chapters {
    color: var(--accent-color);
    font-weight: 600;
    font-size: 1rem;
    background: rgba(69, 183, 209, 0.1);
    padding: 4px 10px;
    border-radius: 15px;
    border: 1px solid rgba(69, 183, 209, 0.2);
    text-align: right;
}

.manga-list-actions {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
    align-items: center;
}

.manga-list-actions .btn {
    padding: 8px 16px;
    font-size: 0.9rem;
    min-width: 80px;
    text-align: center;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
}

@media (min-width: 1024px) {
    .manga-list {
        gap: 12px;
        max-width: 1200px;
        margin: 0 auto;
    }

    .manga-list-item {
        padding: 18px 28px;
        min-height: 75px;
    }

    .manga-list-info {
        gap: 28px;
    }

    .manga-list-title {
        font-size: 1.3rem;
        min-width: 280px;
        max-width: 450px;
        letter-spacing: 0.4px;
    }

    .manga-list-stats {
        gap: 24px;
        font-size: 1rem;
    }

    .manga-list-actions .btn {
        padding: 10px 20px;
        font-size: 0.95rem;
        min-width: 90px;
        height: 40px;
        border-radius: 10px;
    }
}

@media (max-width: 768px) {
    .manga-list-item {
        padding: 10px;
    }
}

/* Grid View */
.manga-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 260px);
    justify-content: center;
    gap: 2rem;
    margin-top: 2rem;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    align-items: stretch;
}

@media (min-width: 768px) and (max-width: 1023px) {
    .manga-grid {
        grid-template-columns: repeat(auto-fill, 260px);
        justify-content: center;
        max-width: 800px;
    }
}

@media (min-width: 1024px) {
    .manga-grid {
        grid-template-columns: repeat(auto-fill, 260px);
        justify-content: center;
        max-width: 1200px;
    }
}

.manga-card {
    background: var(--bg-secondary);
    border-radius: 15px;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
}

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

.manga-cover {
    width: 100%;
    height: 280px;
    overflow: hidden;
    position: relative;
}

.manga-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.manga-card:hover .manga-cover img {
    transform: scale(1.05);
}

.manga-info {
    padding: 1.5rem;
    display: block !important;
}

.manga-card .manga-info {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex: 1;
    min-height: 180px;
}

.manga-card .manga-stats {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 0;
}

.manga-card .manga-actions {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-top: auto;
}

/* Grid card title truncation */
.manga-card .manga-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    max-height: calc(1.3em * 2);
    margin-bottom: 1rem;
}

.manga-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
    color: var(--text-primary);
    line-height: 1.3;
}

.manga-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.chapter-count {
    color: var(--accent-color);
    font-weight: 500;
}

.manga-status {
    color: var(--secondary-color);
    font-weight: 500;
    background: var(--bg-tertiary);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    border: 1px solid var(--border-color);
}

.manga-actions {
    display: flex;
    gap: 0.8rem;
}

.manga-actions .btn {
    flex: 1;
    text-align: center;
    text-decoration: none;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
}

/* Empty States */
.no-mangas {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

.no-mangas-content {
    text-align: center;
    padding: 3rem;
    background: var(--bg-secondary);
    border-radius: 15px;
    box-shadow: var(--shadow);
    max-width: 500px;
    border: 1px solid var(--border-color);
}

.no-mangas-content h2 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.no-mangas-content p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1rem;
}

.no-mangas-content code {
    background: var(--bg-tertiary);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    color: var(--primary-color);
    border: 1px solid var(--border-color);
}

/* Mobile list/grid responsive layout */
@media (max-width: 768px) {
    .manga-list-header {
        margin-top: 2rem;
        margin-bottom: 1.5rem;
        padding: 1.25rem 1rem;
    }

    .library-controls {
        gap: 15px;
    }

    .sort-controls,
    .filter-controls {
        flex-direction: column;
        gap: 10px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        padding: 0;
    }

    .filter-group {
        width: 100%;
        max-width: 100%;
        justify-content: space-between;
        box-sizing: border-box;
    }

    .tag-filter-group {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .tag-filter-container {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .tag-filter-toggle {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .tag-filter-dropdown {
        position: absolute;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .control-select {
        flex: 1;
        min-width: 0;
    }

    .toggle-label {
        font-size: 0.85rem;
    }

    .manga-list {
        gap: 10px;
        padding: 0 12px;
    }

    .manga-list-item {
        padding: 12px 14px;
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    .manga-list-info {
        padding: 0;
        gap: 12px;
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    .manga-list-title {
        max-width: 100%;
        min-width: 0;
        white-space: normal;
        font-size: 1.05rem;
        text-align: center;
    }

    .manga-list-right {
        margin-left: 0;
        gap: 10px;
        flex-wrap: wrap;
        width: 100%;
        justify-content: center;
    }

    .manga-list-stats {
        gap: 10px;
        font-size: 0.85rem;
        justify-content: center;
    }

    .manga-list-chapters {
        font-size: 0.9rem;
        padding: 3px 8px;
        text-align: center;
    }

    .manga-list-actions {
        width: 100%;
        gap: 10px;
    }

    .manga-list-actions .btn {
        flex: 1 1 48%;
        min-width: 0;
        height: 38px;
        padding: 10px 12px;
    }

    /* Grid becomes two columns on small tablets/large phones */
    .manga-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1rem;
        padding: 0 12px;
    }

    .manga-grid .manga-cover {
        height: 180px;
    }

    .manga-grid .manga-info {
        padding: 0.75rem;
        min-height: auto;
    }

    .manga-grid .manga-title {
        font-size: 0.85rem;
        margin-bottom: 0.5rem;
        line-height: 1.2;
        max-height: calc(1.2em * 2);
    }

    .manga-grid .manga-stats {
        font-size: 0.7rem;
        margin-bottom: 0.5rem;
        flex-direction: column;
        gap: 0.25rem;
    }

    /* Hide date on mobile */
    .manga-grid .manga-status {
        display: none;
    }

    /* Change "203 chapitres" to "c203" on mobile */
    .manga-grid .chapter-count {
        position: relative;
        font-size: 0; /* Hide original text */
    }

    .manga-grid .chapter-count::before {
        content: "c";
        font-size: 0.7rem;
        color: var(--accent-color);
        font-weight: 500;
    }

    .manga-grid .chapter-count::after {
        content: attr(data-chapters);
        font-size: 0.7rem;
        color: var(--accent-color);
        font-weight: 500;
    }

    .manga-grid .manga-actions .btn {
        padding: 0.5rem 0.6rem;
        font-size: 0.75rem;
    }

    .view-toggle {
        flex-direction: row;
        gap: 8px;
        margin-top: 15px;
        justify-content: center;
    }

    .view-btn {
        flex: 1;
        max-width: 150px;
        justify-content: center;
        padding: 12px 16px;
    }
}

/* Very small phones */
@media (max-width: 480px) {
    .manga-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem;
    }

    .manga-grid .manga-cover {
        height: 160px;
    }

    .manga-grid .manga-info {
        padding: 0.5rem;
    }

    .manga-grid .manga-title {
        font-size: 0.75rem;
        margin-bottom: 0.4rem;
    }

    .manga-grid .manga-stats {
        font-size: 0.65rem;
    }

    .manga-grid .manga-actions .btn {
        padding: 0.4rem 0.5rem;
        font-size: 0.7rem;
    }

    .manga-list-actions .btn {
        flex-basis: 100%;
    }
}

/* ========================================================================== */
/* Horizontal Scrolling Lists for Home Page                                   */
/* ========================================================================== */
.manga-section {
    margin: 3rem 0;
    padding: 0 1rem;
    /* Prevent horizontal overflow */
    width: 100%;
    overflow-x: hidden;
}

/* Mobile styles - reduce spacing between sections */
@media (max-width: 768px) {
    .manga-section {
        margin: 1rem 0;
        padding: 0 0.5rem;
    }

    .manga-section:first-of-type {
        margin-top: 0.5rem;
    }
}

@media (max-width: 480px) {
    .manga-section {
        margin: 0.75rem 0;
        padding: 0 0.5rem;
    }

    .manga-section:first-of-type {
        margin-top: 0.5rem;
    }
}

.section-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    padding-left: 0.5rem;
}

.manga-scroll-container {
    position: relative;
    width: 100%;
    /* Container has its own horizontal scrollbar */
    overflow-x: auto;
    overflow-y: hidden;
    /* Prevent scroll chaining - isolate this container */
    overscroll-behavior-x: contain;
    overscroll-behavior-y: none;
    /* Isolate scrolling context */
    isolation: isolate;
    /* Smooth scrolling */
    scroll-behavior: smooth;
    /* Scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) var(--bg-tertiary);
}

.manga-scroll-container::-webkit-scrollbar {
    height: 10px;
}

.manga-scroll-container::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 5px;
    margin: 0 0.5rem;
}

.manga-scroll-container::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 5px;
}

.manga-scroll-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

.manga-scroll-list {
    display: flex;
    gap: 1.5rem;
    /* List itself doesn't scroll, container does */
    overflow: visible;
    padding: 1rem 0.5rem;
}

.manga-scroll-list .manga-card {
    flex: 0 0 260px;
    min-width: 260px;
    max-width: 260px;
    height: auto;
}

/* Mobile styles for scroll list cards */
@media (max-width: 768px) {
    .manga-scroll-list {
        gap: 1rem;
        padding: 0.5rem 0.25rem;
    }

    .manga-scroll-list .manga-card {
        flex: 0 0 140px;
        min-width: 140px;
        max-width: 140px;
    }

    .manga-scroll-list .manga-cover {
        height: 180px;
    }

    .manga-scroll-list .manga-info {
        padding: 0.75rem;
        min-height: auto;
    }

    .manga-scroll-list .manga-title {
        font-size: 0.85rem;
        margin-bottom: 0.5rem;
        line-height: 1.2;
        max-height: calc(1.2em * 2);
    }

    .manga-scroll-list .manga-stats {
        font-size: 0.7rem;
        margin-bottom: 0.5rem;
        flex-direction: column;
        gap: 0.25rem;
    }

    /* Hide date on mobile */
    .manga-scroll-list .manga-status {
        display: none;
    }

    /* Change "203 chapitres" to "c203" on mobile */
    .manga-scroll-list .chapter-count {
        position: relative;
        font-size: 0; /* Hide original text */
    }

    .manga-scroll-list .chapter-count::before {
        content: "c";
        font-size: 0.7rem;
        color: var(--accent-color);
        font-weight: 500;
    }

    .manga-scroll-list .chapter-count::after {
        content: attr(data-chapters);
        font-size: 0.7rem;
        color: var(--accent-color);
        font-weight: 500;
    }

    .manga-scroll-list .manga-actions .btn {
        padding: 0.5rem 0.6rem;
        font-size: 0.75rem;
    }
}

/* Very small phones */
@media (max-width: 480px) {
    .manga-scroll-list .manga-card {
        flex: 0 0 120px;
        min-width: 120px;
        max-width: 120px;
    }

    .manga-scroll-list .manga-cover {
        height: 160px;
    }

    .manga-scroll-list .manga-info {
        padding: 0.5rem;
    }

    .manga-scroll-list .manga-title {
        font-size: 0.75rem;
        margin-bottom: 0.4rem;
    }

    .manga-scroll-list .manga-stats {
        font-size: 0.65rem;
    }

    .manga-scroll-list .manga-actions .btn {
        padding: 0.4rem 0.5rem;
        font-size: 0.7rem;
    }
}