/* ========================================
   KALRAV CHAT HISTORY VIEW STYLES
   ======================================== */

/* History Toggle Button in Header */
#history-toggle-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    transition: all 0.2s ease;
    display: none; /* Hidden by default, shown via JS when user is logged in */
}

/*#history-toggle-btn:hover {
    transform: scale(1.1);
    opacity: 0.8;
}*/

#history-toggle-btn.active svg {
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Chat header icon styles */
.chat-header-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #fff;
    font-size: 20px;
    transition: all 0.2s ease;
}

.chat-header-icon:hover {
    transform: scale(1.1);
    opacity: 0.8;
}

.chat-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}


/* ── History header ── */
.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    flex-shrink: 0;
    background: var(--primary-color);
    min-height: 52px;
    box-sizing: border-box;
}

.history-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #222;
}

.history-close-btn {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    line-height: 1;
    padding: 0 4px;
}

.history-close-btn:hover {
    color: #222;
}

#chat-history-container {
    width: 100%;
    min-height: 200px;
}

.history-list {
    width: 100%;
    padding: 0;
    margin: 0;
}
.history-item-avatar {
    width: 24px;
    height: 24px;
    display:none;
   /* background-color: var(--primary-color);*/
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid #ebebeb;
    position: relative;
}
/*.history-item {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 10px 16px;
    margin: 0;
    cursor: pointer;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    display: block;
    width: 100%;
    box-sizing: border-box;
    transition: background 0.15s ease;
}*/

.history-item:hover,
.history-item.active {
    background: rgba(103, 61, 230, 0.06);
}


.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.history-item-date {
    font-size: 12px;
    color: #666;
    font-weight: 500;
}

.history-item-count {
    font-size: 11px;
    background: var(--primary-color);
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
}



/* Empty State */
.history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
    padding: 40px 20px;
    text-align: center;
}

.history-empty svg {
    width: 64px;
    height: 64px;
    margin-bottom: 20px;
    opacity: 0.3;
}



/* Loading State */
.history-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
}

.history-loading svg {
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ========================================
   MESSAGE DISPLAY STYLES
   ======================================== */

.user-message, .bot-message {
   /* margin-bottom: 15px;*/
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-content {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.bot-avatar {
    flex-shrink: 0;
}

.message-text {
    flex: 1;
    line-height: 1.5;
}

.message-text a {
    color: var(--primary-color);
    text-decoration: underline;
}

.message-text strong {
    font-weight: 600;
}

.message-text em {
    font-style: italic;
}

/* Loading state for session messages */
.session-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #666;
}

.session-loading svg {
    animation: spin 1s linear infinite;
    margin-right: 10px;
}
   /* ── History container: full overlay inside chat-box ── */

            /* ── Scrollable list — fills remaining height after header ── */
            .history-list {
                flex: 1 1 auto !important;
                overflow-y: auto !important;
                overflow-x: hidden !important;
               /* padding: 24px !important;*/
                margin: 0 !important;
                min-height: 0 !important;
                display: flex;
                flex-direction: column;
                gap: 8px;
                box-sizing: border-box;
            }

            #chat-scroll-area::-webkit-scrollbar {
                width: 4px;
            }

            #chat-scroll-area::-webkit-scrollbar-track {
                background: transparent;
            }

            #chat-scroll-area::-webkit-scrollbar-thumb {
                background: #aaa;
                border-radius: 10px;
            }
            /* Thin custom scrollbar - Webkit */
            .history-list::-webkit-scrollbar {
                width: 4px;
            }
            .history-list::-webkit-scrollbar-track {
                background: transparent;
            }
            .history-list::-webkit-scrollbar-thumb {
                background: rgba(103, 61, 230, 0.3);
                border-radius: 4px;
            }
            .history-list::-webkit-scrollbar-thumb:hover {
                background: rgba(103, 61, 230, 0.6);
            }
            /* Firefox */
            .history-list {
                scrollbar-width: thin;
               /* scrollbar-color: rgba(103, 61, 230, 0.3) transparent;*/
            }
            .history-item-list:hover {
               
                border-color: var(--primary-color);
            }

            /* ── History items — card style ── */
        

           /* .history-item:hover,
            .history-item.active {
                background: #e8e4f8 !important;
                transform: translateY(-1px);
            }*/

            .history-item:active {
                transform: translateY(0px);
            }

            /* Left content: message + date stacked */
            .history-item-content {
                flex: 1;
                min-width: 0;
                display: flex;
                flex-direction: column;
                gap: 8px;
                color:#0000;
                font-family: Roboto;
                font-weight: 400;
                font-style: Regular;
                font-size: 14px;
                line-height: 100%;
                letter-spacing: 0%;

            }

            .history-item-message { 
                color: #000000 !important;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
                font-family: Roboto;
                font-weight: 400;
                font-style: Regular;
                font-size: 14px;
                line-height: 100%;
                letter-spacing: 0%;

            }

            .history-item-date {
                color: #A1A1A1 !important;
                font-family: Roboto;
                font-weight: 500;
                font-style: Medium;
                font-size: 11px;
                line-height: 100%;
                letter-spacing: 0%;

            }

            /* Right arrow icon */
            .history-item-arrow {
                flex-shrink: 0;
                width: 20px;
                height: 20px;
                color: #818181;
                display: flex;
                align-items: center;
                justify-content: center;
            }

            .history-item-arrow svg {
                width: 18px;
                height: 18px;
                stroke: #aaa;
                transition: stroke 0.15s ease;
            }

           /* .history-item:hover .history-item-arrow svg,
            .history-item.active .history-item-arrow svg {
                stroke: var(--primary-color, #673de6);
            }*/

            /* ── Empty / loading states ── */
            .history-loading,
            .history-empty {
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: center;
                padding: 40px 20px;
                color: #999;
                font-size: 14px;
                gap: 10px;
                text-align: center;
            }

            .history-loading svg {
                animation: kalrav-spin 1s linear infinite;
            }

            .history-empty svg {
                width: 40px;
                height: 40px;
                color: #ccc;
            }

            @keyframes kalrav-spin {
                from { transform: rotate(0deg); }
                to   { transform: rotate(360deg); }
            }

            /* ── Start New Chat button pop animation ── */
            @keyframes kalrav-btn-pop {
                0%   { transform: scale(0.6); opacity: 0; }
                70%  { transform: scale(1.15); opacity: 1; }
                100% { transform: scale(1); opacity: 1; }
            }
            #start-new-chat-btn.kalrav-pop {
                animation: kalrav-btn-pop 0.3s ease forwards;
            }



