/* ===========================================
   Product Hub — Стили для чата с AI
   Минималистичный дизайн
   =========================================== */

/* ===========================================
   Двухколоночный лейаут (quant-layout)
   =========================================== */
.quant-layout {
    display: flex;
    gap: var(--spacing-lg);
    height: calc(100vh - var(--header-height) - 40px);
    min-height: 500px;
}

.quant-sidebar {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.quant-sidebar .page-header.compact {
    padding: 0;
    margin: 0;
}

.quant-sidebar .page-header.compact h1 {
    font-size: 20px;
    margin-bottom: 4px;
}

.quant-sidebar .page-header.compact p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
}

.quant-sidebar .chat-history-panel {
    flex: 1;
    border: none;
    border-radius: var(--radius-lg);
    background: var(--bg-sidebar);
}

.quant-layout .chat-container {
    flex: 1;
    height: 100%;
    max-width: none;
    margin: 0;
}

/* ===========================================
   Выбор режима
   =========================================== */
.mode-selector {
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-xs);
    background: var(--bg-sidebar);
    border-radius: var(--radius-md);
    width: fit-content;
}

.mode-selector.compact {
    width: 100%;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    flex: 1;
    justify-content: center;
}

.mode-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.mode-btn.active {
    background: var(--bg-main);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.mode-btn svg {
    stroke: currentColor;
}

/* ===========================================
   Выбор инструмента
   =========================================== */
.tool-selection {
    max-width: 900px;
    margin: 0 auto;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-lg);
    margin-top: var(--spacing-xl);
}

.tool-card {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    text-align: left;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.tool-card:hover {
    border-color: var(--text-muted);
}

.tool-icon {
    font-size: 48px;
}

.tool-info h3 {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: var(--spacing-xs);
}

.tool-info p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

.tool-features {
    list-style: none;
    margin-top: var(--spacing-sm);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--border);
}

.tool-features li {
    font-size: 13px;
    color: var(--text-secondary);
    padding: var(--spacing-xs) 0;
    padding-left: 20px;
    position: relative;
}

.tool-features li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: bold;
}

/* ===========================================
   Контейнер чата
   =========================================== */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-main);
    overflow: hidden;
}

/* ===========================================
   Сообщения чата
   =========================================== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.message {
    display: flex;
    gap: var(--spacing-md);
    max-width: 85%;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.assistant {
    align-self: flex-start;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--primary);
    color: white;
}

.message.assistant .message-avatar {
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
}

.message-content {
    background: var(--bg-main);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    border: 1px solid var(--border);
    line-height: 1.6;
    font-size: 14px;
}

.message.user .message-content {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.message-content p {
    margin-bottom: var(--spacing-sm);
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul,
.message-content ol {
    margin: var(--spacing-sm) 0;
    padding-left: var(--spacing-lg);
}

.message-content li {
    margin-bottom: var(--spacing-xs);
}

.message-content code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.9em;
}

.message.user .message-content code {
    background: rgba(255, 255, 255, 0.2);
}

.message-content pre {
    background: var(--bg-sidebar);
    color: var(--text-primary);
    padding: var(--spacing-md);
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: var(--spacing-sm) 0;
    border: 1px solid var(--border);
    font-size: 13px;
}

.message-content pre code {
    background: transparent;
    padding: 0;
    color: inherit;
    font-family: 'SF Mono', Monaco, 'Consolas', monospace;
}

.message-content h1,
.message-content h2,
.message-content h3 {
    margin-top: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
}

.message-content h1 { font-size: 1.3em; }
.message-content h2 { font-size: 1.15em; }
.message-content h3 { font-size: 1.05em; }

.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--spacing-sm) 0;
    font-size: 0.9em;
}

.message-content th,
.message-content td {
    border: 1px solid var(--border);
    padding: var(--spacing-sm);
    text-align: left;
}

.message-content th {
    background: var(--bg-sidebar);
    font-weight: 500;
}

.message-content blockquote {
    border-left: 2px solid var(--border);
    padding-left: var(--spacing-md);
    margin: var(--spacing-sm) 0;
    color: var(--text-secondary);
    font-style: italic;
}

/* Streaming status */
.streaming-status {
    color: var(--text-muted);
    font-size: 13px;
    font-style: italic;
    margin-bottom: var(--spacing-sm);
    display: flex;
    align-items: center;
    gap: 8px;
}

