/* Header adjustments for list page */
body.theme-books header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
}

/* Language Selector in List */
.language-selector {
    margin-right: 15px; /* Add margin to avoid touching screen edge */
}

.language-selector select {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.4rem center;
    background-size: 0.8rem;
    padding-right: 1.8rem;
}

.language-selector select:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

.language-selector select:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.7);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

/* Base Container */
body.animated-bg {
    position: relative;
    min-height: 100vh;
    padding-bottom: 120px; /* Increased to account for fixed footer */
    box-sizing: border-box;
}

body.animated-bg::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 1px 1px, rgba(107, 70, 193, 0.15) 2px, transparent 0) 0 0 / 40px 40px,
        radial-gradient(circle at 50% 50%, rgba(107, 70, 193, 0.15) 0%, transparent 70%) center/250% 250%,
        linear-gradient(to bottom right, #f8f9ff, #ffffff);
    z-index: -1;
    animation: 
        moveDots 15s linear infinite,
        glowLight 8s ease-in-out infinite alternate;
}

@keyframes moveDots {
    0% {
        background-position: 0 0, center, 0 0;
    }
    100% {
        background-position: 40px 40px, center, 0 0;
    }
}

@keyframes glowLight {
    0% {
        background-position: 0 0, -50% -50%, 0 0;
    }
    100% {
        background-position: 40px 40px, 150% 150%, 0 0;
    }
}

/* List Container */
.list-container {
    padding: 15px;
    position: relative;
    z-index: 1;
    max-width: 1600px;
    margin: 0 auto;
    min-height: calc(100vh - 300px);
}

/* Filters */
.filters {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 0 auto 20px;
    padding: 0 20px 15px;
    box-sizing: border-box;
    position: relative;
    width: 100%;
    max-width: 1600px;
}

.filters-top {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
}

.filters input {
    width: 100%;
    max-width: 400px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 25px;
    font-size: 1rem;
    color: #333;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    margin: 0;
}

.filters select {
    width: 70%;
    max-width: 400px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 25px;
    font-size: 1rem;
    color: #333;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    margin: 0;
}

.filters input::placeholder {
    color: #aaa;
}

.filters select {
    appearance: none;
    background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24"%3E%3Cpath fill="%23666666" d="M7 10l5 5 5-5z"/%3E%3C/svg%3E');
    background-repeat: no-repeat;
    background-position: calc(100% - 15px) center;
    background-size: 25px;
}

@media (max-width: 768px) {
    .filters {
        padding: 0 15px;
    }
}

/* Sort Switch */
.sort-switch {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 20px;
}

