/* Общие стили */
* {
    max-width: 100%;
    box-sizing: border-box;
}

/* Исправление для белого фона при overscroll */
html {
    background: radial-gradient(circle at 30% 10%, #1e2a3a, #0f172a);
    min-height: 100%;
    height: auto;
    overflow-x: hidden;
}

body {
    font-family: 'Inter', sans-serif;
    background: transparent;
    color: #e0e7ff;
    overflow-x: hidden;
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
}

/* Частицы на фоне */
#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvw;
    z-index: 0;
    pointer-events: none;
    opacity: 0.5;
    background: transparent;
}

/* Контейнер чата */
.chat-container {
    position: relative;
    z-index: 10;
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ========== БОКОВОЕ МЕНЮ ========== */
.sidebar {
    width: 280px;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    border-right: 1px solid rgba(139, 92, 246, 0.2);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 20;
    transition: width 0.3s ease, transform 0.3s ease;
    overflow: hidden;
}

/* Свернутое состояние */
.sidebar.collapsed {
    width: 80px;
    padding: 30px 10px;
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .user-details,
.sidebar.collapsed .user-name,
.sidebar.collapsed .user-plan {
    display: none !important;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 15px 0;
}

.sidebar.collapsed .nav-item i {
    margin: 0;
    font-size: 1.5rem;
}

.sidebar.collapsed .user-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.sidebar.collapsed .user-avatar {
    width: 45px;
    height: 45px;
    margin: 0 0 5px 0;
    border-width: 2px;
    display: block;
}

.sidebar.collapsed .logout-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin: 0;
    display: flex;
}

.sidebar.collapsed .sidebar-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 15px;
    padding-top: 20px;
}

.sidebar.collapsed .logo {
    justify-content: center;
    gap: 0;
}

.sidebar.collapsed .logo-dot {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
}

.sidebar.collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

/* Шапка сайдбара */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 40px;
    width: 100%;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, #a5b4fc, #c4b5fd, #e0e7ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
    overflow: hidden;
    transition: all 0.3s ease;
}



@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.2); }
}

/* Кнопка сворачивания */
.sidebar-toggle {
    width: 36px;
    height: 36px;
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #a78bfa;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1rem;
    flex-shrink: 0;
    margin-left: 10px;
}

.sidebar-toggle:hover {
    background: rgba(139, 92, 246, 0.3);
    transform: scale(1.1);
}

/* Навигация */
.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    color: #9ca3af;
    text-decoration: none;
    border-radius: 15px;
    transition: all 0.3s ease;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item i {
    font-size: 1.3rem;
    width: 24px;
    flex-shrink: 0;
}

.nav-item:hover {
    background: rgba(139, 92, 246, 0.15);
    color: #e0e7ff;
    transform: translateX(5px);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(139, 92, 246, 0.3));
    color: #c4b5fd;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

/* Подвал бокового меню */
.sidebar-footer {
    margin-top: auto;
    padding-top: 30px;
    border-top: 1px solid rgba(139, 92, 246, 0.2);
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    justify-content: space-between;
    transition: all 0.3s ease;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 2px solid #8b5cf6;
    object-fit: cover;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.user-details {
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

.user-name {
    font-weight: 600;
    color: #e0e7ff;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.3s ease;
}

.user-plan {
    font-size: 0.8rem;
    color: #8b5cf6;
    background: rgba(139, 92, 246, 0.2);
    padding: 3px 8px;
    border-radius: 20px;
    display: inline-block;
    margin-top: 3px;
    white-space: nowrap;
    transition: all 0.3s ease;
}

.logout-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 50%;
    color: #ef4444;
    transition: all 0.3s;
    flex-shrink: 0;
    text-decoration: none !important;
}

.logout-btn:hover {
    background: #ef4444;
    color: white;
    transform: scale(1.1);
}

/* ========== ОСНОВНАЯ ОБЛАСТЬ ЧАТА ========== */
.chat-main {
    flex: 1;
    margin-left: 280px;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    transition: margin-left 0.3s ease;
    width: calc(100% - 280px);
}

.sidebar.collapsed + .chat-main {
    margin-left: 80px;
    width: calc(100% - 80px);
}

/* Шапка чата */
.chat-header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px; /* Уменьшил горизонтальные отступы */
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
    max-width: 100%;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-avatar {
    width: 40px; /* Уменьшил аватар */
    height: 40px;
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem; /* Уменьшил иконку */
    color: white;
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
    flex-shrink: 0;
}

.ai-info h2 {
    font-size: 1.1rem; /* Уменьшил имя */
    color: #e0e7ff;
    margin-bottom: 2px;
}

.ai-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    color: #10b981;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.chat-header-right {
    display: flex;
    gap: clamp(5px, 1.5vw, 10px);
}

