/* Live Chat Widget Styling - Premium Glassmorphism & Modern UI */

:root {
    --chat-primary-gradient: linear-gradient(135deg, #05264e 0%, #0d468b 100%);
    --chat-accent-color: #cc2e23;
    --chat-bg-glass: rgba(255, 255, 255, 0.95);
    --chat-border-glass: rgba(255, 255, 255, 0.3);
    --chat-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    --chat-visitor-bubble: #05264e;
    --chat-bot-bubble: #f0f4f9;
    --chat-agent-bubble: #e8f5e9;
    --chat-text-dark: #333333;
    --chat-text-light: #ffffff;
}

/* Floating Action Button */
.chat-trigger-btn {
    position: fixed;
    bottom: 110px; /* Placed perfectly above WhatsApp button */
    right: 30px;
    width: 60px;
    height: 60px;
    background: var(--chat-primary-gradient);
    color: var(--chat-text-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(5, 38, 78, 0.4);
    z-index: 9999;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.chat-trigger-btn:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 6px 20px rgba(5, 38, 78, 0.6);
}

.chat-trigger-btn .chat-unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--chat-accent-color);
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Chat Main Window */
.chat-window-container {
    position: fixed;
    bottom: 185px; /* Sits above the trigger and WhatsApp buttons */
    right: 30px;
    width: 380px;
    height: 550px;
    background: var(--chat-bg-glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--chat-border-glass);
    border-radius: 20px;
    box-shadow: var(--chat-shadow);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.075, 0.82, 0.165, 1);
    transform: translateY(30px) scale(0.95);
    opacity: 0;
    pointer-events: none;
}

.chat-window-container.chat-open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* Header Area */
.chat-header {
    background: var(--chat-primary-gradient);
    color: var(--chat-text-light);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

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

.chat-avatar {
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.chat-avatar-status {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: #4caf50; /* Green online dot */
    border-radius: 50%;
    border: 2px solid #05264e;
}

.chat-avatar-status.offline {
    background: #ff9800; /* Amber away dot */
}

.chat-title-text h5 {
    color: #fff;
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.chat-title-text p {
    margin: 0;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
}

.chat-close-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 20px;
    cursor: pointer;
    transition: color 0.2s;
}

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

/* Body / Chat Area */
.chat-body {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    background: #fdfdfd;
    display: flex;
    flex-direction: column;
}

/* Pre-Chat Form */
.pre-chat-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: auto 0;
}

.pre-chat-form h4 {
    text-align: center;
    color: #05264e;
    font-weight: 700;
    margin-bottom: 5px;
}

.pre-chat-form p {
    text-align: center;
    font-size: 13px;
    color: #666;
    margin-bottom: 15px;
}

.chat-input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.chat-input-group label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
}

.chat-form-control {
    padding: 10px 14px;
    border: 1.5px solid #e1e1e1;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

.chat-form-control:focus {
    border-color: #05264e;
}

.chat-btn-submit {
    background: var(--chat-primary-gradient);
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
    margin-top: 10px;
}

.chat-btn-submit:hover {
    opacity: 0.95;
}

/* Message Bubbles */
.chat-messages-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-grow: 1;
}

.chat-bubble-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

.chat-bubble-wrapper.visitor {
    align-self: flex-end;
}

.chat-bubble-wrapper.system {
    align-self: center;
    max-width: 90%;
}

.chat-bubble-wrapper.visitor .chat-bubble {
    background: var(--chat-visitor-bubble);
    color: #fff;
    border-radius: 18px 18px 4px 18px;
    align-self: flex-end;
}

.chat-bubble-wrapper.ai .chat-bubble {
    background: var(--chat-bot-bubble);
    color: var(--chat-text-dark);
    border-radius: 18px 18px 18px 4px;
}

.chat-bubble-wrapper.agent .chat-bubble {
    background: var(--chat-agent-bubble);
    color: var(--chat-text-dark);
    border-radius: 18px 18px 18px 4px;
    border: 1px solid #c8e6c9;
}

.chat-bubble-wrapper.system .chat-bubble {
    background: #fff9c4;
    color: #574b00;
    font-size: 11px;
    padding: 5px 12px;
    border-radius: 10px;
    text-align: center;
    border: 1.5px dashed #f0e68c;
}

.chat-bubble {
    padding: 12px 16px;
    font-size: 13.5px;
    line-height: 1.5;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    word-break: break-word;
}

.chat-bubble-time {
    font-size: 10px;
    color: #999;
    margin-top: 4px;
    align-self: flex-end;
}

.chat-bubble-wrapper.visitor .chat-bubble-time {
    align-self: flex-end;
}

.chat-bubble-wrapper.ai .chat-bubble-time,
.chat-bubble-wrapper.agent .chat-bubble-time {
    align-self: flex-start;
}

/* Typing Indicator */
.chat-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: var(--chat-bot-bubble);
    border-radius: 18px 18px 18px 4px;
    align-self: flex-start;
    margin-bottom: 10px;
}

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

.chat-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.chat-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

/* Footer / Input Area */
.chat-footer {
    padding: 15px;
    background: #fff;
    border-top: 1px solid #eef2f6;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-input-field {
    flex-grow: 1;
    border: 1px solid #e1e1e1;
    border-radius: 30px;
    padding: 10px 18px;
    outline: none;
    font-size: 13.5px;
    resize: none;
    max-height: 80px;
    transition: border-color 0.3s;
}

.chat-input-field:focus {
    border-color: #05264e;
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--chat-primary-gradient);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: transform 0.2s;
}

.chat-send-btn:hover {
    transform: scale(1.08);
}

/* Escalate human connection footer button */
.chat-escalate-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff3e0;
    border: 1px solid #ffe0b2;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 5px;
}

.chat-escalate-bar span {
    font-size: 11px;
    color: #e65100;
    font-weight: 600;
}

.chat-btn-escalate {
    background: #e65100;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.2s;
}

.chat-btn-escalate:hover {
    opacity: 0.9;
}

/* Chat branding */
.chat-branding {
    text-align: center;
    font-size: 9.5px;
    color: #aaa;
    margin-top: 4px;
}

/* Responsive adjustment for Mobile screens */
@media screen and (max-width: 500px) {
    .chat-window-container {
        width: calc(100% - 40px);
        height: calc(100% - 150px);
        bottom: 120px;
        right: 20px;
        left: 20px;
    }
    
    .chat-trigger-btn {
        bottom: 90px;
        right: 20px;
        width: 50px;
        height: 50px;
        font-size: 22px;
    }
    
    /* If WhatsApp is present in mobile, raise chat trigger button slightly */
    .whatsapp-float {
        bottom: 15px !important;
        right: 15px !important;
        width: 50px !important;
        height: 50px !important;
    }
}

/* intl-tel-input integration styling */
.iti {
    width: 100% !important;
    display: block !important;
}
.iti input {
    width: 100% !important;
    padding-left: 52px !important;
}
.iti--container {
    z-index: 1000000 !important;
}
.iti__country-list {
    z-index: 1000000 !important;
    max-height: 200px !important;
    background: #ffffff !important;
    color: #333333 !important;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15) !important;
    border: 1px solid #ddd !important;
}
