/**
 * Estilos do Chatbot - Rádio Entre Rios
 *
 * Design moderno e responsivo com cores da rádio
 */

/* ========================================
   VARIÁVEIS
======================================== */
:root {
    --chatbot-primary: #FFB580;
    --chatbot-primary-dark: #FF8C42;
    --chatbot-primary-light: #FFC299;
    --chatbot-secondary: #00BFFF;
    --chatbot-bg: #FFFFFF;
    --chatbot-msg-user: #FFB580;
    --chatbot-msg-bot: #F5F5F5;
    --chatbot-text: #333333;
    --chatbot-text-light: #666666;
    --chatbot-border: #E0E0E0;
    --chatbot-shadow: rgba(0, 0, 0, 0.15);
    --chatbot-shadow-lg: rgba(0, 0, 0, 0.25);
    --sticky-player-height: 80px; /* Altura do sticky player */
}

/* ========================================
   CONTAINER PRINCIPAL
======================================== */
.radio-chatbot {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.radio-chatbot.bottom-right {
    bottom: calc(var(--sticky-player-height) + 20px); /* 80px do player + 20px de margem */
    right: 20px;
}

.radio-chatbot.bottom-left {
    bottom: calc(var(--sticky-player-height) + 20px); /* 80px do player + 20px de margem */
    left: 20px;
}

/* ========================================
   BOTÃO FLUTUANTE
======================================== */
.chatbot-toggle {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 181, 128, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(255, 181, 128, 0.5);
}

.chatbot-toggle:active {
    transform: scale(0.95);
}

.chatbot-toggle svg {
    width: 28px;
    height: 28px;
    transition: all 0.3s ease;
}

.chatbot-toggle .icon-close {
    position: absolute;
    opacity: 0;
    transform: rotate(90deg);
}

.radio-chatbot.open .chatbot-toggle .icon-chat {
    opacity: 0;
    transform: rotate(-90deg);
}

.radio-chatbot.open .chatbot-toggle .icon-close {
    opacity: 1;
    transform: rotate(0deg);
}

/* Notification Badge */
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    background: #FF0000;
    color: white;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ========================================
   JANELA DO CHAT
======================================== */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 120px);
    background: var(--chatbot-bg);
    border-radius: 16px;
    box-shadow: 0 8px 32px var(--chatbot-shadow-lg);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.radio-chatbot.open .chatbot-window {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ========================================
   HEADER
======================================== */
.chatbot-header {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chatbot-avatar svg {
    width: 24px;
    height: 24px;
}

.chatbot-title {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 2px;
}

.chatbot-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00FF00;
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chatbot-minimize {
    position: relative;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
    touch-action: manipulation;
    z-index: 10;
}

.chatbot-minimize:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chatbot-minimize svg {
    width: 20px;
    height: 20px;
    pointer-events: none;
}

/* ========================================
   ÁREA DE MENSAGENS
======================================== */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: linear-gradient(to bottom, #F8F9FA 0%, #FFFFFF 100%);
}

/* Scrollbar customizada */
.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--chatbot-border);
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #CCCCCC;
}

/* ========================================
   MENSAGENS
======================================== */
.message {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mensagens do usuário */
.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.user-message .message-content {
    background: var(--chatbot-msg-user);
    color: white;
    border-radius: 16px 16px 4px 16px;
    padding: 10px 14px;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(255, 107, 0, 0.3);
}

.user-message .message-time {
    text-align: right;
    color: var(--chatbot-text-light);
    font-size: 11px;
    margin-top: 4px;
}

/* Mensagens do bot */
.bot-message {
    align-self: flex-start;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--chatbot-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 4px;
}

.message-avatar svg {
    width: 18px;
    height: 18px;
    fill: white;
}

.message-bubble {
    flex: 1;
}

.bot-message .message-content {
    background: var(--chatbot-msg-bot);
    color: var(--chatbot-text);
    border-radius: 16px 16px 16px 4px;
    padding: 10px 14px;
    word-wrap: break-word;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.bot-message .message-content a {
    color: var(--chatbot-primary);
    text-decoration: none;
    border-bottom: 1px solid var(--chatbot-primary);
}

.bot-message .message-content a:hover {
    opacity: 0.8;
}

.bot-message .message-time {
    color: var(--chatbot-text-light);
    font-size: 11px;
    margin-top: 4px;
}

/* Typing indicator */
.typing-indicator .typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 14px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chatbot-text-light);
    animation: typingBounce 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

/* ========================================
   INPUT
======================================== */
.chatbot-input-container {
    flex-shrink: 0;
    border-top: 1px solid var(--chatbot-border);
    background: var(--chatbot-bg);
}

.chatbot-input-wrapper {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    align-items: flex-end;
}

.chatbot-input {
    flex: 1;
    border: 1px solid var(--chatbot-border);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    min-height: 40px;
    max-height: 120px;
    transition: border-color 0.2s;
}

.chatbot-input:focus {
    border-color: var(--chatbot-primary);
}

.chatbot-input::placeholder {
    color: var(--chatbot-text-light);
}

.chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--chatbot-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    color: white;
}

.chatbot-send:hover {
    background: var(--chatbot-primary-dark);
    transform: scale(1.05);
}

.chatbot-send:active {
    transform: scale(0.95);
}

.chatbot-send svg {
    width: 20px;
    height: 20px;
}

.chatbot-footer {
    text-align: center;
    padding: 8px 16px 12px;
    font-size: 11px;
    color: var(--chatbot-text-light);
}