.streaming-status::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.streaming-text {
    min-height: 1em;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: var(--spacing-sm) var(--spacing-md);
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { 
        transform: translateY(0); 
        opacity: 0.4;
    }
    30% { 
        transform: translateY(-6px); 
        opacity: 1;
    }
}

/* ===========================================
   Ввод сообщения
   =========================================== */
.chat-input-container {
    padding: var(--spacing-md);
    border-top: 1px solid var(--border);
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

/* Кнопка микрофона слева */
.mic-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    background: var(--primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(55, 113, 228, 0.3);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.mic-btn:hover {
    transform: scale(1.05);
    background: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(55, 113, 228, 0.4);
}

.mic-btn svg {
    stroke: white;
}

.mic-btn.recording {
    background: var(--error);
    animation: pulse-recording 1s infinite;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

@keyframes pulse-recording {
    0%, 100% { 
        transform: scale(1);
        opacity: 1; 
    }
    50% { 
        transform: scale(1.05);
        opacity: 0.8; 
    }
}

/* Overlay для расшифровки */
.transcribing-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 44px;
    bottom: 0;
    background: var(--bg-main);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: var(--text-muted);
    font-size: 14px;
    z-index: 10;
}

.transcribing-overlay.hidden {
    display: none;
}

.transcribing-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 10px;
    flex-shrink: 0;
}

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

/* Обёртка поля ввода со скрепкой внутри */
.chat-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.chat-input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 44px 12px 16px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    min-height: 44px;
    max-height: 100px;
    overflow-y: hidden;
    transition: border-color 0.15s, height 0.1s ease;
}

.chat-input:focus {
    border-color: var(--text-muted);
}

.chat-input::placeholder {
    color: var(--text-muted);
}

/* Кнопка прикрепления файлов внутри справа */
.attach-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.15s;
}

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

.attach-btn svg {
    stroke: currentColor;
}

/* Кнопка отправки */
.send-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: var(--radius-md);
    background: var(--primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}

.send-btn:hover {
    background: var(--primary-hover);
}

.send-btn:disabled {
    background: var(--border);
    cursor: not-allowed;
}

.send-btn svg {
    stroke: white;
}

/* ===========================================
   Прикреплённые файлы
   =========================================== */
.attached-files {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    padding: 0 var(--spacing-md) var(--spacing-md);
}

.attached-file {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 13px;
    max-width: 200px;
}

.attached-file-icon {
    font-size: 16px;
}

.attached-file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.attached-file-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    padding: 2px;
    line-height: 1;
    transition: color 0.15s;
}

.attached-file-remove:hover {
    color: var(--error);
}

/* ===========================================
   Карточки результатов
   =========================================== */
.result-cards {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin: var(--spacing-md) 0;
}

.result-card {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    cursor: pointer;
    transition: all 0.15s;
}

.result-card:hover {
    border-color: var(--text-muted);
}

.result-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
}

.result-card-title {
    font-size: 15px;
    font-weight: 500;
    margin: 0;
}

.result-card-arrow {
    color: var(--text-muted);
    font-size: 16px;
    transition: transform 0.15s;
}

.result-card:hover .result-card-arrow {
    transform: translateX(2px);
}

.result-card-summary {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: var(--spacing-xs);
    line-height: 1.5;
}

.result-card-meta {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-sm);
    flex-wrap: wrap;
}

.result-card-meta-item {
    font-size: 12px;
    color: var(--text-muted);
}

.result-card-meta-item strong {
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===========================================
   Модалка деталей
   =========================================== */
.detail-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
}

.detail-modal.hidden {
    display: none;
}

.detail-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
}

.detail-modal-content {
    position: relative;
    background: var(--bg-main);
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.detail-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-main);
    z-index: 1;
}

