/**
 * Chat SOAT Profesional — Estilos del Widget
 *
 * Widget flotante de chat para consulta de SOAT
 * con integración WhatsApp y consulta RUNT.
 *
 * @package Chat_SOAT_Profesional
 * @version 1.0.3
 */

/* ═══════════════════════════════════════════════════
   CSS VARIABLES (defaults — override via WP admin)
   ═══════════════════════════════════════════════════ */
:root {
    --csp-primary: #25d366;
    --csp-header: #0f172a;
    --csp-user-msg: #1e4a8a;
    --csp-position-right: 25px;
    --csp-position-left: auto;
    --csp-bot-bg: #ffffff;
    --csp-chat-bg: #f0f2f5;
}

/* ═══════════════════════════════════════════════════
   RESET — Evitar conflictos con temas de WordPress
   ═══════════════════════════════════════════════════ */
#csp-widget,
#csp-widget *,
#csp-widget *::before,
#csp-widget *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.5;
}

/* ═══════════════════════════════════════════════════
   BURBUJA FLOTANTE
   ═══════════════════════════════════════════════════ */
.csp-bubble {
    position: fixed;
    bottom: 25px;
    right: var(--csp-position-right);
    left: var(--csp-position-left);
    width: var(--csp-bubble-size, 64px);
    height: var(--csp-bubble-size, 64px);
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #fff;
    cursor: pointer;
    z-index: 99999;
    box-shadow: none;
    animation: csp-pulse 2s infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    outline: none;
}

.csp-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.csp-bubble:active {
    transform: scale(0.95);
}

.csp-bubble-svg {
    width: var(--csp-bubble-icon, 30px);
    height: var(--csp-bubble-icon, 30px);
}

.csp-hidden {
    display: none !important;
}

@keyframes csp-pulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.08); }
    100% { transform: scale(1); }
}

.csp-bubble.csp-open {
    animation: none;
}

/* ═══════════════════════════════════════════════════
   PANEL DEL CHAT
   ═══════════════════════════════════════════════════ */
.csp-panel {
    position: fixed;
    bottom: 100px;
    right: var(--csp-position-right);
    left: var(--csp-position-left);
    width: var(--csp-panel-width, 420px);
    max-height: var(--csp-panel-height, 650px);
    background: #fff;
    border-radius: 22px;
    overflow: hidden;
    display: none;
    flex-direction: column;
    box-shadow: 0 12px 45px rgba(0, 0, 0, 0.22);
    z-index: 99998;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.csp-panel.csp-open {
    display: flex;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* ═══════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════ */
.csp-header {
    background: var(--csp-header);
    color: #fff;
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.csp-header-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.csp-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}

.csp-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.csp-avatar-default svg {
    width: 28px;
    height: 28px;
}

.csp-header-text {
    display: flex;
    flex-direction: column;
}

.csp-header-title {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
}

.csp-header-status {
    font-size: 13px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.csp-online-dot {
    width: 8px;
    height: 8px;
    background: #25d366;
    border-radius: 50%;
    display: inline-block;
    animation: csp-blink 2s infinite;
}

@keyframes csp-blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}

.csp-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    outline: none;
}

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

.csp-close-btn svg {
    width: 24px;
    height: 24px;
}

/* ═══════════════════════════════════════════════════
   ÁREA DE MENSAJES — Márgenes MUY amplios
   ═══════════════════════════════════════════════════ */
.csp-messages {
    flex: 1;
    padding: var(--csp-chat-padding, 24px);
    overflow-y: auto;
    background: var(--csp-chat-bg);
    min-height: 200px;
    max-height: 440px;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
}

/* Scrollbar personalizado */
.csp-messages::-webkit-scrollbar {
    width: 5px;
}

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

.csp-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* ═══════════════════════════════════════════════════
   MENSAJES — GRANDES, SEPARADOS, LEGIBLES
   ═══════════════════════════════════════════════════ */
.csp-msg {
    padding: var(--csp-msg-padding, 20px 24px) !important;
    border-radius: var(--csp-msg-radius, 22px);
    margin-bottom: var(--csp-msg-margin, 16px) !important;
    font-size: var(--csp-msg-font-size, 17px) !important;
    line-height: 1.75;
    max-width: var(--csp-msg-max-width, 85%);
    word-wrap: break-word;
    overflow-wrap: break-word;
    animation: csp-fadeIn 0.3s ease;
    display: block;
}

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

/* Mensajes del bot — pegado a la IZQUIERDA */
.csp-msg.csp-bot {
    background: var(--csp-bot-bg);
    color: #1a1a2e;
    border-bottom-left-radius: 6px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.08);
    align-self: flex-start;
    margin-right: auto;
    margin-left: 0;
}

.csp-msg.csp-bot strong {
    font-weight: 700;
    color: #0f172a;
}