/* ========================================
   BACKDROP MOBILE
======================================== */
.chatbot-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9997;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.radio-chatbot.open .chatbot-backdrop {
    opacity: 1;
    pointer-events: auto;
}

/* ========================================
   RESPONSIVIDADE
======================================== */
@media (max-width: 480px) {
    .radio-chatbot.bottom-right,
    .radio-chatbot.bottom-left {
        bottom: calc(var(--sticky-player-height) + 20px);
        left: 10px;
        right: 10px;
    }

    .chatbot-window {
        position: fixed !important;
        width: calc(100vw - 20px) !important;
        max-width: calc(100vw - 20px) !important;
        height: 500px !important;
        max-height: calc(100vh - var(--sticky-player-height) - 100px) !important;
        bottom: 80px !important;
        left: 0 !important;
        right: 0 !important;
        border-radius: 20px !important;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3) !important;
        z-index: 9998 !important;
    }

    .chatbot-toggle {
        position: fixed;
        bottom: calc(var(--sticky-player-height) + 20px); /* Acima do player no mobile também */
        right: 20px;
        width: 56px;
        height: 56px;
    }

    .chatbot-toggle svg {
        width: 24px;
        height: 24px;
    }

    .radio-chatbot.bottom-left .chatbot-toggle {
        left: 20px;
        right: auto;
    }

    /* Header redesenhado para mobile */
    .chatbot-header {
        padding: 16px;
        position: relative;
        z-index: 100;
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    }

    .chatbot-header-info {
        flex: 1;
        gap: 10px;
    }

    .chatbot-avatar {
        width: 44px;
        height: 44px;
    }

    .chatbot-avatar svg {
        width: 24px;
        height: 24px;
    }

    .chatbot-title {
        font-size: 16px;
        font-weight: 700;
    }

    .chatbot-status {
        font-size: 12px;
    }

    /* Botão de fechar GIGANTE e ÓBVIO no mobile */
    .chatbot-minimize {
        position: relative !important;
        width: 56px !important;
        height: 56px !important;
        min-width: 56px !important;
        min-height: 56px !important;
        background: rgba(255, 255, 255, 0.95) !important;
        cursor: pointer !important;
        -webkit-tap-highlight-color: transparent !important;
        touch-action: manipulation !important;
        z-index: 99999 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border: none !important;
        border-radius: 50% !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
        margin-left: 12px !important;
    }

    .chatbot-minimize:hover,
    .chatbot-minimize:active,
    .chatbot-minimize:focus {
        background: rgba(255, 255, 255, 1) !important;
        transform: scale(1.1) !important;
    }

    .chatbot-minimize svg {
        width: 32px !important;
        height: 32px !important;
        pointer-events: none !important;
        fill: #FF6B00 !important;
    }

    .chatbot-minimize svg path {
        fill: #FF6B00 !important;
        stroke: #FF6B00 !important;
        stroke-width: 1 !important;
    }

    /* Remove label "Fechar" no mobile para não confundir */
    .chatbot-close-btn::after {
        display: none !important;
    }

    /* Mensagens com melhor espaçamento no mobile */
    .chatbot-messages {
        padding: 16px 12px;
    }

    .message {
        max-width: 90%;
    }

    .message-content {
        font-size: 14px;
        padding: 10px 12px;
    }

    /* Input otimizado e MAIOR para mobile */
    .chatbot-input-wrapper {
        padding: 14px 16px;
        gap: 12px;
    }

    .chatbot-input {
        font-size: 16px !important; /* Evita zoom automático no iOS */
        padding: 14px 16px !important;
        border-radius: 24px !important;
        border: 2px solid var(--chatbot-border) !important;
    }

    .chatbot-input:focus {
        border-color: var(--chatbot-primary) !important;
        box-shadow: 0 0 0 3px rgba(255, 181, 128, 0.2) !important;
    }

    .chatbot-send {
        width: 48px !important;
        height: 48px !important;
        min-width: 48px !important;
        min-height: 48px !important;
        background: var(--chatbot-primary) !important;
        box-shadow: 0 4px 12px rgba(255, 107, 0, 0.3) !important;
    }

    .chatbot-send:active {
        transform: scale(0.95) !important;
    }

    .chatbot-send svg {
        width: 24px !important;
        height: 24px !important;
    }

    .chatbot-footer {
        padding: 6px 12px 10px;
        font-size: 10px;
    }
}

/* ========================================
   ACESSIBILIDADE
======================================== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visível para navegação por teclado */
.chatbot-toggle:focus-visible,
.chatbot-minimize:focus-visible,
.chatbot-send:focus-visible {
    outline: 2px solid var(--chatbot-secondary);
    outline-offset: 2px;
}

.chatbot-input:focus-visible {
    border-color: var(--chatbot-primary);
    box-shadow: 0 0 0 3px rgba(255, 181, 128, 0.1);
}

/* ========================================
   MODO ESCURO (Opcional)
======================================== */
@media (prefers-color-scheme: dark) {
    :root {
        --chatbot-bg: #1E1E1E;
        --chatbot-msg-bot: #2D2D2D;
        --chatbot-text: #E0E0E0;
        --chatbot-text-light: #A0A0A0;
        --chatbot-border: #3D3D3D;
    }

    .chatbot-messages {
        background: linear-gradient(to bottom, #1A1A1A 0%, #1E1E1E 100%);
    }

    .chatbot-input {
        background: #2D2D2D;
        color: var(--chatbot-text);
    }
}