.history-item {
   
                border-radius: 10px;
                /*border: 0.5px solid #A1A1A1;*/
                padding-top: 4px;
                padding-right: 8px;
                padding-bottom: 4px;
                padding-left: 8px;
                margin: 0 !important;
                cursor: pointer;
                border: 1px solid #CBCBCB;
                /*transition: background 0.15s ease, transform 0.1s ease;*/
                display: flex !important;
                align-items: center !important;
                justify-content: space-between !important;
                width: 100%;
                height: 40px;;
                box-sizing: border-box;
                opacity: 1;
                gap: 16px;
}

.history-item:hover {
    background: #f3f4f6;
    border-color: var(--primary-color);
}

.history-item-content {
    flex: 1;
    min-width: 0;
}

.history-item-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

.history-item-date {
    font-size: 12px;
    color: #999;
    white-space: nowrap;
    flex-shrink: 0;
}

.history-item-arrow {
    display: none; /* arrow removed */
}

.history-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px 20px;
    color: #666;
    font-size: 14px;
}

.history-loading svg {
    animation: kalrav-spin 1s linear infinite;
    flex-shrink: 0;
}

.history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: #999;
}

.history-empty-icon {
    width: 40px;
    height: 40px;
    margin-bottom: 12px;
    opacity: 0.4;
}

.history-empty-title {
font-family: Roboto;
font-weight: 500;
font-style: Medium;
margin:0;
height: 29px;
font-size: 25px;
line-height: 100%;
letter-spacing: 0%;
text-align: center;
color:#000000;

}

.history-empty-subtitle {
    font-size: 13px;
   font-family: Roboto;
font-weight: 400;
font-style: Regular;
font-size: 14px;
line-height: 100%;
color:#818181;
letter-spacing: 0%;
 margin: 0;
}

.history-new-chat-footer {
width: 174px;
height: 40px;
align-self: center;
opacity: 1;
border-radius: 10px;
padding-top: 12px;
padding-right: 24px;
padding-bottom: 12px;
padding-left: 24px;
gap: 8px;

}

.history-new-chat-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width:auto;
    padding: 12px 24px;
    background: var(--primary-color);
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px !important;
    color: #fff;
    cursor: pointer;
    transition: background 0.15s;
    font-family: Roboto;
    font-weight: 500;
    font-style: Medium;
    line-height: 16px;
    letter-spacing: 0%;

}



.history-new-chat-btn svg {
    width: 8px;
    height: 8px;
    stroke: #666;
}
            