/* ============================================
   Alpha-Codex.ru - Полный CSS (КОМПАКТНЫЙ)
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100vh;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f5f5f5;
    color: #333;
}

/* === APP LAYOUT === */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* === SIDEBAR === */
.sidebar {
    width: 280px;
    height: 100vh;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.logo-icon {
    font-size: 24px;
}

.sidebar-nav {
    flex: 1;
    padding: 10px 0;
    overflow-y: auto;
}

.nav-item {
    padding: 10px 20px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #333;
}

.nav-item:hover {
    background: #f0f7ff;
}

.nav-text {
    font-size: 14px;
}

.nav-section-title {
    padding: 15px 20px 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #999;
    letter-spacing: 0.5px;
}

.nav-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 10px 0;
}

.chat-search-input {
    width: calc(100% - 40px);
    margin: 0 20px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
}

.chat-search-input:focus {
    border-color: #0066cc;
}

.chat-history-list {
    max-height: 300px;
    overflow-y: auto;
}

.user-block {
    padding: 15px 20px;
    background: #f0f7ff;
    margin: 10px 15px;
    border-radius: 8px;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
    color: #0066cc;
}

.user-email {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

.sidebar-footer {
    padding: 15px;
    border-top: 1px solid #e0e0e0;
    background: #fff;
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.usage-block {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
}

.usage-title {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.usage-info {
    font-size: 13px;
    color: #666;
}

/* === MAIN CONTENT === */
.main-content {
    flex: 1;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* === CHAT CONTAINER === */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

/* === СООБЩЕНИЯ - ОСНОВНОЙ КОНТЕЙНЕР === */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    min-height: 0;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* === ОБЛАЧКА СООБЩЕНИЙ - БАЗОВЫЕ СТИЛИ === */
.chat-message {
    max-width: 80%;
    padding: 10px 14px !important;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.4 !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
    margin: 0;
}

/* Сообщение пользователя - СЛЕВА */
.chat-message.user {
    background: #0066cc;
    color: #ffffff;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

/* Сообщение бота - СПРАВА */
.chat-message.assistant {
    background: #e8e8e8;
    color: #1a1a1a;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Сообщение об ошибке - ПО ЦЕНТРУ */
.chat-message.error {
    background: #fff0f0;
    color: #dc3545;
    border: 1px solid #ffcdd2;
    align-self: center;
    max-width: 80%;
}

/* ========================================
   ВСЕ СТИЛИ ДЛЯ HTML-КОНТЕНТА ВНУТРИ СООБЩЕНИЙ
   ======================================== */

/* --- АБЗАЦЫ - КОМПАКТНЫЕ --- */
.chat-message p {
    margin: 0 0 3px 0 !important;
    padding: 0 !important;
}

.chat-message p:last-child {
    margin-bottom: 0 !important;
}

/* --- ЗАГОЛОВКИ - КОМПАКТНЫЕ --- */
.chat-message h1,
.chat-message h2,
.chat-message h3,
.chat-message h4,
.chat-message h5,
.chat-message h6 {
    margin: 5px 0 3px 0 !important;
    padding: 0 !important;
    font-weight: 700 !important;
    font-size: inherit !important;
    line-height: 1.3 !important;
}

.chat-message h1:first-child,
.chat-message h2:first-child,
.chat-message h3:first-child,
.chat-message h4:first-child {
    margin-top: 0 !important;
}

/* --- ЖИРНЫЙ ТЕКСТ --- */
.chat-message strong,
.chat-message b {
    font-weight: 700 !important;
    color: inherit !important;
}

/* --- КУРСИВ --- */
.chat-message em,
.chat-message i {
    font-style: italic !important;
}

/* --- СПИСКИ - КОМПАКТНЫЕ --- */
.chat-message ul,
.chat-message ol {
    margin: 3px 0 3px 0 !important;
    padding-left: 18px !important;
}

.chat-message li {
    margin: 1px 0 !important;
    line-height: 1.4 !important;
}

.chat-message li:last-child {
    margin-bottom: 0 !important;
}

/* --- ССЫЛКИ --- */
.chat-message a {
    color: #0066cc !important;
    text-decoration: underline !important;
    cursor: pointer;
}

.chat-message a:hover {
    color: #0052a3 !important;
}

/* Ссылки в сообщениях пользователя (на синем фоне) */
.chat-message.user a {
    color: #ffffff !important;
    text-decoration: underline !important;
}

.chat-message.user a:hover {
    color: #d4e4ff !important;
}

/* --- ЦИТАТЫ - КОМПАКТНЫЕ --- */
.chat-message blockquote {
    margin: 3px 0 3px 8px !important;
    padding: 2px 0 2px 10px !important;
    border-left: 3px solid #0066cc !important;
    color: #444 !important;
    background: rgba(0,0,0,0.02) !important;
}

.chat-message.user blockquote {
    border-left-color: #ffffff !important;
    color: #e8f0ff !important;
}

/* --- КОД --- */
.chat-message code {
    background: rgba(0,0,0,0.06) !important;
    padding: 1px 4px !important;
    border-radius: 3px !important;
    font-family: 'Courier New', monospace !important;
    font-size: 13px !important;
}

.chat-message.user code {
    background: rgba(255,255,255,0.15) !important;
    color: #ffffff !important;
}

.chat-message pre {
    background: #f0f0f0 !important;
    padding: 8px 12px !important;
    border-radius: 6px !important;
    overflow-x: auto !important;
    margin: 4px 0 !important;
}

.chat-message pre code {
    background: transparent !important;
    padding: 0 !important;
}

.chat-message.user pre {
    background: rgba(255,255,255,0.1) !important;
}

/* --- ГОРИЗОНТАЛЬНАЯ ЛИНИЯ --- */
.chat-message hr {
    margin: 6px 0 !important;
    border: none !important;
    border-top: 1px solid #ddd !important;
}

.chat-message.user hr {
    border-top-color: rgba(255,255,255,0.3) !important;
}

/* --- ТАБЛИЦЫ --- */
.chat-message table {
    border-collapse: collapse !important;
    margin: 4px 0 !important;
    width: 100% !important;
    font-size: 13px !important;
}

.chat-message th,
.chat-message td {
    border: 1px solid #ddd !important;
    padding: 4px 8px !important;
    text-align: left !important;
}

.chat-message th {
    background: #f5f5f5 !important;
    font-weight: 600 !important;
}

.chat-message.user th {
    background: rgba(255,255,255,0.15) !important;
    color: #ffffff !important;
}

.chat-message.user td {
    border-color: rgba(255,255,255,0.2) !important;
    color: #ffffff !important;
}

/* --- ИЗОБРАЖЕНИЯ --- */
.chat-message img {
    max-width: 100% !important;
    height: auto !important;
    border-radius: 6px !important;
    margin: 3px 0 !important;
}

/* --- УБИРАЕМ ЛИШНИЕ ПЕРЕНОСЫ --- */
.chat-message br {
    display: none !important;
}

/* --- СПЕЦИАЛЬНО ДЛЯ ЖИРНЫХ ЗАГОЛОВКОВ В СООБЩЕНИЯХ БОТА --- */
.chat-message.assistant h1,
.chat-message.assistant h2,
.chat-message.assistant h3,
.chat-message.assistant strong,
.chat-message.assistant b {
    color: #1a1a1a !important;
}

/* --- СПЕЦИАЛЬНО ДЛЯ ЖИРНЫХ ЗАГОЛОВКОВ В СООБЩЕНИЯХ ПОЛЬЗОВАТЕЛЯ --- */
.chat-message.user h1,
.chat-message.user h2,
.chat-message.user h3,
.chat-message.user strong,
.chat-message.user b {
    color: #ffffff !important;
}

/* === ПОЛЕ ВВОДА === */
.chat-input-container {
    background: #f5f5f5;
    padding: 16px 20px;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: center;
    flex-shrink: 0;
}

.chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 900px;
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 30px;
    padding: 6px 6px 6px 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.chat-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    background: transparent;
    resize: none;
    min-height: 24px;
    max-height: 200px;
    overflow-y: auto;
    font-family: inherit;
    padding: 6px 0;
}

.chat-input:focus {
    border-color: #0066cc;
}

#send-btn {
    background: #0066cc;
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    flex-shrink: 0;
    transition: background 0.2s;
}

#send-btn:hover {
    background: #0052a3;
}

#send-btn svg {
    stroke: #fff;
}

/* === MENU TOGGLE === */
.menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 200;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}

/* === MODALS === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #fff;
    border-radius: 16px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-wide {
    max-width: 800px;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #333;
}

/* === FORMS === */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
}

