/* =============================================
   Chat Widget - CFP 12
   ============================================= */

/* --- Widget Container --- */
#chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* --- Botón flotante --- */
#chat-button {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #1a73e8, #0d47a1);
    color: #fff;
    padding: 14px 24px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(26, 115, 232, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    user-select: none;
}

#chat-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(26, 115, 232, 0.5);
}

/* --- Ventana de Chat --- */
#chat-window {
    width: 440px;
    height: 600px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

#chat-window.hidden {
    display: none;
}

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

/* --- Header --- */
.chat-header {
    background: linear-gradient(135deg, #1a73e8, #0d47a1);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 16px;
    font-weight: 600;
    flex-shrink: 0;
}

.close-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
    line-height: 1;
}

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

/* --- Mensajes --- */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f7f8fa;
}

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

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

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

.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: fadeIn 0.2s ease-out;
}

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

.bot-message {
    background: #fff;
    color: #1a1a2e;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.user-message {
    background: linear-gradient(135deg, #1a73e8, #1565c0);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* --- Input --- */
.chat-input {
    display: flex;
    padding: 12px 16px;
    gap: 10px;
    border-top: 1px solid #e8eaed;
    background: #fff;
    flex-shrink: 0;
}

.chat-input input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #dadce0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input input:focus {
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}

.chat-input button {
    background: linear-gradient(135deg, #1a73e8, #0d47a1);
    color: #fff;
    border: none;
    padding: 12px 20px;
    border-radius: 24px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: transform 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}

.chat-input button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26, 115, 232, 0.35);
}

.chat-input button:active {
    transform: translateY(0);
}

/* =============================================
   RESPONSIVE - Celular
   ============================================= */

/* Tablets y pantallas chicas */
@media (max-width: 768px) {
    #chat-widget {
        bottom: 16px;
        right: 16px;
    }

    #chat-window {
        width: calc(100vw - 32px);
        height: 70vh;
    }
}

/* Celulares - Pantalla completa */
@media (max-width: 480px) {
    #chat-widget {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        pointer-events: none;
    }

    #chat-button {
        position: fixed;
        bottom: 16px;
        right: 16px;
        pointer-events: all;
    }

    #chat-window {
        width: 100vw;
        height: 100vh;
        height: 100dvh; /* dynamic viewport height para celulares */
        border-radius: 0;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        pointer-events: all;
    }

    .chat-header {
        padding: 16px 20px;
        /* safe area para notch de iPhones */
        padding-top: max(16px, env(safe-area-inset-top));
    }

    .chat-input {
        /* safe area para barra de navegación de iPhones */
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
}
