/**
 * Mimexpert Universal Conversation Widget Styles
 * Solid, ergonomic, dark glassmorphic design system.
 */

:root {
    --mimex-accent-blue: #3b82f6;
    --mimex-accent-blue-rgb: 59, 130, 246;
    --mimex-accent-sky: #38bdf8;
    --mimex-accent-sky-rgb: 56, 189, 248;
}

.conversation-widget {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
    border-radius: 18px;
    margin: 0;
    background: rgba(30, 41, 59, 0.72);
    border: 1px solid rgba(59, 130, 246, 0.25);
    box-shadow:
        0 0 0 1px rgba(59, 130, 246, 0.05) inset,
        0 12px 32px rgba(0, 0, 0, 0.24);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.conversation-widget::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(
            circle at top right,
            rgba(59, 130, 246, 0.08),
            transparent 45%
        );
    pointer-events: none;
}

.conversation-widget > * {
    position: relative;
    z-index: 1;
}

.conversation-widget__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.conversation-widget__heading {
    min-width: 0;
    flex: 1;
}

.conversation-widget__title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.25;
    color: rgba(255, 255, 255, 0.96);
}

.conversation-widget__subtitle {
    margin-top: 4px;
    font-size: 13px;
    line-height: 1.45;
    color: #94a3b8;
}

.conversation-widget__status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 999px;
    white-space: nowrap;
    font-size: 12px;
    line-height: 1;
    font-weight: 600;
    color: #93c5fd;
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.28);
}

.conversation-widget__messages {
    min-height: 280px;
    max-height: 420px;
    overflow-y: auto;
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}

.conversation-widget__messages::-webkit-scrollbar {
    width: 8px;
}

.conversation-widget__messages::-webkit-scrollbar-track {
    background: transparent;
}

.conversation-widget__messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 999px;
}

.conversation-widget__messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.30);
}

.conversation-widget__placeholder {
    font-size: 14px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.68);
}

.conversation-widget__message {
    display: flex;
    margin-bottom: 12px;
}

.conversation-widget__message:last-child {
    margin-bottom: 0;
}

.conversation-widget__message--own {
    justify-content: flex-end;
}

.conversation-widget__bubble {
    max-width: 84%;
    padding: 12px 14px;
    border-radius: 16px 16px 16px 4px;
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.18);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.20);
}

.conversation-widget__message--own .conversation-widget__bubble {
    border-radius: 16px 16px 4px 16px;
    background: linear-gradient(
        135deg,
        rgba(30, 58, 138, 0.45) 0%,
        rgba(37, 99, 235, 0.20) 100%
    );
    border-color: rgba(96, 165, 250, 0.35);
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.22),
        0 0 0 1px rgba(59, 130, 246, 0.08) inset;
}

.conversation-widget__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
    font-size: 12px;
    line-height: 1.2;
}

.conversation-widget__author {
    font-weight: 700;
    color: #e2e8f0;
}

.conversation-widget__message--own .conversation-widget__author {
    color: #93c5fd;
}

.conversation-widget__time {
    color: #64748b;
    font-size: 11.5px;
    white-space: nowrap;
}

.conversation-widget__message--own .conversation-widget__time {
    color: #94a3b8;
}

.conversation-widget__body {
    font-size: 14px;
    line-height: 1.55;
    color: #f1f5f9;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Реакции на сообщения */
/* Бейдж реакций на десктопе (отображается ТОЛЬКО если есть хотя бы 1 реакция) */
.conversation-widget__bubble {
    position: relative;
}

.conversation-widget__reaction-pill {
    position: absolute;
    bottom: -9px;
    right: 12px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 7px;
    border-radius: 12px;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #cbd5e1;
    font-size: 11.5px;
    line-height: 1.2;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
    z-index: 2;
    user-select: none;
    transition: transform 0.12s ease, background 0.15s ease;
}

.conversation-widget__message:not(.conversation-widget__message--own) .conversation-widget__reaction-pill {
    right: auto;
    left: 12px;
}

.conversation-widget__reaction-pill:active {
    transform: scale(0.92);
}

.conversation-widget__reaction-pill.is-liked {
    background: #1e3a8a;
    border-color: #3b82f6;
    color: #ffffff;
}

.conversation-widget__reaction-icon {
    font-size: 12px;
    line-height: 1;
}

.conversation-widget__reaction-count {
    font-weight: 600;
    font-size: 11px;
    line-height: 1;
}

.conversation-widget__message.has-reaction {
    margin-bottom: 16px;
}

/* Кнопка реакции на десктопе — появляется ТОЛЬКО при наведении курсора на сообщение */
.conversation-widget__hover-react {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.1s ease;
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    margin: 0 6px;
    align-self: center;
    color: #94a3b8;
    user-select: none;
    flex-shrink: 0;
}

.conversation-widget__hover-react:hover {
    background: rgba(59, 130, 246, 0.25);
    border-color: rgba(96, 165, 250, 0.5);
    color: #ffffff;
}

.conversation-widget__hover-react.is-liked {
    color: #60a5fa;
    border-color: rgba(96, 165, 250, 0.5);
    background: rgba(37, 99, 235, 0.25);
}

.conversation-widget__hover-react:active {
    transform: scale(0.9);
}

.conversation-widget__message:hover .conversation-widget__hover-react {
    opacity: 1;
    pointer-events: auto;
}

.conversation-widget__form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.conversation-widget__textarea {
    width: 100%;
    min-height: 86px;
    margin: 0;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(15, 23, 42, 0.85);
    color: #f8fafc;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.conversation-widget__textarea::placeholder {
    color: #64748b;
}

.conversation-widget__textarea:focus {
    outline: none;
    border-color: rgba(59, 130, 246, 0.65);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.conversation-widget__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.conversation-widget__error {
    font-size: 13px;
    line-height: 1.4;
    color: #fca5a5;
}

.conversation-widget__send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 0 0 auto;
    min-width: 130px;
    height: 40px;
    padding: 0 20px;
    border-radius: 12px;
    border: 1px solid rgba(96, 165, 250, 0.45);
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.30);
    transition: all 0.2s ease;
    user-select: none;
    outline: none;
    white-space: nowrap;
}

