﻿html,
body {
    height: 100%;
    overflow: hidden;
}

/* ----- shell layout ----- */
.chat-shell {
    height: 85vh;
    display: flex;
    gap: 12px;
    padding: 12px;
    box-sizing: border-box;
}

/* left pane */
.history-pane {
    width: 320px;
    max-width: 40vw;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, .75);
    border: 1px solid rgba(0, 0, 0, .06);
    border-radius: 16px;
    padding: 12px;
    box-shadow: 0 8px 28px rgba(31, 38, 135, .08);
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.history-header .title {
    font-weight: 700;
    color: #2f2a3b;
}

.icon-btn i {
    pointer-events: none;
}

.history-search {
    padding: .5rem 0 .25rem;
}

.history-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.thread-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    border-radius: 8px;
}

.thread-item:hover {
    background: #f7f5ff;
    border-radius: 8px;
}

.ti-line1 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.ti-title {
    font-weight: 600;
    color: #3b3550;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.ti-chip {
    font-size: .7rem;
    background: #efe8fb;
    color: #5c2fb1;
    border: 1px solid #e7dbff;
    border-radius: 999px;
    padding: .1rem .45rem;
    white-space: nowrap;
}

.ti-line2 {
    font-size: .8rem;
    color: #6b7280;
}

.ti-actions,
.ti-edit-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.ti-edit-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.ti-edit-input {
    min-width: 0;
    flex: 1;
}

.thread-item.is-selected {
    color: #fff;
}

.thread-item.is-selected .ti-line2 {
    color: #e0e0e0;
}

.ti-edit-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}

/* right pane */
.chat-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* toolbar */
.chat-toolbar {
    flex: 0 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: .75rem 1rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, .7);
    border: 1px solid rgba(0, 0, 0, .06);
    box-shadow: 0 8px 28px rgba(31, 38, 135, .08);
    margin-bottom: 8px;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.selector-combo {
    min-width: 280px;
    max-width: 380px;
}

/* chat card fills remaining height */
.chat-card {
    flex: 1 1 auto;
    min-height: 0;
    border-radius: 18px;
    border: 1px solid #eae6f7;
}

.chat-card .card-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    padding: 0;
}

/* DxAIChat sizing */
.my-chat,
.dxbl-chatui-root,
.dxbl-chatui {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.dxbl-chatui-root .dxbl-chatui .dxbl-chatui-scrollviewer {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    overflow: auto;
}

.dxbl-chatui-submitarea-container {
    flex: 0 0 auto;
    width: 100%;
    border-top: 1px solid #ede9fe;
    background: #faf8ff;
}

/* bubbles: alignment & responsive width */
.dxbl-chatui-message {
    display: flex !important;
    gap: .5rem;
}

.dxbl-chatui-message-assistant {
    justify-content: flex-start !important;
    text-align: left !important;
}

.dxbl-chatui-message-user {
    justify-content: flex-end !important;
    text-align: right !important;
}

.dxbl-chatui-message .dxbl-chatui-message-content {
    display: inline-block !important;
    width: auto !important;
    max-width: min(76ch, 70%) !important;
    box-sizing: border-box;
    border-radius: 14px !important;
    padding: 12px 14px !important;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.dxbl-chatui-message-user .dxbl-chatui-message-content {
    background: #6f42c1 !important;
    color: #fff !important;
}

.dxbl-chatui-message-assistant .dxbl-chatui-message-content {
    background: #f5f3ff !important;
    border: 1px solid #ebe6ff !important;
}

.icon-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

/* ===== RESPONSIVE STYLES ===== */

/* Mobile styles */
@media (max-width: 767.98px) {
    .chat-shell {
        padding: 8px;
        gap: 8px;
        height: 90vh;
    }

    .history-pane {
        position: absolute;
        z-index: 30;
        height: calc(100dvh - 16px);
        width: 280px;
        max-width: 85vw;
    }

    .history-pane[hidden] {
        display: none;
    }

    /* Toolbar responsive */
    .chat-toolbar {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.5rem;
    }

    .toolbar-left,
    .toolbar-right {
        width: 100%;
        flex-wrap: wrap;
    }

    .toolbar-label {
        display: none;
        /* Hide label on mobile to save space */
    }

    .selector-combo {
        min-width: 0;
        max-width: 100%;
        flex: 1;
    }

    .toolbar-btn {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }

    /* Make buttons touch-friendly */
    .icon-btn {
        min-width: 44px;
        min-height: 44px;
    }

    /* Adjust chat bubbles for mobile */
    .dxbl-chatui-message .dxbl-chatui-message-content {
        max-width: min(76ch, 85%) !important;
        font-size: 0.9rem;
    }
}

/* Tablet styles */
@media (min-width: 768px) and (max-width: 991.98px) {
    .chat-shell {
        padding: 10px;
        gap: 10px;
    }

    .history-pane {
        width: 280px;
        max-width: 35vw;
    }

    .selector-combo {
        min-width: 220px;
        max-width: 300px;
    }

    .toolbar-btn {
        font-size: 0.9rem;
    }
}

/* Desktop styles */
@media (min-width: 992px) {
    .history-pane {
        width: 320px;
        max-width: 40vw;
    }

    .selector-combo {
        min-width: 280px;
        max-width: 380px;
    }
}