/* ==================== ОБЩИЕ СТИЛИ ==================== */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #22263a;
    --bg-card-hover: #2a2f45;
    --bg-input: #181b25;
    --border: #2d3148;
    --text-primary: #e4e6f0;
    --text-secondary: #8b8fa3;
    --text-muted: #5c6078;
    --accent: #5b6eea;
    --accent-hover: #4c5dd6;
    --green: #34d399;
    --green-bg: rgba(52, 211, 153, 0.12);
    --red: #f87171;
    --red-bg: rgba(248, 113, 113, 0.12);
    --yellow: #fbbf24;
    --yellow-bg: rgba(251, 191, 36, 0.12);
    --blue: #60a5fa;
    --blue-bg: rgba(96, 165, 250, 0.15);
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 2px 12px rgba(0,0,0,0.25);
    --transition: 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ==================== КНОПКИ ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-green { background: var(--green); color: #000; }
.btn-green:hover:not(:disabled) { opacity: 0.85; }
.btn-red { background: var(--red); color: #000; }
.btn-red:hover:not(:disabled) { opacity: 0.85; }
.btn-gray { background: #3a3f55; color: var(--text-primary); }
.btn-gray:hover:not(:disabled) { background: #4a4f65; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); }
.btn-outline:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; }
.btn-icon { padding: 6px 8px; font-size: 16px; }

/* ==================== ФОРМЫ ==================== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}
input[type="text"], input[type="password"], input[type="number"],
input[type="email"], input[type="file"], select, textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition);
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(91, 110, 234, 0.2);
}
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }

.error-message {
    background: var(--red-bg);
    color: var(--red);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 12px;
}

/* ==================== LOGIN ==================== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f1117 0%, #1a1d2e 100%);
}
.login-container { width: 100%; max-width: 400px; padding: 20px; }
.login-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 32px;
    box-shadow: var(--shadow);
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-header h1 { font-size: 26px; margin-bottom: 6px; }
.login-header p { color: var(--text-secondary); font-size: 14px; }

/* ==================== DASHBOARD LAYOUT ==================== */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

/* Боковое меню */
.sidebar {
    width: 220px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}
.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}
.sidebar-header h2 { font-size: 16px; color: var(--text-primary); }
.sidebar-header small { color: var(--text-muted); font-size: 11px; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text-secondary);
    font-size: 14px;
    text-decoration: none;
    transition: var(--transition);
    border-left: 3px solid transparent;
}
.sidebar-nav a:hover {
    color: var(--text-primary);
    background: rgba(91, 110, 234, 0.06);
}
.sidebar-nav a.active {
    color: var(--accent);
    background: rgba(91, 110, 234, 0.1);
    border-left-color: var(--accent);
}
.sidebar-nav a .nav-icon { font-size: 18px; width: 24px; text-align: center; }
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-muted);
}
.sidebar-footer .user-info { margin-bottom: 8px; }
.sidebar-footer .logout-btn {
    color: var(--red);
    cursor: pointer;
    font-size: 13px;
    background: none;
    border: none;
    padding: 0;
}
.sidebar-footer .logout-btn:hover { text-decoration: underline; }

/* Контент */
.main-content {
    flex: 1;
    margin-left: 220px;
    padding: 24px 32px;
    min-height: 100vh;
}
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.page-header h1 { font-size: 22px; font-weight: 600; }

/* ==================== STAT CARDS ==================== */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
}

/* ==================== КАРТОЧКИ ==================== */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: var(--transition);
}
.card:hover { border-color: var(--accent); }
.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}
.card-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--text-muted);
    overflow: hidden;
    flex-shrink: 0;
}
.card-avatar img { width: 100%; height: 100%; object-fit: cover; }
.card-title { font-size: 16px; font-weight: 600; }
.card-subtitle { font-size: 13px; color: var(--text-secondary); }
.card-body { font-size: 13px; color: var(--text-secondary); }
.card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

