/**
 * STYLES POUR LES PUBLICATIONS - BookConnect
 * Fichier dédié à l'affichage et aux interactions des publications
 */

/* ========================================
   ISOLATION ET STRUCTURE DES PUBLICATIONS
   ======================================== */

/* Isolation stricte de chaque publication */
.publication-item {
    display: block;
    position: relative;
    isolation: isolate; /* Crée un nouveau contexte d'empilement */
    margin-bottom: 1rem;
}

/* Force la fermeture de toutes les balises flottantes */
.publication-item::after {
    content: "";
    display: table;
    clear: both;
}

/* Carte de publication */
.publication-card {
    overflow: visible;
}

/* ========================================
   TRONCATURE DU CONTENU
   ======================================== */

/* Contenu avec troncature automatique */
.publication-content-preview {
    max-height: 180px; /* Réduit à 180px pour tronquer plus de publications */
    overflow: hidden;
    position: relative;
    transition: max-height 0.8s ease-in-out;
}

/* État déplié - IMPORTANT : max-height doit être none pour afficher TOUT le contenu */
.publication-content-preview.expanded {
    max-height: none !important;
    overflow: visible;
    transition: none; /* Pas d'animation au déploiement pour éviter les coupures */
}

/* Effet de fondu en bas pour le contenu tronqué - UNIQUEMENT quand NON déplié */
.publication-content-preview:not(.expanded)::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,1));
    pointer-events: none;
    z-index: 1;
}

/* Supprimer l'effet de flou quand déplié */
.publication-content-preview.expanded::after {
    display: none !important;
}

/* Sécurité : empêcher le contenu de déborder */
.publication-content-preview * {
    max-width: 100%;
}

/* Wrapper de contenu isolé - Isolation du contenu utilisateur */
.publication-content-isolated {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ========================================
   BOUTONS "LIRE LA SUITE" / "RÉDUIRE"
   ======================================== */

/* Container du bouton */
[id^="read-more-btn-"] {
    text-align: center;
    margin-top: 1rem;
    padding-top: 0.5rem;
    border-top: 1px solid #e9ecef;
}

/* Style du bouton */
[id^="read-more-btn-"] button {
    min-width: 150px;
    font-weight: 500;
    transition: all 0.3s ease;
}

/* Effet hover sur le bouton */
[id^="read-more-btn-"] button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* ========================================
   EN-TÊTE DE PUBLICATION
   ======================================== */

.publication-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.publication-header img {
    width: 50px;
    height: 50px;
    object-fit: cover;
}

/* ========================================
   CORPS DE PUBLICATION
   ======================================== */

.publication-body {
    padding: 1.25rem;
}

.publication-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #0d6efd;
    margin-bottom: 1rem;
}

/* ========================================
   IMAGES DE PUBLICATION
   ======================================== */

.publication-image {
    margin-top: 1rem;
    text-align: center;
}

.publication-image img {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: 0.375rem;
}

/* ========================================
   SÉPARATEURS
   ======================================== */

.publication-separator {
    margin: 0.5rem 0;
    border-color: #dee2e6;
}

.editor-publications-separator {
    margin: 2rem 0;
    position: relative;
    text-align: center;
}

.editor-publications-separator .separator-line {
    border-top: 2px solid #dee2e6;
}

.editor-publications-separator .separator-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 0 1rem;
    color: #6c757d;
    font-weight: 500;
}

.editor-publications-separator .separator-content i {
    margin-right: 0.5rem;
}

/* ========================================
   PIED DE PUBLICATION (RÉACTIONS)
   ======================================== */

.publication-footer {
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    padding: 0.75rem 1.25rem;
}

.reaction-buttons {
    gap: 0.5rem;
}

.reaction-buttons button {
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
}

/* Indicateur visuel pour les réactions actives */
.reaction-active {
    font-weight: 600;
    opacity: 0.9;
}

.interaction-buttons {
    gap: 0.5rem;
}

/* ========================================
   COMMENTAIRES
   ======================================== */