.detail-modal-header h2 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.detail-modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    line-height: 1;
    transition: color 0.15s;
}

.detail-modal-close:hover {
    color: var(--text-primary);
}

.detail-modal-body {
    padding: var(--spacing-lg);
    line-height: 1.6;
    font-size: 14px;
}

.detail-modal-body h3 {
    font-size: 15px;
    font-weight: 600;
    margin: var(--spacing-lg) 0 var(--spacing-sm);
}

.detail-modal-body h3:first-child {
    margin-top: 0;
}

.detail-modal-body p {
    margin-bottom: var(--spacing-sm);
}

.detail-modal-body ul,
.detail-modal-body ol {
    margin: var(--spacing-sm) 0;
    padding-left: var(--spacing-lg);
}

.detail-modal-body li {
    margin-bottom: var(--spacing-xs);
}

.detail-modal-body table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--spacing-md) 0;
    font-size: 13px;
}

.detail-modal-body th,
.detail-modal-body td {
    border: 1px solid var(--border);
    padding: var(--spacing-sm);
    text-align: left;
}

.detail-modal-body th {
    background: var(--bg-sidebar);
    font-weight: 500;
}

/* ===========================================
   Адаптивность
   =========================================== */
@media (max-width: 768px) {
    .tools-grid {
        grid-template-columns: 1fr;
    }
    
    .chat-container {
        height: calc(100vh - 180px);
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .message {
        max-width: 95%;
    }
    
    .mode-selector {
        width: 100%;
    }
    
    .mode-btn {
        flex: 1;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .tool-card {
        padding: var(--spacing-md);
    }
    
    .tool-icon {
        font-size: 36px;
    }
    
    .tool-info h3 {
        font-size: 16px;
    }
    
    .message-content {
        padding: var(--spacing-sm);
    }
}

/* ===========================================
   Лейаут страницы с чатом
   =========================================== */
.chat-page-content {
    padding: var(--spacing-md);
    overflow: hidden;
}

/* ===========================================
   Панель истории чатов
   =========================================== */
.chat-history-panel {
    background: var(--bg-sidebar);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border);
}

.chat-history-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
}

.new-chat-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: var(--radius-sm);
    background: var(--bg-main);
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.new-chat-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

#chat-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-sm);
}

.chat-list-empty {
    text-align: center;
    padding: var(--spacing-lg);
    color: var(--text-muted);
}

.chat-list-empty p {
    margin: 0;
    font-size: 13px;
}

.chat-list-empty .small {
    font-size: 12px;
    margin-top: var(--spacing-xs);
}

.chat-list-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
}

.chat-list-item:hover {
    background: var(--bg-hover);
}

.chat-list-item.active {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.08) 0%, rgba(37, 99, 235, 0.04) 100%);
    border-left: 3px solid var(--accent);
    padding-left: 9px;
}

.chat-list-item.active .chat-list-item-title {
    color: var(--accent);
    font-weight: 500;
}

.chat-list-item.active .chat-list-item-icon {
    opacity: 1;
}