/* Статусы */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}
.status-online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-running { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-offline { background: var(--text-muted); }
.status-stopped { background: var(--text-muted); }
.status-paused { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }

/* ==================== ТАБЛИЦЫ ==================== */
.table-wrapper { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
th {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    background: var(--bg-card);
}
tr:hover td { background: rgba(91, 110, 234, 0.04); }

/* ==================== МОДАЛЬНОЕ ОКНО ==================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}
.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.modal h2 { margin-bottom: 20px; font-size: 18px; }
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ==================== ЧАТЫ ==================== */
.chats-layout {
    display: grid;
    grid-template-columns: 180px 230px 1fr;
    height: calc(100vh - 130px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-card);
}

.chat-col {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    overflow: hidden;
}
.chat-col:last-child { border-right: none; }
.chat-col.chat-col-messages { min-height: 0; }

.chat-col-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}
.chat-list-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--border);
}
.chat-list-item:hover { background: var(--bg-card-hover); }
.chat-list-item.active { background: rgba(91, 110, 234, 0.12); border-left: 3px solid var(--accent); }
.chat-list-item .item-name { font-size: 14px; font-weight: 500; display: flex; align-items: center; }
.chat-list-item .item-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.chat-list-item .item-badge {
    display: inline-flex;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    align-items: center;
    justify-content: center;
    float: right;
}

/* Окно переписки */
.chat-messages-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}
.chat-messages-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary);
    flex-shrink: 0;
}
.chat-messages-header .contact-name { font-weight: 600; font-size: 15px; }
.chat-messages-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.chat-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 14px;
}

/* Пузырьки сообщений */
.message-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.45;
    word-break: break-word;
}
.message-bubble.user {
    align-self: flex-start;
    background: #2a2f45;
    border-bottom-left-radius: 4px;
}
.message-bubble.blocked-msg {
    border: 1px solid rgba(248, 113, 113, 0.4);
    opacity: 0.7;
}
.message-bubble.agent {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}
.message-bubble.agent .message-time { color: rgba(255,255,255,0.6); }
.message-bubble audio { max-width: 240px; }
.message-bubble img { max-width: 100%; border-radius: 8px; margin-top: 6px; }

/* Бейдж голосового сообщения */
.voice-badge {
    display: inline-block;
    font-size: 13px;
    opacity: 0.8;
    cursor: help;
}

/* Ввод сообщения */
.chat-input-area {
    padding: 8px 12px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    align-items: flex-end;
    background: var(--bg-secondary);
    flex-shrink: 0;
}
.chat-input-area textarea {
    flex: 1;
    min-height: 34px;
    max-height: 100px;
    resize: none;
    padding: 6px 10px;
    font-size: 13px;
}
.chat-input-area .btn { height: 38px; }

/* ==================== ПЕРСОНЫ ==================== */
.persona-card .persona-note {
    font-style: italic;
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 6px;
}
.persona-card .persona-bio {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.persona-card .persona-prompt {
    font-size: 12px;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    background: var(--bg-input);
    padding: 8px;
    border-radius: var(--radius-sm);
    margin-top: 6px;
}

/* Медиафайлы — шторка */
.media-toggle {
    cursor: pointer;
    color: var(--accent);
    font-size: 13px;
    margin-top: 10px;
    user-select: none;
}
.media-toggle:hover { text-decoration: underline; }
.media-panel {
    display: none;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.media-panel.open { display: block; }
.media-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}
.media-item {
    position: relative;
    width: 80px;
    text-align: center;
}
.media-item img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid var(--border);
}
.media-item .media-icon {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    font-size: 28px;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.media-item .media-key {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.media-item .media-delete {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--red);
    color: #fff;
    border: none;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ==================== ПРОКСИ ==================== */
.proxy-upload-area {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}
.proxy-upload-area textarea {
    min-height: 100px;
    margin-bottom: 12px;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 13px;
}
.progress-bar {
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 10px;
    display: none;
}
.progress-bar .progress-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.3s;
    border-radius: 2px;
}

/* ==================== МЕДИА ПРОСМОТР ==================== */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    cursor: pointer;
}
.lightbox img {
    max-width: 90%;
    max-height: 90%;
    border-radius: var(--radius);
}

/* ==================== СКРОЛЛБАР ==================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ==================== ДОСЬЕ КОНТАКТА ==================== */
.contact-panel {
    width: 0;
    overflow: hidden;
    border-left: 1px solid var(--border);
    background: var(--bg-secondary);
    transition: width 0.25s ease;
    flex-shrink: 0;
}
.contact-panel.open {
    width: 300px;
}
.contact-panel-inner {
    width: 300px;
    height: 100%;
    overflow-y: auto;
    padding: 0;
}

