/* Card Styles */
#book-card-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden; /* Empêche les débordements horizontaux */
    position: relative;
    z-index: 1;
}

.book-card {
    display: flex;
    flex-direction: row;
    align-items: flex-start; /* Aligner en haut par défaut */
    background-color: var(--background-color, #ffffff); /* Dynamique */
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    padding: 20px; /* Augmenté pour plus d'espace */
    width: 100%;
    max-width: 600px; /* Limite la largeur totale de la carte */
    position: relative;
    gap: 20px; /* Augmenté pour plus d'espace entre cover et contenu */
    box-sizing: border-box;
    overflow: visible; /* Permet à la bulle de partage de dépasser */
    min-height: 200px; /* Hauteur minimale par défaut */
}

/* Share Button */
.share-button {
    position: absolute;
    top: -6px; /* Dépasse légèrement du haut de la carte */
    right: -6px; /* Dépasse légèrement du côté droit */
    width: 34px;
    height: 34px;
    background-color: #38A169; /* Vert fixe pour le partage */
    color: #ffffff;
    border: none;
    border-radius: 50%;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(56, 161, 105, 0.3);
    z-index: 5 !important;
}

.share-button:hover {
    transform: scale(1.15);
    box-shadow: 0 6px 16px rgba(56, 161, 105, 0.4);
    background-color: #2F855A;
}

.share-button:active {
    transform: scale(0.95);
}

/* Share feedback animation */
.share-feedback {
    position: absolute;
    top: 52px; /* Positionné en dessous du bouton */
    left: 50%;
    transform: translateX(-50%);
    background-color: #38A169; /* Vert du partage */
    color: #ffffff;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-shadow: 0 6px 16px rgba(56, 161, 105, 0.4);
    z-index: 6;
}

.share-feedback.show {
    opacity: 1;
    transform: translateX(-50%) translateY(5px); /* Descend légèrement */
}

/* Book Cover Container */
.cover-container {
    position: relative;
    flex-shrink: 0;
    width: 120px; /* Légèrement plus large */
    height: 180px; /* Maintient le ratio 2:3 */
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Aligne en haut */
    overflow: hidden; /* Garde overflow hidden pour la cover */
    border-radius: 8px; /* Coins arrondis cohérents */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); /* Ombre plus subtile */
}

/* Book Cover Image */
.cover-container img {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.2s ease;
    background-color: #f5f5f5; /* Couleur de fond en cas d'image transparente */
    display: block; /* Évite l'espace sous l'image */
}

.cover-container img:hover {
    transform: scale(1.05);
    border-radius: 8px;
}

/* Emoji Overlay */
.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);
    z-index: 2;
}

.emoji-overlay .emoji {
    font-size: 48px;
    line-height: 1;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

/* Cover Modal */
.cover-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    z-index: 9999999 !important;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.3s ease;
}

.cover-modal.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.cover-modal img {
    max-height: 90vh;
    max-width: 90vw;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: scale(0.95);
    transition: all 0.3s ease;
}

.cover-modal.active img {
    opacity: 1;
    transform: scale(1);
}

.cover-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 24px;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.5);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    opacity: 0;
    transform: scale(0.9);
    transition: all 0.3s ease;
}

.cover-modal.active .cover-modal-close {
    opacity: 1;
    transform: scale(1);
}

.cover-modal-close:hover {
    background: rgba(0, 0, 0, 0.7);
}

/* Book Info Section */
.book-info {
    flex-grow: 1; /* Prend l'espace restant */
    display: flex;
    flex-direction: column;
    gap: 2px; /* Réduit l'espace entre les éléments */
    word-wrap: break-word;
    min-width: 0; /* Important pour que le texte puisse être tronqué */
    max-width: 100%;
    padding-top: 4px; /* Aligne visuellement avec la cover */
}

.book-info h2 {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.44rem;
    font-weight: 600;
    letter-spacing: -0.02em; /* Réduit légèrement l'espacement entre les lettres */
    color: var(--main-color, #6200ea); /* Dynamique */
    margin: 0;
    line-height: 1.2;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    white-space: normal;
}

.book-info p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--default-text-color, #666); /* Dynamique */
    line-height: 1.2; /* Réduit l'espacement des lignes */
    opacity: 0.9;
}

