/* Maya Chatbot Styles */
/* Maya Chatbot Styles
   Brand colors come from CSS custom properties (--maya-primary, --maya-accent,
   --maya-secondary) injected by the plugin from admin settings.
   Text #4c4a63, background #f5f5f5. Font: Signika. */

#maya-chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: 'Signika', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Bottom-left placement */
#maya-chatbot-widget.maya-pos-left {
    right: auto;
    left: 20px;
}

#maya-chatbot-widget.maya-pos-left #maya-chat-container {
    right: auto;
    left: 0;
    transform-origin: bottom left;
}

/* Screen-reader only text */
#maya-chatbot-widget .screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Chat toggle button */
#maya-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: var(--maya-primary, #0f172a);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 14, 28, 0.35);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    padding: 0;
}

#maya-chat-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(0, 14, 28, 0.45), 0 0 0 3px rgba(47, 209, 226, 0.5);
}

#maya-chat-toggle:focus-visible {
    outline: 3px solid var(--maya-secondary, #38bdf8);
    outline-offset: 2px;
}

#maya-chat-toggle .chat-icon,
#maya-chat-toggle .close-icon {
    color: #fff;
    transition: all 0.3s ease;
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
}

#maya-chat-toggle .close-icon {
    opacity: 0;
    transform: rotate(180deg);
}

#maya-chat-toggle.active .chat-icon {
    opacity: 0;
    transform: rotate(-180deg);
}

#maya-chat-toggle.active .close-icon {
    opacity: 1;
    transform: rotate(0deg);
}

/* Chat container */
#maya-chat-container {
    width: 380px;
    height: 500px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 14, 28, 0.25);
    display: flex;
    flex-direction: column;
    position: absolute;
    bottom: 80px;
    right: 0;
    transition: all 0.3s ease;
    transform-origin: bottom right;
    overflow: hidden;
}

#maya-chat-container.chat-hidden {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8) translateY(20px);
}

/* Chat header */
.chat-header {
    background: var(--maya-primary, #0f172a);
    color: #fff;
    padding: 18px 100px 18px 20px;
    position: relative;
    border-bottom: 3px solid var(--maya-accent, #2563eb);
}

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

.ai-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(47, 209, 226, 0.6);
}

/* Letter fallback when no avatar image is set */
.ai-avatar-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--maya-accent, #2563eb);
    color: #fff;
    font-weight: 600;
    font-size: 18px;
    line-height: 1;
}

.header-text {
    flex: 1;
    min-width: 0;
}

