/**
 * Geo21 Chatbot Styles
 * Version: 1.3.0
 * Chat-like interface matching Agente Geo21 design
 */

/* Import Montserrat font */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

/* Container */
#geo21-chatbot-container {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
}

/* Complete WordPress theme color reset */
#geo21-chatbot-container,
#geo21-chatbot-container *,
#geo21-chatbot-container *::before,
#geo21-chatbot-container *::after {
    --wp--preset--color--primary: #1E1E1E !important;
    --wp--preset--color--secondary: #1E1E1E !important;
    --wp--preset--color--accent: #1E1E1E !important;
    --theme-color: #1E1E1E !important;
    -webkit-tap-highlight-color: transparent !important;
}

#geo21-chatbot-container *:focus,
#geo21-chatbot-container *:focus-visible,
#geo21-chatbot-container *:active,
#geo21-chatbot-container *::selection {
    outline: none !important;
    outline-color: #1E1E1E !important;
    box-shadow: none !important;
    -webkit-tap-highlight-color: transparent !important;
}

#geo21-chatbot-container input,
#geo21-chatbot-container button,
#geo21-chatbot-container textarea {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

#geo21-chatbot-container input:focus,
#geo21-chatbot-container button:focus,
#geo21-chatbot-container button:active,
#geo21-chatbot-container textarea:focus {
    outline: none !important;
    box-shadow: none !important;
    -webkit-tap-highlight-color: transparent !important;
}

#geo21-chatbot-container button:active {
    background-color: #000000 !important;
    color: #ffffff !important;
}

/* Override WordPress theme button styles */
#geo21-chatbot-container button:focus,
#geo21-chatbot-container button:hover,
#geo21-chatbot-container [type=button]:focus,
#geo21-chatbot-container [type=button]:hover,
#geo21-chatbot-container [type=submit]:focus,
#geo21-chatbot-container [type=submit]:hover {
    background-color: inherit !important;
    color: inherit !important;
    text-decoration: none !important;
}

#geo21-chatbot-container .chatbot-option-btn:focus,
#geo21-chatbot-container .chatbot-option-btn:hover {
    background-color: #000000 !important;
    color: #ffffff !important;
}

#geo21-chatbot-container .chatbot-close-btn:focus,
#geo21-chatbot-container .chatbot-close-btn:hover,
#geo21-chatbot-container .chatbot-back-btn:focus,
#geo21-chatbot-container .chatbot-back-btn:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
}

#geo21-chatbot-container #chatbot-submit-btn:focus,
#geo21-chatbot-container #chatbot-submit-btn:hover {
    background-color: #000000 !important;
    color: #ffffff !important;
}

#geo21-chatbot-container #geo21-chatbot-trigger:focus,
#geo21-chatbot-container #geo21-chatbot-trigger:hover {
    background-color: #ffffff !important;
}

/* Floating Trigger Button */
#geo21-chatbot-trigger {
    position: fixed;
    bottom: 75px;
    right: 20px;
    z-index: 10000;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #ffffff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#geo21-chatbot-trigger:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

#geo21-chatbot-trigger:focus {
    outline: none;
}

.chatbot-trigger-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Chat Panel */
#geo21-chatbot-panel {
    position: fixed;
    bottom: 145px;
    right: 20px;
    z-index: 10001;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 700px;
    max-height: calc(100vh - 180px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    overflow: hidden;
}

#geo21-chatbot-panel.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header */
.chatbot-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #1E1E1E;
    color: #ffffff;
    flex-shrink: 0;
    gap: 12px;
}

.chatbot-back-btn {
    background: transparent;
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.chatbot-back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.chatbot-header-logo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: contain;
    background: #ffffff;
    padding: 2px;
}

.chatbot-title {
    font-weight: 600;
    font-size: 16px;
}

.chatbot-close-btn {
    background: transparent;
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    margin-left: auto;
}

.chatbot-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Messages Area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #ffffff;
}

/* Timestamp */
.chatbot-timestamp {
    text-align: center;
    color: #999999;
    font-size: 12px;
    margin: 8px 0;
}

/* Message Group (for bot messages with label and logo) */
.chatbot-message-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chatbot-message-label {
    font-size: 12px;
    color: #666666;
    margin-left: 4px;
}

/* Message Row */
.chatbot-message-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.chatbot-message-row.bot {
    flex-direction: row;
}

.chatbot-message-row.user {
    flex-direction: row-reverse;
}

/* Message Logo */
.chatbot-message-logo {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: contain;
    flex-shrink: 0;
    align-self: flex-end;
    margin-bottom: 4px;
}

