/* AI Stats Styles */

/* === Финансовый блок расхода ИИ (в дизайне админки) === */
.spend-wrap { margin-bottom: 22px; }
.spend-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--gray-900, #111827);
    margin: 0 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}
.spend-title .spend-month { font-size: 12px; font-weight: 600; color: #9ca3af; }
.spend-sub { font-size: 13px; font-weight: 600; color: var(--gray-600, #4b5563); margin: 18px 0 8px; }
.spend-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 46px;
    background: #fff;
    border-radius: 10px;
    padding: 10px 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.spend-bars i {
    flex: 1;
    min-width: 3px;
    display: block;
    background: var(--primary, #6366f1);
    border-radius: 3px 3px 0 0;
    opacity: .85;
}
.spend-rel { font-size: 13px; color: var(--gray-600, #4b5563); margin-top: 10px; }
.spend-rel b { color: var(--gray-900, #111827); }
.spend-note { font-size: 12px; color: #94a3b8; line-height: 1.5; margin-top: 12px; border-top: 1px solid var(--gray-100, #f3f4f6); padding-top: 10px; }
.spend-budget { background: #fff; border-radius: 10px; padding: 14px 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.spend-budget-bar { height: 10px; background: var(--gray-100, #f3f4f6); border-radius: 6px; overflow: hidden; margin-bottom: 8px; }
.spend-budget-bar span { display: block; height: 100%; border-radius: 6px; transition: width .3s; }
.spend-budget-info { font-size: 13px; color: var(--gray-700, #374151); margin-bottom: 12px; }
.spend-budget-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.spend-budget-form label { display: flex; flex-direction: column; font-size: 12px; color: var(--gray-600, #4b5563); gap: 4px; }
.spend-budget-form input[type=number], .spend-budget-form input[type=email] { padding: 8px 10px; border: 1px solid var(--gray-200, #e5e7eb); border-radius: 8px; font-size: 13px; }
.spend-budget-form input[type=number] { width: 90px; }
.spend-budget-form input[type=email] { width: 210px; }
.spend-budget-toggle { flex-direction: row !important; align-items: center; gap: 6px !important; font-size: 13px !important; color: var(--gray-700, #374151) !important; }
.spend-budget-msg { font-size: 12px; align-self: center; }

.ai-stats-table td.num, .ai-stats-table th.num { text-align: right; }
.ai-stats-table td.money { text-align: right; color: #e74c3c; font-weight: 600; }
.ai-stats-table td.muted { text-align: right; color: #94a3b8; }

.ai-stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.ai-stats-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.ai-stats-card h4 {
    margin: 0 0 10px 0;
    color: #666;
    font-size: 14px;
}

.ai-stats-card .value {
    font-size: 28px;
    font-weight: bold;
    color: #333;
}

.ai-stats-card .value.cost {
    color: #e74c3c;
}

.ai-stats-card .value.success {
    color: #27ae60;
}

.ai-stats-card .value.errors {
    color: #e67e22;
}

/* Фильтры */
.ai-stats-filters {
    background: #fff;
    border-radius: 10px;
    padding: 15px 20px;
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.ai-stats-filters input,
.ai-stats-filters select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.ai-stats-filters input[type="date"] {
    width: 150px;
}

.ai-stats-filters input[type="text"] {
    width: 200px;
}

/* Таблица */
.ai-stats-table {
    width: 100%;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.ai-stats-table table {
    width: 100%;
    border-collapse: collapse;
}

.ai-stats-table th,
.ai-stats-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.ai-stats-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
}

.ai-stats-table tr:hover {
    background: #f8f9fa;
}

.ai-stats-table .user-info {
    display: flex;
    flex-direction: column;
}

.ai-stats-table .username {
    font-weight: 600;
    color: #333;
}

.ai-stats-table .telegram-id {
    font-size: 12px;
    color: #999;
}

.ai-stats-table .cost {
    color: #e74c3c;
    font-weight: 600;
}

.ai-stats-table .errors {
    color: #e67e22;
}

.ai-stats-table .btn-dialogs {
    padding: 5px 12px;
    background: #3498db;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
}

.ai-stats-table .btn-dialogs:hover {
    background: #2980b9;
}

/* Модальное окно диалогов */
/* Модальное окно диалогов */
#dialogModal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
    background: rgba(0, 0, 0, 0.5) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 99999 !important;
    overflow: hidden !important;
}

#dialogModal.hidden {
    display: none !important;
}

#dialogModal .modal-content {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

#dialogModal .modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

#dialogModal .modal-header h3 {
    margin: 0;
}

#dialogModal .modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    padding: 0 10px;
    line-height: 1;
}

#dialogModal .modal-close:hover {
    color: #333;
}

#dialogModal .modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-large .modal-body {
    max-height: 60vh;
    overflow-y: auto;
}

/* Диалоги */
.dialog-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dialog-item {
    padding: 12px 15px;
    border-radius: 8px;
    max-width: 85%;
}

.dialog-item.user {
    background: #e3f2fd;
    align-self: flex-end;
    border-bottom-right-radius: 0;
}

.dialog-item.bot {
    background: #f5f5f5;
    align-self: flex-start;
    border-bottom-left-radius: 0;
}

.dialog-item.error {
    background: #ffebee;
    align-self: flex-start;
    border-left: 3px solid #e74c3c;
}

.dialog-item .meta {
    font-size: 11px;
    color: #999;
    margin-top: 5px;
    display: flex;
    justify-content: space-between;
}

.dialog-item .meta .cost {
    color: #e74c3c;
}

.dialog-item .message {
    word-wrap: break-word;
    white-space: pre-wrap;
}

.dialog-item.error .error-text {
    color: #e74c3c;
    font-weight: 500;
    margin-top: 5px;
}

/* Статус блокировки */
.status-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.active {
    background: #d4edda;
    color: #155724;
}

.status-badge.blocked {
    background: #f8d7da;
    color: #721c24;
}

/* Пустое состояние */
.ai-stats-empty {
    text-align: center;
    padding: 40px;
    color: #999;
}

.ai-stats-empty svg {
    width: 60px;
    height: 60px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.dialog-item.skip {
    background: #fff3cd;
    align-self: flex-start;
    border-left: 3px solid #ffc107;
}

.dialog-item.skip .error-text {
    color: #856404;
    font-weight: 500;
    margin-top: 5px;
}

/* Стили для разных типов пользователей */
.username.has-username {
    color: #059669;
    font-weight: 500;
}

.username.has-firstname {
    color: #3b82f6;
}

.username.hidden-username {
    color: #94a3b8;
    font-style: italic;
}

.telegram-id {
    font-size: 11px;
    color: #64748b;
    font-family: 'Courier New', monospace;
}
/* === 08.07.2026: график «Расход по дням» v2 (подписи чисел, всё внутри карточки) === */
.spend-chart {
    background: #fff;
    border-radius: 10px;
    padding: 12px 14px 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.spend-chart-info { font-size: 12.5px; color: #94a3b8; margin: 0 0 10px; }
.spend-chart-info b { color: var(--gray-900, #111827); }
.spend-chart-info #spendBarReadout { color: var(--primary, #6366f1); font-weight: 700; }
.spend-cols { display: flex; align-items: flex-end; gap: 3px; height: 80px; }
.spend-col {
    flex: 1; min-width: 0; height: 100%;
    display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
    cursor: default;
}
.spend-col b {
    width: 100%; max-width: 26px;
    background: var(--primary, #6366f1);
    border-radius: 3px 3px 0 0;
    opacity: .85;
    transition: opacity .15s;
}
.spend-col:hover b { opacity: 1; }
.spend-col span {
    font-size: 9px; line-height: 1; color: #94a3b8;
    margin-top: 5px; user-select: none;
}
.spend-col:hover span { color: var(--primary, #6366f1); font-weight: 700; }

/* === 08.07.2026: компактная таблица пользователей === */
.ai-stats-table .ai-user-row td { padding: 7px 10px; font-size: 13px; line-height: 1.3; }
.ai-user-actions { white-space: nowrap; display: flex; gap: 6px; }

/* === 08.07.2026: кнопка «Профиль» возле имени === */
.ai-user-cell { display: inline-flex; align-items: center; gap: 8px; }
.btn-profile {
    padding: 3px 10px;
    background: transparent;
    color: #3498db;
    border: 1px solid #3498db;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1.4;
    white-space: nowrap;
}
.btn-profile:hover { background: #3498db; color: #fff; }
.btn-profile:disabled { opacity: .6; cursor: wait; }

/* === 08.07.2026: кнопки/акценты в таблице users-table (единый дизайн со «Пользователями») === */
.users-table .btn-dialogs {
    padding: 4px 12px;
    background: #3498db;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12.5px;
}
.users-table .btn-dialogs:hover { background: #2980b9; }
.users-table td.cost { color: #e74c3c; font-weight: 600; }
.users-table td.errors { color: #e67e22; }
.users-table .username { font-weight: 600; color: #333; }
