/* ===== ONE4CARS AI Chat Widget ===== */
/* Colores de marca: Azul #0b2a4a | Dorado #d4a017 | Rojo #D9001D */

:root {
    --o4c-blue: #0b2a4a;
    --o4c-blue-dark: #001F4F;
    --o4c-gold: #d4a017;
    --o4c-gold-light: #e9b52c;
    --o4c-red: #D9001D;
    --o4c-white: #ffffff;
    --o4c-gray-light: #f4f6f8;
    --o4c-gray: #6c757d;
    --o4c-shadow: 0 8px 32px rgba(11, 42, 74, 0.25);
}

/* ===== BUBBLE (Botón flotante) ===== */
.o4c-chat-bubble {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 65px;
    height: 65px;
    background: linear-gradient(135deg, var(--o4c-blue) 0%, var(--o4c-blue-dark) 100%);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(11, 42, 74, 0.4);
    transition: all 0.3s ease;
    z-index: 9999;
    border: 3px solid var(--o4c-gold);
}

.o4c-chat-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 28px rgba(11, 42, 74, 0.5);
}

.o4c-chat-bubble svg {
    width: 32px;
    height: 32px;
    fill: var(--o4c-white);
    transition: all 0.3s ease;
}

.o4c-chat-bubble:hover svg {
    transform: scale(1.1);
}

/* Estado cuando el chat está abierto */
.o4c-chat-bubble.active svg.icon-chat {
    display: none;
}

.o4c-chat-bubble:not(.active) svg.icon-close {
    display: none;
}

/* Indicador de "typing" */
.o4c-chat-bubble::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    background: var(--o4c-red);
    border-radius: 50%;
    border: 2px solid var(--o4c-white);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.o4c-chat-bubble.typing::after {
    opacity: 1;
    animation: o4c-pulse 1.5s infinite;
}

@keyframes o4c-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
}

/* ===== VENTANA DE CHAT ===== */
.o4c-chat-window {
    position: fixed;
    bottom: 110px;
    left: 30px;
    width: 400px;
    max-width: calc(100vw - 30px);
    height: 550px;
    max-height: calc(100vh - 140px);
    background: var(--o4c-white);
    border-radius: 16px;
    box-shadow: var(--o4c-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(11, 42, 74, 0.1);
}

.o4c-chat-window.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ===== HEADER ===== */
.o4c-chat-header {
    background: linear-gradient(135deg, var(--o4c-blue) 0%, var(--o4c-blue-dark) 100%);
    color: var(--o4c-white);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 3px solid var(--o4c-gold);
}

.o4c-chat-header-avatar {
    width: 45px;
    height: 45px;
    background: var(--o4c-gold);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    color: var(--o4c-blue);
    flex-shrink: 0;
}

.o4c-chat-header-info {
    flex: 1;
}

.o4c-chat-header-title {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.o4c-chat-header-subtitle {
    font-size: 12px;
    opacity: 0.85;
    margin: 2px 0 0 0;
}

.o4c-chat-header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
}

.o4c-chat-header-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #28a745;
    border-radius: 50%;
    animation: o4c-blink 2s infinite;
}

@keyframes o4c-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== MENSAJES ===== */
.o4c-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--o4c-gray-light);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

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

.o4c-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(11, 42, 74, 0.2);
    border-radius: 3px;
}

/* Mensaje del usuario */
.o4c-msg-user {
    align-self: flex-end;
    max-width: 85%;
}

.o4c-msg-user .o4c-msg-bubble {
    background: linear-gradient(135deg, var(--o4c-blue) 0%, var(--o4c-blue-dark) 100%);
    color: var(--o4c-white);
    padding: 12px 16px;
    border-radius: 16px 16px 4px 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(11, 42, 74, 0.2);
}

