/* IAM Smart Chatbot Styles — Premium Glassmorphism Upgrade */
:root {
    --iam-blue: #3D5561;
    --iam-orange: #E3A14C;
    --iam-white: #ffffff;
    --iam-light-gray: rgba(248, 249, 250, 0.85);
    --iam-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --iam-border: 1px solid rgba(255, 255, 255, 0.4);
}

/* Floating Action Button */
#iam-chat-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: var(--iam-orange);
    border-radius: 50%;
    box-shadow: var(--iam-shadow);
    cursor: pointer;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.2s;
}

#iam-chat-fab:hover {
    transform: scale(1.1) rotate(5deg);
    background: #d4913c;
}

#iam-chat-fab svg {
    width: 28px;
    height: 28px;
    fill: var(--iam-white);
}

/* Tooltip/Label floating next to the FAB */
.iam-chat-fab-tooltip {
    position: absolute;
    right: 75px;
    background: var(--iam-blue);
    color: var(--iam-white);
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    pointer-events: none;
    font-family: 'DM Sans', 'Source Sans Pro', sans-serif;
    opacity: 0;
    transform: translateX(-10px);
    animation: tooltipFadeIn 0.8s 1s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
    transition: opacity 0.3s, transform 0.3s;
}

.iam-chat-fab-tooltip::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -6px;
    transform: translateY(-50%);
    border-width: 6px 0 6px 6px;
    border-style: solid;
    border-color: transparent transparent transparent var(--iam-blue);
}

@keyframes tooltipFadeIn {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

#iam-chat-fab.open .iam-chat-fab-tooltip {
    opacity: 0 !important;
    transform: translateX(10px) !important;
    pointer-events: none;
}

@media (max-width: 480px) {
    .iam-chat-fab-tooltip {
        display: none !important;
    }
}

/* Chat Window Container - Frosted Glassmorphism */
#iam-chat-window {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 380px;
    height: 550px;
    max-height: 80vh;
    background: rgba(255, 255, 255, 0.94) !important;
    backdrop-filter: blur(15px) !important;
    -webkit-backdrop-filter: blur(15px) !important;
    border: var(--iam-border) !important;
    border-radius: 20px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.18);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(30px) scale(0.95);
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    font-family: 'DM Sans', 'Source Sans Pro', sans-serif;
}

#iam-chat-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header with Brand Identity */
.iam-chat-header {
    background: var(--iam-blue);
    color: var(--iam-white);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

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

/* Branded Favicon Wheel Avatar */
.iam-chat-avatar-container {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
    overflow: hidden;
}

.iam-chat-avatar-img {
    width: 26px;
    height: 26px;
    object-fit: contain;
    animation: slowSpin 25s linear infinite;
}

@keyframes slowSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.iam-chat-title-wrapper {
    display: flex;
    flex-direction: column;
}

.iam-chat-header h3 {
    margin: 0;
    font-family: 'Playfair Display', serif;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    line-height: 1.2;
    color: var(--iam-white) !important;
}

/* Pulsing Active Status Indicator */
.online-status-container {
    display: flex;
    align-items: center;
    font-size: 11px;
    opacity: 0.8;
    margin-top: 2px;
    gap: 5px;
}

.online-status-dot {
    width: 7px;
    height: 7px;
    background: #2ecc71;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 6px #2ecc71;
    animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
    0% {
        box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(46, 204, 113, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(46, 204, 113, 0);
    }
}

.iam-chat-close {
    background: transparent !important;
    border: none !important;
    color: var(--iam-white) !important;
    font-size: 26px !important;
    cursor: pointer !important;
    padding: 0 !important;
    line-height: 1 !important;
    opacity: 0.7 !important;
    min-height: unset !important;
    min-width: unset !important;
    width: auto !important;
    height: auto !important;
    border-radius: 0 !important;
    display: inline-block !important;
    transition: opacity 0.2s, transform 0.2s !important;
}

.iam-chat-close:hover {
    opacity: 1 !important;
    transform: scale(1.1) !important;
    background: transparent !important;
}

/* Messages Area */
#iam-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: var(--iam-light-gray);
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
}

/* Message Bubbles with Elastic Animation */
.iam-message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
    animation: bubbleElastic 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

@keyframes bubbleElastic {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.iam-message.bot {
    background: var(--iam-white);
    color: #333;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(225, 225, 225, 0.5);
    align-self: flex-start;
}

/* User Message: Warm Gold Color */
.iam-message.user {
    background: var(--iam-orange);
    color: var(--iam-white);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.iam-message a {
    color: #0d6efd;
    text-decoration: underline;
    font-weight: 600;
}

.iam-message.user a {
    color: #fff;
}

/* Dynamic Jumping Typing Indicator Spans */
.iam-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    height: 14px;
}

.iam-typing-indicator span {
    display: inline-block;
    width: 7px;
    height: 7px;
    background: #999;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite both;
}

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

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

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.1) translateY(-4px);
        opacity: 1;
        background: var(--iam-orange);
    }
}

