/* /assets/css/ai.css */

:root {
--color-brand: #f8604a;
--color-brand-hover: #e05643;
--color-text-primary: #000;
--color-text-secondary: #333;
--color-text-tertiary: rgba(0,0,0,0.6);
--color-border: rgba(0,0,0,0.1);
--color-bg-primary: #fff;
--color-bg-secondary: #f5f5f5;
--color-bg-overflow: #fbfbfb;
--font-family: 'YS Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
:root {
    --color-text-primary: #fff;
    --color-text-secondary: rgba(255,255,255,0.75);
    --color-text-tertiary: rgba(255,255,255,0.6);
    --color-border: rgba(255,255,255,0.1);
    --color-bg-primary: #18181a;
    --color-bg-secondary: #222224;
    --color-bg-overflow: #111112;
}
}

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

body {
font-family: var(--font-family);
background: var(--color-bg-overflow);
color: var(--color-text-primary);
height: 100vh;
display: flex;
flex-direction: column;
overflow: hidden;
}

/* ========== ШАПКА ========== */
.ai-topbar {
background: var(--color-bg-primary);
border-bottom: 1px solid var(--color-border);
padding: 12px 20px;
display: flex;
justify-content: space-between;
align-items: center;
flex-shrink: 0;
gap: 12px;
}

.ai-topbar-left {
display: flex;
align-items: center;
gap: 10px;
min-width: 0;
}

.ai-topbar-logo {
width: 32px;
height: 32px;
object-fit: contain;
flex-shrink: 0;
}

.ai-topbar-title {
font-size: 16px;
font-weight: 600;
color: var(--color-text-primary);
}

.ai-topbar-subtitle {
font-size: 12px;
color: var(--color-text-tertiary);
margin-top: 2px;
}

.ai-topbar-right {
display: flex;
gap: 8px;
flex-shrink: 0;
}

/* ========== ЧАТ ========== */
.ai-chat {
flex: 1;
overflow-y: auto;
padding: 20px;
display: flex;
flex-direction: column;
gap: 12px;
max-width: 900px;
width: 100%;
margin: 0 auto;
}

.ai-message {
max-width: 75%;
padding: 10px 14px;
border-radius: 14px;
line-height: 1.5;
white-space: pre-wrap;
font-size: 15px;
word-wrap: break-word;
}

.ai-message-user {
align-self: flex-end;
background: var(--color-brand);
color: #fff;
border-bottom-right-radius: 4px;
}

.ai-message-bot {
align-self: flex-start;
background: var(--color-bg-secondary);
border: 1px solid var(--color-border);
color: var(--color-text-primary);
border-bottom-left-radius: 4px;
}

/* ========== ЗАСТАВКА ========== */
.ai-welcome {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-tertiary);
    margin: auto 0;
}

.ai-welcome img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 20px;
}

.ai-welcome h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 8px;
    line-height: 1.4;
}

.ai-welcome p {
    font-size: 14px;
    color: var(--color-text-tertiary);
}

/* ========== ФОРМА ========== */
.ai-form-wrapper {
    background: var(--color-bg-primary);
    border-top: 1px solid var(--color-border);
    padding: 12px 20px 20px;
    flex-shrink: 0;
}

.ai-form {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.ai-form textarea {
    flex: 1;
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px solid var(--color-border);
    background: var(--color-bg-secondary);
    font-size: 15px;
    font-family: inherit;
    color: var(--color-text-primary);
    resize: none;
    min-height: 48px;
    max-height: 140px;
    outline: none;
    transition: border 0.2s;
}

.ai-form textarea:focus {
    border-color: var(--color-brand);
}

.ai-form button {
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
    border-radius: 50%;
    background: var(--color-brand);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
    font-family: inherit;
    flex-shrink: 0;
}

.ai-form button:hover {
    background: var(--color-brand-hover);
}

.ai-form button:active {
    transform: scale(0.95);
}

.ai-form button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.ai-form button svg {
    display: block;
}

/* Иконки в шапке — как на сайте */
.ai-topbar-right .header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-topbar-right .action-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--color-text-tertiary);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
}

.ai-topbar-right .action-icon:hover {
    color: var(--color-text-primary);
    background: var(--color-bg-secondary);
}

.ai-topbar-right .user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    object-fit: cover;
}

