/**
 * Стили для чат-режима навыков
 * Отдельная реализация от основных стилей навыков
 * 
 * СТРУКТУРА МОБИЛЬНЫХ СТИЛЕЙ:
 * 
 * 1. ОСНОВНЫЕ МОБИЛЬНЫЕ СТИЛИ - ВЕРТИКАЛЬНАЯ ОРИЕНТАЦИЯ
 *    - Все основные стили для мобильных устройств
 *    - Глобальный контейнер кнопок
 *    - Форма ввода ИИ
 *    - Адаптивные размеры и отступы
 * 
 * 2. КОМПАКТНЫЕ МОБИЛЬНЫЕ СТИЛИ
 *    - Специальные стили для очень маленьких экранов (414x896)
 *    - Уменьшенные отступы и размеры
 *    - Оптимизация для компактных устройств
 * 
 * 3. ГОРИЗОНТАЛЬНАЯ ОРИЕНТАЦИЯ (АЛЬБОМНАЯ)
 *    - Стили для горизонтальной ориентации
 *    - Компактная форма ввода ИИ
 *    - Оптимизация для альбомного режима
 * 
 * Селекторы мобильных устройств:
 * - (max-width: 768px) - маленькие экраны
 * - (pointer: coarse) - сенсорные устройства (палец)
 * - (hover: none) - устройства без hover (мобильные)
 * - (pointer: coarse) and (hover: none) - точное определение мобильных
 * - (max-width: 1024px) and (max-height: 768px) and (pointer: coarse) - планшеты 1024x768
 */

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

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

/* КРИТИЧНО: Убираем все тени и границы у кнопок - должно быть в самом начале */
button:not(.site-header-btn), .action-btn, .reset-button, .continue-btn, .ai-help-btn, .complete-btn, .send-btn, .reset-btn, .new-skill-btn {
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    -moz-box-shadow: none !important;
    text-shadow: none !important;
    outline: none !important;
    filter: none !important;
    border: none !important;
}