/* Quick Options (Chips) */
.iam-chat-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 5px;
    animation: bubbleElastic 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

.iam-chat-option {
    background: var(--iam-white);
    border: 1.5px solid var(--iam-orange);
    color: var(--iam-orange);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(227, 161, 76, 0.08);
    transition: all 0.2s ease-in-out;
}

.iam-chat-option:hover {
    background: var(--iam-orange);
    color: var(--iam-white);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(227, 161, 76, 0.2);
}

/* Input Area */
.iam-chat-input-area {
    padding: 15px 20px;
    background: var(--iam-white);
    border-top: 1px solid rgba(238, 238, 238, 0.8);
    display: flex;
    align-items: center;
    gap: 12px;
}

#iam-chat-input {
    flex: 1;
    border: 1.5px solid #e2e8f0;
    border-radius: 25px;
    padding: 10px 18px;
    font-size: 14px;
    outline: none;
    background: #fdfdfd;
    transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}

#iam-chat-input:focus {
    border-color: var(--iam-orange);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(227, 161, 76, 0.1);
}

/* Persistent Helper Menu Action (Reset Menu) */
#iam-chat-menu-btn {
    background: #f1f5f9 !important;
    color: #475569 !important;
    border: none !important;
    width: 38px !important;
    height: 38px !important;
    min-height: unset !important;
    min-width: unset !important;
    padding: 0 !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background-color 0.2s, transform 0.2s !important;
}

#iam-chat-menu-btn:hover {
    background: #e2e8f0 !important;
    color: var(--iam-blue) !important;
    transform: rotate(45deg) !important;
}

#iam-chat-menu-btn svg {
    width: 18px !important;
    height: 18px !important;
    fill: currentColor !important;
}

#iam-chat-send {
    background: var(--iam-blue) !important;
    color: var(--iam-white) !important;
    border: none !important;
    width: 38px !important;
    height: 38px !important;
    min-height: unset !important;
    min-width: unset !important;
    padding: 0 !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: transform 0.2s, background-color 0.2s !important;
    box-shadow: 0 3px 8px rgba(61, 85, 97, 0.2) !important;
}

#iam-chat-send:hover {
    transform: scale(1.08) !important;
    background: #2d3f48 !important;
}

#iam-chat-send svg {
    width: 15px !important;
    height: 15px !important;
    fill: var(--iam-white) !important;
    margin-left: 2px !important;
}

/* ── Service Ticket Form Styles ── */
.iam-tkt-form {
    font-family: 'DM Sans', 'Source Sans Pro', sans-serif;
}
.iam-tkt-form input.tkt-input, 
.iam-tkt-form textarea.tkt-input {
    background: #ffffff !important;
    color: #1e293b !important;
    font-family: inherit !important;
    transition: border-color 0.2s, box-shadow 0.2s !important;
}
.iam-tkt-form input.tkt-input:focus, 
.iam-tkt-form textarea.tkt-input:focus {
    border-color: var(--iam-orange) !important;
    box-shadow: 0 0 0 3px rgba(227, 161, 76, 0.15) !important;
    outline: none !important;
}
.iam-tkt-form .iam-tkt-submit:hover {
    background: #2d3f48 !important;
}

/* Dark Mode support for Service Ticket Form */
html.dark-mode .iam-tkt-form {
    background: #161e29 !important;
    border-color: #2a3646 !important;
}
html.dark-mode .iam-tkt-form div,
html.dark-mode .iam-tkt-form label {
    color: #cbd5e1 !important;
}
html.dark-mode .iam-tkt-form input.tkt-input, 
html.dark-mode .iam-tkt-form textarea.tkt-input {
    background: #121820 !important;
    border-color: #2a3646 !important;
    color: #ffffff !important;
}
html.dark-mode .iam-tkt-form input.tkt-input:focus, 
html.dark-mode .iam-tkt-form textarea.tkt-input:focus {
    border-color: var(--iam-orange) !important;
}
html.dark-mode .iam-tkt-form .iam-tkt-submit {
    background: var(--iam-orange) !important;
    color: #ffffff !important;
}
html.dark-mode .iam-tkt-form .iam-tkt-submit:hover {
    background: #d4913c !important;
}