.header-btn {
    width: clamp(35px, 5vw, 40px);
    height: clamp(35px, 5vw, 40px);
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 50%;
    color: #a78bfa;
    cursor: pointer;
    transition: all 0.3s;
    font-size: clamp(1rem, 1.8vw, 1.1rem);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.header-btn:hover {
    background: rgba(139, 92, 246, 0.2);
    transform: scale(1.1);
}

/* Область сообщений */
.messages-area {
    flex: 1;
    padding: clamp(15px, 3vw, 30px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: clamp(10px, 2vw, 20px);
}

/* Стилизация скроллбара */
.messages-area::-webkit-scrollbar {
    width: 6px;
}

.messages-area::-webkit-scrollbar-track {
    background: rgba(139, 92, 246, 0.1);
    border-radius: 10px;
}

.messages-area::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 10px;
}

.messages-area::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.5);
}

/* Сообщение */
.message {
    display: flex;
    gap: clamp(10px, 2vw, 15px);
    max-width: 85%;
    animation: messageAppear 0.3s ease;
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: clamp(35px, 5vw, 40px);
    height: clamp(35px, 5vw, 40px);
    background: rgba(139, 92, 246, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #a78bfa;
    flex-shrink: 0;
    font-size: clamp(1rem, 1.8vw, 1.2rem);
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.message-sender {
    font-size: clamp(0.8rem, 1.5vw, 0.9rem);
    color: #9ca3af;
    margin-left: 5px;
}

.message-bubble {
    padding: clamp(12px, 2vw, 15px) clamp(15px, 2.5vw, 20px);
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 20px;
    color: #e0e7ff;
    line-height: 1.6;
    max-width: 100%;
    word-wrap: break-word;
    font-size: clamp(0.9rem, 1.8vw, 1rem);
}

.user-message .message-bubble {
    background: linear-gradient(135deg, #8b5cf6, #a78bfa);
    color: #0f172a;
    border: none;
}

.message-time {
    font-size: clamp(0.65rem, 1.2vw, 0.75rem);
    color: #6b7280;
    margin-left: 5px;
}

/* Приветственное сообщение */
.welcome-message {
    margin-bottom: 20px;
}

.welcome-message .message-bubble {
    background: rgba(139, 92, 246, 0.15);
    border-color: #8b5cf6;
}

/* Индикатор печатания */
.typing-indicator {
    display: none;
    align-items: center;
    gap: 15px;
    padding: 10px 0;
}

.typing-dots {
    display: flex;
    gap: 5px;
    padding: clamp(10px, 2vw, 15px) clamp(15px, 2.5vw, 20px);
    background: rgba(30, 41, 59, 0.4);
    border-radius: 20px;
}

.typing-dots span {
    width: clamp(6px, 1.5vw, 8px);
    height: clamp(6px, 1.5vw, 8px);
    background: #8b5cf6;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Быстрые действия */
.quick-actions-bar {
    display: flex;
    gap: clamp(5px, 1.5vw, 10px);
    padding: clamp(10px, 2vw, 15px) clamp(15px, 3vw, 30px);
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(139, 92, 246, 0.2);
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.quick-action {
    display: flex;
    align-items: center;
    gap: clamp(5px, 1vw, 8px);
    padding: clamp(6px, 1.5vw, 8px) clamp(12px, 2vw, 15px);
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 30px;
    color: #a78bfa;
    cursor: pointer;
    transition: all 0.3s;
    font-size: clamp(0.8rem, 1.5vw, 0.9rem);
    white-space: nowrap;
    flex-shrink: 0;
}

.quick-action:hover {
    background: rgba(139, 92, 246, 0.2);
    transform: translateY(-2px);
}

.quick-action i {
    font-size: clamp(0.9rem, 1.8vw, 1rem);
}

/* Поле ввода */
.input-area {
    flex-shrink: 0;
    display: flex;
    align-items: center; /* Выравнивание по центру */
    gap: 8px; /* Уменьшил отступ */
    padding: 8px 15px; /* Уменьшил отступы */
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(139, 92, 246, 0.2);
    min-height: 60px; /* Фиксированная высота */
}

.attach-btn, .voice-btn, .send-btn {
    width: 36px; /* Уменьшил кнопки */
    height: 36px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 50%;
    color: #a78bfa;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.attach-btn:hover, .voice-btn:hover {
    background: rgba(139, 92, 246, 0.2);
    transform: scale(1.1);
}

.send-btn {
    background: linear-gradient(135deg, #8b5cf6, #a78bfa);
    color: #0f172a;
    border: none;
}

.send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 20px #8b5cf6;
}

.input-wrapper {
    flex: 1;
    display: flex;
    align-items: center; /* Центрирование */
    gap: 8px;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 25px;
    padding: 2px 2px 2px 15px; /* Уменьшил отступы */
    min-height: 40px; /* Фикс. высота */
}

.message-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #e0e7ff;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    padding: 8px 0; /* Уменьшил отступы */
    line-height: 1.4;
    max-height: 80px;
}

.message-input:focus {
    outline: none;
}

.message-input::placeholder {
    color: #6b7280;
}

.voice-btn {
    width: clamp(35px, 5vw, 40px);
    height: clamp(35px, 5vw, 40px);
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: rgba(15, 23, 42, 0.95);
    border: 2px solid #8b5cf6;
    border-radius: 40px;
    padding: clamp(30px, 5vw, 40px);
    max-width: 450px;
    width: 90%;
    text-align: center;
    animation: modalAppear 0.4s;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.close-modal {
    float: right;
    font-size: 2rem;
    cursor: pointer;
    color: #a78bfa;
    transition: all 0.3s;
}

.close-modal:hover {
    color: #fff;
    transform: rotate(90deg);
}

.modal-content h2 {
    font-size: clamp(1.5rem, 4vw, 2rem);
    margin: 20px 0 10px;
    background: linear-gradient(135deg, #fff, #c4b5fd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-content p {
    color: #9ca3af;
    margin-bottom: 30px;
    font-size: clamp(0.9rem, 1.8vw, 1rem);
}

.export-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(10px, 2vw, 15px);
}

.export-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: clamp(15px, 2.5vw, 20px);
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 20px;
    color: #e0e7ff;
    cursor: pointer;
    transition: all 0.3s;
    font-size: clamp(0.9rem, 1.5vw, 1rem);
}

.export-option:hover {
    background: rgba(139, 92, 246, 0.2);
    transform: translateY(-5px);
}

.export-option i {
    font-size: clamp(1.5rem, 3vw, 2rem);
    color: #8b5cf6;
}

/* ========== МОДАЛЬНОЕ ОКНО ИСТОРИИ ========== */
.history-modal {
    max-width: 500px !important;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    padding: clamp(20px, 4vw, 30px) !important;
}

.history-search {
    position: relative;
    margin: 20px 0;
}

.history-search i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #6b7280;
}

.history-search input {
    width: 100%;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 30px;
    padding: 12px 20px 12px 45px;
    color: #e0e7ff;
    font-size: clamp(0.9rem, 1.5vw, 0.95rem);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    max-height: 350px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-list::-webkit-scrollbar {
    width: 5px;
}

.history-list::-webkit-scrollbar-track {
    background: rgba(139, 92, 246, 0.1);
}

.history-list::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 5px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: clamp(10px, 2vw, 15px);
    padding: clamp(12px, 2vw, 15px);
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.4);
}

.history-item.active {
    background: rgba(139, 92, 246, 0.2);
    border-color: #8b5cf6;
}

.history-item-icon {
    width: clamp(35px, 5vw, 45px);
    height: clamp(35px, 5vw, 45px);
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    flex-shrink: 0;
}

.history-item-content {
    flex: 1;
    min-width: 0;
}

.history-item-title {
    color: #e0e7ff;
    font-weight: 500;
    margin-bottom: 4px;
    font-size: clamp(0.9rem, 1.8vw, 1rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-preview {
    color: #9ca3af;
    font-size: clamp(0.75rem, 1.5vw, 0.85rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.history-item-date {
    color: #6b7280;
    font-size: clamp(0.65rem, 1.2vw, 0.75rem);
    margin-top: 4px;
}

.history-item-delete {
    width: clamp(28px, 4vw, 32px);
    height: clamp(28px, 4vw, 32px);
    background: rgba(239, 68, 68, 0.1);
    border: none;
    border-radius: 50%;
    color: #ef4444;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.history-item:hover .history-item-delete {
    opacity: 1;
}

.history-item-delete:hover {
    background: #ef4444;
    color: white;
}

.history-footer {
    display: flex;
    justify-content: center;
    padding-top: 15px;
    border-top: 1px solid rgba(139, 92, 246, 0.2);
}

.history-btn {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    border-radius: 30px;
    padding: clamp(10px, 2vw, 12px) clamp(20px, 4vw, 30px);
    color: white;
    font-size: clamp(0.9rem, 1.8vw, 1rem);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px #4c1d95;
}

/* ========== АДАПТИВ ========== */

/* Планшеты и маленькие ноутбуки */
@media (max-width: 1200px) {
    .message {
        max-width: 85%;
    }
}

/* Планшеты вертикально */
/* Планшеты вертикально */
@media (max-width: 900px) {
    .sidebar {
        width: 80px;
        padding: 20px 10px;
    }
    
    /* Скрываем текстовые элементы */
    .sidebar .logo-text,
    .sidebar .nav-text,
    .sidebar .user-details,
    .sidebar .user-name,
    .sidebar .user-plan {
        display: none !important;
    }
    
    /* Центрируем иконки */
    .nav-item {
        justify-content: center;
        padding: 15px 0;
    }
    
    .nav-item i {
        margin: 0;
        font-size: 1.5rem;
    }
    
    /* Аватарка остается видимой */
    .sidebar .user-avatar {
        width: 45px;
        height: 45px;
        margin: 0 auto;
        display: block !important;
    }
    
    /* Кнопка выхода */
    .sidebar .logout-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex !important;
    align-items: center;
    justify-content: center;
}
    
    /* Подвал меню */
    .sidebar-footer {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
    
    .user-info {
        justify-content: center;
        width: 100%;
    }
    
    .chat-main {
        margin-left: 80px;
        width: calc(100% - 80px);
    }
    
    .message {
        max-width: 90%;
    }
}

/* Мобильные телефоны */
@media (max-width: 600px) {
    /* Отключаем размытие для всего */
    * {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    
    .chat-main {
        margin-left: 0 !important;
        padding: 0;
        width: 100% !important;
    }
    
    /* Боковое меню - используем transform как в рабочем коде */
    .sidebar {
        position: fixed;
        transform: translateX(-100%);
        width: 280px;
        height: 100vh;
        z-index: 100;
        transition: transform 0.3s ease;
        padding: 30px 20px;
        background: rgba(15, 23, 42, 0.95);
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    .sidebar .logo {
        justify-content: flex-start !important;
        padding-left: 0 !important;
        margin-left: -5px !important;
    }
    
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 5px 0 30px rgba(0, 0, 0, 0.5);
    }
    
    /* Показываем текст в меню */
    .sidebar .logo-text,
    .sidebar .nav-text,
    .sidebar .user-details {
        display: block !important;
    }
    
    .sidebar .nav-item {
        justify-content: flex-start;
        padding: 15px 20px;
    }
    
    .sidebar .nav-item i {
        margin-right: 15px;
        font-size: 1.3rem;
    }
    
    .sidebar .sidebar-footer {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        margin-top: -20px;
    }
    
    .sidebar .user-info {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
    }
    
    .sidebar .user-name {
    display: block !important;
    color: #e0e7ff;
    font-size: 0.95rem;
    font-weight: 600;
}

.sidebar .user-plan {
    display: inline-block !important;
    color: #8b5cf6;
    background: rgba(139, 92, 246, 0.2);
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 0.8rem;
    margin-top: 3px;
}
    
    .sidebar .logout-btn {
        width: 40px;
        height: 40px;
        border-radius: 50%;
    }
    
    /* Игнорируем свернутое состояние на мобильных */
    .sidebar.collapsed {
        width: 280px;
        padding: 30px 20px;
    }
    
    .sidebar.collapsed .logo-text,
    .sidebar.collapsed .nav-text,
    .sidebar.collapsed .user-details {
        display: block !important;
    }
    
    .sidebar.collapsed .nav-item {
        justify-content: flex-start;
        padding: 15px 20px;
    }
    
    .sidebar.collapsed .nav-item i {
        margin-right: 15px;
        font-size: 1.3rem;
    }
    
    .sidebar.collapsed .sidebar-footer {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    
    .sidebar.collapsed .user-info {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
    }
    
    .sidebar.collapsed .logout-btn {
        width: 40px;
        height: 40px;
        border-radius: 50%;
    }
    
    /* Кнопка мобильного меню */
    .mobile-menu-toggle {
        display: flex !important;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 50;
        width: 45px;
        height: 45px;
        background: linear-gradient(135deg, #8b5cf6, #6366f1);
        border-radius: 50%;
        align-items: center;
        justify-content: center;
        color: white;
        font-size: 1.3rem;
        cursor: pointer;
        box-shadow: 0 10px 25px -5px #4c1d95;
        border: 1px solid rgba(255, 255, 255, 0.2);
        transition: left 0.3s ease, transform 0.3s ease;
    }
    
    .mobile-menu-toggle i {
        transition: transform 0.3s ease;
    }
    
    /* Оверлей */
    .sidebar-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        z-index: 90;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s, visibility 0.3s;
    }
    
    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* Шапка чата */
    .chat-header {
        padding: 15px 15px 15px 70px;
    }
    
    .chat-header-left {
        gap: 10px;
    }
    
    .ai-avatar {
        width: 40px;
        height: 40px;
        font-size: 1.4rem;
    }
    
    .ai-info h2 {
        font-size: 1.1rem;
    }
    
    /* Убираем крестик на мобильных */
    #closeChat {
        display: none !important;
    }
    
    /* Область сообщений */
    .messages-area {
        padding: 20px 15px;
    }
    
    .message {
        max-width: 95%;
    }
    
    .message-bubble {
        padding: 12px 15px;
        font-size: 0.95rem;
    }
    
    /* Быстрые действия */
    .quick-actions-bar {
        padding: 10px 15px;
        overflow-x: auto;
    }
    
    .quick-action {
        flex-shrink: 0;
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    
    /* Поле ввода */
    .input-area {
        padding: 15px;
    }
    
    .input-wrapper {
        padding: 5px 5px 5px 15px;
    }
    
    .message-input {
        font-size: 0.95rem;
        padding: 10px 0;
    }
    
    .attach-btn, .voice-btn, .send-btn {
        width: 40px;
        height: 40px;
    }
    

    
    /* Экспорт */
    .export-options {
        grid-template-columns: 1fr;
    }
}




/* Очень маленькие телефоны */
@media (max-width: 380px) {
    .chat-header-left {
        gap: 8px;
    }
    
    .ai-avatar {
        width: 35px;
        height: 35px;
        font-size: 1.2rem;
    }
    
    .ai-info h2 {
        font-size: 1rem;
    }
    
    .header-btn {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }
    
    .message-bubble {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
    
    .quick-action {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
}

/* Кнопка мобильного меню (скрыта на десктопе) */
.mobile-menu-toggle {
    display: none;
}

/* Оверлей (скрыт на десктопе) */
.sidebar-overlay {
    display: none;
}

/* Горизонтальная ориентация на телефонах */
@media (max-height: 500px) and (orientation: landscape) {
    .sidebar {
        padding-top: 15px;
    }
    
    .sidebar-header {
        margin-bottom: 20px;
    }
    
    .nav-item {
        padding: 10px 15px;
    }
    
    .user-avatar {
        width: 35px;
        height: 35px;
    }
    
    .messages-area {
        padding: 15px;
    }
    
    .input-area {
        padding: 10px 15px;
    }
}

input, textarea {
    font-size: 16px !important; /* Предотвращает автоматический зум в iOS */
}

@media (max-width: 600px) {
    input, textarea, select {
        font-size: 16px !important;
    }
}

/* Исправление для белой полосы */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    background: #0f172a; /* fallback */
}

body {
    background: transparent !important;
}

.dashboard-container {
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
}

.main-content {
    box-sizing: border-box;
    min-height: 100vh;
    min-height: 100dvh;
}

.stats-row:last-child {
    margin-bottom: 0;
}

/* Запасной вариант */
.dashboard-container::after {
    content: '';
    display: table;
    clear: both;
}

/* ========== СТИЛИ ДЛЯ БОКОВОЙ ПАНЕЛИ (КАК В ДАШБОРДЕ) ========== */

/* Обрезаем длинное имя с троеточием */
.sidebar .user-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
    display: block;
    font-weight: 600;
    color: #e0e7ff;
    font-size: 0.95rem;
}

/* Закругленный тариф с двух сторон */
.sidebar .user-plan {
    display: inline-block;
    background: rgba(139, 92, 246, 0.2);
    padding: 3px 12px;
    border-radius: 30px;
    font-size: 0.75rem;
    color: #a78bfa;
    font-weight: 500;
    white-space: nowrap;
    margin-top: 4px;
}

/* Структура футера */
.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid rgba(139, 92, 246, 0.2);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
    flex: 1;
}

.user-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
}

/* Скрываем стрелочку сворачивания только на мобильных устройствах */
@media (max-width: 600px) {
    .sidebar-toggle {
        display: none !important;
    }
}

/* ========== ФИКС ДЛЯ ФОРМЫ ТАРИФА В ЧАТЕ ========== */

/* Делаем тариф компактным и закругленным */
.sidebar .user-plan {
    display: inline-block !important;
    background: rgba(139, 92, 246, 0.2) !important;
    padding: 4px 12px !important;
    border-radius: 30px !important;
    font-size: 0.75rem !important;
    color: #a78bfa !important;
    font-weight: 500 !important;
    white-space: nowrap !important;
    width: auto !important;
    min-width: auto !important;
    max-width: 100px !important;
    text-align: center !important;
    margin-top: 4px !important;
    letter-spacing: 0.3px !important;
}

/* Для мобильных устройств */
@media (max-width: 600px) {
    .sidebar .user-plan {
        padding: 3px 10px !important;
        font-size: 0.7rem !important;
        max-width: 90px !important;
    }
}

/* Обрезаем длинное имя */
.sidebar .user-name {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 130px !important;
    display: block !important;
}

.message-bubble {
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.5;
}

.message-bubble p {
    margin-bottom: 12px;
}