.chat-list-item-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.chat-list-item-title {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-list-item-date {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.chat-list-item-delete {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background: none;
    border: none;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.chat-list-item:hover .chat-list-item-delete {
    display: flex;
}

.chat-list-item-delete:hover {
    background: var(--error-bg);
    color: var(--error);
}

/* ===========================================
   Контейнер чата (в новом лейауте)
   =========================================== */
/* ===========================================
   Адаптивность
   =========================================== */
@media (max-width: 900px) {
    .quant-sidebar {
        width: 220px;
    }
}

@media (max-width: 768px) {
    .quant-layout {
        flex-direction: column;
        height: auto;
    }
    
    .quant-sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: var(--spacing-sm);
    }
    
    .quant-sidebar .chat-history-panel {
        display: none;
    }
    
    .quant-layout .chat-container {
        height: calc(100vh - 200px);
    }
}

/* ===========================================
   Мини-артефакты (внутри чата)
   =========================================== */
.artifacts-bar {
    display: flex;
    gap: 8px;
    padding: 10px var(--spacing-md);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    flex-shrink: 0;
}

.artifacts-bar.hidden {
    display: none;
}

.artifact-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

.artifact-chip:hover {
    border-color: var(--primary);
    background: rgba(55, 113, 228, 0.05);
}

.artifact-chip-icon {
    font-size: 14px;
}

/* Модальное окно артефакта */
.artifact-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.artifact-modal.hidden {
    display: none;
}

.artifact-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.artifact-modal-content {
    position: relative;
    background: var(--bg-main);
    border-radius: var(--radius-lg);
    max-width: 700px;
    max-height: 80vh;
    width: 90%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.artifact-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--border);
}

.artifact-modal-header h2 {
    font-size: 18px;
    font-weight: 500;
    margin: 0;
}

.artifact-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.artifact-modal-close:hover {
    color: var(--text-primary);
}

.artifact-modal-body {
    padding: var(--spacing-lg);
    overflow-y: auto;
    flex: 1;
    font-size: 14px;
    line-height: 1.5;
}

.artifact-modal-body p {
    margin: 0 0 6px 0;
}

/* Убираем пустые параграфы */
.artifact-modal-body p:empty {
    display: none;
}

/* Убираем лишние br перед/после списков */
.artifact-modal-body ul,
.artifact-modal-body ol {
    margin: 4px 0;
    padding-left: 20px;
}

.artifact-modal-body li {
    margin-bottom: 2px;
    line-height: 1.4;
}

/* Убираем br внутри li */
.artifact-modal-body li br {
    display: none;
}

.artifact-modal-body strong {
    font-weight: 600;
}

.artifact-modal-body pre {
    background: var(--bg-sidebar);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.5;
    margin: 6px 0;
}

/* Заголовки в модальном окне */
.artifact-modal-body h1,
.artifact-modal-body h2,
.artifact-modal-body h3 {
    margin: 12px 0 6px 0;
}

.artifact-modal-body h1 { font-size: 1.2em; }
.artifact-modal-body h2 { font-size: 1.1em; }
.artifact-modal-body h3 { font-size: 1em; }

.artifact-modal-actions {
    padding: var(--spacing-md) var(--spacing-lg);
    border-top: 1px solid var(--border);
    display: flex;
    gap: var(--spacing-sm);
    justify-content: flex-end;
}

.artifact-btn {
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.artifact-btn-primary {
    background: var(--primary);
    color: white;
    border: none;
}

.artifact-btn-primary:hover {
    background: var(--primary-hover);
}

.artifact-btn-secondary {
    background: var(--bg-sidebar);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.artifact-btn-secondary:hover {
    background: var(--bg-hover);
}

.artifact-btn-bug {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 8px 12px;
}

.artifact-btn-bug:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
    color: var(--danger);
}

.artifact-btn-bug svg {
    stroke: currentColor;
}

/* =============================================
   АРТЕФАКТ "ДИЗАЙН ВЫБОРКИ" — СТРУКТУРИРОВАННЫЙ ВИД
   ============================================= */

/* Выделенный блок "Итого" */
.sample-highlight {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(59, 130, 246, 0.05) 100%);
    border: 2px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 20px;
}

.sample-highlight-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.sample-highlight-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Квоты */
.sample-quotas {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(59, 130, 246, 0.2);
}

.sample-quotas-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.sample-quotas-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sample-quota-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(59, 130, 246, 0.1);
}

.sample-quota-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.sample-quota-item:first-child {
    padding-top: 0;
}