.comments-section {
    padding: 1rem;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

.comment-item {
    padding: 0.75rem;
    background: white;
    border-radius: 0.375rem;
    margin-bottom: 0.75rem;
}

.comment-item img {
    width: 40px;
    height: 40px;
    object-fit: cover;
}

.comment-header {
    font-size: 0.875rem;
}

.comment-content {
    margin-top: 0.5rem;
    color: #212529;
}

.comment-actions {
    margin-top: 0.5rem;
}

.comment-like-btn,
.comment-dislike-btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

/* ========================================
   PUBLICITÉS
   ======================================== */

.ad-banner {
    background-color: #fff9e6;
    border-left: 4px solid #ffc107;
}

.ad-banner .card-body {
    padding: 1.5rem;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .publication-content-preview {
        max-height: 180px;
    }
    
    [id^="read-more-btn-"] button {
        min-width: 120px;
        font-size: 0.875rem;
    }
    
    .reaction-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .reaction-buttons button {
        width: 100%;
    }
}

/* ========================================
   ANIMATIONS ET TRANSITIONS
   ======================================== */

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

.publication-item {
    animation: fadeIn 0.3s ease-in-out;
}

/* Transition fluide pour les boutons */
button {
    transition: all 0.2s ease-in-out;
}

/* ========================================
   UTILITAIRES
   ======================================== */

/* Empêcher la sélection du texte sur les boutons */
.reaction-buttons button,
.interaction-buttons button,
[id^="read-more-btn-"] button {
    user-select: none;
}

/* État de chargement */
.loading-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0d6efd;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================
   MENU AUTEUR (dropdown custom sans Bootstrap)
   ======================================== */

.author-menu {
    position: relative;
}

.author-menu-toggle {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
    font-size: 1.1rem;
    padding: 0;
}

.author-menu-toggle:hover {
    background-color: rgba(0, 0, 0, 0.08);
    color: #333;
}

.author-menu-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 1050;
    min-width: 190px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 0.375rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 0.25rem 0;
    margin-top: 4px;
}

.author-menu-dropdown.open {
    display: block;
}

.author-menu-dropdown a {
    display: block;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    color: #212529;
    text-decoration: none;
    white-space: nowrap;
}

.author-menu-dropdown a:hover {
    background-color: #f8f9fa;
}

.author-menu-dropdown a.text-danger {
    color: #dc3545 !important;
}

.author-menu-dropdown hr {
    margin: 0.25rem 0;
    border-top: 1px solid #e9ecef;
}

/* Edition inline dans la carte */
.inline-edit-form {
    padding: 0.5rem 0;
}

.inline-edit-toolbar {
    padding: 8px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem 0.375rem 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.inline-edit-toolbar .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    line-height: 1;
}

.inline-edit-content {
    border: 1px solid #ced4da;
    border-top: none;
    border-radius: 0 0 0.375rem 0.375rem;
    padding: 0.75rem;
    min-height: 150px;
    max-height: 400px;
    overflow-y: auto;
    background: #fff;
}

.inline-edit-content:focus {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.inline-edit-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 8px 0;
}

/* Restaurer les styles de listes (supprimes par Bulma: ol,ul { list-style:none; margin:0; padding:0 }) */
.inline-edit-content ul,
.publication-content-isolated ul,
.publication-body ul,
.publication-content-preview ul,
[contenteditable="true"] ul {
    list-style: disc !important;
    list-style-type: disc !important;
    padding-left: 2rem !important;
    margin: 0.5rem 0 !important;
}

.inline-edit-content ol,
.publication-content-isolated ol,
.publication-body ol,
.publication-content-preview ol,
[contenteditable="true"] ol {
    list-style: decimal !important;
    list-style-type: decimal !important;
    padding-left: 2rem !important;
    margin: 0.5rem 0 !important;
}

.inline-edit-content li,
.publication-content-isolated li,
.publication-body li,
.publication-content-preview li,
[contenteditable="true"] li {
    display: list-item !important;
    margin-bottom: 0.25rem;
}
