/**
 * Comments Section Styles
 *
 * Styles for question discussions feature.
 * BEM naming convention.
 * Uses CSS variables from variables.css for theme consistency.
 */

/* ==========================================================================
   WRAPPER CONTAINER (from QuestionDisplay)
   ========================================================================== */

.question__comments {
    width: 100%;
    box-sizing: border-box;
}

/* ==========================================================================
   COMMENTS SECTION CONTAINER
   ========================================================================== */

.comments-section {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    border-top: 1px solid var(--color-border-light);
    padding-top: 1rem;
}

.comments-section__toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    font-family: inherit;
}

.comments-section__toggle:hover {
    background: var(--color-bg-hover);
    border-color: var(--color-primary);
    color: var(--color-text-primary);
}

.comments-section__icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--color-primary);
}

.comments-section__count {
    font-weight: 500;
}

.comments-section__chevron {
    width: 16px;
    height: 16px;
    margin-left: auto;
    transition: transform 0.2s ease;
}

.comments-section__chevron--up {
    transform: rotate(180deg);
}

/* ==========================================================================
   COMMENTS CONTENT AREA
   ========================================================================== */

.comments-section__content {
    margin-top: 1rem;
    animation: commentsFadeIn 0.2s ease;
}

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

.comments-section__loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    color: var(--color-text-muted);
}

.comments-section__spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: commentsSpin 0.8s linear infinite;
}

@keyframes commentsSpin {
    to { transform: rotate(360deg); }
}

.comments-section__empty {
    text-align: center;
    padding: 2rem;
    color: var(--color-text-muted);
    font-style: italic;
}

.comments-section__list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ==========================================================================
   ADD COMMENT FORM
   ========================================================================== */

.comments-section__form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--color-border-light);
}

.comments-section__input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: var(--color-bg-input);
    color: var(--color-text-primary);
}

.comments-section__input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: var(--input-focus-ring);
}

.comments-section__input::placeholder {
    color: var(--color-text-muted);
}

.comments-section__input--reply {
    font-size: 0.85rem;
}

.comments-section__form .btn {
    align-self: flex-end;
}

/* ==========================================================================
   INDIVIDUAL COMMENT
   ========================================================================== */

.comment {
    padding: 1rem;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
}

.comment--reply {
    margin-left: 1.5rem;
    background: var(--color-bg-hover);
    border-left: 3px solid var(--color-primary);
}

.comment--pinned {
    border-color: var(--color-warning);
    background: linear-gradient(135deg, var(--color-bg-card), var(--color-warning-light));
}

.comment__header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.comment__author {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-text-primary);
}

.comment__author--admin {
    color: var(--color-primary);
}

.comment__badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    background: var(--color-primary);
    color: var(--color-text-inverse);
    font-size: 10px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.comment__time {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.comment__pinned-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    background: var(--color-warning);
    color: var(--color-warning-dark);
    font-size: 10px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
}

.comment__body {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--color-text-primary);
    white-space: pre-wrap;
    word-break: break-word;
}

/* ==========================================================================
   COMMENT ACTIONS
   ========================================================================== */

.comment__actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border-light);
}

.comment__vote {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    transition: all 0.2s ease;
    font-family: inherit;
}

.comment__vote svg {
    width: 14px;
    height: 14px;
}

.comment__vote:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.comment__vote--active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-text-inverse);
}

.comment__vote--active:hover {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
    color: var(--color-text-inverse);
}

.comment__action {
    padding: 4px 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    transition: color 0.2s ease;
    font-family: inherit;
}

.comment__action:hover {
    color: var(--color-primary);
}

.comment__action--danger:hover {
    color: var(--color-danger);
}

/* ==========================================================================
   REPLY & EDIT FORMS
   ========================================================================== */

.comment__reply-form,
.comment__edit-form {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border-light);
}

.comment__reply-actions,
.comment__edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.comment__replies {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* ==========================================================================
   COMMENT REPORT MODAL
   ========================================================================== */

.comment-report-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.comment-report-modal.show {
    opacity: 1;
    visibility: visible;
}

/* Modal Content Box */
.comment-report-modal__content {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s ease;
}

.comment-report-modal.show .comment-report-modal__content {
    transform: scale(1) translateY(0);
}

/* Header */
.comment-report-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e9ecef;
}

