/**
 * CATALOG PAGE STYLES - PREMIUM EDITION
 * Styles pour la page du catalogue
 */

/* ==================== CONTAINER ==================== */
.catalog-container {
    padding-top: var(--space-xl);
    padding-bottom: var(--space-3xl);
    position: relative;
    max-width: 1400px;
    margin: 0 auto;
    padding-left: var(--space-md);
    padding-right: var(--space-md);
    z-index: 1;
    overflow-x: hidden;
    overflow-x: clip; /* Modern clean constraint avoiding scrollbars entirely */
}

/* Ambient Background Glow */
.catalog-container::before {
    content: '';
    position: absolute;
    top: -100px;
    left: 20%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.15) 0%, transparent 70%);
    z-index: -1;
    pointer-events: none;
    filter: blur(50px);
    opacity: 0.8;
}

.catalog-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: var(--space-2xl);
    align-items: start;
}


/* ==================== MAIN CONTENT ==================== */
.catalog-main {
    min-width: 0;
}

/* ==================== SEARCH SECTION ==================== */
.catalog-search {
    margin-bottom: var(--space-2xl);
}

.catalog-search-wrapper {
    position: relative;
    width: 100%;
}

.catalog-search-input {
    width: 100%;
    padding: 20px 30px;
    padding-right: 60px;
    /* Glassmorphism */
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    color: var(--color-text-primary);
    font-size: 1.2rem;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.catalog-search-input:focus {
    background: rgba(30, 30, 30, 0.8);
    border-color: var(--color-purple-primary);
    box-shadow:
        0 15px 40px rgba(0, 0, 0, 0.4),
        0 0 0 2px rgba(139, 92, 246, 0.3);
    transform: translateY(-2px);
    outline: none;
}

.catalog-search-icon {
    position: absolute;
    right: 25px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.4rem;
    pointer-events: none;
    opacity: 0.8;
    color: var(--color-text-muted);
}

/* ==================== CATALOG GRID ==================== */
.catalog-section {
    position: relative;
    margin-top: var(--space-lg);
}

/* Section Title decoration */
.block-title {
    position: relative;
    display: inline-block;
    padding-bottom: 5px;
}

/* Layout handled by Bootstrap row-cols */

@media (max-width: 480px) {

    .manga-info {
        padding: var(--space-sm);
    }

    .manga-title {
        font-size: 0.95rem;
    }

    .manga-meta {
        font-size: 0.75rem;
    }

    .badge-status,
    .badge-type {
        font-size: 0.55rem;
        padding: 4px 6px;
    }

    .manga-badges {
        top: 8px;
        left: 8px;
    }

    .badge-rating {
        font-size: 0.55rem;
        padding: 4px 8px;
        bottom: 8px;
        right: 8px;
    }
}

/* ==================== PREMIUM MANGA CARD ==================== */
.manga-card {
    /* Glassmorphism Base */
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    text-decoration: none;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0; /* CRITICAL: Prevent flexbox blowout */
}

.manga-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.1),
        0 0 20px rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.5);
    background: var(--glass-bg-hover);
    z-index: 10;
}

/* Glowing Border Effect on Hover */
.manga-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(139, 92, 246, 0.8), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.manga-card:hover::before {
    opacity: 1;
}

.manga-cover {
    width: 100%;
    aspect-ratio: 2/3;
    overflow: hidden;
    position: relative;
}

.manga-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
    filter: brightness(0.9);
}

.manga-card:hover .manga-image {
    transform: scale(1.1);
    filter: brightness(1.1);
}

/* Premium Badges */
.manga-badges {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 2;
}

.badge-status,
.badge-type {
    background: rgba(0, 0, 0, 0.6);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: fit-content;
}

.badge-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background-color: var(--color-accents-success, #10b981);
    border-radius: 50%;
    box-shadow: 0 0 6px #10b981;
}

.badge-type {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.8), rgba(236, 72, 153, 0.8));
    border-color: rgba(236, 72, 153, 0.4);
    box-shadow: 0 4px 10px rgba(236, 72, 153, 0.3);
}

.badge-rating {
    position: absolute;
    bottom: 12px;
    right: 12px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.7);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fbbf24;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    z-index: 2;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.manga-info {
    padding: var(--space-lg);
    flex: 1;
    display: flex;
    flex-direction: column;
    /* Clean gradient overlay */
    background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.4) 100%);
    min-width: 0; /* CRITICAL: Allow text-overflow ellipsis to function natively inside a flex container */
}

.manga-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: var(--space-xs);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    word-break: break-word; /* CRITICAL: Prevent long words from breaking flex boundaries */
}

.manga-meta {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ==================== PREMIUM SIDEBAR ==================== */
.trending-sidebar {
    position: sticky;
    top: 120px;
}

.trending-block {
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-xl);
    position: relative;
    overflow: hidden;
}

/* Shine effect on sidebar */
.trending-block::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.02) 0%, transparent 100%);
    pointer-events: none;
}

.trending-header {
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--color-border);
}

.trending-title {
    font-size: 1.4rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--color-text-primary);
}

.trending-title span {
    filter: drop-shadow(0 0 8px rgba(253, 186, 116, 0.6));
}

.trending-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.trending-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 10px;
    border-radius: var(--radius-lg);
    text-decoration: none;
    transition: all 0.2s ease;
    background: transparent;
    border: 1px solid transparent;
    position: relative;
}

