/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    width: 100%;
}

body {
    height: 100%;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Söhne", "Segoe UI", Helvetica, Arial, sans-serif;
    background: #212121;
    color: #ececec;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Page Layout */
.page-wrapper {
    display: flex;
    flex: 1;
    width: 100%;
    min-height: 0;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.chat-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

/* Empty State */
.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -60%);
    text-align: center;
    z-index: 1;
    transition: opacity 0.3s, transform 0.3s;
}

.empty-state.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -65%);
}

.empty-title {
    font-size: 40px;
    font-weight: 600;
    color: #ececec;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.empty-subtitle {
    font-size: 16px;
    color: #8e8ea0;
    font-weight: 400;
}

.empty-subtitle-hint {
    font-size: 12px;
    color: rgba(142, 142, 160, 0.6);
    font-weight: 400;
    transition: opacity 0.2s;
}

.empty-subtitle-hint:hover {
    opacity: 1;
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.3s;
    padding: 16px;
    max-width: 48rem;
    margin: 0 auto;
    width: 100%;
    padding-bottom: 100px;
}

.messages-container.visible {
    opacity: 1;
}

.messages-container::-webkit-scrollbar {
    width: 8px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background: #ffffff1a;
    border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: #ffffff33;
}

/* Message Groups */
.message-group {
    display: flex;
    margin-bottom: 16px;
    max-width: 100%;
    align-items: flex-start;
}

/* AI сообщения слева */
.message-group.assistant {
    flex-direction: row;
    justify-content: flex-start;
}

/* Сообщения пользователя справа */
.message-group.user {
    flex-direction: row;
    justify-content: flex-end;
}

/* Скрываем аватарки */
.message-avatar {
    display: none;
}

/* Message Content */
.message-content {
    max-width: 75%;
    min-width: 0;
    line-height: 1.6;
    font-size: 15px;
}

/* Фон только для сообщений пользователя */
.message-group.user .message-content {
    background: #2f2f2f;
    border-radius: 18px;
    padding: 12px 16px;
}

/* AI сообщения без фона */
.message-group.assistant .message-content {
    background: transparent;
    padding: 0;
}

.message-content p {
    margin-bottom: 12px;
    line-height: 1.6;
}

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

.message-content code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 5px;
    border-radius: 3px;
    font-family: "Söhne Mono", Monaco, "Courier New", monospace;
    font-size: 13px;
    color: #e8e8e8;
    max-width: 100%;
    word-wrap: break-word;
}

.message-content pre {
    background: #0d0d0d;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 12px 0;
    font-size: 13px;
    line-height: 1.5;
    border: 1px solid #ffffff1a;
    max-width: 100%;
}

.message-content h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 16px 0 8px 0;
    color: #ececec;
}

.message-content h3:first-child {
    margin-top: 0;
}

/* Списки более компактные */
.message-content ul {
    margin: 6px 0;
    padding-left: 20px;
}

.message-content li {
    margin-bottom: 4px;
    line-height: 1.5;
}

.message-content strong {
    font-weight: 600;
    color: #66b5ff;
    display: block;
    margin: 24px 0 12px 0;
    padding-top: 20px;
    border-top: 1px solid #ffffff1a;
    font-size: 15px;
}

.message-content em {
    color: #9b9b9b;
    font-style: italic;
    font-size: 13px;
    display: block;
    margin-top: 8px;
}

.message-content a {
    color: #66b5ff;
    text-decoration: underline;
    transition: color 0.2s;
}

.message-content a:hover {
    color: #8fc7ff;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #666;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        opacity: 0.4;
    }
    30% {
        opacity: 1;
    }
}

/* Input Section */
.input-section {
    padding: 16px;
    background: #212121;
    transition: all 0.3s;
    position: relative;
    padding-bottom: 24px;
}

/* Центрируем инпут когда чат пустой */
.input-section.centered {
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform: translate(-50%, 120px);
    width: 100%;
    max-width: 48rem;
    background: transparent;
}

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

.input-form {
    position: relative;
    display: flex;
    align-items: center;
    background: #2f2f2f;
    border: 1px solid #ffffff26;
    border-radius: 24px;
    padding: 4px 4px 4px 16px;
    transition: border-color 0.2s;
}

.input-form:focus-within {
    border-color: #ffffff40;
}

#user-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #ececec;
    font-size: 16px;
    padding: 10px 8px;
    font-family: inherit;
}

#user-input::placeholder {
    color: #8e8ea0;
}

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

.send-btn:not(:disabled) {
    background: #fff;
}

.send-btn:not(:disabled):hover {
    background: #d4d4d4;
}

.send-btn:disabled {
    background: #676767;
    cursor: not-allowed;
    opacity: 0.4;
}