/* Mensajes del usuario — pegado a la DERECHA */
.csp-msg.csp-user {
    background: #1e4a8a;
    color: #fff;
    align-self: flex-end;
    margin-left: auto;
    margin-right: 0;
    border-bottom-right-radius: 6px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.12);
    font-size: 15px;
}

/* ═══════════════════════════════════════════════════
   INDICADOR DE ESCRITURA (typing)
   ═══════════════════════════════════════════════════ */
.csp-typing {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 16px 22px;
    background: var(--csp-bot-bg);
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    margin-bottom: 24px;
    max-width: 80px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.08);
}

.csp-typing-dot {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: csp-typing-bounce 1.4s infinite ease-in-out;
}

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

@keyframes csp-typing-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%           { transform: scale(1); opacity: 1; }
}

/* ═══════════════════════════════════════════════════
   BOTONES DE ACCIÓN — Grandes y visibles
   ═══════════════════════════════════════════════════ */
.csp-actions {
    display: flex !important;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px !important;
    margin-bottom: 24px !important;
    padding: 0 !important;
    animation: csp-fadeIn 0.3s ease;
    width: 100%;
}

.csp-action-btn {
    border: none !important;
    padding: 18px 24px !important;
    border-radius: 14px !important;
    cursor: pointer !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    text-align: center !important;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px;
    line-height: 1.4 !important;
    text-decoration: none !important;
    letter-spacing: 0.01em;
    text-transform: uppercase;
    width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    -webkit-appearance: none !important;
    appearance: none !important;
}

.csp-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18) !important;
    text-decoration: none !important;
}

.csp-action-btn:active {
    transform: translateY(0);
}

.csp-action-btn.csp-btn-primary {
    background: var(--csp-header) !important;
    color: #fff !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2) !important;
}

.csp-action-btn.csp-btn-secondary {
    background: #e2e8f0 !important;
    color: #475569 !important;
}

.csp-action-btn.csp-btn-danger {
    background: #fee2e2 !important;
    color: #dc2626 !important;
}

/* Botón WhatsApp */
.csp-action-btn.csp-btn-whatsapp {
    background: #25d366 !important;
    color: #fff !important;
    font-size: 16px !important;
    padding: 18px 28px !important;
    border-radius: 16px !important;
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.35) !important;
}

.csp-action-btn.csp-btn-whatsapp:hover {
    background: #20bd5a !important;
    color: #fff !important;
    box-shadow: 0 8px 24px rgba(37, 211, 102, 0.45) !important;
}

.csp-wa-icon {
    width: 24px;
    height: 24px;
    display: inline-flex;
}

/* ═══════════════════════════════════════════════════
   ÁREA DE INPUT — Grande y cómodo
   ═══════════════════════════════════════════════════ */
.csp-input-area {
    display: flex !important;
    align-items: center !important;
    gap: 10px;
    padding: 14px 16px !important;
    border-top: 1px solid #e2e8f0 !important;
    background: #ffffff !important;
    flex-shrink: 0;
}

.csp-input {
    flex: 1 !important;
    border: 1.5px solid #d1d5db !important;
    border-radius: 50px !important;
    padding: 13px 20px !important;
    font-size: 15px !important;
    outline: none !important;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #ffffff !important;
    color: #1e293b !important;
    min-width: 0;
    height: var(--csp-input-height, 52px) !important;
    font-size: var(--csp-msg-font-size, 16px) !important;
    box-shadow: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    line-height: normal !important;
    margin: 0 !important;
}

.csp-input:focus {
    border-color: var(--csp-primary);
    box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.12);
}

.csp-input::placeholder {
    color: #94a3b8 !important;
    font-size: 15px !important;
    opacity: 1 !important;
}

.csp-input:disabled {
    background: #f1f5f9;
    cursor: not-allowed;
    opacity: 0.7;
}

.csp-send-btn {
    width: 52px;
    height: 52px;
    min-width: 52px;
    border: none;
    border-radius: 50%;
    background: var(--csp-primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, background 0.2s;
    outline: none;
    box-shadow: 0 3px 10px rgba(37, 211, 102, 0.25);
}

.csp-send-btn:hover {
    background: #20bd5a;
    transform: scale(1.05);
}

.csp-send-btn:active {
    transform: scale(0.95);
}

.csp-send-btn svg {
    width: 22px;
    height: 22px;
}

.csp-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}


/* ═══════════════════════════════════════════════════
   PANTALLA DE BIENVENIDA
   ═══════════════════════════════════════════════════ */
.csp-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--csp-chat-bg);
    padding: 40px 28px;
    gap: 24px;
}

.csp-welcome-text {
    font-size: 17px !important;
    color: #475569;
    text-align: center;
    line-height: 1.6;
    margin: 0 !important;
    padding: 0 !important;
}

.csp-start-btn {
    background: var(--csp-header);
    color: #fff;
    border: none;
    border-radius: 14px;
    padding: 18px 40px !important;
    font-size: 15px !important;
    font-weight: 700;
    letter-spacing: .06em;
    cursor: pointer;
    width: 100%;
    max-width: 320px;
    transition: opacity 0.2s;
    margin: 0 !important;
}

