/**
 * Chat Widget Styles - Complete and Updated
 */

:root {
    --sagitta-primary-color: #9333ea;
    --sagitta-secondary-color: #ec4899;
    --sagitta-accent-color: #f97316;
}

.sagitta-chat-widget * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.sagitta-chat-widget {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.sagitta-chat-widget[data-position="bottom_left"] {
    right: auto;
    left: 20px;
}

.sagitta-chat-widget[data-position="top_right"] {
    bottom: auto;
    top: 20px;
}

.sagitta-chat-widget[data-position="top_left"] {
    bottom: auto;
    top: 20px;
    right: auto;
    left: 20px;
}

/* ===== LAUNCHER ===== */

.launcher-container {
    display: flex;
    align-items: center;
    gap: 12px;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.launcher-container.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9);
}

.chat-button {
    position: relative;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, #9333ea 0%, #ec4899 50%, #f97316 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(147, 51, 234, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: pulse 2s infinite;
    overflow: visible;
    flex-shrink: 0;
    padding: 3px;
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 32px rgba(147, 51, 234, 0.6);
}

.chat-button-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.3);
}

.chat-button-status {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: #10b981;
    border-radius: 50%;
    border: 3px solid #1a0b2e;
    z-index: 10;
}

@keyframes statusBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 8px 24px rgba(147, 51, 234, 0.4);
    }
    50% {
        box-shadow: 0 8px 32px rgba(147, 51, 234, 0.7);
    }
}

/* ===== LAUNCHER MESSAGES ===== */

.message-bubble-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.attention-bubble {
    background: white;
    padding: 14px 18px;
    border-radius: 10px 10px 5px 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
    max-width: 280px;
    animation: bubbleIn 0.5s ease;
    display: none;
    position: relative;
    color: #1a0b2e;
    font-size: 13px;
    line-height: 1.5;
    font-weight: 500;
}

.attention-bubble.active {
    display: block;
}

.attention-bubble::after {
    content: '';
    position: absolute;
    bottom: 14px;
    right: -10px;
    width: 0;
    height: 0;
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    border-left: 12px solid white;
}

@keyframes bubbleIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.typing-bubble {
    background: white;
    padding: 14px 18px;
    border-radius: 10px 10px 5px 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
    animation: bubbleIn 0.5s ease;
    display: none;
    position: relative;
}

.typing-bubble.active {
    display: block;
}

.typing-bubble::after {
    content: '';
    position: absolute;
    bottom: 14px;
    right: -10px;
    width: 0;
    height: 0;
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    border-left: 12px solid white;
}

.typing-dots {
    display: flex;
    gap: 5px;
    padding: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #9333ea;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* ===== CHAT CONTAINER ===== */

.chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 400px;
    height: 650px;
    background: #0f0520;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
    border: 1px solid rgba(147, 51, 234, 0.2);
}

.chat-container.active {
    display: flex;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== CHAT HEADER ===== */

.chat-header {
    background: linear-gradient(135deg, #9333ea 0%, #ec4899 100%);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    position: relative;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: visible;
    flex-shrink: 0;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.3);
}

.avatar-status {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 14px;
    height: 14px;
    background: #10b981;
    border-radius: 50%;
    border: 3px solid #ec4899;
    animation: statusBlink 2s infinite;
}

.header-text h3 {
    color: white;
    font-size: 18px;
    margin-bottom: 2px;
    font-weight: 600;
}

.header-text p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 13px;
}

.close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
    font-size: 20px;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== CHAT MESSAGES ===== */

.chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background: #0f0520;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #9333ea;
    border-radius: 3px;
}

