:root {
    /* Цветовая палитра - Чистый, строгий темный минимализм */
    --bg-main: #0a0a0c; /* Почти черный */
    --bg-glass: rgba(255, 255, 255, 0.03); /* Эффект жидкого стекла */
    --bg-glass-hover: rgba(255, 255, 255, 0.06);
    --bg-glass-active: rgba(255, 255, 255, 0.09);
    
    --text-primary: #ffffff;
    --text-secondary: #8a8d93;
    
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-glass-light: rgba(255, 255, 255, 0.12);
    
    --radius-xl: 24px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    --shadow-glass: 0 10px 40px -10px rgba(0,0,0,0.5);
    --shadow-inner: inset 0 1px 0 rgba(255,255,255,0.05);
}

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

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

/* === 3D CANVAS === */
#bg-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
    opacity: 0.8;
}

/* === КАСТОМНОЕ МОДАЛЬНОЕ ОКНО === */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-modal {
    background: #2b2b2b;
    border-radius: 12px;
    padding: 24px;
    width: 320px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    font-family: 'Inter', sans-serif;
}

.custom-modal h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.custom-modal p {
    font-size: 14px;
    color: #a3a3a3;
    margin-bottom: 24px;
}

.custom-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-btn {
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.modal-btn.confirm {
    background: #e5e5e5;
    color: #1a1a1a;
}
.modal-btn.confirm:hover {
    background: #ffffff;
}

.modal-btn.cancel {
    background: #404040;
    color: #ffffff;
}
.modal-btn.cancel:hover {
    background: #4d4d4d;
}

/* Скроллбары */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.2);
}

/* === БОКОВОЕ МЕНЮ (ЖИДКОЕ СТЕКЛО) === */
.sidebar {
    width: 280px;
    background: var(--bg-glass);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    padding: 20px;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 10;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.logo i {
    font-size: 24px;
    color: var(--text-primary);
}

/* Премиальная стеклянная кнопка "Новый чат" */
.primary-btn {
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    font-size: 14px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    box-shadow: var(--shadow-inner), var(--shadow-glass);
}

.primary-btn:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-glass-light);
    transform: translateY(-1px);
}

.primary-btn:active {
    transform: translateY(1px);
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-item {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    position: relative;
}

.chat-item-text {
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis;
    flex: 1;
}

.chat-item:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.chat-item.active {
    background: var(--bg-glass-active);
    color: var(--text-primary);
    border-color: var(--border-glass);
    box-shadow: var(--shadow-inner);
}

.chat-item i.ph-chat-teardrop-text {
    font-size: 18px;
    opacity: 0.7;
}

.delete-chat-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    padding: 4px;
}

.chat-item:hover .delete-chat-btn {
    opacity: 1;
}

.delete-chat-btn:hover {
    color: #ef4444; /* Красный цвет при наведении */
    transform: scale(1.1);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
}

/* Синяя кнопка Telegram (Точно как на макете) */
.telegram-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #2A9D8F; /* Fallback */
    background: linear-gradient(180deg, #38A1F3 0%, #2A90E0 100%);
    color: white;
    text-decoration: none;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 1px;
    padding: 14px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(42, 144, 224, 0.3), inset 0 1px 0 rgba(255,255,255,0.2);
    transition: all 0.2s;
    text-transform: uppercase;
}

.telegram-btn i {
    font-size: 20px;
}

.telegram-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(42, 144, 224, 0.4), inset 0 1px 0 rgba(255,255,255,0.3);
}

.telegram-btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 10px rgba(42, 144, 224, 0.3);
}

/* === ГЛАВНОЕ ОКНО === */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: transparent; /* Чтобы было видно 3D-фон */
    z-index: 1;
}

.mobile-header {
    display: none;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-glass);
    align-items: center;
    justify-content: space-between;
    background: rgba(10, 10, 12, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 5;
}

.header-title {
    font-weight: 500;
    letter-spacing: -0.3px;
}

.icon-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-size: 22px;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.icon-btn:hover {
    color: var(--text-primary);
    background: var(--bg-glass);
    border-color: var(--border-glass);
}
.mobile-only {
    display: none;
}

/* === ЗОНА СООБЩЕНИЙ === */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    scroll-behavior: smooth;
}

