/* =========================================================================
   KORDAGRAPH AI CHATBOT — PREMIUM THEMING (NAVY #1E2245 & GOLD #AA8147)
   ========================================================================= */

/* --- Custom Avatar Support --- */
.custom-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* --- Dynamic Upload Button inside Bot Bubble --- */
.dynamic-chat-upload-btn {
    display: inline-block;
    margin-top: 12px;
    background: #AA8147;
    color: #ffffff;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(170, 129, 71, 0.4);
    transition: all 0.25s ease;
}

.dynamic-chat-upload-btn:hover {
    background: #FFE29A;
    color: #1E2245;
    transform: translateY(-2px);
}

/* --- Floating Trigger Button --- */
.kordagraph-chat-trigger {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 999990;
    background: linear-gradient(135deg, #1E2245 0%, #0F1229 100%);
    border: 2px solid #AA8147;
    border-radius: 50px;
    padding: 10px 22px 10px 14px;
    display: flex !important;
    align-items: center;
    gap: 12px;
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(30, 34, 69, 0.4), 0 0 20px rgba(170, 129, 71, 0.3);
    transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.kordagraph-chat-trigger:hover {
    transform: translateY(-4px) scale(1.04);
    box-shadow: 0 15px 35px rgba(30, 34, 69, 0.5), 0 0 30px rgba(170, 129, 71, 0.6);
    border-color: #FFE29A;
}

.chat-trigger-icon {
    width: 44px;
    height: 44px;
    background: #AA8147;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(170, 129, 71, 0.4);
}

.chat-trigger-badge {
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #ffffff;
    text-transform: uppercase;
}

/* --- Floating Chat Modal Window --- */
.kordagraph-chat-modal {
    position: fixed;
    bottom: 95px;
    right: 30px;
    z-index: 999995;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 580px;
    max-height: calc(100vh - 120px);
    background: #0D1024;
    border: 1.5px solid rgba(170, 129, 71, 0.4);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 30px rgba(30, 34, 69, 0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.kordagraph-chat-modal.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* --- Chat Header --- */
.chat-modal-header {
    background: linear-gradient(135deg, #1E2245 0%, #121530 100%);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(170, 129, 71, 0.25);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #AA8147 0%, #8A6432 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    overflow: hidden;
    border: 1.5px solid #FFE29A;
}

.chat-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}

.chat-status {
    font-size: 0.75rem;
    color: #bbb;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #27ae60;
    border-radius: 50%;
    box-shadow: 0 0 8px #27ae60;
}

.chat-close-btn {
    background: transparent;
    border: none;
    color: #aaa;
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
}

.chat-close-btn:hover {
    color: #AA8147;
}

/* --- Messages Container --- */
.chat-messages-container {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: radial-gradient(circle at top right, rgba(30, 34, 69, 0.3), transparent);
}

.chat-msg {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    animation: fadeInMsg 0.3s ease forwards;
}

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

.chat-msg.bot-msg {
    align-self: flex-start;
}

.chat-msg.user-msg {
    align-self: flex-end;
}

.msg-bubble {
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}

.bot-msg .msg-bubble {
    background: #1B2044;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-top-left-radius: 2px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.user-msg .msg-bubble {
    background: linear-gradient(135deg, #AA8147 0%, #8C6430 100%);
    color: #ffffff;
    border-top-right-radius: 2px;
    box-shadow: 0 4px 15px rgba(170, 129, 71, 0.25);
}

.msg-time {
    font-size: 0.68rem;
    color: #777;
    margin-top: 4px;
}

.bot-msg .msg-time { align-self: flex-start; }
.user-msg .msg-time { align-self: flex-end; }

/* Uploaded Image Thumb in Bubble */
.chat-msg-image {
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid rgba(255,255,255,0.2);
}

/* Typing Indicator */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 16px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #AA8147;
    border-radius: 50%;
    animation: typingBlink 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBlink {
    0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* --- Image Preview Bar --- */
.chat-image-preview-bar {
    background: rgba(30, 34, 69, 0.8);
    border-top: 1px solid rgba(170, 129, 71, 0.3);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.preview-thumb-wrapper {
    position: relative;
    width: 44px;
    height: 44px;
}

.preview-thumb-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #AA8147;
}

.remove-preview-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #c0392b;
    color: #ffffff;
    border: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-label {
    font-size: 0.8rem;
    color: #FFE29A;
}

/* --- Escalation Overlay Form --- */
.chat-escalation-overlay {
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 13, 29, 0.95);
    backdrop-filter: blur(8px);
    z-index: 20;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.escalation-card {
    background: #1B2044;
    border: 1.5px solid #AA8147;
    border-radius: 12px;
    padding: 20px;
    width: 100%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.escalation-card h4 {
    margin: 0 0 6px 0;
    color: #ffffff;
    font-size: 1.05rem;
}

.escalation-card p {
    margin: 0 0 15px 0;
    color: #aaa;
    font-size: 0.82rem;
}

.escalation-card input,
.escalation-card textarea {
    width: 100%;
    background: #0D1024;
    border: 1px solid rgba(255,255,255,0.15);
    color: #ffffff;
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 10px;
    font-size: 0.88rem;
    box-sizing: border-box;
}

.escalation-card textarea {
    height: 70px;
    resize: none;
}

.escalate-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.btn-escalate-send {
    flex: 1;
    background: #AA8147;
    color: #ffffff;
    border: none;
    padding: 10px;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-escalate-send:hover {
    background: #8A6432;
}

.btn-escalate-cancel {
    background: transparent;
    color: #aaa;
    border: 1px solid rgba(255,255,255,0.2);
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
}

/* --- Input Footer --- */
.chat-modal-footer {
    padding: 12px 14px;
    background: #121530;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 10px;
}

#kordagraph-chat-input {
    flex: 1;
    background: #0D1024;
    border: 1px solid rgba(170, 129, 71, 0.3);
    color: #ffffff;
    padding: 10px 14px;
    border-radius: 20px;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.25s ease;
}

#kordagraph-chat-input:focus {
    border-color: #AA8147;
}

.chat-send-btn {
    width: 38px;
    height: 38px;
    background: #AA8147;
    border: none;
    border-radius: 50%;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    background: #8C6430;
    transform: scale(1.05);
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
    .kordagraph-chat-trigger {
        bottom: 20px;
        right: 20px;
        padding: 8px 16px 8px 10px;
    }

    .kordagraph-chat-modal {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        border: none;
    }
}