.message {
    margin-bottom: 20px;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.bot {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.message.user {
    display: flex;
    justify-content: flex-end;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid #9333ea;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-content {
    background: #2d1b4e;
    padding: 14px 18px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    max-width: 70%;
    color: white;
    font-size: 15px;
    line-height: 1.5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.message.user .message-content {
    background: linear-gradient(135deg, #9333ea, #ec4899);
    border-radius: 18px;
    border-bottom-right-radius: 4px;
    border-bottom-left-radius: 18px;
    box-shadow: 0 4px 12px rgba(147, 51, 234, 0.3);
}

.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 14px 18px;
    background: #2d1b4e;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #9333ea;
    border-radius: 50%;
    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;
}

/* ===== INPUT AREA ===== */

.chat-input-area {
    padding: 20px;
    background: #1a0b2e;
    border-top: 1px solid rgba(147, 51, 234, 0.2);
}

/* Layout padrão: Input e botão lado a lado */
.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-label {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    font-weight: 500;
    padding-left: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-input {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid rgba(147, 51, 234, 0.3);
    border-radius: 24px;
    background: #0f0520;
    color: white;
    font-size: 15px;
    outline: none;
    transition: all 0.3s ease;
}

.chat-input:focus {
    border-color: #9333ea;
    background: #1a0b2e;
    box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.1);
}

.chat-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.chat-input[type="email"] {
    text-transform: lowercase;
}

textarea.chat-input {
    resize: vertical;
    min-height: 80px;
    max-height: 150px;
    font-family: inherit;
    line-height: 1.5;
    padding: 14px 18px;
    border-radius: 16px;
}

/* Phone Input */
.phone-input-container {
    display: flex;
    gap: 10px;
}

.ddi-select {
    max-width: 90px;
    padding: 14px 12px;
    border: 2px solid rgba(147, 51, 234, 0.3);
    border-radius: 24px;
    background: #0f0520;
    color: white;
    font-size: 14px;
    font-weight: 600;
    outline: none;
    transition: all 0.3s ease;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.ddi-select:focus {
    border-color: #9333ea;
    background-color: #1a0b2e;
    box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.1);
}

.ddi-select option {
    background: #1a0b2e;
    color: white;
    padding: 10px;
}

.phone-number-input {
    flex: 1;
}

/* ===== BUTTONS ===== */

/* Botão de envio padrão (ao lado do input) */
.send-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #9333ea, #ec4899);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
    box-shadow: 0 4px 12px rgba(147, 51, 234, 0.3);
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(147, 51, 234, 0.4);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-btn svg {
    width: 22px;
    height: 22px;
    fill: white;
}

/* ===== BUTTON CONTAINER (Textarea com Skip) ===== */

/* Container para botões lado a lado */
.button-container {
    display: flex;
    gap: 12px;
    align-items: stretch;
    width: 100%;
    margin-top: 12px;
}

/* Muda layout do wrapper quando tem button-container */
.input-wrapper:has(.button-container) {
    flex-direction: column;
    align-items: stretch;
}

.input-wrapper:has(.button-container) .input-group {
    width: 100%;
}

/* Botões dentro do container (lado a lado, embaixo) */
.button-container .send-btn {
    flex: 1;
    width: auto;
    height: 50px;
    border-radius: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 24px;
    font-size: 15px;
    font-weight: 500;
}

.button-container .send-btn svg {
    width: 20px;
    height: 20px;
}

.button-container .send-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(147, 51, 234, 0.4);
}

/* Skip Button */
.skip-btn {
    flex: 1;
    height: 50px;
    padding: 0 24px;
    background: rgba(107, 114, 128, 0.25);
    color: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(107, 114, 128, 0.4);
    border-radius: 25px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}

.skip-btn:hover {
    background: rgba(107, 114, 128, 0.35);
    color: rgba(255, 255, 255, 1);
    border-color: rgba(107, 114, 128, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.skip-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* ===== QUICK REPLIES ===== */

.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.quick-reply-btn {
    padding: 10px 18px;
    border: 2px solid #9333ea;
    background: rgba(147, 51, 234, 0.1);
    color: #ec4899;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.quick-reply-btn:hover {
    background: linear-gradient(135deg, #9333ea, #ec4899);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(147, 51, 234, 0.3);
}

/* ===== ERROR MESSAGE ===== */

.error-message {
    color: #ef4444;
    font-size: 12px;
    margin-top: 4px;
    padding-left: 4px;
    display: none;
}

.error-message.active {
    display: block;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 480px) {
    .chat-container {
        width: calc(100vw - 20px);
        height: calc(100vh - 30px);
        right: 10px;
        bottom: 10px;
    }

    .sagitta-chat-widget {
        right: 10px;
        bottom: 10px;
    }

    .attention-bubble,
    .typing-bubble {
        max-width: 220px;
        font-size: 12px;
    }

    .launcher-container {
        flex-direction: column-reverse;
        align-items: flex-end;
    }

    .attention-bubble::after,
    .typing-bubble::after {
        bottom: -10px;
        right: 28px;
        border-left: 12px solid transparent;
        border-right: 12px solid transparent;
        border-top: 12px solid white;
        border-bottom: none;
    }

    .button-container .send-btn,
    .button-container .skip-btn {
        padding: 0 16px;
        font-size: 13px;
    }

    .button-container .send-btn svg {
        width: 18px;
        height: 18px;
    }
    
    textarea.chat-input {
        min-height: 60px;
    }
}

@media (max-width: 360px) {
    .message-content {
        max-width: 65%;
        font-size: 14px;
    }

    .chat-input {
        font-size: 14px;
    }
}

/* Fallback para navegadores que não suportam :has() */
@supports not (selector(:has(*))) {
    .input-wrapper {
        flex-direction: column;
    }
    
    .input-wrapper > .input-group {
        width: 100%;
    }
    
    .input-wrapper > .send-btn {
        align-self: flex-end;
    }
}