/* assets/css/chatbot.css */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --chat-primary: #061f22;
    --chat-secondary: #5DA9AA;
    --chat-highlight: #F4C15C;
    --chat-bg: rgba(255, 255, 255, 0.95);
    --chat-surface: #ffffff;
    --chat-text: #0f172a;
    --chat-text-muted: #64748b;
    --chat-gradient: linear-gradient(135deg, #061f22, #0d3b40);
    --chat-accent-gradient: linear-gradient(135deg, #5DA9AA, #4b8c8d);
    --z-index-widget: 9990;
    /* Ensure it's on top */
}

/* ---------------------------------------------------------
   Widget Container
--------------------------------------------------------- */
#chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: var(--z-index-widget);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    box-sizing: border-box;
    color: #333;
}

#chatbot-widget * {
    box-sizing: border-box;
}

/* ---------------------------------------------------------
   Toggle Button
--------------------------------------------------------- */
#chatbot-toggle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--chat-primary);
    color: var(--chat-highlight);
    border: 2px solid var(--chat-highlight);
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(244, 193, 92, 0.5);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    position: relative;
    z-index: 91;
}

#chatbot-toggle:hover {
    transform: scale(1.1) rotate(-5deg);
    box-shadow: 0 12px 32px rgba(244, 193, 92, 0.6);
}

#chatbot-widget:not(.active) #chatbot-toggle {
    animation: pulse 3s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(244, 193, 92, 0.7);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(244, 193, 92, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(244, 193, 92, 0);
    }
}

.toggle-icon-open,
.toggle-icon-close {
    position: absolute;
    transition: all 0.4s ease;
}

.toggle-icon-close {
    opacity: 0;
    transform: rotate(-180deg) scale(0.5);
}

#chatbot-widget.active #chatbot-toggle {
    background: white;
    color: var(--chat-primary);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

#chatbot-widget.active #chatbot-toggle .toggle-icon-open {
    opacity: 0;
    transform: rotate(180deg) scale(0.5);
}

#chatbot-widget.active #chatbot-toggle .toggle-icon-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* ---------------------------------------------------------
   CTA Bubble
--------------------------------------------------------- */
.chatbot-cta {
    position: fixed;
    bottom: 105px;
    right: 35px;
    background: white;
    padding: 12px 20px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 9998;
    animation: slideUp 0.3s ease-out;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    border: 1px solid rgba(0, 0, 0, 0.05);
    cursor: pointer;
}

.chatbot-cta.hidden {
    display: none;
}

.cta-text-wrapper {
    overflow: hidden;
    white-space: nowrap;
    width: 0;
    transition: width 1.5s cubic-bezier(0.25, 1, 0.5, 1);
    display: inline-block;
    vertical-align: middle;
}

.cta-close {
    cursor: pointer;
    color: #94a3b8;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    transition: all 0.2s;
    margin-left: 8px;
}

.cta-close:hover {
    background: #f1f5f9;
    color: #333;
}

/* ---------------------------------------------------------
   Window Container & Views
--------------------------------------------------------- */
#chatbot-window {
    position: absolute;
    bottom: 85px;
    right: 0;
    width: 350px;
    height: 520px;
    max-height: calc(100vh - 120px);
    background: var(--chat-surface);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    /* Enforce positioning context */
    display: block;
    overflow: hidden;
    transform-origin: bottom right;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(0, 0, 0, 0.05);
    /* Ensure child absolute positioning works relative to this */
}

#chatbot-window.hidden {
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

/* View Utility */
.view-active {
    display: block !important;
    height: 100%;
    width: 100%;
    animation: fadeIn 0.3s ease-out forwards;
    position: relative;
    /* Context for absolute children */
}

.view-hidden {
    display: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------------------------------------------------------
   Header Styles
--------------------------------------------------------- */
#chatbot-widget .chatbot-header {
    background: white;
    border-bottom: 1px solid #f1f5f9;
    border-top: 4px solid var(--chat-highlight);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
    /* Fixed height for header */
}

#chatbot-widget .chat-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--chat-primary);
    margin: 0;
}

#chatbot-widget .chat-subtitle {
    font-size: 13px;
    font-weight: 400;
    color: var(--chat-text-muted);
    margin: 2px 0 0 0;
}

#chatbot-widget .icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--chat-text-muted);
    font-size: 1.2rem;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chatbot-widget .icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--chat-primary);
}

.header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

#chatbot-widget .avatar {
    width: 40px;
    height: 40px;
    background: #f1f5f9;
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e2e8f0;
}

#chatbot-widget .avatar img {
    width: 22px;
    height: 22px;
}

#chatbot-widget .status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: #10b981;
    border: 2px solid #fff;
    border-radius: 50%;
}

#chatbot-widget .meta h3 {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    line-height: 1.2;
}

#chatbot-widget .status-text {
    font-size: 12px;
    color: #64748b;
}

/* ---------------------------------------------------------
   Content Areas (Messages / Lead Body)
--------------------------------------------------------- */
.chat-messages,
.lead-body {
    position: absolute;
    top: 70px;
    /* Below header */
    bottom: 70px;
    /* Above footer */
    left: 0;
    right: 0;
    background: #f9f9f9;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lead-body {
    background: white;
    padding: 20px;
    justify-content: center;
    align-items: center;
    text-align: center;
    bottom: 0;
    /* Override generic rule to use full height */
}

