/**
 * MDS CMS - Education Theme: Comments Stylesheet
 * Matching comments_template.tpl & personal-messages media styles
 */

/* ==========================================================================
   1. Основная секция и карточка комментариев
   ========================================================================== */
.comments-wrapper {
    max-width: 100%;
}

.comment-item {
    transition: background-color 0.2s ease;
}

.comment-item:last-child {
    border-bottom: none !important;
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

.comment-avatar {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.comment-author-name {
    font-size: 0.95rem;
    font-weight: 600;
}

.comment-meta-time {
    font-size: 0.8rem;
    color: #64748b;
}

/* Кнопка действий (три точки) */
.comment-action-btn {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50% !important;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.comment-action-btn:hover,
.comment-action-btn:focus {
    background-color: rgba(100, 116, 139, 0.12);
    color: #0f172a !important;
}

.comment-dropdown .dropdown-menu {
    min-width: 170px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.comment-dropdown .dropdown-item {
    font-size: 0.875rem;
    border-radius: 6px;
    margin: 2px 4px;
    width: calc(100% - 8px);
}

/* ==========================================================================
   2. Telegram / PM-стиль Аудиоплеера голосового сообщения (.tg-voice-player)
   ========================================================================== */
.chat-message-voice {
    width: 290px;
    max-width: 100%;
    display: inline-block;
    margin-bottom: 2px;
}

.tg-voice-play-btn {
    font-size: 15px;
}

.tg-voice-waveform {
    -webkit-user-select: none;
}

/* ==========================================================================
   3. Панель активной записи голосового сообщения (в точности как в PM)
   ========================================================================== */
.voice-recording-bar {
    border-radius: 16px;
    padding: 0.6rem 1rem;
    animation: fadeInVoicePanel 0.25s ease-out;
}

@keyframes fadeInVoicePanel {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   4. Превью прикрепленного медиафайла
   ========================================================================== */
.comment-attachment-preview {
    border-style: dashed !important;
    border-color: #94a3b8 !important;
    border-radius: 12px;
    animation: fadeInVoicePanel 0.2s ease-out;
}

.cursor-pointer {
    cursor: pointer !important;
}

/* ==========================================================================
   5. Вложенные ответы в стиле YouTube (Раскрытие / Сворачивание)
   ========================================================================== */
.comment-replies-section {
    position: relative;
}

.comment-replies-toggle {
    font-size: 0.875rem;
    color: #0d6efd !important;
    padding: 4px 8px !important;
    border-radius: 18px;
    transition: background-color 0.15s ease, transform 0.1s ease;
    user-select: none;
}

.comment-replies-toggle:hover {
    background-color: rgba(13, 110, 253, 0.08);
}

.comment-replies-toggle:active {
    transform: scale(0.98);
}

.comment-replies-toggle .replies-icon {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.comment-replies-container {
    transition: all 0.2s ease-in-out;
}

.replies {
    border-left: 2px solid #e2e8f0 !important;
    margin-left: 1rem !important;
    padding-left: 1rem !important;
}

@media (max-width: 576px) {
    .replies {
        margin-left: 0.5rem !important;
        padding-left: 0.75rem !important;
    }
    .chat-message-voice {
        width: 100%;
    }
}

/* ==========================================================================
   6. Форма быстрого ответа (Reply)
   ========================================================================== */
.comment-reply-form {
    border: 1px solid #bfdbfe !important;
    background: #f8fafc !important;
    animation: fadeInVoicePanel 0.2s ease-out;
}

.comment-attachment-image img {
    transition: transform 0.2s ease;
}

.comment-attachment-image img:hover {
    transform: scale(1.015);
}

/* ==========================================================================
   7. Темная тема (Dark Mode Support)
   ========================================================================== */

[data-bs-theme="dark"] .replies,
body[data-bs-theme="dark"] .replies {
    border-left-color: #334155 !important;
}

[data-bs-theme="dark"] .comment-replies-toggle:hover,
body[data-bs-theme="dark"] .comment-replies-toggle:hover {
    background-color: rgba(56, 189, 248, 0.12);
}

/* Shared social-style discussion layout, kept local to comments. */
.comments-wrapper {
    scroll-margin-top: 190px;
}
.comments-wrapper .comment-main {
    min-width: 0;
}
.comments-wrapper .comment-item .comment-avatar {
    width: 40px;
    height: 40px;
    border: 0;
    box-shadow: none;
}
.comments-wrapper .comment-message {
    width: fit-content;
    min-width: min(180px, 100%);
    max-width: min(760px, 100%);
    background: rgba(var(--bs-primary-rgb, 38, 150, 219), 0.055);
    transition: background-color 0.15s ease;
}
.comments-wrapper .comment-message:hover {
    background: rgba(var(--bs-primary-rgb, 38, 150, 219), 0.085);
}
.comments-wrapper .comment-header {
    min-height: 20px;
    margin-bottom: 6px;
}
.comments-wrapper .comment-author-name {
    font-size: 15px;
    font-weight: 600;
    line-height: 20px;
    overflow-wrap: anywhere;
}
.comments-wrapper .comment-header .badge {
    font-size: 12px;
    padding-block: 2px !important;
}
.comments-wrapper .comment-text {
    font-size: 16px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}
.comments-wrapper .comment-text > :last-child {
    margin-bottom: 0;
}
.comments-wrapper .comment-text img,
.comments-wrapper .comment-attachment-image img {
    max-width: 100%;
    max-height: 280px;
    object-fit: contain;
}
.comments-wrapper .comment-text a {
    overflow-wrap: anywhere;
}
.comments-wrapper .comment-meta-time {
    font-size: 12px;
    white-space: normal !important;
    flex-wrap: wrap;
}
.comments-wrapper .comment-action-row {
    padding-left: 0;
}
.comments-wrapper .js-comment-reply {
    font-size: 14px;
    line-height: 24px;
}
.comments-wrapper .js-comment-reply:hover,
.comments-wrapper .js-comment-reply:focus-visible,
.comments-wrapper .js-comment-reply[aria-expanded="true"] {
    background: rgba(var(--bs-primary-rgb, 38, 150, 219), 0.08);
    color: var(--bs-primary, #268aca) !important;
}
.comments-wrapper .comment-action-btn {
    width: 24px;
    height: 24px;
    border-radius: var(--bs-border-radius, 6px) !important;
}
.comments-wrapper .comment-attachment-video {
    max-width: 520px;
}
.comments-wrapper .comment-attachment-video video {
    max-height: 320px;
}
.comments-wrapper :is(.voice-recording-bar, .comment-attachment-preview, .tg-voice-player, .tg-voice-play-btn, .comment-replies-toggle) {
    border-radius: var(--bs-border-radius, 6px);
}
.comments-wrapper .tg-voice-player {
    min-width: 0;
}
.comments-wrapper .comment-replies-section {
    margin-left: 56px !important;
    margin-top: 4px !important;
}
.comments-wrapper .replies {
    border-left: 0 !important;
}
.comments-wrapper .comment-reply-container:not(.d-none) {
    max-width: 760px;
    margin-top: 12px !important;
    padding: 12px 0 4px;
    animation: comment-reply-appear 0.15s ease-out;
}
.comments-wrapper .comment-reply-form {
    border: 0 !important;
    background: var(--bs-body-bg, #fff) !important;
}
.comments-wrapper .jodit-container {
    max-width: 100%;
}
.comments-wrapper .comment-text:empty {
    display: none;
}
@keyframes comment-reply-appear {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 575.98px) {
    .comments-wrapper { scroll-margin-top: 160px; }
    .comments-wrapper .comment-dropdown { margin-left: auto; }
    .comments-wrapper .comment-replies-section { margin-left: 16px !important; }
    .comments-wrapper .replies .comment-replies-section { margin-left: 0 !important; }
    .comments-wrapper .replies .replies { margin-left: 0 !important; padding-left: 8px !important; }
    .comments-wrapper .comment-form-actions { align-items: stretch !important; }
    .comments-wrapper .comment-tools { flex-wrap: nowrap !important; min-width: 0; max-width: 56%; }
    .comments-wrapper .comment-tools .js-record-voice-btn { max-width: 100%; padding: 6px 8px; }
    .comments-wrapper .comment-tools .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .comments-wrapper .comment-submit-actions { flex: 1; justify-content: flex-end; }
    .comments-wrapper .js-submit-comment-btn { justify-content: center; padding-inline: 12px !important; }
}
@media (prefers-reduced-motion: reduce) {
    .comments-wrapper * { animation: none !important; transition: none !important; }
}

.comments-wrapper .comment-text p {
    margin-bottom: 4px;
}
.comments-wrapper .comment-text p:last-child {
    margin-bottom: 0;
}
.comments-wrapper .jodit-container:not(.jodit_inline) .jodit-wysiwyg {
    padding: 8px 12px;
    font-size: 14px;
    line-height: 1.5;
}
.comments-wrapper .comment-reply-form .js-record-voice-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    justify-content: center;
}
.comments-wrapper .comment-reply-form .js-record-voice-btn .small {
    display: none;
}
.comments-wrapper .comment-reply-form .comment-tools {
    flex-shrink: 0;
}

.comments-wrapper .comment-tools { display: none !important; }
.comments-wrapper .comment-is-recording [data-ref="commentVoice"] .jodit-toolbar-button__button {
    background: rgba(var(--bs-danger-rgb, 220, 53, 69), 0.12);
    box-shadow: inset 0 -2px var(--bs-danger, #dc3545);
}
.comments-wrapper .comment-reply-form > .d-flex:first-of-type {
    align-items: flex-start !important;
}
.comments-wrapper .comment-reply-form > .d-flex:first-of-type > span {
    min-width: 0;
    flex-wrap: wrap;
    overflow-wrap: anywhere;
}

.comments-wrapper input[name="author"]:focus {
    border-color: var(--bs-border-color, #dee2e6);
    box-shadow: none;
    outline: none;
}
.comments-wrapper .jodit-container.jodit_focused {
    border-color: var(--bs-primary, #268aca);
    box-shadow: none;
}
.comments-wrapper .comment-author-name {
    color: var(--bs-emphasis-color, #20354b);
}
.comments-wrapper .comment-item .comment-avatar {
    background: rgba(var(--bs-primary-rgb, 38, 150, 219), 0.08);
}
.comments-wrapper .js-comment-reply {
    color: var(--bs-primary, #268aca) !important;
}

/* Frontend-only reaction chooser; no server requests or artificial counts. */
.comments-wrapper .comment-reaction-trigger {
    width: auto;
    height: auto;
    justify-content: center;
    border: 0;
    background: transparent;
    box-shadow: none;
    color: var(--bs-primary, #268aca);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
}
.comments-wrapper .comment-reaction-trigger:hover,
.comments-wrapper .comment-reaction-trigger.is-selected {
    background: transparent;
}
.comments-wrapper .comment-reactions .dropdown-menu {
    min-width: 0;
}
.comments-wrapper .comment-reactions .js-comment-reaction {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: 28px;
    line-height: 1;
}
.comments-wrapper .comment-reactions .js-comment-reaction.active {
    background: rgba(var(--bs-primary-rgb, 38, 150, 219), 0.12);
    color: inherit;
}

.comments-wrapper .comment-reaction-symbol {
    display: inline-flex;
    align-items: center;
    font-size: 13px;
}
.comments-wrapper .comment-reactions[data-reaction="❤️"] .comment-reaction-trigger {
    color: var(--bs-danger, #dc3545);
}
.comments-wrapper .comment-reactions .js-comment-reaction:focus-visible {
    outline: 2px solid var(--bs-primary, #268aca);
    outline-offset: -2px;
}

.comments-wrapper .comment-reactions .js-comment-reaction {
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    transition: background-color 0.12s ease;
}
.comments-wrapper .comment-reactions .js-comment-reaction:hover {
    background: rgba(var(--bs-primary-rgb, 38, 150, 219), 0.08);
}