.sort-label {
    font-size: 0.9rem;
    color: #666;
    white-space: nowrap;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--main-color, #6200ea);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* Book Grid */
.book-grid {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    justify-content: center;
    margin: 20px auto;
    max-width: 100%;
    min-height: 200px;
    opacity: 1;
    transform: none;
    margin-bottom: 40px;
}

/* Book Card */
.book-card {
    background-color: var(--card-bg-color, #ffffff);
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: 100%;
    will-change: transform, opacity;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    -webkit-tap-highlight-color: transparent; /* Supprime le highlight par défaut sur mobile */
    pointer-events: auto !important; /* Force l'interactivité immédiate */
}

/* Animation de bounce au tap/click */
.book-card:active {
    transform: scale(0.97);
    transition: transform 0.1s ease;
}

/* Effet hover seulement sur les appareils non-tactiles */
@media (hover: hover) {
    .book-card:hover {
        transform: translateY(-5px) !important;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    }
}

.cover-container {
    position: relative;
    width: 100%;
    aspect-ratio: 2/3; /* Force le ratio 2:3 sur le container */
    overflow: hidden; /* Cache tout débordement */
    background-color: #f8f9fa; /* Couleur de fond par défaut */
    border-radius: 8px;
}

.cover-container img {
    width: 100%;
    height: 100%; /* Remplit tout le container */
    object-fit: cover; /* Couvre toute la zone en gardant le ratio */
    display: block;
    transform: scale(1.02);
    transition: transform 0.3s ease;
}

/* Badges for public/private flashcards */
.book-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.6rem;
    font-weight: 600;
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.community-badge {
    background: linear-gradient(135deg, #48BB78, #38A169);
}

.private-badge {
    background: linear-gradient(135deg, #0EA5E9, #7C3AED, #EC4899);
}

/* Clickable badges for user's own Flaaash */
.book-badge.clickable-badge {
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.book-badge.clickable-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 3px 8px rgba(0,0,0,0.3);
}

.book-badge.clickable-badge:active {
    transform: scale(0.95);
}

.emoji-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    background-color: rgba(255, 255, 255, 0.1);
}

.emoji-overlay .emoji {
    font-size: 4rem;
    line-height: 1;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.book-card h3 {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin: 8px 8px 4px;
    color: var(--main-color, #6200ea);
    flex-grow: 0;
    line-height: 1.2;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    white-space: normal;
}

.book-card p {
    color: #666;
    margin: 0 8px 4px;
    font-size: 0.7rem;
    flex-grow: 0;
}

/* No Results Message */
.no-results {
    text-align: center;
    font-size: 1.1rem;
    color: #b0b0b0;
    margin-top: 20px;
}

.no-results-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    text-align: center;
    display: none;
}

.no-results-container .no-results {
    margin: 0 0 15px 0;
}

.no-results-container .weekly-update {
    margin: 0;
    padding: 0;
}

/* Responsive Design */
@media (max-width: 480px) {
    .book-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .emoji-overlay .emoji {
        font-size: 3rem;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .book-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .book-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 1025px) and (max-width: 1200px) {
    .book-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (min-width: 1201px) and (max-width: 1400px) {
    .book-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (min-width: 1401px) {
    .book-grid {
        grid-template-columns: repeat(8, 1fr);
    }
}

/* Create Button */
.create-button-container {
    display: none; /* Hidden by default */
    justify-content: center;
    padding: 20px;
    margin: 25px 0px 10px 0px;
}

/* Only show for everything theme */
body[data-theme="everything"] .create-button-container {
    display: flex;
}

.create-button {
    display: none; /* Hidden by default, shown via JS for everything theme */
    background: linear-gradient(135deg, #6a436f, #74A2D1);
    color: white;
    padding: 15px 30px 15px 75px; /* Increased left padding from 65px to 75px */
    border-radius: 25px;
    border: none;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(106, 67, 111, 0.3);
    position: relative; /* For absolute positioning of the icon */
}

.create-button::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px; /* Increased from 32px to 40px */
    height: 40px; /* Increased from 32px to 40px */
    background-image: var(--theme-icon, url('/images/icons/Flaaash-AI.jpg'));
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 8px; /* Changed from 50% to 8px */
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.create-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(106, 67, 111, 0.4);
}

.create-button:active {
    transform: translateY(0);
    box-shadow: 0 4px 15px rgba(106, 67, 111, 0.3);
}

/* Page Title Section */
.page-title-section {
    text-align: center;
    padding: 2rem 1rem;
    margin-bottom: 1rem;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.page-title {
    font-size: 2rem;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.page-description {
    font-size: 1.1rem;
    color: var(--text-light);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.5;
}

@media (max-width: 768px) {
    .page-title-section {
        padding: 1.5rem 1rem;
    }

    .page-title {
        font-size: 1.75rem;
    }

    .page-description {
        font-size: 1rem;
    }
}

/* Welcome Text */
.welcome-text {
    padding: 2.5rem 1rem 1rem; /* Augmente l'espace au-dessus, réduit en-dessous */
    text-align: center;
}

.theme-title {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    color: var(--main-color);
    margin: 0;
    line-height: 1.2;
}

body[data-theme="everything"] .welcome-text {
    display: none;
}

/* Bottom Section */
.bottom-section {
    text-align: center;
    padding: 15px 20px 25px;
    margin-top: 30px;
}

.separator {
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(106, 70, 193, 0.3), transparent);
    margin: 20px auto;
    max-width: 300px;
}

.separator.light {
    background: linear-gradient(to right, transparent, rgba(106, 70, 193, 0.15), transparent);
    margin: 15px auto;
    max-width: 300px;
}

.weekly-update {
    text-align: center;
    padding: 15px 0 0 0;
    margin: 0;
    font-size: 1.1rem;
    color: #6a436f;
    font-weight: 500;
}

.create-prompt {
    font-size: 1.2rem;
    color: #333;
    margin: 20px 0;
    line-height: 1.6;
}

/* Loading Animation */
.book-card.loading {
    background: #f8f9fa;
    position: relative;
    overflow: hidden;
}

.book-card.loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 200%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.6) 50%,
        transparent 100%
    );
    animation: loading-shine 1.5s infinite;
}

.book-card.loading .cover-container {
    background: #eee;
    height: 0;
    padding-bottom: 150%; /* 2:3 aspect ratio */
}

.book-card.loading h3 {
    height: 20px;
    background: #eee;
    margin: 10px;
    border-radius: 4px;
}

.book-card.loading p {
    height: 12px;
    background: #eee;
    margin: 8px 10px;
    border-radius: 4px;
    width: 80%;
}

.book-card.loading p:last-child {
    width: 60%;
}

@keyframes loading-shine {
    to {
        transform: translateX(50%);
    }
}

/* Create Button Container Override */
.bottom-section .create-button-container {
    display: flex;
    margin: 25px 0 0 0;
}

.bottom-section .create-button {
    display: inline-flex;
    background: linear-gradient(135deg, #6a436f, #74A2D1);
}

@media (max-width: 768px) {
    .filters-top {
        flex-direction: column;
        gap: 15px;
    }
    
    .sort-switch {
        position: relative;
        transform: none;
        justify-content: center;
        width: 100%;
        margin: 10px 0;
    }
    
    .filters input {
        width: 100%;
    }
    
    .bottom-section {
        padding: 10px 15px;
    }
    
    .weekly-update,
    .create-prompt {
        font-size: 1rem;
    }
}

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

/* Create Button */
.create-button-container.always-show {
    display: flex;
    justify-content: center;
    margin: 25px 0 0 0;
}

.create-button {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #6a436f, #74A2D1);
    color: white;
    padding: 15px 30px 15px 75px;
    border-radius: 25px;
    border: none;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(106, 67, 111, 0.3);
    position: relative;
}

.create-button::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background-image: var(--theme-icon, url('/images/icons/Flaaash-AI.jpg'));
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.create-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(106, 67, 111, 0.4);
}

/* Weekly update and bottom section positioning */
.weekly-update {
    margin-top: 40px;
}

.bottom-section {
    margin-top: 20px;
    opacity: 0;
    transition: opacity 0.5s ease;
}

/* Animation states for loading and no results */
body:has(.book-card.loading) .weekly-update,
body:has(.book-card.loading) .bottom-section {
    display: none;
}

/* Footer positioning */
.bottom-section {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 20px;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

/* Hidden state for bottom section when not supposed to be visible */
.bottom-section[style*="display: none"] {
    bottom: -200px; /* Move it completely off-screen */
    pointer-events: none; /* Disable all interactions */
    opacity: 0;
    z-index: -1; /* Put it behind everything */
}

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

/* Highlight Animation pour les Flaaash récemment claim - SIMPLIFIÉE */
.recently-claimed {
    position: relative;
    animation: claimHighlightSimple 2s ease-in-out;
    z-index: 10; /* Au-dessus des autres cartes */
}

@keyframes claimHighlightSimple {
    0%, 100% { 
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 8px 24px rgba(76, 175, 80, 0.5);
        transform: scale(1.03);
    }
}

/* Badge "New" pour les Flaaash récemment claim */
.new-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: linear-gradient(135deg, #FF6B6B, #FF5252);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    z-index: 5;
    box-shadow: 0 2px 6px rgba(255, 107, 107, 0.4);
    animation: newBadgeBounce 0.5s ease-out;
}

@keyframes newBadgeBounce {
    0% {
        transform: scale(0) rotate(-10deg);
        opacity: 0;
    }
    60% {
        transform: scale(1.1) rotate(5deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
} 