.comment-report-modal__title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: #212529;
}

.comment-report-modal__title svg {
    color: #dc3545;
    flex-shrink: 0;
}

.comment-report-modal__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #f8f9fa;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: #6c757d;
    transition: all 0.2s ease;
}

.comment-report-modal__close:hover {
    background: #e9ecef;
    color: #212529;
}

/* Form */
.comment-report-modal__form {
    padding: 24px;
}

.comment-report-modal__field {
    margin-bottom: 20px;
}

.comment-report-modal__field:last-of-type {
    margin-bottom: 24px;
}

.comment-report-modal__label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 10px;
}

.comment-report-modal__label-hint {
    font-weight: 400;
    color: #6c757d;
    font-size: 0.85rem;
}

/* Select */
.comment-report-modal__select {
    width: 100%;
    padding: 12px 16px;
    font-size: 0.95rem;
    font-family: inherit;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    background: #fff;
    color: #212529;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236c757d' 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 12px center;
    padding-right: 40px;
}

.comment-report-modal__select:focus {
    outline: none;
    border-color: #368BC1;
    box-shadow: 0 0 0 3px rgba(54, 139, 193, 0.15);
}

.comment-report-modal__select:hover {
    border-color: #adb5bd;
}

/* Textarea */
.comment-report-modal__textarea {
    width: 100%;
    padding: 12px 16px;
    font-size: 0.95rem;
    font-family: inherit;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    background: #fff;
    color: #212529;
    resize: vertical;
    min-height: 100px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.comment-report-modal__textarea:focus {
    outline: none;
    border-color: #368BC1;
    box-shadow: 0 0 0 3px rgba(54, 139, 193, 0.15);
}

.comment-report-modal__textarea:hover {
    border-color: #adb5bd;
}

.comment-report-modal__textarea::placeholder {
    color: #adb5bd;
}

/* Actions */
.comment-report-modal__actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.comment-report-modal__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.comment-report-modal__btn--primary {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
}

.comment-report-modal__btn--primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
}

.comment-report-modal__btn--primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.comment-report-modal__btn--secondary {
    background: #f8f9fa;
    color: #495057;
    border: 1px solid #dee2e6;
}

.comment-report-modal__btn--secondary:hover {
    background: #e9ecef;
}

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

@media (max-width: 768px) {
    .comment--reply {
        margin-left: 0.75rem;
    }

    .comment__actions {
        flex-wrap: wrap;
    }

    /* Report Modal - Mobile Bottom Sheet */
    .comment-report-modal {
        align-items: flex-end;
        padding: 0;
    }

    .comment-report-modal__content {
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        max-height: 90vh;
        overflow-y: auto;
        transform: translateY(100%);
    }

    .comment-report-modal.show .comment-report-modal__content {
        transform: translateY(0);
    }

    .comment-report-modal__header {
        padding: 16px 20px;
    }

    .comment-report-modal__form {
        padding: 20px;
    }

    .comment-report-modal__actions {
        flex-direction: column-reverse;
    }

    .comment-report-modal__btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .comments-section__toggle {
        padding: 0.5rem 0.75rem;
    }

    .comment {
        padding: 0.75rem;
    }

    .comment__header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
}

/* ==========================================================================
   HIGHLIGHTED COMMENT (from notification link)
   ========================================================================== */

@keyframes comment-highlight {
    0% {
        background-color: rgba(54, 139, 193, 0.3);
        box-shadow: 0 0 0 4px rgba(54, 139, 193, 0.2);
    }
    50% {
        background-color: rgba(54, 139, 193, 0.15);
        box-shadow: 0 0 0 2px rgba(54, 139, 193, 0.1);
    }
    100% {
        background-color: transparent;
        box-shadow: none;
    }
}

.comment--highlighted {
    animation: comment-highlight 3s ease-out;
    border-radius: var(--radius-md);
}