.form-group input:focus {
    border-color: #0066cc;
}

.form-submit {
    width: 100%;
    padding: 12px;
    background: #0066cc;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.form-submit:hover {
    background: #0052a3;
}

.form-error {
    color: #dc3545;
    font-size: 13px;
    margin-bottom: 10px;
}

.form-success {
    color: #28a745;
    font-size: 13px;
    margin-bottom: 10px;
}

.form-hint {
    font-size: 12px;
    color: #999;
    text-align: center;
    margin-top: 10px;
}

.modal-footer {
    text-align: center;
    margin-top: 15px;
    font-size: 14px;
    color: #666;
}

.modal-footer a {
    color: #0066cc;
    text-decoration: none;
}

.modal-footer a:hover {
    text-decoration: underline;
}

/* === PROFILE === */
.profile-info {
    margin-bottom: 20px;
}

.profile-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
    font-size: 14px;
}

.profile-label {
    color: #666;
}

.profile-value {
    font-weight: 600;
    color: #333;
}

/* === TARIFFS === */
.tariffs-subtitle {
    color: #666;
    margin-bottom: 20px;
}

.tariffs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.tariff-card {
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 25px;
    text-align: center;
    position: relative;
    transition: border-color 0.2s;
}

.tariff-card:hover {
    border-color: #0066cc;
}

