/* ========================================
   MAIN WIDGET CONTAINER
   ======================================== */

.ai-chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

#ai-chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

/* ========================================
   CHAT BUTTON
   ======================================== */

.ai-chatbot-button,
#ai-chatbot-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #45556c 0%, #90a2b9 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.ai-chatbot-button:hover,
#ai-chatbot-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

#ai-chatbot-button .chat-icon {
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========================================
   CHAT WINDOW
   ======================================== */

.ai-chatbot-window,
#ai-chatbot-window {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 380px;
    height: 600px;
    max-height: 80vh;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
    z-index: 10000; /* ✅ ENSURE ABOVE GOOGLE AUTOCOMPLETE */
}

#ai-chatbot-window {
    display: none;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   CHAT HEADER WITH PROGRESS
   ======================================== */

.ai-chatbot-header,
#ai-chatbot-header {
    background: linear-gradient(135deg, #45556c 0%, #90a2b9 100%);
    color: white;
    padding: 20px;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 2;
}

.ai-chatbot-header-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.ai-chatbot-agent-info,
.chatbot-agent-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-agent-info .chatbot-status {
    display: flex;
    align-items: center;
    gap: 5px;
}

.chatbot-agent-info .chatbot-status div {
    font-size: 16px;
    background: #05df71;
    border-radius: 100%;
    width: 10px;
    height: 10px;
}

.ai-chatbot-avatar,
.chatbot-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-width: 2px;
    border-style: solid;
    border-color: rgba(255, 255, 255, 0.3);
    transition: border-color .5s ease-in-out;
}

.chatbot-avatar-active {
    border-color: #00c94f;
}

.ai-chatbot-avatar img,
.chatbot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: width, height .5s ease-in-out;
}

.chatbot-avatar-active img {
    width: 110%;
    height: 110%;
}

.chatbot-avatar .avatar-placeholder {
    font-size: 24px;
}

.chatbot-agent-details {
    flex: 1;
}

.ai-chatbot-agent-name,
.chatbot-agent-name {
    font-weight: 600;
    font-size: 16px;
}

.ai-chatbot-status,
.chatbot-status {
    font-size: 12px;
    opacity: 0.9;
}

.ai-chatbot-minimize,
.chatbot-close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background 0.2s;
    font-size: 24px;
    line-height: 1;
}

.ai-chatbot-minimize:hover,
.chatbot-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ========================================
   HEADER PROGRESS CIRCLE
   ======================================== */

.ai-chatbot-progress {
    border-radius: 100%;
    border: 1px solid #000;
    width: 65px;
    height: 65px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    transition: background 0.4s ease;
}

.ai-chatbot-progress-inner {
    background: #fff;
    border-radius: 100%;
    border: 1px solid #000;
    width: 55px;
    height: 55px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chatbot-progress-value {
    font-size: 16px;
    font-weight: 500;
    color: #45556c;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 55px;
    height: 55px;
}

/* ========================================
   MESSAGES AREA
   ======================================== */

.ai-chatbot-messages,
#ai-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    scroll-behavior: smooth;
    position: relative;
    z-index: 1;
}

.ai-chatbot-message,
.chatbot-message {
    margin-bottom: 16px;
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-chatbot-message.user,
.chatbot-message.user {
    justify-content: flex-end;
}

.ai-chatbot-message.assistant,
.chatbot-message.assistant {
    justify-content: flex-start;
}

.ai-chatbot-message-bubble,
.message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    word-wrap: break-word;
    font-size: 14px;
}