.send-btn svg {
    width: 20px;
    height: 20px;
}

.input-footer {
    text-align: center;
    margin-top: 12px;
    font-size: 12px;
    color: #8e8ea0;
}

.input-footer code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    color: #d4d4d4;
}

/* Animations */
.message-group {
    animation: slideIn 0.3s ease-out;
}

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

.ascii-art {
    font-size: 10px;
    line-height: 1;
    white-space: pre;
    overflow-x: auto;
    font-family: monospace;
}

.em-large {
    font-size: 24px;
    font-weight: bold;
    display: inline-block;
    color: #333;
}

/* Responsive */
@media (max-width: 768px) {
    /* ASCII-арт мельче */
    .ascii-art {
        font-size: 8px !important;
    }

    /* Empty state */
    .empty-state {
        transform: translate(-50%, -50%);
        padding: 0 12px;
        max-width: calc(100vw - 24px);
    }

    .empty-title {
        font-size: 32px;
    }

    .empty-subtitle {
        font-size: 14px;
    }

    /* Messages container - на всю ширину */
    .messages-container {
        padding: 12px;
        padding-bottom: 120px;
        max-width: 100% !important;
        margin: 0 !important;
    }

    .message-group {
        margin-bottom: 12px;
    }

    /* Сообщения шире, но без перелёта */
    .message-content {
        font-size: 15px;
        line-height: 1.55;
        max-width: 100% !important;
    }

    .message-group.user .message-content {
        padding: 12px 16px;
    }

    /* Заголовки и отступы */
    .message-content h3 {
        font-size: 15px;
    }

    .message-content strong {
        font-size: 14px;
        margin: 20px 0 10px 0;
    }

    /* Списки */
    .message-content ul {
        padding-left: 18px;
        margin: 8px 0;
    }

    .message-content li {
        margin-bottom: 6px;
    }

    /* Input section */
    .input-section {
        padding: 12px;
        padding-bottom: 20px;
    }

    .input-section.centered {
        bottom: 40%;
        transform: translate(-50%, 50px);
        padding: 12px;
        max-width: 100% !important;
    }

    .input-container {
        max-width: 100% !important;
        padding: 0 12px;
    }

    .input-form {
        padding: 6px 6px 6px 12px;
    }

    #user-input {
        font-size: 16px;
        padding: 12px 12px;
    }

    .send-btn {
        width: 44px;
        height: 44px;
    }

    .send-btn svg {
        width: 22px;
        height: 22px;
    }

    .input-footer {
        font-size: 11px;
        margin-top: 10px;
    }

    /* Header */
    .chat-header {
        padding: 10px 12px;
        max-width: 100% !important;
    }

    /* Глобально убираем горизонтальный скролл */
    .page-wrapper,
    .main-content,
    .chat-wrapper {
        max-width: 100%;
        width: 100%;
        margin: 0;
        box-sizing: border-box;
    }
}

/* Очень маленькие экраны */
@media (max-width: 480px) {
    .ascii-art {
        font-size: 7px !important;
    }

    .messages-container {
        padding: 8px;
        padding-bottom: 140px;
    }

    #user-input {
        padding: 14px 14px;
    }

    .send-btn {
        width: 48px;
        height: 48px;
    }
}

/* Header */
.chat-header {
    max-width: 48rem;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-header.hidden {
    transform: translateY(-100%);
    opacity: 0;
    height: 0;
    padding: 0;
    overflow: hidden;
}

.chat-header {
    background: #212121;
    border-bottom: 1px solid #ffffff1a;
    padding: 12px 16px;
    transition: all 0.3s;
    max-width: 48rem;
    margin: 0 auto;
    width: 100%;
}

.chat-header.hidden {
    display: none;
}

/* Job separator */
.message-content strong {
    font-weight: 600;
    color: #fff;
    display: block;
    margin: 24px 0 12px 0;
    padding-top: 20px;
    border-top: 1px solid #ffffff1a;
}

.message-content h3 + strong {
    border-top: none;
    padding-top: 0;
}

/* Вложенные списки с отступами */
.message-content ul ul {
    margin: 4px 0;
    padding-left: 24px;
}

.message-content ul ul ul {
    padding-left: 20px;
}

/* Em после блока - больше отступ */
.message-content em {
    color: #9b9b9b;
    font-style: italic;
    font-size: 13px;
    display: block;
    margin: 16px 0 0 0;
    padding-bottom: 16px;
}
.collapsible-header {
    cursor: pointer;
    color: #6cf;
    font-weight: 600;
    margin-top: 12px;
}

.collapsible-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.collapsible-body.open {
    max-height: 1000px;
}

.collapsible-body pre {
    background: #0d1117;
    color: #c9d1d9;
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    white-space: pre-wrap;
}