.sample-quota-name {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.sample-quota-value {
    color: var(--text-primary);
    line-height: 1.5;
}

/* Старый формат тегов (для совместимости) */
.sample-quota-tag {
    display: inline-block;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px 8px;
    font-size: 12px;
    color: var(--text-secondary);
    margin: 2px 4px 2px 0;
}

/* Секции артефакта */
.sample-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.sample-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.sample-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.sample-section-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.sample-section-note {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.sample-section-note em {
    color: var(--text-muted);
    font-style: italic;
}

/* Источники */
.sample-sources {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sample-source {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-sidebar);
    border-radius: var(--radius-md);
    gap: 12px;
}

.sample-source-info {
    flex: 1;
    min-width: 0;
}

.sample-source-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
}

.sample-source-link:hover {
    text-decoration: underline;
}

.sample-source-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.sample-source-trust {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.sample-source-trust-text {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: capitalize;
}

/* Иконка доверия — как сигнал сотовой связи */
.trust-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 16px;
}

.trust-bar {
    width: 4px;
    border-radius: 1px;
    transition: all 0.2s;
}

/* Tooltip иконка для объяснения доверия */
.trust-tooltip-icon {
    font-size: 12px;
    cursor: help;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.trust-tooltip-icon:hover {
    opacity: 1;
}

/* Tooltip для sample-source-trust */
.sample-source-trust {
    position: relative;
}

.sample-source-trust[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    right: 0;
    background: var(--text-primary);
    color: white;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 12px;
    line-height: 1.5;
    white-space: normal;
    max-width: 320px;
    min-width: 200px;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    margin-bottom: 6px;
}

/* =============================================
   АРТЕФАКТ "ДИЗАЙН ИССЛЕДОВАНИЯ"
   ============================================= */

.design-highlight {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(59, 130, 246, 0.05) 100%);
    border: 2px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 20px;
}

.design-highlight-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.design-highlight-value {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.5;
}

.design-section {
    margin-bottom: 20px;
}

.design-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

/* Задачи */
.design-tasks {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.design-task {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-sidebar);
    border-radius: var(--radius-md);
}

.design-task-number {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

.design-task-text {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
}

/* Методология */
.design-methodology {
    margin-bottom: 12px;
}

.design-method-badge {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 6px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
}

/* Метрики */
.design-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.design-metric-badge {
    display: inline-block;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 13px;
}

/* =============================================
   СЕКЦИЯ КЛЮЧЕВЫХ РИСКОВ (оранжевые)
   ============================================= */
.design-risks-section {
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.design-risks-section .design-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--warning);
}

.design-risks-icon {
    font-size: 14px;
}

.design-risks {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.design-risk {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, rgba(245, 158, 11, 0.03) 100%);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
}

.design-risk-title {
    font-weight: 600;
    color: var(--text-primary);
}

.design-risk-desc {
    color: var(--text-secondary);
}

/* =============================================
   СЕКЦИЯ ОБЩИХ РИСКОВ (серые/нейтральные)
   ============================================= */
.design-general-risks-section {
    margin-top: 8px;
}

.design-general-risks {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.design-general-risk {
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.5;
}

.design-general-risk .design-risk-title {
    font-weight: 600;
    color: var(--text-primary);
}

.design-general-risk .design-risk-desc {
    color: var(--text-secondary);
}

/* =============================================
   СЕКЦИЯ РЕКОМЕНДАЦИЙ (зелёные)
   ============================================= */
.design-mitigations-section {
    margin-top: 8px;
}

.design-mitigations-section .design-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--success);
}

.design-mitigation-icon {
    font-size: 14px;
}

.design-mitigations {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.design-mitigation {
    background: linear-gradient(135deg, rgba(16, 163, 74, 0.08) 0%, rgba(16, 163, 74, 0.03) 100%);
    border: 1px solid rgba(16, 163, 74, 0.3);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
}

/* =============================================
   АРТЕФАКТ "АНКЕТА"
   ============================================= */

.survey-intro {
    background: linear-gradient(135deg, rgba(16, 163, 74, 0.1) 0%, rgba(16, 163, 74, 0.05) 100%);
    border: 1px solid var(--success);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    margin-bottom: 20px;
}

.survey-intro-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--success);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.survey-intro-text {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.6;
}

