/* ==========================================================================
   HIA (HubBroker Intelligent Assistant) Chatbot Styles
   Matching HubBroker platform theme system (var(--hb-primary))
   ========================================================================== */

/* --- Floating Action Button (FAB) --- */
.hia-fab-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 25000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
}

.hia-fab-wrapper:hover {
    transform: translateY(-4px) scale(1.05);
}

.hia-fab-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--hb-primary, #6E7740) 0%, var(--hb-primary-dark, #4A5228) 100%);
    box-shadow: 0 8px 24px rgba(110, 119, 64, 0.35), 0 2px 6px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.3);
    position: relative;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.hia-fab-wrapper:hover .hia-fab-button {
    background: linear-gradient(135deg, var(--hb-primary-dark, #4A5228) 0%, var(--hb-primary, #6E7740) 100%);
    box-shadow: 0 12px 28px rgba(110, 119, 64, 0.5), 0 4px 10px rgba(0, 0, 0, 0.15);
}

.hia-fab-icon {
    font-size: 22px;
    line-height: 1;
    margin-bottom: 2px;
}

.hia-fab-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    line-height: 1;
    color: #ffffff;
}

.hia-fab-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background-color: #22c55e;
    border: 2.5px solid #ffffff;
    border-radius: 50%;
}

/* --- Chatbot Window Container --- */
.hia-chat-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 410px;
    max-width: calc(100vw - 32px);
    height: 620px;
    max-height: calc(100vh - 120px);
    background-color: #ffffff;
    border-radius: 20px;
    /* Theme color border and glowing outline */
    border: 2.5px solid var(--hb-primary, #6E7740);
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.16), 0 0 0 2px var(--hb-primary-light, #F0F2E8);
    display: flex;
    flex-direction: column;
    z-index: 25000;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), 
                transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), 
                visibility 0.3s ease,
                border-color 0.3s ease;
}

.hia-chat-window.hia-active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.hia-chat-window.hia-minimized {
    height: 60px !important;
    max-height: 60px !important;
    overflow: hidden;
}

.hia-chat-window.hia-expanded {
    width: 900px !important;
    max-width: calc(100vw - 48px) !important;
    height: 820px !important;
    max-height: calc(100vh - 120px) !important;
}

/* --- Header Section --- */
.hia-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background-color: #ffffff;
    border-bottom: 1px solid var(--hb-primary-light, #F0F2E8);
    flex-shrink: 0;
    height: 60px;
}

.hia-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.hia-avatar-circle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: var(--hb-primary-light, #F0F2E8);
    border: 1px solid var(--hb-accent, #C8D89A);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--hb-primary, #6E7740);
    font-size: 18px;
    flex-shrink: 0;
}

/* --- Custom AI Sparkles Icon --- */
.fa-sparkles {
    display: inline-block;
    width: 1em;
    height: 1em;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M12 2L14.5 9.5L22 12L14.5 14.5L12 22L9.5 14.5L2 12L9.5 9.5L12 2zm6 15l1.25 3.75L23 22l-3.75 1.25L18 27l-1.25-3.75L13 22l3.75-1.25L18 17z'/%3E%3C/svg%3E") no-repeat center / contain;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M12 2L14.5 9.5L22 12L14.5 14.5L12 22L9.5 14.5L2 12L9.5 9.5L12 2zm6 15l1.25 3.75L23 22l-3.75 1.25L18 27l-1.25-3.75L13 22l3.75-1.25L18 17z'/%3E%3C/svg%3E") no-repeat center / contain;
}

/* --- Modern Trending AI Send Arrow Icon --- */
.fa-send-icon {
    display: inline-block;
    width: 1.1em;
    height: 1.1em;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='12' y1='19' x2='12' y2='5'%3E%3C/line%3E%3Cpolyline points='5 12 12 5 19 12'%3E%3C/polyline%3E%3C/svg%3E") no-repeat center / contain;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='12' y1='19' x2='12' y2='5'%3E%3C/line%3E%3Cpolyline points='5 12 12 5 19 12'%3E%3C/polyline%3E%3C/svg%3E") no-repeat center / contain;
    transform: translateY(-1px);
}

.hia-header-title-box {
    display: flex;
    flex-direction: column;
}

.hia-header-title {
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
    margin: 0;
}