/* Message Bubbles */
.chatbot-message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    white-space: pre-wrap;
    font-weight: 400;
    animation: fadeIn 0.3s ease;
}

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

/* Bot Messages */
.chatbot-message.bot {
    background: #F4F6F8;
    color: #1E1E1E;
    border-bottom-left-radius: 4px;
    font-weight: 400;
}

/* User Messages */
.chatbot-message.user {
    background: #1E1E1E;
    color: #ffffff;
    border-bottom-right-radius: 4px;
    margin-left: auto;
}

/* System Messages */
.chatbot-message.system {
    background: #fff3cd;
    color: #856404;
    font-size: 13px;
    text-align: center;
    max-width: 90%;
    align-self: center;
    border-radius: 12px;
}

/* Options Container */
.chatbot-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
    padding-left: 32px;
}

/* Option Buttons */
.chatbot-option-btn {
    background: #ffffff;
    border: 1.5px solid #000000;
    color: #000000;
    padding: 12px 20px;
    border-radius: 24px;
    cursor: pointer;
    text-align: center;
    font-size: 14px;
    font-weight: 400;
    transition: all 0.2s ease;
    animation: fadeInUp 0.3s ease forwards;
    opacity: 0;
    /* Fix text overflow - allow wrapping */
    white-space: normal !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    line-height: 1.4;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    /* Prevent pink/purple tap highlight on mobile */
    -webkit-tap-highlight-color: transparent;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

.chatbot-option-btn:hover,
.chatbot-option-btn:active,
.chatbot-option-btn:visited,
.chatbot-option-btn:target {
    background: #000000 !important;
    color: #ffffff !important;
    -webkit-tap-highlight-color: transparent !important;
}

.chatbot-option-btn:focus {
    outline: none;
}

.chatbot-option-btn:focus-visible {
    outline: none;
}

/* Primary option - same as regular buttons */
.chatbot-option-btn.primary {
    background: #ffffff;
    color: #000000;
    border-color: #000000;
}

.chatbot-option-btn.primary:hover {
    background: #000000;
    color: #ffffff;
}

/* Staggered animation for options */
.chatbot-option-btn:nth-child(1) { animation-delay: 0.05s; }
.chatbot-option-btn:nth-child(2) { animation-delay: 0.1s; }
.chatbot-option-btn:nth-child(3) { animation-delay: 0.15s; }
.chatbot-option-btn:nth-child(4) { animation-delay: 0.2s; }
.chatbot-option-btn:nth-child(5) { animation-delay: 0.25s; }

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

/* Disabled options (already selected) */
.chatbot-options.disabled .chatbot-option-btn {
    pointer-events: none;
    opacity: 0.5;
    cursor: default;
}

/* Input Area */
.chatbot-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #eeeeee;
    background: #ffffff;
    flex-shrink: 0;
}

#chatbot-text-input {
    flex: 1;
    padding: 12px 18px;
    border: 1.5px solid #e0e0e0;
    border-radius: 24px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #ffffff;
}

#chatbot-text-input:focus {
    border-color: #1E1E1E !important;
    outline: none !important;
    box-shadow: none !important;
    background: #ffffff !important;
}

#chatbot-text-input::placeholder {
    color: #999999;
}

#chatbot-submit-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    border-radius: 50%;
    background: #000000;
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, transform 0.1s ease;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

#chatbot-submit-btn:hover {
    background: #000000;
    transform: scale(1.05);
}

#chatbot-submit-btn:active {
    background: #000000;
    transform: scale(0.95);
}

#chatbot-submit-btn svg {
    width: 24px;
    height: 24px;
    margin-left: 2px;
}

.chatbot-send-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

/* Typing Indicator */
.chatbot-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #f5f5f5;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.chatbot-typing span {
    width: 8px;
    height: 8px;
    background: #666666;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.chatbot-typing span:nth-child(1) { animation-delay: 0s; }
.chatbot-typing span:nth-child(2) { animation-delay: 0.2s; }
.chatbot-typing span:nth-child(3) { animation-delay: 0.4s; }

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

/* Scrollbar Styling */
.chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 2px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #b0b0b0;
}

/* Responsive Adjustments */
@media screen and (max-width: 480px) {
    #geo21-chatbot-panel {
        width: calc(100vw - 20px);
        right: 10px;
        bottom: 135px;
        height: calc(100vh - 160px);
        max-height: none;
        border-radius: 12px;
    }

    #geo21-chatbot-trigger {
        right: 10px;
        bottom: 70px;
        width: 50px;
        height: 50px;
    }

    .chatbot-option-btn {
        padding: 10px 16px;
        font-size: 13px;
    }

    .chatbot-options {
        padding-left: 0;
    }
}