.profile-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    position: relative;
}
.profile-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}
.profile-username {
    font-size: 13px;
    color: var(--text-secondary);
}
.profile-stage {
    font-size: 13px;
    margin-top: 6px;
    color: var(--text-primary);
}
.profile-close {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 2px 6px;
    font-size: 14px;
}

.profile-section {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.profile-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 8px;
}
.profile-summary {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.interests-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.interest-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--blue-bg);
    color: var(--blue);
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.facts-list, .events-list, .emotions-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.profile-fact {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 3px 0;
}
.profile-fact .fact-text {
    flex: 1;
}
.profile-fact .fact-delete {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    border: none;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.2s;
}
.profile-fact:hover .fact-delete { opacity: 1; }
.profile-fact .fact-delete:hover { color: var(--red); background: var(--red-bg); }

.profile-event, .profile-emotion {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 2px 0;
}
.profile-event::before { content: "• "; color: var(--text-muted); }
.profile-emotion::before { content: "💭 "; }

.add-fact-row {
    display: flex;
    gap: 6px;
    align-items: center;
}
.add-fact-row input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
}

.profile-actions {
    padding: 12px 16px;
}

/* ==================== TYPING ИНДИКАТОР ==================== */
.typing-indicator {
    padding: 12px 18px !important;
}
.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    height: 16px;
}
.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255,255,255,0.6);
    animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* ==================== СЕКЦИЯ КОНФИГУРАЦИИ ПЕРСОНЫ ==================== */
.config-section {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.config-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}
.config-row {
    display: flex;
    gap: 12px;
}
.config-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.config-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
}
.config-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}
.persona-config-summary {
    margin-top: 8px;
}

/* ==================== УТИЛИТЫ ==================== */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-10 { margin-top: 10px; }
.mb-10 { margin-bottom: 10px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }

/* ==================== ЛОГИ ==================== */
.logs-container {
    background: #0d0f14;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    height: calc(100vh - 150px);
    overflow-y: auto;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 12px;
    line-height: 1.6;
}
.log-line {
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-all;
}
.log-line.log-error { color: #f87171; }
.log-line.log-warn { color: #fbbf24; }
.log-line.log-success { color: #34d399; }

/* ==================== АВАТАРКИ ДИАЛОГОВ ==================== */
.dialog-avatar, .dialog-avatar-fallback {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    margin: 2px 10px 0 0;
    object-fit: cover;
}
.dialog-avatar-fallback {
    background: linear-gradient(135deg, #5b6eea, #8b5cf6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
}
.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

/* ==================== МЕДИА В СООБЩЕНИЯХ ==================== */
.msg-media { margin-bottom: 6px; }
.msg-photo {
    max-width: 220px;
    max-height: 220px;
    border-radius: 8px;
    cursor: pointer;
    display: block;
}
.msg-photo:hover { opacity: 0.9; }
.msg-video {
    max-width: 220px;
    max-height: 220px;
    border-radius: 8px;
    display: block;
}
.msg-video-note {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}
.message-bubble audio {
    max-width: 240px;
    height: 32px;
}

/* ==================== ПРЕВЬЮ ПРИКРЕПЛЁННОГО ФАЙЛА ==================== */
.chat-input-inner {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 6px;
}
.chat-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.chat-input-row textarea { flex: 1; }
.chat-attach-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    position: relative;
}
.chat-attach-preview .attach-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 6px;
}
.chat-attach-preview .attach-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.05);
    border-radius: 6px;
    font-size: 24px;
}
.chat-attach-preview .attach-info {
    flex: 1;
    min-width: 0;
}
.chat-attach-preview .attach-name {
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-attach-preview .attach-size {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}
.chat-attach-preview .attach-remove {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
}
.chat-attach-preview .attach-remove:hover { color: var(--red, #f87171); }

/* ==================== ФОТО ПРОФИЛЯ АККАУНТА ==================== */
.profile-photos-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.profile-photo-item {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--border);
}
.profile-photo-item.current {
    border-color: var(--green, #34d399);
}
.profile-photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
}
.profile-photo-item .photo-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(52, 211, 153, 0.85);
    color: #fff;
    font-size: 9px;
    text-align: center;
    padding: 1px 0;
    font-weight: 600;
}
.profile-photo-item .photo-delete {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(248, 113, 113, 0.9);
    color: #fff;
    border: none;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
}
.profile-photo-item:hover .photo-delete { opacity: 1; }
.profile-photo-item .photo-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
    font-size: 24px;
}

