/**
 * DevBrothers Comments — frontend
 */

.dbcmt {
    --dbcmt-bg: #f4f6f8;
    --dbcmt-surface: #ffffff;
    --dbcmt-text: #1d2327;
    --dbcmt-muted: #646970;
    --dbcmt-border: #d8dde3;
    --dbcmt-accent: #2271b1;
    --dbcmt-accent-text: #ffffff;
    --dbcmt-danger: #d63638;
    --dbcmt-radius: 16px;
    --dbcmt-shadow: 0 8px 28px rgba(15, 23, 42, 0.06);
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    margin: 48px auto 24px;
    padding: 24px;
    color: var(--dbcmt-text);
    background: var(--dbcmt-bg);
    border: 1px solid var(--dbcmt-border);
    border-radius: calc(var(--dbcmt-radius) + 4px);
    font-family: inherit;
    line-height: 1.5;
}

.dbcmt[data-theme="dark"] {
    --dbcmt-bg: #14171c;
    --dbcmt-surface: #1d2229;
    --dbcmt-text: #eef2f6;
    --dbcmt-muted: #9aa3b2;
    --dbcmt-border: #2c333d;
    --dbcmt-accent: #6ea8fe;
    --dbcmt-accent-text: #10141a;
    --dbcmt-danger: #ff8085;
    --dbcmt-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

.dbcmt *,
.dbcmt *::before,
.dbcmt *::after {
    box-sizing: border-box;
}

.dbcmt .screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.dbcmt-hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.dbcmt-composer {
    margin: 0 0 28px;
}

.dbcmt-reply-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    padding: 8px 12px;
    background: var(--dbcmt-surface);
    border: 1px solid var(--dbcmt-border);
    border-radius: 999px;
    color: var(--dbcmt-muted);
    font-size: 13px;
}

.dbcmt-chip-cancel {
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0 4px;
}

.dbcmt-composer-box {
    background: var(--dbcmt-surface);
    border: 1px solid var(--dbcmt-border);
    border-radius: var(--dbcmt-radius);
    box-shadow: var(--dbcmt-shadow);
    overflow: hidden;
}

.dbcmt-composer-box textarea {
    display: block;
    width: 100%;
    min-height: 96px;
    margin: 0;
    padding: 16px 18px 8px;
    border: 0;
    resize: vertical;
    background: transparent;
    color: var(--dbcmt-text);
    font: inherit;
    line-height: 1.55;
}

.dbcmt-composer-box textarea:focus {
    outline: none;
}

.dbcmt-composer-box textarea::placeholder {
    color: var(--dbcmt-muted);
}

.dbcmt-preview {
    position: relative;
    display: inline-block;
    margin: 0 18px 8px;
}

.dbcmt-preview img {
    display: block;
    max-width: 180px;
    max-height: 120px;
    object-fit: cover;
    border-radius: 10px;
}

.dbcmt-preview-remove,
.dbcmt-chip-cancel:hover {
    color: var(--dbcmt-danger);
}

.dbcmt-preview-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 50%;
    background: var(--dbcmt-text);
    color: var(--dbcmt-surface);
    cursor: pointer;
    font-size: 14px;
    line-height: 22px;
    padding: 0;
}

.dbcmt-composer-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 8px 12px 12px;
}

.dbcmt-attach {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-right: auto;
    border-radius: 10px;
    color: var(--dbcmt-muted);
    cursor: pointer;
}

.dbcmt-attach:hover {
    background: var(--dbcmt-bg);
    color: var(--dbcmt-text);
}

.dbcmt-attach input {
    display: none;
}