.csp-start-btn:hover {
    opacity: 0.85;
}

/* ═══════════════════════════════════════════════════
   TIMESTAMP DE MENSAJES
   ═══════════════════════════════════════════════════ */
.csp-msg-time {
    display: block;
    font-size: 11px !important;
    opacity: 0.55;
    margin-top: 5px !important;
    padding: 0 !important;
    text-align: right;
    line-height: 1;
}

.csp-msg.csp-bot .csp-msg-time {
    text-align: left;
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE — Mobile
   ═══════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .csp-panel {
        width: calc(100vw - 20px);
        right: 10px !important;
        left: 10px !important;
        bottom: 90px;
        max-height: calc(100vh - 110px);
        border-radius: 18px;
    }

    .csp-messages {
        max-height: calc(100vh - 260px);
        padding: 22px;
    }

    .csp-msg {
        max-width: 85%;
        font-size: 15px;
        padding: 16px 18px !important;
        margin-bottom: 14px !important;
    }

    .csp-msg.csp-user {
        font-size: 14.5px;
    }

    .csp-input-area {
        padding: 16px 18px;
    }

    .csp-input {
        padding: 13px 20px;
        font-size: 15px;
    }

    .csp-input::placeholder {
        font-size: 14px;
    }

    .csp-action-btn {
        padding: 15px 20px;
        font-size: 14px;
    }

    .csp-action-btn.csp-btn-whatsapp {
        font-size: 15px;
        padding: 16px 22px;
    }

    .csp-bubble {
        width: 58px;
        height: 58px;
        bottom: 20px;
        right: 15px !important;
        left: auto !important;
    }

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

    .csp-header {
        padding: 14px 18px;
    }

    .csp-header-title {
        font-size: 15px;
    }

    .csp-typing {
        margin-bottom: 20px;
    }

    .csp-send-btn {
        width: 48px;
        height: 48px;
        min-width: 48px;
    }
}

@media (max-width: 360px) {
    .csp-panel {
        width: calc(100vw - 14px);
        right: 7px !important;
        left: 7px !important;
    }

    .csp-header {
        padding: 12px 16px;
    }

    .csp-avatar {
        width: 40px;
        height: 40px;
    }

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

    .csp-header-status {
        font-size: 11px;
    }

    .csp-messages {
        padding: 24px 22px;
    }

    .csp-msg {
        font-size: 15px;
        padding: 14px 16px !important;
        margin-bottom: 18px !important;
    }

    .csp-input-area {
        padding: 14px 14px;
    }

    .csp-input {
        padding: 12px 18px;
        font-size: 14px;
    }
}

/* ═══════════════════════════════════════════════════
   NUEVOS ESTILOS v1.0.4
   ═══════════════════════════════════════════════════ */

/* Botones de tipo de documento en columna */
.csp-actions.csp-actions-col {
    flex-direction: column !important;
}

/* Botón opción (tipo documento) */
.csp-action-btn.csp-btn-option {
    background: #f0fdf4 !important;
    color: #166534 !important;
    border: 2px solid #86efac !important;
    font-size: 14px !important;
    padding: 13px 20px !important;
    text-transform: none !important;
    font-weight: 600 !important;
    letter-spacing: 0 !important;
    justify-content: flex-start !important;
}

.csp-action-btn.csp-btn-option:hover {
    background: #dcfce7 !important;
    border-color: #4ade80 !important;
    color: #14532d !important;
}

/* Botones de acción (Cotizar / Descargar) en fila */
.csp-actions:not(.csp-actions-col) {
    flex-direction: row !important;
    flex-wrap: wrap !important;
}

.csp-actions:not(.csp-actions-col) .csp-action-btn {
    flex: 1 1 140px !important;
    min-width: 130px !important;
}

/* Botón Descargar SOAT */
.csp-action-btn.csp-btn-secondary {
    background: #eff6ff !important;
    color: #1d4ed8 !important;
    border: 2px solid #93c5fd !important;
}

.csp-action-btn.csp-btn-secondary:hover {
    background: #dbeafe !important;
    border-color: #60a5fa !important;
}

/* Botón Descarga SURA */
.csp-action-btn.csp-btn-descarga {
    background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 100%) !important;
    color: #fff !important;
    border: none !important;
    font-size: 15px !important;
    padding: 16px 24px !important;
    border-radius: 16px !important;
    box-shadow: 0 6px 20px rgba(29, 78, 216, 0.35) !important;
    text-transform: none !important;
    font-weight: 700 !important;
    letter-spacing: 0 !important;
}

.csp-action-btn.csp-btn-descarga:hover {
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%) !important;
    box-shadow: 0 8px 24px rgba(29, 78, 216, 0.45) !important;
    color: #fff !important;
}

/* Opacidad visual cuando input está deshabilitado */
#csp-input-area[style*="opacity: 0.5"] {
    pointer-events: none;
}