.survey-questions {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.survey-question {
    background: var(--bg-sidebar);
    border-radius: var(--radius-md);
    padding: 14px 18px;
}

.survey-question-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.survey-question-number {
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
}

.survey-question-type {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.survey-question-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.survey-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-left: 4px;
}

.survey-option {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.survey-option-marker {
    color: var(--text-muted);
    font-size: 14px;
}

.survey-open-field {
    background: white;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
}

.survey-open-placeholder {
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
}

.survey-outro {
    background: linear-gradient(135deg, rgba(16, 163, 74, 0.08) 0%, rgba(16, 163, 74, 0.03) 100%);
    border: 1px solid rgba(16, 163, 74, 0.3);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    margin-top: 20px;
}

.survey-outro-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--success);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.survey-outro-text {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.6;
    font-style: italic;
}

/* Сводка анкеты (вверху артефакта) */
.survey-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: white;
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

.survey-summary-main {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.survey-summary-count {
    font-size: 32px;
    font-weight: 700;
    line-height: 1;
}

.survey-summary-label {
    font-size: 16px;
    opacity: 0.9;
}

.survey-summary-details {
    display: flex;
    align-items: center;
    gap: 12px;
}

.survey-summary-time {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
}

/* Бейджи типов вопросов */
.survey-type-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.survey-type-badge {
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
}

.survey-type-single {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.survey-type-multiple {
    background: rgba(139, 92, 246, 0.1);
    color: #8B5CF6;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.survey-type-scale {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.survey-type-open {
    background: rgba(16, 163, 74, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 163, 74, 0.3);
}

/* Секции анкеты */
.survey-sections {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    padding: 10px 14px;
    background: var(--bg-sidebar);
    border-radius: var(--radius-md);
}

.survey-sections-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.survey-section-badge {
    background: white;
    border: 1px solid var(--border);
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-primary);
}

/* Улучшенные вопросы */
.survey-question {
    background: var(--bg-sidebar);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    border-left: 3px solid var(--border);
    transition: border-color 0.2s;
}

.survey-question:hover {
    border-left-color: var(--primary);
}

.survey-question-single {
    border-left-color: rgba(59, 130, 246, 0.5);
}

.survey-question-multiple {
    border-left-color: rgba(139, 92, 246, 0.5);
}

.survey-question-scale {
    border-left-color: rgba(245, 158, 11, 0.5);
}

.survey-question-open {
    border-left-color: rgba(16, 163, 74, 0.5);
}

.survey-type-icon {
    margin-right: 4px;
}

.survey-option-text {
    flex: 1;
}

/* Превью шкалы */
.survey-scale-preview {
    display: flex;
    gap: 8px;
    padding: 8px 0;
}

.survey-scale-item {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid var(--border);
    border-radius: 50%;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Улучшенное вступление */
.survey-intro {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08) 0%, rgba(59, 130, 246, 0.03) 100%);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    margin-bottom: 16px;
}

.survey-intro-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 8px;
}

.survey-intro-text {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.6;
    font-style: italic;
}

/* =============================================
   УТОЧНЯЮЩИЕ ВОПРОСЫ В СООБЩЕНИЯХ
   ============================================= */

.clarifying-questions {
    margin-top: 16px;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(245, 158, 11, 0.05) 100%);
    border: 1px solid var(--warning);
    border-radius: var(--radius-md);
}

.clarifying-questions-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--warning);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.clarifying-questions-icon {
    font-size: 14px;
}

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

.clarifying-questions-content {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.5;
}

.clarifying-questions-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

.clarifying-questions-content li {
    margin-bottom: 6px;
}

.clarifying-question {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
}

/* ===========================================
   Индикатор присутствия (кто в чате)
   =========================================== */
.presence-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border-radius: var(--radius-md);
    font-size: 12px;
    color: #2e7d32;
    margin-left: auto;
    animation: presenceFadeIn 0.3s ease;
}

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

.presence-dot {
    width: 8px;
    height: 8px;
    background: #4caf50;
    border-radius: 50%;
    animation: presencePulse 2s ease-in-out infinite;
}

@keyframes presencePulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(0.9);
    }
}

.presence-text {
    font-weight: 500;
}

/* В истории чатов — маленькая иконка если кто-то в чате */
.chat-list-item .presence-badge {
    width: 8px;
    height: 8px;
    background: #4caf50;
    border-radius: 50%;
    margin-left: auto;
    flex-shrink: 0;
}