.dbcmt-submit {
    min-width: 128px;
    height: 40px;
    padding: 0 18px;
    border: 0;
    border-radius: 999px;
    background: var(--dbcmt-accent);
    color: var(--dbcmt-accent-text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.dbcmt-submit:hover {
    filter: brightness(1.05);
}

.dbcmt-submit:disabled {
    opacity: 0.65;
    cursor: wait;
}

.dbcmt-name-row[hidden],
.dbcmt-reply-chip[hidden],
.dbcmt-preview[hidden],
.dbcmt-message[hidden] {
    display: none !important;
}

.dbcmt-name-row {
    display: grid;
    gap: 6px;
    margin-top: 12px;
}

.dbcmt-name-row label {
    font-size: 13px;
    color: var(--dbcmt-muted);
}

.dbcmt-name-row input {
    width: 100%;
    max-width: 320px;
    height: 42px;
    padding: 0 14px;
    border: 1px solid var(--dbcmt-border);
    border-radius: 12px;
    background: var(--dbcmt-surface);
    color: var(--dbcmt-text);
    font: inherit;
}

.dbcmt-name-row input:focus {
    outline: 2px solid var(--dbcmt-accent);
    outline-offset: 1px;
}

.dbcmt-captcha {
    margin-top: 12px;
    min-height: 0;
}

.dbcmt-message {
    margin: 10px 0 0;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
}

.dbcmt-message.is-error {
    color: var(--dbcmt-danger);
    background: rgba(214, 54, 56, 0.1);
}

.dbcmt-message.is-ok {
    color: #008a20;
    background: rgba(0, 163, 42, 0.12);
}

.dbcmt[data-theme="dark"] .dbcmt-message.is-ok {
    color: #8be59a;
    background: rgba(104, 222, 124, 0.12);
}

.dbcmt-captcha-notice {
    margin: 10px 0 0;
    font-size: 12px;
    color: var(--dbcmt-muted);
}

.dbcmt-captcha-notice a {
    color: inherit;
    text-decoration: underline;
}

.dbcmt-closed {
    margin: 0 0 20px;
    color: var(--dbcmt-muted);
}

.dbcmt-title {
    margin: 0 0 18px;
    padding: 0;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--dbcmt-text);
}

.dbcmt-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dbcmt-thread {
    padding: 4px 0 8px;
}

.dbcmt-item {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 12px;
    padding: 12px 4px;
}

.dbcmt-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: hsl(var(--dbcmt-hue, 210), 42%, 46%);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.dbcmt[data-theme="dark"] .dbcmt-avatar {
    background: hsl(var(--dbcmt-hue, 210), 38%, 40%);
}

.dbcmt-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px 10px;
    margin-bottom: 6px;
}

.dbcmt-author {
    font-weight: 700;
}

.dbcmt-reply-to,
.dbcmt-when {
    color: var(--dbcmt-muted);
    font-size: 13px;
}

.dbcmt-text {
    color: var(--dbcmt-text);
    font-size: 15px;
}

.dbcmt-text p {
    margin: 0 0 10px;
    color: var(--dbcmt-text);
}

.dbcmt-text p:last-child {
    margin-bottom: 0;
}

.dbcmt-image {
    display: block;
    max-width: min(100%, 420px);
    height: auto;
    margin: 12px 0 4px;
    border-radius: 12px;
}

.dbcmt-actions {
    margin-top: 8px;
}

.dbcmt-reply-btn {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--dbcmt-accent);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.dbcmt-reply-btn:hover {
    text-decoration: underline;
}

.dbcmt-replies {
    margin: 0 0 0 28px;
    padding-left: 14px;
    border-left: 2px solid var(--dbcmt-border);
}

.dbcmt-more {
    display: block;
    width: 100%;
    margin-top: 16px;
    padding: 12px;
    border: 1px solid var(--dbcmt-border);
    border-radius: 12px;
    background: var(--dbcmt-surface);
    color: var(--dbcmt-text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.dbcmt-more:hover {
    border-color: var(--dbcmt-accent);
}

@media (max-width: 600px) {
    .dbcmt {
        margin: 32px 0 16px;
        padding: 16px 12px;
        border-radius: 16px;
    }

    .dbcmt-replies {
        margin-left: 12px;
        padding-left: 10px;
    }

    .dbcmt-item {
        grid-template-columns: 32px minmax(0, 1fr);
        gap: 10px;
    }

    .dbcmt-avatar {
        width: 32px;
        height: 32px;
        font-size: 11px;
    }
}

/*
 * Тема (и настройки H2) красит заголовки и p глобально, часто с !important.
 * Цвета блока комментариев держим внутри .dbcmt.
 */
body .dbcmt,
body .dbcmt .dbcmt-title,
body .dbcmt h2.dbcmt-title,
body .dbcmt .dbcmt-author,
body .dbcmt .dbcmt-text,
body .dbcmt .dbcmt-text p,
body .dbcmt .dbcmt-more {
    color: var(--dbcmt-text) !important;
}

body .dbcmt .dbcmt-title,
body .dbcmt h2.dbcmt-title {
    font-size: 22px !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    margin: 0 0 18px !important;
}

body .dbcmt .dbcmt-when,
body .dbcmt .dbcmt-reply-to,
body .dbcmt .dbcmt-closed,
body .dbcmt .dbcmt-name-row label {
    color: var(--dbcmt-muted) !important;
}

body .dbcmt .dbcmt-reply-btn {
    color: var(--dbcmt-accent) !important;
}

body .dbcmt .dbcmt-message.is-ok {
    color: #008a20 !important;
}

body .dbcmt[data-theme="dark"] .dbcmt-message.is-ok {
    color: #8be59a !important;
}

body .dbcmt .dbcmt-message.is-error {
    color: var(--dbcmt-danger) !important;
}