/* Style spécifique pour l'auteur (premier p) */
.book-info p:first-of-type {
    font-weight: 500;
    opacity: 1;
    margin-top: -1px; /* Rapproche du titre */
}

/* Style spécifique pour la catégorie (deuxième p) */
.book-info p:last-of-type {
    font-size: 0.8rem;
    opacity: 0.75;
    margin-top: -1px; /* Rapproche de l'auteur */
}

/* Podcast Info */
.audio-podcast {
    margin: 8px 0 4px 0;
    font-size: 0.9rem;
    color: var(--main-color, #6200ea);
    text-align: center;
    width: 100%;
}

/* Card Controls Section */
.card-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 8px;
}

/* Buttons */
.card-controls button {
    width: 32px;
    height: 32px;
    background-color: var(--main-color, #6200ea); /* Dynamique */
    color: var(--text-color, #ffffff); /* Dynamique */
    border: none;
    border-radius: 50%;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.card-controls .audio-control-play {
    width: 48px;
    height: 48px;
    font-size: 1.1rem;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .book-card {
        padding: 12px;
        gap: 12px;
        min-height: 160px; /* Hauteur minimale pour garantir l'espace */
    }

    .share-button {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
        top: 10px;
        right: 10px;
    }

    .cover-container {
        height: calc(160px - 24px); /* Hauteur de la card moins les paddings */
        width: calc((160px - 24px) * 2/3); /* Maintient le ratio 2:3 */
        flex-shrink: 0;
        align-self: center; /* Centre verticalement dans la card */
    }

    .cover-container img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

    .book-info h2 {
        font-size: 1.32rem;
    }

    .book-info p {
        font-size: 0.85rem;
    }

    .audio-podcast {
        font-size: 0.85rem;
    }

    .card-controls {
        gap: 12px;
    }

    .card-controls button {
        width: 30px;
        height: 30px;
    }

    .card-controls .audio-control-play {
        width: 42px;
        height: 42px;
        font-size: 1rem;
    }

    /* Animation text style */
    .animation-text {
        position: absolute;
        font-size: 12px;
        font-weight: bold;
        color: var(--main-color, #6200ea); /* Dynamique */
        opacity: 0;
        transform: translateY(0px);
        transition: opacity 0.3s ease, transform 0.3s ease;
        pointer-events: none; /* Empêche les interactions */
    }

    .audio-rewind .animation-text {
        bottom: 100%; /* Position au-dessus du bouton */
        left: 50%;
        transform: translate(-50%, 10px); /* Montée de l'animation */
    }

    .audio-forward .animation-text {
        bottom: 100%; /* Position au-dessus du bouton */
        left: 50%;
        transform: translate(-50%, 10px); /* Montée de l'animation */
    }

    .animation-text.show {
        opacity: 1;
        transform: translate(-50%, -10px); /* L'animation monte */
    }
}

/* Ajuster le positionnement de l'icône audio */
.flashcard-controls {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: flex;
    gap: 10px;
    z-index: 2;
}

/* Empêcher le flick du bookmark sur iOS */
.flashcard-back .flashcard-controls {
    opacity: 1;
    transform: none;
    -webkit-backface-visibility: visible;
    backface-visibility: visible;
}

/* Positionner l'icône audio en haut à droite sur le back */
.flashcard-back .sound-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    bottom: auto;
}

/* S'assurer que les contrôles restent au-dessus */
.flashcard-content {
    position: relative;
    z-index: 1;
}

/* Empêcher la propagation des clics sur les contrôles */
.flashcard-controls button {
    position: relative;
    z-index: 3;
}

/* Modifier les chemins d'accès aux images si nécessaire */
.card-image {
    /* Le chemin sera construit dynamiquement en JavaScript */
}

/* Ajustements spécifiques pour la modal */
.cover-modal .cover-container {
    width: auto;
    height: auto;
    max-height: 90vh;
    max-width: 90vw;
}

.cover-modal .cover-container img {
    max-height: 90vh;
    max-width: 90vw;
    height: auto;
    width: auto;
}

.cover-modal .emoji-overlay .emoji {
    font-size: 96px;
}

/* Share Modal Popup */
.share-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.share-modal.active {
    display: flex;
}

.share-modal-content {
    background: linear-gradient(135deg, #38A169 0%, #2F855A 100%);
    color: white;
    padding: 2.5rem;
    border-radius: 20px;
    width: 90%;
    max-width: 520px;
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.25), 
        0 0 0 1px rgba(255, 255, 255, 0.1) inset,
        0 0 40px rgba(56, 161, 105, 0.6),
        0 0 80px rgba(56, 161, 105, 0.3);
    position: relative;
    animation: shareModalSlideIn 0.3s ease;
}

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

.share-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.share-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.share-modal-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.share-modal-title i {
    font-size: 1.5rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.share-modal-description {
    font-size: 0.95rem;
    opacity: 0.95;
    margin-bottom: 1.5rem;
    line-height: 1.6;
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 12px;
    border-left: 3px solid rgba(255, 255, 255, 0.3);
}

.share-referral-code {
    background: rgba(255, 255, 255, 0.15);
    padding: 1.25rem;
    border-radius: 16px;
    margin: 1.25rem 0;
    border: 2px solid rgba(255, 255, 255, 0.25);
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.share-referral-code-label {
    font-size: 0.85rem;
    opacity: 0.85;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.share-referral-code-value {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: 2px;
    margin: 0.75rem 0;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px dashed rgba(255, 255, 255, 0.4);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.share-referral-code-value:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
    border-style: solid;
}

.share-referral-benefits {
    font-size: 0.9rem;
    opacity: 0.95;
    margin-top: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.referral-info-tooltip {
    font-size: 0.7rem;
    opacity: 0.7;
    cursor: help;
    transition: opacity 0.2s ease;
    position: relative;
    display: inline-block;
}

.referral-info-tooltip:hover {
    opacity: 1;
}

.referral-info-tooltip::after {
    content: attr(title);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.98);
    color: #2d3748;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.65rem;
    font-weight: 400;
    font-family: Arial, sans-serif;
    text-transform: none;
    white-space: normal;
    max-width: 280px;
    width: max-content;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
    z-index: 1000;
    line-height: 1.5;
    letter-spacing: 0.3px;
}

.referral-info-tooltip:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-2px);
}

.share-referral-benefits::before {
    content: "💰";
    font-size: 1.2rem;
}

/* Share buttons row 1 - Main actions */
.share-social-buttons-row1 {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.share-social-btn-main {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.25);
    color: white;
    padding: 0.875rem 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.25s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    flex: 1;
}

.share-social-btn-main:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
}

.share-social-btn-main i {
    font-size: 1.5rem;
}

/* Share buttons row 2 - Social media icons only */
.share-social-buttons-row2 {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.2rem;
    margin-top: 1.4rem;
    width: 100%;
    padding: 0;
    box-sizing: border-box;
}

.share-social-icon {
    background: transparent;
    border: none;
    color: white;
    padding: 0;
    cursor: pointer;
    transition: all 0.25s ease;
    opacity: 0.8;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
    margin: 0;
}

.share-social-icon:hover {
    opacity: 1;
    transform: scale(1.2);
}

.share-social-icon i {
    font-size: 1.75rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Fix Telegram icon alignment */
.share-social-icon[data-platform="telegram"] i {
    font-size: 1.75rem;
}

.share-social-icon[data-platform="telegram"] {
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 640px) {
    .share-modal-content {
        padding: 1.75rem;
        width: calc(100% - 2rem); /* Margin de 1rem de chaque côté */
        margin: 1rem;
    }

    .share-modal-title {
        font-size: 1.35rem;
    }

    .share-referral-code-value {
        font-size: 1.4rem;
        letter-spacing: 1px;
    }

    .share-social-btn-main {
        padding: 0.75rem 0.625rem;
        font-size: 0.8rem;
    }

    .share-social-btn-main i {
        font-size: 1.35rem;
    }

    .share-social-icon i {
        font-size: 1.5rem;
    }

    .share-modal-description {
        font-size: 0.9rem;
        padding: 0.875rem;
    }

    .share-button {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
        top: -5px;
        right: -5px;
    }
}