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


body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background-color: #212121;
    color: #ececec;
    overflow: hidden;
}


.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}


/* Боковая панель */
.sidebar {
    width: 260px;
    background-color: #171717;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #2f2f2f;
    transition: transform 0.3s ease;
}


.sidebar-header {
    padding: 12px;
}


.btn-new-chat {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: transparent;
    border: 1px solid #3f3f3f;
    border-radius: 8px;
    color: #ececec;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}


.btn-new-chat:hover {
    background: #2a2a2a;
}


.sidebar-menu {
    padding: 8px;
    border-bottom: 1px solid #2f2f2f;
}


.menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #ececec;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
    text-align: left;
    position: relative;
}


.menu-item:hover {
    background: #2a2a2a;
}


.menu-item.active {
    background: #2a2a2a;
}


.badge {
    margin-left: auto;
    padding: 2px 6px;
    background: #10a37f;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    color: white;
}


.sidebar-section {
    padding: 8px;
    border-bottom: 1px solid #2f2f2f;
}


.section-title {
    padding: 8px 12px;
    font-size: 12px;
    color: #8e8e8e;
    font-weight: 600;
    text-transform: uppercase;
}


.chats-section {
    flex: 1;
    overflow-y: auto;
    border-bottom: none;
}


.chat-list {
    display: flex;
    flex-direction: column;
}


.chat-item {
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #ececec;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


.chat-item:hover {
    background: #2a2a2a;
}


.sidebar-footer {
    padding: 12px;
    display: flex;
    gap: 8px;
    align-items: center;
    border-top: 1px solid #2f2f2f;
}


.user-profile {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #ececec;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}


.user-profile:hover {
    background: #2a2a2a;
}


.avatar {
    width: 32px;
    height: 32px;
    background: #10a37f;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}


.user-badge {
    margin-left: auto;
    padding: 2px 6px;
    background: #3f3f3f;
    border-radius: 4px;
    font-size: 11px;
    color: #ececec;
}


.btn-upgrade {
    padding: 8px 12px;
    background: transparent;
    border: 1px solid #3f3f3f;
    border-radius: 8px;
    color: #ececec;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}


.btn-upgrade:hover {
    background: #2a2a2a;
}


/* Основная область чата */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #212121;
    position: relative;
    height: 100vh;
    overflow: hidden;
}


.chat-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #2f2f2f;
    background: #212121;
}


.toggle-sidebar {
    display: none;
    padding: 8px;
    background: transparent;
    border: none;
    color: #ececec;
    cursor: pointer;
    border-radius: 6px;
    margin-right: 8px;
}


.toggle-sidebar:hover {
    background: #2a2a2a;
}


.chat-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}


.header-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
}


.icon-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid #3f3f3f;
    border-radius: 8px;
    color: #ececec;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}


.icon-btn:hover {
    background: #2a2a2a;
}


.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    opacity: 0;
    transition: opacity 0.3s ease;
    max-width: 100%;
}


.message {
    display: flex;
    flex-direction: column;
    max-width: 48rem;
    margin: 0 auto;
    width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}


.user-message {
    align-items: flex-end;
}


.user-message .message-content {
    background: #2f2f2f;
    padding: 16px;
    border-radius: 18px;
    max-width: 70%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}


.ai-message {
    display: flex;
    flex-direction: column;
    gap: 12px;
}


.ai-message .message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}


.ai-message .message-content {
    color: #ececec;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}


.ai-message .message-content p {
    margin-bottom: 12px;
}


.ai-message .message-content p:last-child {
    margin-bottom: 0;
}


/* .message-actions removed - no longer used */


/* .action-btn removed - no longer used */


/* Область ввода */
.chat-input-container {
    padding: 16px;
    background: #212121;
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform: translate(-50%, 50%);
    width: 100%;
    max-width: 768px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2;
}


.scroll-btn {
    position: absolute;
    top: -48px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    background: #2f2f2f;
    border: 1px solid #3f3f3f;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
}


.scroll-btn:hover {
    background: #3a3a3a;
}


.chat-input-form {
    max-width: 48rem;
    margin: 0 auto;
}


.input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #2f2f2f;
    border: 1px solid #3f3f3f;
    border-radius: 24px;
    padding: 12px 16px;
    transition: border-color 0.2s;
}


.input-wrapper:focus-within {
    border-color: #565656;
}


#messageInput {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #ececec;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    max-height: 200px;
    line-height: 1.5;
}


#messageInput::placeholder {
    color: #8e8e8e;
}


.send-btn {
    padding: 8px;
    background: #ececec;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}


.send-btn:hover {
    background: #d1d1d1;
}


.send-btn:disabled {
    background: #3f3f3f;
    cursor: not-allowed;
}


.send-btn svg {
    fill: #212121;
}


.disclaimer {
    text-align: center;
    margin-top: 12px;
    font-size: 12px;
    color: #8e8e8e;
}


.disclaimer a {
    color: #8e8e8e;
    text-decoration: underline;
}


/* ========================================
   НОВЫЕ СТИЛИ: ЦЕНТРИРОВАННЫЙ ПРИВЕТСТВЕННЫЙ ЭКРАН
   ======================================== */


.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 1;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1;
}