.trending-item:hover {
    background: var(--glass-bg-hover);
    border-color: var(--color-border-hover);
    transform: translateX(5px);
}

.trending-rank {
    font-size: 2rem;
    font-weight: 900;
    color: transparent;
    -webkit-text-stroke: 2px var(--color-border);
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%) rotate(-10deg);
    z-index: 0;
    pointer-events: none;
    transition: all 0.3s;
}

.trending-item:hover .trending-rank {
    -webkit-text-stroke: 2px var(--color-border-hover);
    transform: translateY(-50%) rotate(0deg) scale(1.1);
}

.trending-cover {
    width: 50px;
    height: 75px;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    z-index: 1;
    transition: transform 0.2s;
}

.trending-item:hover .trending-cover {
    transform: scale(1.1) rotate(2deg);
}

.trending-info {
    flex: 1;
    z-index: 1;
    min-width: 0;
}

.trending-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trending-stats {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.trending-stat-icon {
    font-size: 0.9rem;
    color: var(--color-purple-primary);
}

@media (max-width: 1024px) {
    .catalog-layout {
        display: flex;
        flex-direction: column;
        gap: var(--space-lg);
    }
    
    /* Make the inner wrapper invisible to flex so its children can be reordered */
    .catalog-main {
        display: contents;
    }
    
    /* 1. Search Bar stays precisely at the top */
    .catalog-search {
        order: 1;
        width: 100%;
        margin-bottom: 0;
    }
    
    /* 2. Tendance moves to the middle */
    .trending-sidebar {
        order: 2;
        width: 100%;
    }
    
    /* 3. Catalogue Grid is at the bottom */
    .catalog-section {
        order: 3;
        width: 100%;
        margin-top: 0;
    }
    
    /* Mobile/Tablet Horizontal Carousel Styling for Tendance */
    .trending-sidebar {
        position: relative;
        top: 0;
    }
    
    .trending-block {
        padding: var(--space-md) 0; /* Remove horizontal padding so items scroll edge-to-edge */
    }
    
    .trending-header {
        padding-left: var(--space-md);
        padding-right: var(--space-md);
        margin-bottom: var(--space-md);
    }
    
    .trending-list {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        gap: var(--space-md);
        padding-left: var(--space-md);
        padding-right: var(--space-md);
        padding-bottom: 10px;
        -ms-overflow-style: none; /* IE and Edge */
        scrollbar-width: none; /* Firefox */
    }
    
    .trending-list::-webkit-scrollbar {
        display: none;
    }
    
    .trending-item {
        flex-direction: column; /* Stack image and text */
        min-width: 112px; /* Slight bump for touch area */
        flex-shrink: 0; /* Prevent squishing */
        scroll-snap-align: start;
        padding: 5px;
        border: none;
        background: transparent;
        text-align: center;
        align-items: center;
        justify-content: flex-start;
    }
    
    .trending-item:hover {
        transform: translateY(-4px);
        background: transparent;
    }
    
    .trending-cover {
        width: 90px;
        height: 135px;
        margin-bottom: var(--space-sm);
        border-radius: var(--radius-md);
    }
    
    .trending-rank {
        top: -5px;
        left: 5px;
        right: auto;
        transform: rotate(-10deg);
        z-index: 5;
        font-size: 1.5rem;
    }
    
    .trending-item:hover .trending-rank {
        transform: translateY(-2px) rotate(0deg) scale(1.1);
    }
    
    .trending-info {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
    }
    
    .trending-name {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        font-size: 0.9rem;
        line-height: 1.2;
    }
}

/* ==================== PLACEHOLDERS ==================== */
.placeholder {
    background: linear-gradient(135deg, #1f2937, #111827);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.placeholder::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    100% {
        left: 100%;
    }
}

.placeholder-trending {
    background: var(--color-bg-secondary);
    width: 50px;
    height: 75px;
    border-radius: 8px;
    color: var(--color-text-muted);
    font-weight: 500;
}

/* ==================== PAGINATION ==================== */
.pagination {
    margin-top: var(--space-2xl);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap; /* CRITICAL: Prevent horizontal stretching on mobile */
    gap: var(--space-md);
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
}

.pagination-btn {
    padding: 10px 20px;
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: all 0.3s;
    border: 1px solid var(--color-border);
}

.pagination-btn:hover {
    background: var(--color-purple-primary);
    border-color: var(--color-purple-accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.pagination-current {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

/* Make sure pagination strictly respects mobile boundaries */
@media (max-width: 480px) {
    .pagination {
        gap: var(--space-sm);
        padding: var(--space-sm);
    }
    .pagination-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    .pagination-current {
        font-size: 0.8rem;
        /* Force line break for symmetry if needed */
        width: 100%;
        text-align: center;
        order: -1; /* Put current page on top */
        margin-bottom: 4px;
    }
}

/* ==================== GRID MARGIN OVERRIDES (PERFECT CENTERING) ==================== */
@media (max-width: 480px) {
    /* Provide safe wrapping padding since catalog lacks .home-block's generic padding */
    .catalog-section {
        padding-left: var(--space-sm);
        padding-right: var(--space-sm);
    }
    
    /* Manually lock the gutters if Bootstrap util classes (g-2) fail on edge networks */
    .catalog-grid {
        --bs-gutter-x: 0.75rem !important; /* 12px */
        --bs-gutter-y: 0.75rem !important;
        /* Zero-margin to remove the bleed, relying strictly on col padding and section padding */
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}