/* Mensaje del bot */
.o4c-msg-bot {
    align-self: flex-start;
    max-width: 85%;
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.o4c-msg-bot-avatar {
    width: 32px;
    height: 32px;
    background: var(--o4c-gold);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    color: var(--o4c-blue);
    flex-shrink: 0;
}

.o4c-msg-bot .o4c-msg-bubble {
    background: var(--o4c-white);
    color: #333;
    padding: 12px 16px;
    border-radius: 16px 16px 16px 4px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(11, 42, 74, 0.08);
}

/* Enlaces dentro de mensajes */
.o4c-msg-bubble a {
    color: var(--o4c-gold);
    text-decoration: underline;
    font-weight: 600;
}

.o4c-msg-bot .o4c-msg-bubble a {
    color: var(--o4c-blue);
}

/* ===== INDICADOR DE ESCRITURA ===== */
.o4c-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 4px;
}

.o4c-typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--o4c-gray);
    border-radius: 50%;
    animation: o4c-typing 1.4s infinite;
}

.o4c-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.o4c-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes o4c-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-8px); opacity: 1; }
}

/* ===== INPUT ===== */
.o4c-chat-input {
    padding: 16px;
    background: var(--o4c-white);
    border-top: 1px solid rgba(11, 42, 74, 0.1);
    display: flex;
    gap: 10px;
    align-items: center;
}

.o4c-chat-input input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid rgba(11, 42, 74, 0.15);
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s ease;
    font-family: inherit;
}

.o4c-chat-input input:focus {
    border-color: var(--o4c-gold);
}

.o4c-chat-input input::placeholder {
    color: var(--o4c-gray);
}

.o4c-chat-input button {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, var(--o4c-gold) 0%, var(--o4c-gold-light) 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.o4c-chat-input button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(212, 160, 23, 0.4);
}

.o4c-chat-input button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.o4c-chat-input button svg {
    width: 20px;
    height: 20px;
    fill: var(--o4c-blue);
}

/* ===== FOOTER ===== */
.o4c-chat-footer {
    padding: 8px 16px;
    background: var(--o4c-white);
    border-top: 1px solid rgba(11, 42, 74, 0.05);
    text-align: center;
    font-size: 11px;
    color: var(--o4c-gray);
}

.o4c-chat-footer a {
    color: var(--o4c-blue);
    text-decoration: none;
    font-weight: 600;
}

/* ===== BIENVENIDA ===== */
.o4c-welcome-card {
    background: linear-gradient(135deg, rgba(11, 42, 74, 0.05) 0%, rgba(212, 160, 23, 0.1) 100%);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 8px;
    border: 1px solid rgba(212, 160, 23, 0.2);
}

.o4c-welcome-card h4 {
    margin: 0 0 8px 0;
    font-size: 15px;
    color: var(--o4c-blue);
}

.o4c-welcome-card p {
    margin: 0;
    font-size: 13px;
    color: #555;
    line-height: 1.5;
}

.o4c-welcome-card .o4c-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    justify-content: center;
}

.o4c-welcome-card .o4c-quick-btn {
    background: var(--o4c-white);
    border: 1px solid var(--o4c-blue);
    color: var(--o4c-blue);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.o4c-welcome-card .o4c-quick-btn:hover {
    background: var(--o4c-blue);
    color: var(--o4c-white);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
    .o4c-chat-bubble {
        bottom: 20px;
        left: 20px;
        width: 55px;
        height: 55px;
    }

    .o4c-chat-bubble svg {
        width: 26px;
        height: 26px;
    }

    .o4c-chat-window {
        bottom: 90px;
        left: 10px;
        right: 10px;
        width: auto;
        height: calc(100vh - 120px);
        border-radius: 12px;
    }

    .o4c-chat-header {
        padding: 12px 16px;
    }

    .o4c-chat-header-avatar {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }

    .o4c-chat-header-title {
        font-size: 14px;
    }

    .o4c-chat-messages {
        padding: 16px;
    }

    .o4c-chat-input {
        padding: 12px;
    }
}

/* ===== ANIMACIÓN DE ENTRADA ===== */
@keyframes o4c-slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.o4c-msg-animate {
    animation: o4c-slideIn 0.3s ease forwards;
}