.lead-icon {
    font-size: 42px;
    margin-bottom: 10px;
    animation: wave 2.5s infinite;
    transform-origin: 70% 70%;
    display: block;
}

@keyframes wave {

    0%,
    60%,
    100% {
        transform: rotate(0deg);
    }

    10%,
    30% {
        transform: rotate(14deg);
    }

    20%,
    40% {
        transform: rotate(-8deg);
    }

    50% {
        transform: rotate(10deg);
    }
}

.lead-body p {
    color: #64748b;
    font-size: 14px;
    line-height: 1.4;
    max-width: 280px;
    margin: 0 auto 20px;
}

/* ---------------------------------------------------------
   Footers (Input / Lead Footer) - ABSOLUTE POSITIONING
--------------------------------------------------------- */
.chatbot-footer,
.lead-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    min-height: 70px;
    /* Ensure space */
    background: white;
    padding: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    width: 100%;
    z-index: 10;
}

.lead-footer {
    position: relative;
    bottom: auto;
    left: auto;
    right: auto;
    text-align: center;
    background: transparent;
    border: none;
    margin-top: 20px;
    padding-top: 0;
    min-height: auto;
}

.chat-input-area {
    display: flex;
    gap: 8px;
    align-items: center;
}

#chatbot-widget .input-wrapper {
    display: flex;
    gap: 8px;
    background: #f1f5f9;
    padding: 4px 6px 4px 16px;
    border-radius: 24px;
    align-items: center;
    border: 1px solid transparent;
    transition: all 0.2s;
    width: 100%;
}

#chatbot-widget .input-wrapper:focus-within {
    background: white;
    border-color: transparent;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    outline: none !important;
}

#chatbot-widget .input-wrapper input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none !important;
    box-shadow: none !important;
    padding: 8px 0;
    font-size: 14px;
    /* Default desktop size */
    color: #333;
}

#chat-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--chat-primary);
    color: var(--chat-highlight);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 1.1rem;
    flex-shrink: 0;
}

#chat-send:hover {
    transform: scale(1.05);
}

/* ---------------------------------------------------------
   Form Styles
--------------------------------------------------------- */
#chatbot-widget form {
    width: 100%;
    text-align: left;
}

#chatbot-widget .form-group-chat {
    margin-bottom: 16px;
}

#chatbot-widget .form-group-chat label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

#chatbot-widget .form-group-chat input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 15px;
    transition: all 0.2s;
    outline: none;
    color: #0f172a;
    background: #f8fafc;
}

#chatbot-widget .form-group-chat input:focus {
    background: white;
    border-color: #0f2e30;
    box-shadow: 0 0 0 3px rgba(15, 46, 48, 0.1);
}

#chatbot-widget .btn-chat-submit {
    width: 100%;
    padding: 14px;
    background: #0f2e30;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#chatbot-widget .btn-chat-submit i {
    color: var(--chat-highlight);
    font-size: 1.2em;
}

#chatbot-widget .btn-chat-submit:hover {
    background: #0a1f20;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(15, 46, 48, 0.2);
}

.privacy-link {
    color: #94a3b8;
    text-decoration: underline;
    font-size: 12px;
    display: inline-block;
    margin-top: 10px;
    /* Add spacing to prevent overlap */
}

/* ---------------------------------------------------------
   Menu Dropdown
--------------------------------------------------------- */
#chatbot-widget .dropdown {
    position: relative;
}

#chatbot-widget .dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    width: 160px;
    z-index: 1000;
    overflow: hidden;
    padding: 6px 0;
    display: flex;
    flex-direction: column;
}

#chatbot-widget .dropdown-menu button {
    display: block;
    width: 100%;
    padding: 10px 16px;
    text-align: left;
    background: none;
    border: none;
    font-size: 13px;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

#chatbot-widget .dropdown-menu button:hover {
    background: #f8fafc;
    color: #0f172a;
}

#chatbot-widget .dropdown-menu.hidden {
    display: none;
}

/* ---------------------------------------------------------
   Message Styles
--------------------------------------------------------- */
.message {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.5;
    max-width: 85%;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    animation: slideUp 0.3s ease-out forwards;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.bot {
    align-self: flex-start;
    background: white;
    color: var(--chat-text);
    border-bottom-left-radius: 4px;
}

.message.user {
    align-self: flex-end;
    background: var(--chat-gradient);
    color: white;
    border-bottom-right-radius: 4px;
}

/* ---------------------------------------------------------
   Mobile & Zoom Fixes
--------------------------------------------------------- */

/* Prevent iOS Zoom on focus by enforcing 16px font size */
@media screen and (-webkit-min-device-pixel-ratio:0) {

    select,
    textarea,
    input {
        font-size: 16px !important;
    }
}

@media (max-width: 480px) {
    #chatbot-window {
        position: fixed !important;
        inset: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        z-index: 92 !important;
        background: #fff;
    }

    #chatbot-widget {
        bottom: calc(30px + env(safe-area-inset-bottom));
        right: calc(30px + env(safe-area-inset-right));
        z-index: 92;
    }

    #chatbot-toggle {
        width: 56px;
        height: 56px;
        min-width: 56px;
        min-height: 56px;
        font-size: 26px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    }

    /* Padding Adjustments for Mobile Safe Area */
    .chatbot-footer {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    /* Adjust content area bottom for mobile absolute footer */
    .chat-messages,
    .lead-body {
        bottom: 80px;
        /* Increase if footer is taller on mobile */
    }
}