:root {
    --bg-color: #0B1120;
    --chat-bg: #151E32;
    --text-color: #E2E8F0;
    --accent: #38BDF8;
    --user-msg: #2563EB;
    --bot-msg: #334155;
    --debug-bg: #0F172A;
}

body { font-family: 'Inter', sans-serif; background-color: var(--bg-color); color: var(--text-color); margin: 0; display: flex; height: 100vh; overflow: hidden; }

.container { display: flex; width: 100%; }
.chat-panel { flex: 1; display: flex; flex-direction: column; border-right: 1px solid #334155; max-width: 850px; margin: 0 auto;}
.debug-panel { flex: 1; background: var(--debug-bg); padding: 20px; overflow-y: auto; font-family: 'Courier New', monospace; font-size: 13px; color: #4ADE80; display: none; border-left: 1px solid #334155; }
.debug-panel.active { display: block; }

/* Login Modal */
#login-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); display: flex; justify-content: center; align-items: center; z-index: 100; }
.login-box { background: var(--chat-bg); padding: 30px; border-radius: 12px; width: 400px; text-align: center; }
input { width: 90%; padding: 12px; margin: 10px 0; background: #0F172A; border: 1px solid #475569; color: white; border-radius: 6px; outline: none; }
button { background: var(--accent); color: #000; padding: 10px 20px; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; width: 100%; transition: 0.2s; }
button:hover { opacity: 0.9; }

/* Chat Messages */
.header { padding: 15px; border-bottom: 1px solid #334155; display: flex; justify-content: space-between; align-items: center; background: var(--chat-bg); }
.messages { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 15px; scroll-behavior: smooth; }

.msg { 
    max-width: 85%; 
    padding: 12px 18px; 
    border-radius: 12px; 
    line-height: 1.6;
    font-size: 15px; 
    word-wrap: break-word; 
}
.msg.user { align-self: flex-end; background: var(--user-msg); border-bottom-right-radius: 2px; }
.msg.bot { align-self: flex-start; background: var(--bot-msg); border-bottom-left-radius: 2px; }
.msg.system { align-self: center; background: transparent; color: #64748B; font-size: 12px; text-align: center; padding: 5px; }

.msg b, .msg strong {
    font-weight: 700;
    color: #fff;
}

/* Actions & Buttons */
.action-row { 
    display: flex !important;          /* Принудительно флекс */
    flex-direction: row !important;    /* Принудительно в строку */
    flex-wrap: nowrap !important;      /* Принудительно БЕЗ переноса */
    gap: 10px;
    margin-top: 10px; 
    width: 100%;            
    justify-content: center;
    align-items: stretch;              /* Чтобы были одной высоты */
}

/* Удаляем любые media query, если они есть */

.action-btn { 
    background: #475569; 
    color: white; 
    border: none; 
    
    /* Делаем квадратнее */
    border-radius: 6px !important;     /* Было 20px, стало 6px */
    
    padding: 12px 10px;
    font-size: 14px; 
    cursor: pointer; 
    
    /* Растягиваем по ширине равномерно */
    flex: 1 1 0px !important;          /* Магия: всем кнопкам равную ширину */
    width: auto !important;
    max-width: 100%;       
    
    white-space: nowrap;               /* Текст в одну строку */
    text-overflow: ellipsis;
    overflow: hidden;
    
    display: flex;
    align-items: center;
    justify-content: center;
    
    transition: transform 0.1s, background-color 0.2s;
}

.action-btn:hover { background: var(--accent); color: #000; }
.action-btn.primary { background: var(--accent); color: #000; }
.action-btn:active { transform: scale(0.96); }


.action-btn:active {
    transform: scale(0.96);
    background-color: #cbd5e1;
    color: #000;
}

/* Controls */
.controls { padding: 20px; background: var(--chat-bg); border-top: 1px solid #334155; }
.input-group { display: flex; gap: 10px; }

/* JSON Styling */
pre { white-space: pre-wrap; word-wrap: break-word; margin: 0; }
.key { color: #93C5FD; }
.string { color: #FCA5A5; }
.number { color: #FCD34D; }
.boolean { color: #C4B5FD; }

.status-badge { font-size: 12px; padding: 4px 8px; border-radius: 10px; background: #334155; color: #94A3B8; }
.status-badge.online { background: #065F46; color: #34D399; }
.typing { font-style: italic; opacity: 0.7; font-size: 13px; }

/* ============================================================================
   КНОПКА "ЗАВЕРШИТЬ СЕССИЮ" (появляется через 20 сек)
   ============================================================================ */
.floating-end-button {
    display: block;
    margin: 15px auto 0;
    max-width: 85%;
    
    background: rgba(51, 65, 85, 0.6);  /* Полупрозрачный серый */
    color: #94A3B8;  /* Приглушённый текст */
    border: 1px solid rgba(148, 163, 184, 0.2);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    
    backdrop-filter: blur(10px);
    transition: all 0.2s ease;
    animation: fadeIn 0.4s ease-in-out;
}

.floating-end-button:hover {
    background: rgba(71, 85, 105, 0.8);  /* Чуть светлее при наведении */
    color: #E2E8F0;
    border-color: rgba(148, 163, 184, 0.4);
    transform: translateY(-1px);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
/* ============================================================================
   ARCHIVE MODAL STYLES (New)
   ============================================================================ */

/* Контейнер списка */
#archive-content {
    display: flex;
    flex-direction: column;
    min-height: 200px; /* Чтобы не скакало при загрузке */
}

/* Элемент списка сессий */
.archive-item {
    background: #1e293b; /* Чуть светлее фона */
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.archive-item:hover {
    background: #334155; /* Цвет как у кнопок */
    border-color: #475569;
    transform: translateX(2px);
}

.archive-date {
    color: #94a3b8; /* Серый текст */
    font-size: 0.85em;
    min-width: 50px;
    font-family: monospace; /* Чтобы цифры стояли ровно */
}

.archive-title {
    color: #e2e8f0;
    font-weight: 500;
    flex-grow: 1;
    margin-left: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Троеточие, если длинная тема */
}

.archive-arrow {
    color: #64748b;
    font-size: 1.2em;
}

/* Детальная карточка сессии */
.session-detail-card {
    background: #1e293b;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid #334155;
    animation: fadeIn 0.3s ease;
}

.detail-header {
    border-bottom: 1px solid #334155;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.detail-label {
    font-size: 0.7em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    margin-bottom: 5px;
    display: block;
    font-weight: bold;
}

.detail-text {
    color: #e2e8f0;
    line-height: 1.6;
    margin-bottom: 20px;
    white-space: pre-wrap; /* Важно! Сохраняет переносы строк от AI */
    font-size: 0.95em;
	text-align: left;
}

/* Текст запроса пользователя (курсив, чуть тусклее) */
.detail-text.user-request {
    font-style: italic;
    opacity: 0.8;
    border-left: 2px solid #3b82f6;
    padding-left: 10px;
}

/* Пагинация */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #334155;
}

.pagination button {
    background: #334155;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 13px;
    transition: opacity 0.2s;
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Анимация появления */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Кастомный скроллбар для архива (если список длинный) */
.login-box::-webkit-scrollbar {
    width: 6px;
}
.login-box::-webkit-scrollbar-track {
    background: #0f172a; 
}
.login-box::-webkit-scrollbar-thumb {
    background: #334155; 
    border-radius: 3px;
}
.login-box::-webkit-scrollbar-thumb:hover {
    background: #475569; 
}