.header-text h3 {
    margin: 0 0 4px 0;
    font-size: 17px;
    font-weight: 600;
    font-family: 'Signika', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-text p {
    margin: 0;
    font-size: 13px;
    color: var(--maya-secondary, #38bdf8);
    line-height: 1.3;
}

/* Office open/closed indicator in the subtitle */
.office-status::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-right: 4px;
    background: #999;
}

.office-status.open::before {
    background: #7dba2f;
}

.office-status.closed::before {
    background: var(--maya-accent, #2563eb);
}

/* Header action buttons (call + close) */
.header-actions {
    position: absolute;
    top: 50%;
    right: 14px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-close,
.chat-call {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    padding: 0;
    text-decoration: none;
}

.chat-close:hover,
.chat-call:hover {
    background: var(--maya-accent, #2563eb);
}

.chat-close:focus-visible,
.chat-call:focus-visible {
    outline: 2px solid var(--maya-secondary, #38bdf8);
    outline-offset: 2px;
}

/* Messages container */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f5f5f5;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

/* Message bubbles */
.bot-message,
.user-message {
    display: flex;
    animation: messageSlide 0.3s ease;
}

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

.user-message {
    justify-content: flex-end;
}

.message-content {
    max-width: 78%;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.bot-message .message-content {
    background: #fff;
    color: #4c4a63;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 14, 28, 0.08);
}

.user-message .message-content {
    background: var(--maya-primary, #0f172a);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    background: #fff;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    max-width: 60px;
    box-shadow: 0 2px 8px rgba(0, 14, 28, 0.08);
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--maya-secondary, #38bdf8);
    border-radius: 50%;
    animation: typingAnimation 1.4s infinite ease-in-out;
}

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

@keyframes typingAnimation {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Quick reply chips */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 15px;
    background: #fff;
    border-top: 1px solid #e9ecef;
}

.quick-replies.quick-replies-hidden {
    display: none;
}

.quick-reply {
    border: 1px solid var(--maya-primary, #0f172a);
    background: #fff;
    color: var(--maya-primary, #0f172a);
    border-radius: 20px;
    padding: 7px 14px;
    font-size: 12.5px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-reply:hover {
    background: var(--maya-primary, #0f172a);
    color: #fff;
    border-color: var(--maya-primary, #0f172a);
}

.quick-reply:focus-visible {
    outline: 2px solid var(--maya-secondary, #38bdf8);
    outline-offset: 2px;
}

/* In-conversation chip rows (intake steps) */
.chips-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 4px;
}

/* Action buttons inside bot messages ([Get a Quote] / [Request a Callback]) */
.action-link {
    display: inline-block;
    background: var(--maya-accent, #2563eb);
    color: #fff !important;
    border: none;
    font-family: inherit;
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    margin: 4px 4px 0;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(246, 1, 0, 0.25);
}

.action-link:hover {
    background: #c90000;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(246, 1, 0, 0.4);
}

.action-link:focus-visible {
    outline: 2px solid var(--maya-secondary, #38bdf8);
    outline-offset: 2px;
}

/* Input container */
.chat-input-container {
    background: #fff;
    border-top: 1px solid #e9ecef;
    padding: 15px;
}

/* Contact links in messages */
.contact-link {
    display: inline-block;
    background: var(--maya-accent, #2563eb);
    color: #fff !important;
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    margin: 4px 4px 0;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(246, 1, 0, 0.25);
}

.contact-link:hover {
    background: #c90000;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(246, 1, 0, 0.4);
    text-decoration: none;
}

/* Input area */
.input-area {
    display: flex;
    gap: 10px;
    align-items: center;
}

#chat-input {
    flex: 1;
    border: 1px solid #e9ecef;
    border-radius: 25px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    color: #4c4a63;
    outline: none;
    transition: all 0.2s ease;
}

#chat-input:focus {
    border-color: var(--maya-secondary, #38bdf8);
    box-shadow: 0 0 0 3px rgba(47, 209, 226, 0.2);
}

#send-button {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--maya-accent, #2563eb);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0;
}

#send-button:hover {
    transform: scale(1.05);
    background: #c90000;
    box-shadow: 0 4px 12px rgba(246, 1, 0, 0.35);
}

#send-button:focus-visible {
    outline: 3px solid var(--maya-secondary, #38bdf8);
    outline-offset: 2px;
}

#send-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Mobile responsive */
@media (max-width: 480px) {
    #maya-chatbot-widget {
        bottom: 20px;
        right: 20px;
    }

    #maya-chat-container {
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100vh; /* fallback for iOS < 15.4 */
        height: 100dvh;
        z-index: 999999;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    /* Mobile header adjustments */
    .chat-header {
        padding: 15px 20px;
        flex-shrink: 0;
    }

    .header-content {
        gap: 8px;
    }

    .ai-avatar {
        width: 32px;
        height: 32px;
    }

    .header-text h3 {
        font-size: 16px;
    }

    .header-text p {
        font-size: 12px;
    }

    .chat-header {
        padding-right: 96px;
    }

    .chat-close,
    .chat-call {
        width: 36px;
        height: 36px;
        background: rgba(255, 255, 255, 0.2);
    }

    /* Mobile messages area */
    .chat-messages {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Mobile input container */
    .chat-input-container {
        flex-shrink: 0;
        padding: 10px 20px 20px 20px;
        position: relative;
        z-index: 1;
    }

    /* Mobile input field */
    #chat-input {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 14px 16px;
    }
}

@media (max-width: 360px) {
    .header-text h3 {
        font-size: 14px;
    }

    .header-text p {
        font-size: 11px;
    }

    .ai-avatar {
        width: 28px;
        height: 28px;
    }
}

/* Error and success states */
.message-error {
    background: #f8d7da !important;
    color: #721c24 !important;
    border: 1px solid #f5c6cb;
}

.message-success {
    background: #d4edda !important;
    color: #155724 !important;
    border: 1px solid #c3e6cb;
}

/* Loading state for send button */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    #maya-chat-container,
    #maya-chat-toggle,
    .bot-message,
    .user-message,
    .typing-dot,
    .loading::after {
        animation: none !important;
        transition: none !important;
    }
}