.ai-chatbot-message.user .ai-chatbot-message-bubble,
.chatbot-message.user .message-bubble {
    background: linear-gradient(135deg, #45556c 0%, #90a2b9 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-chatbot-message.assistant .ai-chatbot-message-bubble,
.chatbot-message.assistant .message-bubble {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* ========================================
   TEXT SEGMENT CLASSES
   ======================================== */

.message-bubble.text-segment-1 {
    margin-top: -8px;
    animation-delay: 0.1s;
}

.message-bubble.text-segment-2 {
    margin-top: -8px;
    animation-delay: 0.2s;
}

.message-bubble.text-segment-3 {
    margin-top: -8px;
    animation-delay: 0.3s;
}

.message-bubble.text-segment-4 {
    margin-top: -8px;
    animation-delay: 0.4s;
}

/* ========================================
   TYPING INDICATOR
   ======================================== */

.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #999;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

.typing-indicator-message {
    margin-bottom: 16px;
}

/* ========================================
   QUICK REPLIES
   ======================================== */

.ai-chatbot-quick-replies,
#ai-chatbot-quick-replies {
    padding: 10px 20px;
    display: flex;
    flex-wrap: nowrap;
    overflow: auto hidden;
    gap: 8px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    z-index: 2;
}

.ai-chatbot-quick-reply-btn {
    background: white;
    border: 2px solid #45556c;
    color: #45556c;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.ai-chatbot-quick-reply-btn:hover,
.quick-reply-btn:hover {
    background: #45556c;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* ========================================
   INLINE QUICK REPLIES (INSIDE MESSAGES)
   ======================================== */

.inline-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 0;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}

.inline-quick-replies .starter-btn:last-child {
    margin-bottom: 0;
}

.ai-chatbot-quick-replies {
    display: none !important;
}

.inline-quick-replies .quick-reply-btn {
    border-radius: 6px !important;
}

/* ========================================
   INLINE QUICK REPLIES - EDIT MODE
   ======================================== */

.inline-quick-replies-edit {
    flex-direction: column !important;
    gap: 10px !important;
}

.inline-quick-replies-edit .quick-reply-btn {
    width: 100% !important;
    text-align: left !important;
    padding: 12px 16px !important;
    font-size: 14px !important;
}

.inline-quick-replies-edit .quick-reply-btn:hover {
    background: #45556c !important;
    color: white !important;
    transform: translateX(4px) !important;
}

/* ========================================
   CONVERSATION STARTER BUTTONS
   ======================================== */

.starter-btn {
    cursor: pointer;
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    background: #45556c;
    border-radius: 24px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    width: 100%;
    padding: 12px 24px;
    margin-bottom: 8px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    transition: all 0.3s ease-in-out;
    animation: pop 3s infinite;
}

.starter-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4) !important;
    animation: none;
}

.starter-btn:last-child {
    margin-bottom: 0;
}

@keyframes pop {
    0% { transform: scale(1); box-shadow: 0 0 0 rgba(102,126,234,0.3); }
    5% { transform: scale(1.1); box-shadow: 0 6px 20px rgba(102,126,234,0.4); }
    10% { transform: scale(1); box-shadow: 0 0 0 rgba(102,126,234,0.3); }
    100% { transform: scale(1); box-shadow: 0 0 0 rgba(102,126,234,0.3); }
}

#ai-chatbot-quick-replies.has-starters {
    padding: 15px 20px;
    flex-wrap: wrap;
}

#ai-chatbot-quick-replies.has-starters .starter-btn {
    display: block;
    width: 100%;
}

/* ========================================
   INPUT AREA
   ======================================== */

.ai-chatbot-input-area,
#ai-chatbot-input-area {
    display: flex;
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e9ecef;
    gap: 10px;
    position: relative;
    z-index: 2;
}

.ai-chatbot-input,
#ai-chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e9ecef;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.ai-chatbot-input:focus,
#ai-chatbot-input:focus {
    border-color: #45556c;
}

.ai-chatbot-send,
#ai-chatbot-send {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #45556c 0%, #90a2b9 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 20px;
}

.ai-chatbot-send:hover,
#ai-chatbot-send:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.ai-chatbot-send:disabled,
#ai-chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========================================
   SCROLLBAR STYLING
   ======================================== */

.ai-chatbot-messages::-webkit-scrollbar,
#ai-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chatbot-messages::-webkit-scrollbar-track,
#ai-chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.ai-chatbot-messages::-webkit-scrollbar-thumb,
#ai-chatbot-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.ai-chatbot-messages::-webkit-scrollbar-thumb:hover,
#ai-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.ai-chatbot-quick-replies::-webkit-scrollbar {
    height: 6px;
}

.ai-chatbot-quick-replies::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.ai-chatbot-quick-replies::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

/* ============================
   CUSTOM CHATBOT CALENDAR UI
   ============================ */

.chatbot-calendar {
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 15px;
    margin-top: 10px;
    width: 100%;
    animation: fadeIn 0.25s ease-out;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 12px;
}

