/**
 * Comments Modal Styles
 */

/* Modal Container */
.ew-comments-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.ew-comments-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
}

.ew-comments-container {
    position: relative;
    background: white;
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
    overflow: hidden;
}

/* Header */
.ew-comments-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    z-index: 10;
}

.ew-comments-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
}

.ew-close-comments {
    background: none;
    border: none;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

.ew-close-comments:hover {
    background: #f3f4f6;
}

.ew-close-comments svg {
    width: 20px;
    height: 20px;
}

/* Loading */
.ew-comments-loading {
    padding: 60px 20px;
    text-align: center;
    color: #6b7280;
}

.ew-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border: 3px solid #f3f4f6;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Liste commentaires */
.ew-comments-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    /* PAS de scroll horizontal */
    padding: 20px;
    min-height: 200px;
    max-height: 400px;
}

/* Empty state */
.ew-comments-empty {
    padding: 60px 20px;
    text-align: center;
    color: #9ca3af;
}

.ew-comments-empty svg {
    width: 60px;
    height: 60px;
    margin: 0 auto 16px;
    opacity: 0.5;
}

.ew-comments-empty p {
    font-size: 16px;
    font-weight: 600;
    margin: 8px 0;
    color: #6b7280;
}

.ew-comments-empty small {
    font-size: 14px;
}

/* ===== COMMENTAIRE (STYLE FACEBOOK EXACT) ===== */
.ew-comment-item {
    display: block;
    /* BLOCK pas FLEX pour empiler verticalement */
    margin-bottom: 12px;
    animation: slideIn 0.3s ease;
}

/* Wrapper pour avatar + contenu sur même ligne */
.ew-comment-main {
    display: flex;
    gap: 8px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* AVATAR PARENT */
.ew-comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 16px;
}

.ew-comment-content {
    flex: 1;
}

/* BULLE GRISE FACEBOOK */
.ew-comment-bubble {
    background: #F0F2F5;
    border-radius: 18px;
    padding: 8px 12px;
    display: inline-block;
    max-width: fit-content;
}

.ew-comment-bubble .ew-comment-author {
    font-size: 13px;
    font-weight: 600;
    color: #050505;
    margin-bottom: 2px;
}

.ew-comment-bubble .ew-comment-text {
    font-size: 15px;
    line-height: 1.3;
    color: #050505;
    margin: 0;
}

/* ACTIONS FACEBOOK */
.ew-comment-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
    margin-left: 12px;
    font-size: 12px;
    color: #65676B;
}

.ew-comment-actions button {
    background: none;
    border: none;
    font-size: 12px;
    color: #65676B;
    cursor: pointer;
    font-weight: 600;
    padding: 0;
}

.ew-comment-actions button:hover {
    text-decoration: underline;
}

.ew-comment-actions span {
    color: #65676B;
}

/* ===== THREAD (Fils de discussion) ===== */
.ew-comment-thread {
    position: relative;
    margin-left: 40px;
    /* EXACTEMENT 40px */
    margin-top: 8px;
    overflow: visible;
    /* Pas de scroll horizontal */
}

/* LIGNE VERTICALE */
.ew-thread-line {
    position: absolute;
    left: -22px;
    top: 0;
    bottom: 12px;
    width: 2px;
    background: #E4E6EB;
}

/* ===== RÉPONSE ===== */
.ew-comment-reply {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    position: relative;
}

/* RACCORD EN L */
.ew-comment-reply::before {
    content: '';
    position: absolute;
    left: -22px;
    top: 12px;
    width: 14px;
    height: 14px;
    border-left: 2px solid #E4E6EB;
    border-bottom: 2px solid #E4E6EB;
    border-bottom-left-radius: 8px;
}

/* AVATAR RÉPONSE 24px */
.ew-comment-reply .ew-comment-avatar {
    width: 24px;
    height: 24px;
    font-size: 12px;
}

/* Badge Réponse */
.ew-reply-badge {
    color: #10b981;
    font-weight: 600;
    font-size: 13px;
}

/* HOVER MENU */
.ew-comment-item:hover .ew-hover-menu,
.ew-comment-reply:hover .ew-hover-menu {
    opacity: 1;
}