/* ========== ВРЕМЯ ПОД СООБЩЕНИЯМИ ========== */
.ai-time {
    font-size: 11px;
    color: var(--color-text-tertiary);
    margin-top: -6px;
    padding: 0 8px;
    line-height: 1;
}

.ai-time-user {
    align-self: flex-end;
    text-align: right;
}

.ai-time-bot {
    align-self: flex-start;
    text-align: left;
}

/* ========== АДАПТИВ ========== */
@media (max-width: 480px) {
    .ai-topbar {
        padding: 10px 12px;
    }
    
    .ai-topbar-title {
        font-size: 14px;
    }
    
    .ai-topbar-subtitle {
        display: none;
    }
    
    .ai-topbar-logo {
        width: 28px;
        height: 28px;
    }
    
    .ai-topbar-right .header-actions { gap: 2px; }
    .ai-topbar-right .action-icon { width: 36px; height: 36px; }
    .ai-topbar-right .user-avatar { width: 36px; height: 36px; }
    
    .ai-chat {
        padding: 12px;
    }
    
    .ai-message {
        max-width: 88%;
        font-size: 14px;
    }
    
    .ai-form-wrapper {
        padding: 10px 12px 16px;
    }
    
    .ai-form textarea {
        font-size: 16px; /* iOS не увеличивает */
    }
    
    .ai-form button {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }
}

/* ====== LAYOUT с сайдбаром ====== */
.ai-layout {
    display: flex;
    height: calc(100vh - 60px);
    overflow: hidden;
}

.ai-sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--color-bg-primary);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    transition: width 0.3s, min-width 0.3s, transform 0.3s;
    flex-shrink: 0;
    overflow: hidden;
}

.ai-sidebar.hidden {
    width: 0 !important;
    min-width: 0 !important;
    border-right: 0 !important;
    overflow: hidden !important;
}

.ai-sidebar-header,
.ai-sessions-list {
    min-width: 280px;
}

.ai-sidebar-header {
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--color-border);
    gap: 8px;
    flex-wrap: nowrap;
}

.ai-sidebar .ai-new-chat-btn {
    flex: 1;
    padding: 8px 16px;
    background: var(--color-brand) !important;
    color: #fff !important;
    border: 0 !important;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.ai-new-chat-btn:hover {
    background: #e04e3a;
}

.ai-sidebar .ai-sidebar-toggle {
    width: 28px;
    height: 28px;
    background: transparent !important;
    color: var(--color-text-tertiary) !important;
    border: 1px solid var(--color-border) !important;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-sidebar .ai-sidebar-toggle:hover {
    background: var(--color-bg-secondary) !important;
    color: var(--color-text-primary) !important;
}

.ai-sessions-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.ai-sidebar .ai-session-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 4px;
    background: var(--color-bg-secondary) !important;
    position: relative;
    transition: background 0.2s;
}

.ai-sidebar .ai-session-item:hover {
    background: var(--color-bg-overflow) !important;
}

.ai-sidebar .ai-session-item.active {
    background: var(--color-brand) !important;
    color: #fff !important;
}

.ai-session-title {
    flex: 1;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-sidebar .ai-session-delete {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-bg-secondary) !important;
    border: 0 !important;
    color: var(--color-text-secondary) !important;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: none;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    flex-shrink: 0;
}

.ai-sidebar .ai-session-item:hover .ai-session-delete,
.ai-sidebar .ai-session-item.active .ai-session-delete {
    display: flex;
}

.ai-sidebar .ai-session-delete:hover {
    background: #ff4444 !important;
    color: #fff !important;
}

.ai-sidebar-open {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 100;
    padding: 8px 14px;
    background: var(--color-bg-primary) !important;
    color: var(--color-text-primary) !important;
    border: 1px solid var(--color-border) !important;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}

.ai-sidebar-open:hover {
    background: var(--color-bg-secondary) !important;
}

.ai-chat-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Мобильная версия */
@media (max-width: 768px) {
    .ai-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 1000;
        transform: translateX(-100%);
        width: 280px;
    }
    
    .ai-sidebar.open {
        transform: translateX(0);
    }
    
    .ai-sidebar.hidden {
        transform: translateX(-100%);
        width: 280px;
    }
    
    .ai-sidebar-open {
        display: flex !important;
    }
}