.calendar-header button {
    background: linear-gradient(135deg, var(--user-primary, #45556c) 0%, var(--user-secondary, #90a2b9) 100%);
    color: white;
    border: none;
    flex: 1;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calendar-header button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.cal-title {
    font-weight: 600;
    font-size: 16px;
    color: #333;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.cal-day-label {
    text-align: center;
    font-weight: bold;
    color: #555;
}

.cal-empty {
    height: 35px;
}

.cal-day {
    background: #f0f3f7;
    border-radius: 8px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
}

.cal-day:hover {
    background: #45556c;
    color: white;
    transform: scale(1.05);
}

.cal-selectors {
    width: 100%;
}

.cal-selectors select {
    padding: 4px 6px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 14px;
}

/* ========================================
   ✅ ADDRESS AUTOCOMPLETE CONTAINER - FIXED
   ======================================== */

.address-autocomplete-container {
    background: white;
    border-radius: 12px;
    padding: 15px;
    margin: 10px 0;
    border: 2px solid #0073aa;
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.15);
    animation: slideUp 0.3s ease;
    position: relative;
    z-index: 1; /* ✅ ENSURE IT'S INSIDE THE CHAT FLOW */
}

.address-autocomplete-container h4 {
    margin: 0 0 12px 0;
    color: #0073aa;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.address-suggestions {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 15px;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 10px;
}

.address-suggestion-item {
    padding: 12px;
    cursor: pointer;
    border-radius: 8px;
    margin-bottom: 5px;
    transition: all 0.2s;
    background: #f8f9fa;
    font-size: 14px;
    line-height: 1.4;
}

.address-suggestion-item:hover {
    background: #e3f2fd;
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(0, 115, 170, 0.1);
}

.address-suggestion-item .main-text {
    font-weight: 600;
    color: #333;
}

.address-suggestion-item .secondary-text {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

.address-fields-preview {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 15px;
}

.address-field-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    transition: all 0.2s;
}

.address-field-item.filled {
    background: #e3f2fd;
    border-color: #0073aa;
}

.address-field-item .field-label {
    font-weight: 600;
    font-size: 12px;
    color: #666;
    min-width: 80px;
    text-transform: uppercase;
}

.address-field-item .field-value {
    flex: 1;
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

.address-field-item .field-value.empty {
    color: #999;
    font-style: italic;
}

.address-confirm-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
}

.address-confirm-btn {
    flex: 1;
    padding: 10px 16px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.address-confirm-btn.confirm {
    background: linear-gradient(135deg, #00a32a 0%, #00c94f 100%);
    color: white;
}

.address-confirm-btn.confirm:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 163, 42, 0.3);
}

.address-confirm-btn.edit {
    background: white;
    border: 2px solid #0073aa;
    color: #0073aa;
}

.address-confirm-btn.edit:hover {
    background: #0073aa;
    color: white;
}

/* ✅ HIDE GOOGLE AUTOCOMPLETE DEFAULT DROPDOWN */
.pac-container {
    display: none !important;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 480px) {
    .ai-chatbot-window,
    #ai-chatbot-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        bottom: 80px;
        right: 20px;
    }

    .ai-chatbot-widget,
    #ai-chatbot-container {
        bottom: 10px;
        right: 10px;
    }

    .ai-chatbot-button,
    #ai-chatbot-button {
        width: 50px;
        height: 50px;
    }

    #ai-chatbot-button .chat-icon {
        font-size: 24px;
    }

    .ai-chatbot-progress {
        width: 40px;
        height: 40px;
        bottom: -12px;
    }

    .ai-chatbot-progress-inner {
        width: 50px;
        height: 50px;
    }

    .ai-chatbot-progress-value {
        font-size: 16px;
        width: 50px;
        height: 50px;
    }
}

@media (max-width: 360px) {
    .ai-chatbot-message-bubble,
    .message-bubble {
        max-width: 85%;
        font-size: 13px;
    }

    .ai-chatbot-input,
    #ai-chatbot-input {
        font-size: 13px;
        padding: 10px 14px;
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

.slide-up {
    animation: slideUp 0.3s ease;
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .ai-chatbot-widget,
    #ai-chatbot-container,
    .ai-chatbot-window,
    #ai-chatbot-window {
        display: none !important;
    }
}