.hia-header-subtitle {
    font-size: 11.5px;
    color: #64748b;
    margin: 1px 0 0 0;
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.hia-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.hia-header-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hia-header-btn:hover {
    background-color: var(--hb-primary-light, #F0F2E8);
    color: var(--hb-primary-dark, #4A5228);
}

/* --- Body / Messages Stream --- */
.hia-chat-body {
    flex: 1;
    padding: 18px;
    overflow-y: auto;
    background-color: #fcfdfd;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.hia-chat-body::-webkit-scrollbar {
    width: 6px;
}

.hia-chat-body::-webkit-scrollbar-track {
    background: transparent;
}

.hia-chat-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* --- Message Rows --- */
.hia-msg-row {
    display: flex;
    gap: 10px;
    max-width: 90%;
    text-align: left;
    animation: hiaFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes hiaFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hia-msg-bot {
    align-self: flex-start;
}

.hia-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.hia-msg-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background-color: var(--hb-primary-light, #F0F2E8);
    border: 1px solid var(--hb-accent, #C8D89A);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--hb-primary, #6E7740);
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 2px;
}

.hia-msg-content-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: left;
    width: 100%;
}

.hia-msg-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.5;
    word-break: break-word;
    text-align: left !important;
}

.hia-msg-bot .hia-msg-bubble {
    background-color: #e2e8f0;
    color: #0f172a;
    border-top-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    font-weight: 500;
    white-space: normal;
}

.hia-msg-user .hia-msg-bubble {
    background-color: var(--hb-primary-light, #F0F2E8);
    color: #0f172a;
    border-top-right-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    font-weight: 500;
}

.hia-msg-meta {
    font-size: 11px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 4px;
}

.hia-msg-bot .hia-msg-meta {
    padding-left: 4px;
}

.hia-msg-user .hia-msg-meta {
    justify-content: flex-end;
    padding-right: 4px;
}

.hia-meta-check {
    color: var(--hb-primary, #6E7740);
    font-size: 12px;
    font-weight: bold;
}

/* --- Quick Suggestions Pills --- */
.hia-suggestions-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
    margin-bottom: 6px;
}

.hia-suggestion-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 13px;
    color: #334155;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    width: fit-content;
}

.hia-suggestion-pill:hover {
    background-color: var(--hb-primary-light, #F0F2E8);
    border-color: var(--hb-primary, #6E7740);
    color: var(--hb-primary-dark, #4A5228);
    transform: translateX(4px);
    box-shadow: 0 2px 6px rgba(110, 119, 64, 0.15);
}

.hia-suggestion-pill i {
    color: var(--hb-primary, #6E7740);
    font-size: 13px;
}

/* --- Response Action Buttons --- */
.hia-action-btns-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.hia-btn-action-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background-color: var(--hb-primary, #6E7740);
    color: #ffffff !important;
    border: 1px solid var(--hb-primary, #6E7740);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none !important;
    box-shadow: 0 2px 5px rgba(110, 119, 64, 0.25);
}

.hia-btn-action-primary:hover {
    background-color: var(--hb-primary-dark, #4A5228);
    border-color: var(--hb-primary-dark, #4A5228);
    color: #ffffff !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(110, 119, 64, 0.35);
}

.hia-btn-action-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background-color: #ffffff;
    color: #334155 !important;
    border: 1px solid var(--hb-primary, #6E7740);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none !important;
}

.hia-btn-action-secondary:hover {
    background-color: var(--hb-primary-light, #F0F2E8);
    border-color: var(--hb-primary-dark, #4A5228);
    color: var(--hb-primary-dark, #4A5228) !important;
    transform: translateY(-1px);
}

/* --- "You can also try:" Section & Feature Cards --- */
.hia-try-section {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hia-try-header {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 2px;
}

.hia-try-cards-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hia-try-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.hia-try-card:hover {
    border-color: var(--hb-primary, #6E7740);
    background-color: var(--hb-primary-light, #F0F2E8);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(110, 119, 64, 0.15);
}

.hia-try-card-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background-color: #f1f5f9;
    color: var(--hb-primary, #6E7740);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.hia-try-card:hover .hia-try-card-icon {
    background-color: var(--hb-primary-light, #F0F2E8);
    color: var(--hb-primary-dark, #4A5228);
}

.hia-try-card-info {
    display: flex;
    flex-direction: column;
}

.hia-try-card-title {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.3;
}

.hia-try-card-desc {
    font-size: 11.5px;
    color: #64748b;
    margin-top: 1px;
}

/* --- Typing Indicator --- */
.hia-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background-color: #f1f5f9;
    border-radius: 16px;
    border-top-left-radius: 4px;
    width: fit-content;
}

.hia-typing-dot {
    width: 6px;
    height: 6px;
    background-color: #94a3b8;
    border-radius: 50%;
    animation: hiaTyping 1.4s infinite ease-in-out;
}

.hia-typing-dot:nth-child(1) { animation-delay: 0s; }
.hia-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.hia-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes hiaTyping {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.4); opacity: 1; }
}

/* --- Footer / Input Section --- */
.hia-chat-footer {
    padding: 12px 16px;
    background-color: #ffffff;
    border-top: 1px solid #f1f3f5;
    flex-shrink: 0;
}

.hia-input-form {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 4px 6px 4px 12px;
    transition: all 0.2s ease;
}

.hia-input-form:focus-within {
    border-color: var(--hb-primary, #6E7740);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(110, 119, 64, 0.15);
}

.hia-attach-btn {
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 17px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 50%;
    transition: color 0.2s ease;
}

.hia-attach-btn:hover {
    color: var(--hb-primary, #6E7740);
}

.hia-input-field {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 13.5px;
    color: #1e293b;
    outline: none;
    padding: 6px 4px;
}

.hia-input-field::placeholder {
    color: #94a3b8;
}

.hia-send-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background-color: var(--hb-primary, #6E7740);
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.hia-send-btn:hover {
    background-color: var(--hb-primary-dark, #4A5228);
    transform: scale(1.05);
}

.hia-send-btn:disabled {
    background-color: #cbd5e1;
    cursor: not-allowed;
    transform: none;
}

/* --- Attachment Preview --- */
.hia-attachment-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background-color: #f1f5f9;
    border-radius: 8px;
    font-size: 12px;
    color: #334155;
    margin-bottom: 6px;
}

.hia-attachment-preview-remove {
    cursor: pointer;
    color: #ef4444;
    font-weight: bold;
    margin-left: 8px;
}

/* --- Context Pill & Badges --- */
.hia-context-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
    padding: 2px 8px;
    background-color: var(--hb-primary-light, #F0F2E8);
    color: var(--hb-primary-dark, #4A5228);
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.hia-progress-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: #f1f5f9;
    border-left: 3px solid var(--hb-primary, #6E7740);
    border-radius: 6px;
    font-size: 12px;
    color: #475569;
    margin-bottom: 8px;
    animation: hiaPulse 1.5s infinite ease-in-out;
}

@keyframes hiaPulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* --- Data Table Rendering --- */
.hia-table-wrapper {
    margin-top: 10px;
    margin-bottom: 10px;
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.hia-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    background-color: #ffffff;
}

.hia-data-table th {
    background-color: #f8fafc;
    color: #334155;
    font-weight: 600;
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid #e2e8f0;
}

.hia-data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
}

.hia-data-table tr:last-child td {
    border-bottom: none;
}

/* --- Stop Button --- */
.hia-send-btn.hia-stop-btn {
    background-color: #ef4444 !important;
}

.hia-send-btn.hia-stop-btn:hover {
    background-color: #dc2626 !important;
}

/* --- Image & File Event Cards --- */
.hia-image-card {
    margin-top: 8px;
    margin-bottom: 8px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background-color: #ffffff;
    max-width: 100%;
}

.hia-image-card img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 380px;
    object-fit: contain;
    background-color: #f8fafc;
    cursor: pointer;
}

.hia-image-caption {
    padding: 6px 12px;
    font-size: 11.5px;
    color: #64748b;
    background-color: #f8fafc;
    border-top: 1px solid #f1f5f9;
}

.hia-file-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    margin-top: 8px;
    margin-bottom: 8px;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.hia-file-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hia-file-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background-color: var(--hb-primary-light, #F0F2E8);
    color: var(--hb-primary, #6E7740);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.hia-file-meta {
    display: flex;
    flex-direction: column;
}

.hia-file-name {
    font-size: 12.5px;
    font-weight: 600;
    color: #1e293b;
    word-break: break-all;
}

.hia-file-size {
    font-size: 11px;
    color: #64748b;
}

.hia-file-dl-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background-color: var(--hb-primary, #6E7740);
    color: #ffffff !important;
    border-radius: 8px;
    font-size: 11.5px;
    font-weight: 600;
    text-decoration: none !important;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

.hia-file-dl-btn:hover {
    background-color: var(--hb-primary-dark, #4A5228);
}

/* --- Markdown & Text Formatting Styles --- */
.hia-md-h1, .hia-md-h2, .hia-md-h3 {
    margin-top: 12px;
    margin-bottom: 6px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
}

.hia-md-h3 {
    font-size: 14px;
    border-bottom: 1px dashed #cbd5e1;
    padding-bottom: 3px;
}

.hia-bullet-main {
    margin-top: 4px;
    margin-bottom: 4px;
    padding-left: 4px;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    line-height: 1.45;
}

.hia-bullet-sub {
    margin-top: 2px;
    margin-bottom: 2px;
    padding-left: 20px;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 12.5px;
    color: #334155;
    line-height: 1.4;
}

.hia-bullet-icon {
    color: var(--hb-primary, #6E7740);
    font-size: 14px;
    font-weight: bold;
    line-height: 1.2;
    flex-shrink: 0;
}

.hia-md-code {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background-color: #e2e8f0;
    color: #0f172a;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid #cbd5e1;
}

.hia-md-code i {
    color: var(--hb-primary, #6E7740);
}

.hia-md-link {
    color: var(--hb-primary, #6E7740) !important;
    font-weight: 600;
    text-decoration: underline !important;
}

.hia-md-link:hover {
    color: var(--hb-primary-dark, #4A5228) !important;
}