/* ==================== NEEDS ATTENTION ==================== */
.chat-list-item.needs-attention {
    border-left: 3px solid #ff4444 !important;
    background: rgba(255, 68, 68, 0.05) !important;
}
.needs-attention-dot {
    width: 8px;
    height: 8px;
    background: #ff4444;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
    flex-shrink: 0;
    animation: pulse-dot 1.5s infinite;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ==================== CRM КАРТОЧКА SALES ==================== */
.crm-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.crm-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: rgba(255,255,255,0.03);
    border-radius: 6px;
    font-size: 13px;
}
.crm-row .crm-icon { font-size: 16px; flex-shrink: 0; }
.crm-row .crm-label { color: var(--text-muted); flex-shrink: 0; }
.crm-row strong { color: var(--text-primary); font-weight: 600; }

/* ==================== БЕЙДЖ СТАТУСА ПЕРЕВОДА ==================== */
.tr-badge {
    display: inline-block;
    padding: 2px 8px;
    margin-left: 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 500;
    vertical-align: middle;
}
.tr-badge.tr-done { background: rgba(52, 211, 153, 0.15); color: var(--green, #34d399); }
.tr-badge.tr-pending { background: rgba(251, 191, 36, 0.15); color: var(--yellow, #fbbf24); }
.tr-badge.tr-error { background: rgba(248, 113, 113, 0.15); color: var(--red, #f87171); }
.tr-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 13px;
    padding: 2px 4px;
    margin-left: 4px;
    vertical-align: middle;
    opacity: 0.6;
    transition: opacity 0.15s;
}
.tr-btn:hover { opacity: 1; }
.tr-btn:disabled { cursor: default; }

/* ==================== ВЫБОР ТИПА ПЕРСОНЫ ==================== */
.persona-type-picker {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 16px 0 8px;
}
.persona-type-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
}
.persona-type-card:hover {
    background: var(--bg-hover, rgba(124, 92, 252, 0.08));
    border-color: var(--accent, #7c5cfc);
    transform: translateY(-1px);
}
.persona-type-card .type-icon {
    font-size: 32px;
    flex-shrink: 0;
}
.persona-type-card .type-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.persona-type-card .type-desc {
    font-size: 13px;
    color: var(--text-muted);
}

/* ==================== ЧЕКБОКСЫ ДИАЛОГОВ ==================== */
.dialog-checkbox {
    width: 16px;
    height: 16px;
    margin: 3px 8px 0 0;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--accent, #7c5cfc);
    opacity: 0;
    transition: opacity 0.15s;
}
.chat-list-item:hover .dialog-checkbox,
.chat-list-item.checked .dialog-checkbox { opacity: 1; }
.chat-list-item.checked { background: rgba(124, 92, 252, 0.08); }

.dialog-checkbox-all {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent, #7c5cfc);
}

/* ==================== ПАНЕЛЬ МАССОВЫХ ДЕЙСТВИЙ ==================== */
.bulk-bar {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.bulk-count {
    font-size: 13px;
    color: var(--text-muted);
    margin-right: 4px;
}
.btn-red-outline { border-color: rgba(255, 77, 79, 0.3) !important; color: #ff4d4f !important; }
.btn-red-outline:hover { background: rgba(255, 77, 79, 0.1) !important; }

/* ==================== КНОПКА МЕНЮ ДИАЛОГА ==================== */
.dialog-menu-btn {
    margin-left: auto;
    padding: 0 6px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
}
.chat-list-item:hover .dialog-menu-btn { opacity: 1; }
.dialog-menu-btn:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }

/* ==================== КОНТЕКСТНОЕ МЕНЮ ДИАЛОГОВ ==================== */
.dialog-context-menu {
    position: absolute;
    z-index: 9999;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px 0;
    min-width: 200px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.dialog-context-menu .ctx-item {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    transition: background 0.15s;
}
.dialog-context-menu .ctx-item:hover {
    background: var(--bg-hover, rgba(255,255,255,0.06));
}
.dialog-context-menu .ctx-delete:hover { color: #ff4d4f; }
.dialog-context-menu .ctx-block:hover { color: #faad14; }