.conversation-widget__send:hover {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border-color: rgba(147, 197, 253, 0.65);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45);
    transform: translateY(-1px);
}

.conversation-widget__send:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.conversation-widget__send:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(51, 65, 85, 0.8);
}

@media (max-width: 1100px) {
    .conversation-widget__messages {
        max-height: 340px;
    }
}

@media (max-width: 640px) {
    .conversation-widget {
        padding: 14px;
        border-radius: 16px;
        gap: 12px;
    }

    .conversation-widget__header {
        flex-direction: column;
        align-items: stretch;
    }

    .conversation-widget__status {
        align-self: flex-start;
    }

    .conversation-widget__messages {
        min-height: 220px;
        max-height: 300px;
        padding: 10px;
        border-radius: 12px;
    }

    .conversation-widget__bubble {
        max-width: 92%;
        padding: 10px 12px;
        border-radius: 14px;
    }

    .conversation-widget__footer {
        flex-direction: column;
        align-items: stretch;
    }

    .conversation-widget__send {
        width: 100%;
        min-width: 0;
    }
}

.conversation-widget__intro {
    background: rgba(15, 23, 42, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 16px 18px;
    margin-bottom: 8px;
}

.conversation-widget__intro-title {
    font-size: 14px;
    font-weight: 700;
    color: #e2e8f0;
    margin-bottom: 6px;
}

.conversation-widget__intro-text {
    font-size: 13px;
    line-height: 1.45;
    color: #94a3b8;
    margin-bottom: 10px;
}

.conversation-widget__intro-note {
    font-size: 12px;
    line-height: 1.4;
    color: #64748b;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 8px;
}

/* Context Chip above Form Input */
.conversation-widget__context-chip {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 14px;
    border-radius: 10px;
    background: rgba(14, 116, 144, 0.20);
    border: 1px solid rgba(56, 189, 248, 0.40);
    font-size: 13px;
    color: #e0f2fe;
    margin-bottom: 4px;
}

.conversation-widget__context-chip strong {
    color: #38bdf8;
    font-family: monospace;
    font-size: 13.5px;
    letter-spacing: 0.8px;
}

.conversation-widget__context-remove {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.conversation-widget__context-remove:hover {
    color: #f87171;
    background: rgba(248, 113, 113, 0.15);
}

/* Message Result Context Block */
.conversation-widget__msg-context {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 7px 12px;
    border-radius: 8px;
    background: rgba(14, 116, 144, 0.18);
    border: 1px solid rgba(56, 189, 248, 0.35);
    margin-bottom: 8px;
    font-size: 12.5px;
    color: #bae6fd;
}

.conversation-widget__msg-context strong {
    color: #38bdf8;
    font-family: monospace;
    font-size: 13px;
    letter-spacing: 0.6px;
}

.conversation-widget__msg-context--unavailable {
    background: rgba(148, 163, 184, 0.08);
    border-color: rgba(148, 163, 184, 0.20);
    color: #94a3b8;
}

.conversation-widget__msg-context--unavailable strong {
    color: #cbd5e1;
}

.conversation-widget__msg-context-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.45);
    text-decoration: none;
    transition: all 0.15s ease;
}

.conversation-widget__msg-context-btn:hover {
    background: rgba(56, 189, 248, 0.30);
    border-color: rgba(56, 189, 248, 0.75);
    color: #ffffff;
    transform: translateY(-1px);
}