.welcome-screen {
    margin: auto;
    text-align: center;
    max-width: 500px;
    animation: fadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.welcome-logo {
    font-size: 56px;
    color: var(--text-primary);
    margin-bottom: 24px;
    opacity: 0.9;
}

.welcome-screen h1 {
    font-size: 32px;
    font-weight: 500;
    letter-spacing: -1px;
    margin-bottom: 12px;
}

.welcome-screen p {
    color: var(--text-secondary);
    margin-bottom: 40px;
    font-size: 15px;
    line-height: 1.5;
}

/* Стеклянные чипсы (Точно как на макете пользователя) */
.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.chip {
    background: #131314;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #ffffff;
    padding: 10px 18px;
    border-radius: 30px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.chip i {
    font-size: 18px;
    opacity: 0.9;
}

.chip:hover {
    background: #1e1e1f;
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

/* === СООБЩЕНИЯ (ПУЗЫРИ) === */
.message {
    display: flex;
    gap: 20px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.message-avatar {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-inner);
}

.message.user .message-avatar {
    background: var(--bg-glass-active);
    color: var(--text-secondary);
}

.message.ai .message-avatar {
    background: #ffffff;
    color: #000000;
}

.message-content {
    flex: 1;
    line-height: 1.7;
    font-size: 15px;
    color: #e5e7eb;
}

/* Оформление Markdown и Блоков Кода */
.message-content p {
    margin-bottom: 16px;
}
.message-content p:last-child {
    margin-bottom: 0;
}

.code-block-wrapper {
    background: #000000;
    border-radius: var(--radius-md);
    margin: 16px 0;
    border: 1px solid #1a1a1a;
    overflow: hidden;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #111111;
    padding: 8px 16px;
    border-bottom: 1px solid #1a1a1a;
    font-size: 12px;
    color: #888;
    font-family: 'Inter', sans-serif;
}

.code-actions {
    display: flex;
    gap: 12px;
}

.code-action-btn {
    background: transparent;
    border: none;
    color: #888;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s;
}
.code-action-btn:hover {
    color: #fff;
}

.code-block-wrapper pre {
    padding: 16px;
    overflow-x: auto;
    margin: 0;
    background: transparent;
    border: none;
}

.message-content code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    background-color: var(--bg-glass-active);
    padding: 3px 6px;
    border-radius: 6px;
    font-size: 0.9em;
}
.message-content pre code {
    background-color: transparent;
    padding: 0;
    font-size: 0.9em;
    color: #a1a1aa;
}

/* === ПОЛЕ ВВОДА === */
.input-area-container {
    padding: 24px;
    /* Плавный переход фона снизу */
    background: linear-gradient(0deg, var(--bg-main) 70%, transparent);
    position: relative;
    max-width: 850px;
    margin: 0 auto;
    width: 100%;
}

.input-wrapper {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: flex-end;
    padding: 10px 10px 10px 16px;
    box-shadow: var(--shadow-glass), var(--shadow-inner);
    transition: border-color 0.3s, background 0.3s;
}

.input-wrapper:focus-within {
    border-color: var(--border-glass-light);
    background: var(--bg-glass-hover);
}

#chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    resize: none;
    padding: 8px 4px;
    max-height: 200px;
    outline: none;
}
#chat-input::placeholder {
    color: var(--text-secondary);
}

.send-btn {
    background: var(--text-primary);
    color: var(--bg-main);
    border: none;
    border-radius: var(--radius-lg);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
    margin-left: 12px;
    margin-bottom: 2px;
}

.send-btn:hover {
    transform: scale(1.05);
    background: #e5e5e5;
}

.send-btn:disabled {
    background: var(--bg-glass-active);
    color: var(--text-secondary);
    cursor: not-allowed;
    transform: none;
}

.footer-text {
    text-align: center;
    font-size: 12px;
    color: #6b7280;
    margin-top: 16px;
}

/* Анимации */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 0;
}
.typing-indicator span {
    width: 6px;
    height: 6px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
    40% { transform: scale(1); opacity: 1; }
}

/* Адаптивность для мобилок */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        height: 100%;
        transform: translateX(-100%);
        border-right: none;
        background: rgba(15, 15, 17, 0.85);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .mobile-header {
        display: flex;
    }
    
    .mobile-only {
        display: block;
    }
    
    .messages-area {
        padding: 20px 16px;
    }
    
    .input-area-container {
        padding: 16px;
    }
    
    .input-wrapper {
        border-radius: var(--radius-lg);
    }
}