body {
    font-family: var(--it-font, 'OpenSansLight', Verdana, 'Geneva CY', sans-serif);
    font-weight: normal;
    font-size: var(--it-fs, 14px);
    line-height: var(--it-lh, 1.25);
    color: var(--it-ink, #111);
    font-synthesis: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: var(--it-surface, #f7f5f2);
    height: 100vh;
    overflow: hidden;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.chat-container {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-height: 100vh;
    flex: 1;
    width: 100%;
    max-width: 100%;
}

/* Заголовок чата */
.chat-header {
    background: white;
    color: #333;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    border-radius: 12px 12px 0 0;
    overflow: visible;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.chat-icon {
    font-size: 20px;
    background: #e9ecef;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-title h1 {
    font-size: var(--it-fs-title, 26px);
    line-height: var(--it-lh-title, 1.4);
    letter-spacing: var(--it-tracking, 0.02em);
    font-family: var(--it-font-display, 'Noto Sans Display Condensed', 'Segoe UI', sans-serif);
    font-weight: 600;
    font-synthesis: none;
    color: var(--it-ink, #111);
    margin: 0;
}

.chat-title p {
    font-size: var(--it-fs-page, 18px);
    line-height: var(--it-lh-text, 1.6);
    letter-spacing: var(--it-tracking, 0.02em);
    color: var(--it-meta, #888);
    margin: 5px 0 0 0;
}

.chat-controls {
    display: flex;
    gap: 10px;
}

.skill-session-menu {
    position: relative;
    display: inline-flex;
    z-index: 5;
}

.skill-session-menu:has(.skill-session-dropdown:not([hidden])) {
    z-index: 90;
}

body.skill-chat-app-open .skill-scroll > .chat-header:has(.skill-session-dropdown:not([hidden])) {
    z-index: 90;
}

.reset-button {
    background: var(--it-paper, #fff);
    border: 1px solid var(--it-line, #e6e1d8) !important;
    color: var(--it-ink, #0d0d0d);
    padding: 8px 12px;
    border-radius: var(--it-radius, 8px);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    overflow: visible;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
}

.reset-button:hover {
    background: var(--it-surface, #f7f5f2);
    border-color: var(--it-line, #e6e1d8) !important;
}

.skill-session-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 240px;
    max-width: min(340px, 92vw);
    max-height: min(360px, 60vh);
    overflow-y: auto;
    background: var(--it-paper, #fff);
    border: 1px solid var(--it-line, #e6e1d8);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(13, 13, 13, 0.1);
    z-index: 80;
    padding: 6px 0;
}

.skill-session-dd-row {
    display: flex;
    align-items: flex-start;
    gap: 2px;
}

.skill-session-dd-item {
    display: block;
    flex: 1;
    min-width: 0;
    width: auto;
    text-align: left;
    padding: 10px 8px 10px 14px;
    border: none;
    background: none;
    font: inherit;
    font-size: 14px;
    line-height: 1.35;
    cursor: pointer;
    color: var(--it-ink, #0d0d0d);
    white-space: normal;
    overflow-wrap: anywhere;
}

.skill-session-menu .hub-session-rename-btn,
.skill-session-menu .hub-session-delete-btn,
.skill-session-menu .hub-session-fav-btn,
.skill-session-action-btn {
    flex: none;
    margin: 6px 4px 0 0;
    border: none;
    background: transparent;
    color: var(--it-ink-soft, #5c584f);
    cursor: pointer;
    font: inherit;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 6px;
    opacity: 0;
    pointer-events: none;
}

.skill-session-menu .hub-session-fav-btn {
    font-size: 1.05rem;
    color: #a67c00;
}

.skill-session-menu .hub-session-fav-btn.is-on {
    color: #d4a017;
}

.skill-session-menu .hub-session-delete-btn {
    margin-right: 6px;
    font-size: 1.15rem;
    font-weight: 600;
    color: #8a4b4b;
}

.skill-session-dd-row:hover .hub-session-rename-btn,
.skill-session-dd-row:focus-within .hub-session-rename-btn,
.skill-session-dd-row:hover .hub-session-delete-btn,
.skill-session-dd-row:focus-within .hub-session-delete-btn,
.skill-session-dd-row:hover .hub-session-fav-btn,
.skill-session-dd-row:focus-within .hub-session-fav-btn {
    opacity: 1;
    pointer-events: auto;
}

@media (hover: none) {
    .skill-session-menu .hub-session-rename-btn,
    .skill-session-menu .hub-session-delete-btn,
    .skill-session-menu .hub-session-fav-btn {
        opacity: 1;
        pointer-events: auto;
    }
}

.skill-session-menu .hub-session-rename-btn:hover,
.skill-session-menu .hub-session-delete-btn:hover,
.skill-session-menu .hub-session-fav-btn:hover {
    background: var(--it-surface, #f7f5f2);
}

.skill-session-menu .hub-session-delete-btn:hover {
    color: #b91c1c;
}

.skill-session-fav-btn {
    flex: none;
    align-self: center;
    box-sizing: border-box;
    background: var(--it-paper, #fff);
    border: 1px solid var(--it-line, #e6e1d8) !important;
    color: #a67c00;
    padding: 8px 12px;
    border-radius: var(--it-radius, 8px);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    min-width: 42px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    opacity: 1;
    pointer-events: auto;
}

.skill-session-fav-btn.is-on {
    color: #d4a017;
}

.skill-session-fav-btn:hover {
    background: var(--it-surface, #f7f5f2);
    border-color: var(--it-line, #e6e1d8) !important;
}

.skill-session-menu .hub-session-rename-input {
    flex: 1;
    min-width: 0;
    margin: 6px 8px 6px 10px;
    padding: 6px 8px;
    border: 1px solid var(--it-line, #e6e1d8);
    border-radius: 8px;
    font: inherit;
    color: var(--it-ink, #0d0d0d);
    background: #fff;
}

.skill-session-dd-item:hover {
    background: var(--it-surface, #f7f5f2);
}

.skill-session-dd-item--new {
    font-weight: 600;
    color: var(--it-btn, #ff9600);
}

.skill-session-dd-row--status {
    pointer-events: none;
}

.skill-session-dd-status {
    padding: 8px 14px 10px;
    font-size: 13px;
    line-height: 1.35;
    color: var(--it-muted, #585858);
}

.skill-session-dd-item.is-current {
    background: var(--it-surface, #f7f5f2);
    font-weight: 600;
}

.skill-session-dd-sep {
    height: 1px;
    margin: 4px 10px;
    background: var(--it-line, #e6e1d8);
}

.reset-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    line-height: 0;
    flex-shrink: 0;
    overflow: visible;
}

.reset-icon svg {
    display: block;
    width: 18px;
    height: 18px;
    overflow: visible;
}

/* Область сообщений */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 10px; /* Уменьшенные боковые отступы */
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: white;
    min-height: 0; /* Важно для правильного flex-скроллинга */
    -webkit-overflow-scrolling: touch; /* iOS momentum scroll */
    overscroll-behavior: contain;
    touch-action: pan-y;
}

/* Тонкий скроллбар для сообщений */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.4);
}

/* Сообщения */
.message {
    background: #f8f9fa;
    border-radius: 8px;
    overflow: visible; /* Изменено с hidden на visible для кнопок */
    animation: messageSlideIn 0.3s ease-out;
    min-height: auto;
    flex-shrink: 0; /* Предотвращает сжатие сообщений */
}

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

.message-header {
    padding: 12px 16px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--it-font-semibold, 'OpenSansSemiBold', Verdana, 'Geneva CY', sans-serif);
    font-weight: normal;
    background: white;
    border-bottom: 1px solid #e9ecef;
}

.message-content {
    padding: 0px 16px;
    background: white;
    overflow: visible;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: manual;
    font-family: var(--it-font-read, var(--it-font-regular, 'OpenSansRegular', Verdana, 'Geneva CY', sans-serif));
    font-weight: normal;
    font-size: var(--it-fs-text, 18px);
    line-height: var(--it-lh-text, 1.6);
    letter-spacing: var(--it-tracking, 0.02em);
    word-spacing: 0.04em;
    color: var(--it-muted, #585858);
    font-synthesis: none;
}

/* Заголовки сообщений */
.step-number {
    background: #007bff;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    flex-shrink: 0;
}

.step-title {
    flex: 1;
    font-size: var(--it-fs-page, 18px);
    line-height: var(--it-lh-title, 1.4);
    letter-spacing: var(--it-tracking, 0.02em);
    color: var(--it-ink, #111);
    font-family: var(--it-font-semibold, 'OpenSansSemiBold', Verdana, 'Geneva CY', sans-serif);
    font-weight: normal;
    font-synthesis: none;
}

.step-progress {
    background: #e9ecef;
    color: #6c757d;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.ai-icon {
    font-size: 20px;
}

.ai-title {
    color: #667eea;
    font-size: var(--it-fs-page, 18px);
    font-family: var(--it-font-semibold, 'OpenSansSemiBold', Verdana, 'Geneva CY', sans-serif);
    font-weight: normal;
    font-synthesis: none;
}

.message-time {
    background: #e9ecef;
    color: #6c757d;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 500;
    margin-left: auto;
}

.completion-icon {
    font-size: 20px;
}

.completion-title {
    color: #28a745;
    font-size: var(--it-fs-page, 18px);
}

/* Типы сообщений */
.step-message {
    border-left: 4px solid #667eea;
}

.ai-message {
    border-left: 4px solid #17a2b8;
    background: #f8f9ff;
    margin: 16px 0;
    border-radius: 8px;
    overflow: hidden;
}

.welcome-message {
    border-left: 4px solid #667eea;
    background: linear-gradient(135deg, #f8f9ff 0%, #e9ecff 100%);
    margin: 0 0 24px 0;
    border-radius: 8px;
    overflow: hidden;
}

.welcome-message .message-header {
    background: rgba(102, 126, 234, 0.1);
    padding: 12px 16px;
    border-bottom: 1px solid rgba(102, 126, 234, 0.2);
}

.welcome-message .message-content {
    padding: 16px;
}

.welcome-message .message-content h3 {
    color: #667eea;
    margin-top: 16px;
    margin-bottom: 8px;
    font-size: var(--it-fs-page, 18px);
}

.welcome-message .message-content p {
    margin: 8px 0;
    line-height: var(--it-lh-text, 1.6);
}

.welcome-message .message-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

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

.welcome-message .message-content strong {
    color: #667eea;
    font-family: var(--it-font-semibold, 'OpenSansSemiBold', Verdana, 'Geneva CY', sans-serif);
    font-weight: normal;
}

/* welcomeStyle — те же значения, что style у шага */
.welcome-message.primary {
    border-left-color: #3498db;
    background: linear-gradient(135deg, #f5fafe 0%, #e8f4fc 100%);
}
.welcome-message.primary .message-header {
    background: rgba(52, 152, 219, 0.1);
    border-bottom-color: rgba(52, 152, 219, 0.2);
}
.welcome-message.primary .ai-title,
.welcome-message.primary .message-content strong,
.welcome-message.primary .message-content h3 {
    color: #3498db;
}

.welcome-message.success {
    border-left-color: #27ae60;
    background: linear-gradient(135deg, #f5fcf8 0%, #e8f8ef 100%);
}
.welcome-message.success .message-header {
    background: rgba(39, 174, 96, 0.1);
    border-bottom-color: rgba(39, 174, 96, 0.2);
}
.welcome-message.success .ai-title,
.welcome-message.success .message-content strong,
.welcome-message.success .message-content h3 {
    color: #27ae60;
}

.welcome-message.warning {
    border-left-color: #f39c12;
    background: linear-gradient(135deg, #fffbf5 0%, #fef3e0 100%);
}
.welcome-message.warning .message-header {
    background: rgba(243, 156, 18, 0.1);
    border-bottom-color: rgba(243, 156, 18, 0.2);
}
.welcome-message.warning .ai-title,
.welcome-message.warning .message-content strong,
.welcome-message.warning .message-content h3 {
    color: #d68910;
}

.welcome-message.info {
    border-left-color: #2980b9;
    background: linear-gradient(135deg, #f4f9fc 0%, #e4f1f9 100%);
}
.welcome-message.info .message-header {
    background: rgba(41, 128, 185, 0.1);
    border-bottom-color: rgba(41, 128, 185, 0.2);
}
.welcome-message.info .ai-title,
.welcome-message.info .message-content strong,
.welcome-message.info .message-content h3 {
    color: #2980b9;
}

.welcome-message.purple {
    border-left-color: #8e44ad;
    background: linear-gradient(135deg, #faf6fc 0%, #f0e6f5 100%);
}
.welcome-message.purple .message-header {
    background: rgba(142, 68, 173, 0.1);
    border-bottom-color: rgba(142, 68, 173, 0.2);
}
.welcome-message.purple .ai-title,
.welcome-message.purple .message-content strong,
.welcome-message.purple .message-content h3 {
    color: #8e44ad;
}

.welcome-message.control {
    border-left-color: #0f57c1;
    background: linear-gradient(135deg, #f4f7fc 0%, #e6eef9 100%);
}
.welcome-message.control .message-header {
    background: rgba(15, 87, 193, 0.1);
    border-bottom-color: rgba(15, 87, 193, 0.2);
}
.welcome-message.control .ai-title,
.welcome-message.control .message-content strong,
.welcome-message.control .message-content h3 {
    color: #0f57c1;
}

.welcome-message.influence {
    border-left-color: #28a477;
    background: linear-gradient(135deg, #f4fbf8 0%, #e6f5ef 100%);
}
.welcome-message.influence .message-header {
    background: rgba(40, 164, 119, 0.1);
    border-bottom-color: rgba(40, 164, 119, 0.2);
}
.welcome-message.influence .ai-title,
.welcome-message.influence .message-content strong,
.welcome-message.influence .message-content h3 {
    color: #28a477;
}

.welcome-message.observe {
    border-left-color: #8c1f7e;
    background: linear-gradient(135deg, #faf5f9 0%, #f3e6f1 100%);
}
.welcome-message.observe .message-header {
    background: rgba(140, 31, 126, 0.1);
    border-bottom-color: rgba(140, 31, 126, 0.2);
}
.welcome-message.observe .ai-title,
.welcome-message.observe .message-content strong,
.welcome-message.observe .message-content h3 {
    color: #8c1f7e;
}

.welcome-message.clean {
    border-left: none;
    background: transparent;
}
.welcome-message.clean .message-header {
    background: transparent;
    border-bottom: none;
}
.welcome-message.clean .ai-title,
.welcome-message.clean .message-content strong,
.welcome-message.clean .message-content h3 {
    color: #6c757d;
}

.system-message {
    border-left: 4px solid #dc3545;
    background: #fff5f5;
    margin: 16px 0;
    border-radius: 8px;
    overflow: hidden;
}

.skill-description-message {
    background: #e7f5f7;
    margin: 0 0 24px 0;
    border-radius: 8px;
    overflow: hidden;
    border-left: none !important; /* Убираем границу от родительского класса */
}

.skill-description-message .message-content {
    padding: 16px;
}

.skill-description-message .message-content p {
    margin: 0;
    color: #0c5460;
    font-size: var(--it-fs-text, 18px);
    line-height: var(--it-lh-text, 1.6);
    letter-spacing: var(--it-tracking, 0.02em);
    font-style: italic;
}

.user-message {
    border-left: 4px solid #007bff;
    background: #f0f7ff;
    margin: 16px 0;
    border-radius: 8px;
    overflow: hidden;
}

.ai-loading-message {
    border-left: 4px solid #6c757d;
    background: #f8f9fa;
    margin: 16px 0;
    border-radius: 8px;
    overflow: hidden;
}

.completion-message {
    border-left: 4px solid #28a745;
    background: #f8fff9;
}

