/* ===== Page-level: lock body scroll ===== */
body.page-assistant {
    height: 100vh;
    overflow: hidden;
}

/* ===== AlfaHRAssistent Layout ===== */
.assistant-main {
    display: flex;
    flex: 1;
    min-height: 0;
    max-width: none;
    padding: 0;
    overflow: hidden;
}

/* ===== Sidebar ===== */
.chat-sidebar {
    width: 280px;
    min-width: 280px;
    background: #fff;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1rem 0.75rem;
    border-bottom: 1px solid var(--gray-100);
}

.sidebar-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
}

.btn-new-chat {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1.5px solid var(--blue-300);
    border-radius: 8px;
    background: var(--blue-50);
    color: var(--blue-600);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.btn-new-chat:hover {
    background: var(--blue-100);
    border-color: var(--blue-400);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.chat-list-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--gray-700);
    transition: background 0.15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.chat-list-item:hover {
    background: var(--blue-50);
}

.chat-list-item.active {
    background: var(--blue-100);
    color: var(--blue-700);
    font-weight: 500;
}

.chat-list-item-icon {
    flex-shrink: 0;
    color: var(--gray-400);
}

.chat-list-item.active .chat-list-item-icon {
    color: var(--blue-500);
}

.chat-list-item-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-list-item-date {
    font-size: 0.72rem;
    color: var(--gray-400);
    flex-shrink: 0;
}

.chat-list-item-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--gray-400);
    cursor: pointer;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
}

.chat-list-item:hover .chat-list-item-delete {
    opacity: 1;
}

.chat-list-item-delete:hover {
    color: #b91c1c;
    background: #fef2f2;
}

.chat-list-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--gray-400);
    font-size: 0.85rem;
}

/* ===== Chat Area ===== */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: var(--gray-50);
    overflow: hidden;
}

/* Welcome screen */
.chat-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    text-align: center;
    padding: 2rem;
}

.chat-welcome-icon {
    color: var(--blue-400);
    opacity: 0.7;
}

.chat-welcome h2 {
    font-size: 1.5rem;
    color: var(--gray-800);
    margin: 0;
}

.chat-welcome p {
    color: var(--gray-500);
    font-size: 0.95rem;
    max-width: 380px;
    line-height: 1.5;
}

/* Conversation */
.chat-conversation {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    min-height: 52px;
    flex-shrink: 0;
}

.chat-title {
    flex: 1;
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--gray-500);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 6px;
}

.btn-sidebar-toggle:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}

.btn-icon:hover {
    color: #b91c1c;
    background: #fef2f2;
}

/* Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.msg {
    display: flex;
    gap: 0.75rem;
    max-width: 85%;
    animation: msgFadeIn 0.25s ease;
}

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

.msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.msg-assistant {
    align-self: flex-start;
}

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.85rem;
    font-weight: 600;
}

.msg-user .msg-avatar {
    background: var(--blue-100);
    color: var(--blue-600);
}

.msg-assistant .msg-avatar {
    background: linear-gradient(135deg, var(--blue-500), var(--blue-600));
    color: #fff;
}

.msg-bubble {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.92rem;
    line-height: 1.6;
    word-break: break-word;
}

.msg-user .msg-bubble {
    background: var(--blue-600);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.msg-assistant .msg-bubble {
    background: #fff;
    color: var(--gray-800);
    border: 1px solid var(--gray-200);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.msg-bubble p { margin: 0 0 0.5rem; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { margin: 0.25rem 0 0.5rem 1.25rem; }
.msg-bubble li { margin-bottom: 0.2rem; }
.msg-bubble strong { font-weight: 600; }
.msg-bubble code {
    background: var(--gray-100);
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    font-size: 0.85em;
    font-family: "Consolas", "Monaco", monospace;
}
.msg-bubble pre {
    background: var(--gray-800);
    color: #e2e8f0;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.85em;
    margin: 0.5rem 0;
}
.msg-bubble pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3, .msg-bubble h4 {
    margin: 0.75rem 0 0.35rem;
    font-weight: 600;
    color: var(--gray-800);
}
.msg-bubble h1 { font-size: 1.1em; }
.msg-bubble h2 { font-size: 1.05em; }
.msg-bubble h3 { font-size: 1em; }

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

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--blue-400);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Input area */
.chat-input-area {
    padding: 0.75rem 1.25rem 1rem;
    background: #fff;
    border-top: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    background: var(--gray-50);
    border: 1.5px solid var(--gray-200);
    border-radius: 12px;
    padding: 0.5rem 0.75rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input-row:focus-within {
    border-color: var(--blue-400);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, .15);
}

#chatInput {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--gray-800);
    resize: none;
    outline: none;
    max-height: 150px;
    line-height: 1.5;
    padding: 0.25rem 0;
}

#chatInput::placeholder {
    color: var(--gray-400);
}

.btn-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: var(--blue-600);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.15s;
}

.btn-send:hover:not(:disabled) {
    background: var(--blue-700);
    transform: scale(1.05);
}

.btn-send:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .chat-sidebar {
        position: fixed;
        top: 56px;
        left: 0;
        bottom: 0;
        z-index: 90;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 4px 0 20px rgba(0, 0, 0, .1);
    }

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

    .btn-sidebar-toggle {
        display: flex;
    }

    .msg {
        max-width: 95%;
    }
}