.welcome-title {
    font-size: 20px;
    font-weight: 600;
    color: #ececec;
    text-align: center;
    margin-bottom: 140px;
}


/* Состояние после начала диалога */
.chat-main.chat-started .welcome-screen {
    opacity: 0;
    pointer-events: none;
}


.chat-main.chat-started .chat-messages {
    opacity: 1;
}


.chat-main.chat-started .chat-input-container {
    position: relative;
    bottom: 0;
    left: 0;
    transform: none;
    max-width: 100%;
    padding: 16px;
}


.chat-main.chat-started .scroll-btn {
    opacity: 1;
    pointer-events: auto;
}


/* Стили для контейнера источников */
.sources-container {
    max-width: 48rem;
    margin: 0 auto;
    width: 100%;
    padding: 0 16px;
    margin-bottom: 1rem;
    display: none;
}


.sources-container.visible {
    display: block;
}


.sources-title {
    font-size: 0.9rem;
    color: #8e8e8e;
    margin-bottom: 0.5rem;
}


.sources-list {
    font-size: 0.85rem;
    list-style-type: none;
    padding-left: 0;
}


.sources-list li {
    background-color: #2a2a2a;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}



/* ========================================
   КОНЕЦ НОВЫХ СТИЛЕЙ
   ======================================== */


/* Markdown styles for AI messages */
.message-content p {
    margin-bottom: 12px;
}


.message-content p:last-child {
    margin-bottom: 0;
}


.message-content ul,
.message-content ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}


.message-content li {
    margin-bottom: 0.25rem;
}


.message-content pre {
    background-color: #2d2d2d;
    color: #e0e0e0;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 1rem 0;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    border: 1px solid #565656;
    max-width: 100%;
}


.message-content :not(pre) > code {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 0.3rem;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    word-break: break-all;
}


.message-content a {
    color: #5ab1f7;
    text-decoration: underline;
    word-break: break-word;
}


.message-content h1, .message-content h2, .message-content h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}


.message-content table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.95rem;
    display: block;
    overflow-x: auto;
}


.message-content th,
.message-content td {
    padding: 0.75rem;
    border: 1px solid #565656;
    text-align: left;
    word-wrap: break-word;
}


.message-content th {
    background-color: #40414f;
    font-weight: 600;
}


.message-content tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.05);
}


.message-content blockquote {
    border-left: 4px solid #5ab1f7;
    padding-left: 1rem;
    margin-left: 0;
    color: #8e8e8e;
    font-style: italic;
}


/* Скроллбары */
.chats-section::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
    width: 6px;
}


.chats-section::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}


.chats-section::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb {
    background: #3f3f3f;
    border-radius: 10px;
}


.chats-section::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #565656;
}


/* Адаптивность */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
        overflow-y: hidden;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 1000;
        transform: translateX(-100%);
    }


    .sidebar.open {
        transform: translateX(0);
    }


    .toggle-sidebar {
        display: block;
    }


    .header-actions .icon-btn span {
        display: none;
    }


    .user-message .message-content {
        max-width: 85%;
    }


    .chat-messages {
        padding: 16px 12px;
        padding-bottom: 120px;
    }

    .chat-main.chat-started .chat-messages {
        padding-bottom: 100px;
    }

    .welcome-title {
        font-size: 20px;
        margin-bottom: 200px; /* УВЕЛИЧЕНО с 80px до 200px */
        padding: 0 20px;
    }


    .chat-input-container {
        max-width: 100%;
        padding: 12px;
        width: calc(100% - 24px);
        left: 12px;
        right: 12px;
        transform: translateY(50%);
    }

    .chat-main.chat-started .chat-input-container {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        padding: 12px;
        transform: none;
        background: #212121;
        border-top: 1px solid #2f2f2f;
    }

    .message-content table {
        font-size: 0.8rem;
    }

    .message-content th,
    .message-content td {
        padding: 0.5rem;
        font-size: 0.8rem;
    }

    .message-content pre {
        font-size: 0.75em;
        padding: 0.75rem;
    }

    .message-content {
        font-size: 15px;
    }

    .ai-message .message-content {
        font-size: 15px;
        line-height: 1.5;
    }
}


@media (max-width: 480px) {
    .chat-header {
        padding: 8px 12px;
    }


    .header-actions {
        gap: 4px;
    }


    .icon-btn {
        padding: 6px 8px;
    }


    .input-wrapper {
        padding: 10px 14px;
    }

    .welcome-title {
        font-size: 18px;
        margin-bottom: 220px; /* УВЕЛИЧЕНО с 70px до 220px */
    }

    .message-content {
        font-size: 14px;
    }

    .ai-message .message-content {
        font-size: 14px;
    }

    #messageInput {
        font-size: 16px;
    }
}