.tariff-card.popular {
    border-color: #0066cc;
}

.tariff-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: #0066cc;
    color: #fff;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.tariff-name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
}

.tariff-price {
    font-size: 32px;
    font-weight: 700;
    color: #0066cc;
    margin-bottom: 15px;
}

.tariff-features {
    list-style: none;
    text-align: left;
    margin-bottom: 20px;
}

.tariff-features li {
    padding: 5px 0;
    font-size: 14px;
}

.tariff-btn {
    width: 100%;
    padding: 10px;
    background: #0066cc;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.tariff-btn:hover {
    background: #0052a3;
}

/* === PAYMENT METHODS === */
.payment-methods {
    margin: 20px 0;
}

.payment-methods h3 {
    margin-bottom: 10px;
}

.payment-method {
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    text-align: left;
}

.payment-method:hover {
    border-color: #0066cc;
}

/* === COOKIE BANNER === */
.cookie-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(0, 102, 204, 0.2);
    border-radius: 16px;
    padding: 20px 25px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 2001;
    max-width: 600px;
    width: calc(100% - 40px);
    display: flex;
    flex-direction: column;
    gap: 15px;
    animation: slideUp 0.5s ease;
}

.cookie-banner.hidden {
    display: none;
}

@keyframes slideUp {
    from { transform: translateX(-50%) translateY(100px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.cookie-text {
    font-size: 14px;
    color: #333;
    line-height: 1.6;
}

.cookie-text a {
    color: #0066cc;
    text-decoration: underline;
    font-weight: 500;
}

.cookie-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.cookie-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    flex: 1;
}

.cookie-btn.accept {
    background: #0066cc;
    color: #fff;
}

.cookie-btn.accept:hover {
    background: #0052a3;
}

.cookie-btn.decline {
    background: #f5f5f5;
    color: #333;
}

.cookie-btn.decline:hover {
    background: #e0e0e0;
}

/* === SCROLLBAR === */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* === MOBILE === */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        transition: left 0.3s;
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .sidebar-overlay.open {
        display: block;
    }
    
    .menu-toggle {
        display: block;
    }
    
    .cookie-banner {
        bottom: 10px;
        padding: 15px 20px;
        width: calc(100% - 20px);
    }
    
    .cookie-buttons {
        flex-direction: column;
    }

    .chat-message {
        max-width: 90%;
        padding: 8px 12px !important;
    }

    .chat-messages {
        padding: 12px;
        gap: 6px;
    }

    .chat-input-container {
        padding: 12px 16px;
    }

    .chat-input-wrapper {
        padding: 4px 4px 4px 14px;
    }
}