.ew-hover-menu {
    opacity: 0;
    transition: opacity 0.2s;
    margin-left: 8px;
    color: #65676B;
    cursor: pointer;
    font-size: 18px;
}

/* HIDDEN REPLIES */
.ew-hidden-replies {
    display: none;
}

.ew-hidden-replies.show {
    display: block;
}

/* LOAD MORE BUTTON */
.ew-load-more-replies {
    background: transparent;
    border: none;
    color: #65676B;
    font-weight: 600;
    font-size: 13px;
    padding: 8px 0 8px 16px;
    cursor: pointer;
    margin-bottom: 8px;
    display: block;
}

.ew-load-more-replies:hover {
    text-decoration: underline;
}

/* Formulaire */
.ew-comment-form {
    padding: 20px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

.ew-form-row {
    margin-bottom: 12px;
    position: relative;
}

.ew-comment-form input,
.ew-comment-form textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
}

.ew-comment-form input:focus,
.ew-comment-form textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.ew-comment-form textarea {
    resize: none;
}

.ew-char-count {
    display: block;
    text-align: right;
    font-size: 12px;
    color: #9ca3af;
    margin-top: 4px;
}

.ew-form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.ew-btn-cancel,
.ew-btn-submit-comment {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.ew-btn-cancel {
    background: transparent;
    color: #6b7280;
}

.ew-btn-cancel:hover {
    background: #e5e7eb;
}

.ew-btn-submit-comment {
    background: #3b82f6;
    color: white;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ew-btn-submit-comment:hover {
    background: #2563eb;
}

.ew-btn-submit-comment:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

.ew-btn-submit-comment svg {
    width: 16px;
    height: 16px;
}

/* Comment Actions (Like + Reply) */
.ew-comment-actions {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    padding-top: 8px;
}

.ew-like-comment-btn,
.ew-reply-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    color: #6b7280;
}

.ew-like-comment-btn:hover {
    background: #fee2e2;
    color: #ef4444;
}

.ew-reply-btn:hover {
    background: #dbeafe;
    color: #3b82f6;
}

/* Like button liked state */
.ew-like-comment-btn.liked {
    color: #ef4444;
}

.ew-like-comment-btn.liked .ew-heart-icon {
    fill: #ef4444;
    stroke: #ef4444;
    animation: heartPulse 0.3s ease;
}

@keyframes heartPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}

.ew-heart-icon {
    width: 16px;
    height: 16px;
    transition: all 0.2s;
}

.ew-like-count {
    font-size: 13px;
    font-weight: 600;
    min-width: 16px;
    text-align: center;
}

/* Replies (Réponses) */
.ew-comment-replies {
    margin-left: 52px;
    border-left: 2px solid #e5e7eb;
    padding-left: 16px;
    margin-top: 12px;
}

.ew-reply {
    margin-top: 12px;
}

/* Reply Form Inline */
.ew-reply-form-inline {
    margin-top: 12px;
    margin-left: 52px;
    padding: 12px;
    background: #f3f4f6;
    border-radius: 8px;
}

.ew-reply-form-inline input,
.ew-reply-form-inline textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    margin-bottom: 8px;
}

.ew-reply-form-inline input:focus,
.ew-reply-form-inline textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.ew-reply-form-inline textarea {
    resize: none;
}

.ew-reply-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.ew-btn-cancel-reply,
.ew-btn-send-reply {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.ew-btn-cancel-reply {
    background: transparent;
    color: #6b7280;
}

.ew-btn-cancel-reply:hover {
    background: #e5e7eb;
}

.ew-btn-send-reply {
    background: #3b82f6;
    color: white;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ew-btn-send-reply:hover {
    background: #2563eb;
}

.ew-btn-send-reply:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

.ew-btn-send-reply svg {
    width: 14px;
    height: 14px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile */
@media (max-width: 640px) {
    .ew-comments-container {
        width: 95%;
        max-height: 90vh;
    }

    .ew-comments-header {
        padding: 16px;
    }

    .ew-comments-list {
        padding: 16px;
    }

    .ew-comment-form {
        padding: 16px;
    }
}