/*
 * Estilos para el módulo ps_whatsappbutton (Doble Acción)
 */

:root {
    --color-whatsapp: #25D366;
    --color-crm: #007bff;
    --color-shadow: rgba(0, 0, 0, 0.25);
    --border-radius-lg: 12px;
    --border-radius-sm: 8px;
}

.whatsapp-crm-container {
    position: fixed;
    bottom: 25px; /* Ligeramente más arriba del borde */
    right: 25px;
    z-index: 1000;
}

/* --- Botón Principal --- */

.whatsapp-crm-main-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    
    /* Fondo degradado: CRM (azul) en la esquina superior izquierda, WhatsApp (verde) en la inferior derecha */
    background: linear-gradient(135deg, var(--color-crm) 50%, var(--color-whatsapp) 50%);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 15px var(--color-shadow);
    
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden; 
}

.whatsapp-crm-main-button:hover {
    transform: scale(1.1); /* Efecto de "rebote" más notorio */
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

/* Contenedor y ajuste de íconos */
.main-button-icons {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    position: relative;
}

.main-button-icons .bi-whatsapp {
  top: 10px;
  position: relative;
  right: -20px;
}

.main-button-icons .bi-envelope {
  position: relative;
  top: -10px;
  right: 20px;
}


/* --- Popover de Opciones (Menú) --- */

.whatsapp-crm-popover {
    position: absolute;
    bottom: 85px; 
    right: 0;
    width: 320px;
    background: #fff;
    border-radius: var(--border-radius-lg);
    box-shadow: 0 10px 30px var(--color-shadow);
    overflow: hidden;
    z-index: 999;
    opacity: 1;
    transition: opacity 0.3s ease, transform 0.3s ease;
    /* Apunta hacia el botón (pequeño triángulo) - Opcional */
    /* &::after { ... } */
}

.whatsapp-crm-popover.hidden {
    display: none;
    opacity: 0;
    transform: translateY(10px);
}

.popover-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px; 
    background-color: #f7f7f7; 
    border-bottom: 1px solid #e0e0e0;
}

.popover-header h4 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #333;
}

.close-popover {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #888;
    line-height: 1;
    transition: color 0.1s;
}

.close-popover:hover {
    color: #555;
}

.popover-content {
    padding: 15px; 
}

/* --- Opciones Individuales (Estilo de Lista de Chat) --- */

.channel-option {
    display: flex;
    align-items: center;
    padding: 12px 10px; 
    margin-bottom: 10px;
    border-radius: var(--border-radius-sm); 
    text-decoration: none;
    color: #333;
    border: 1px solid #f0f0f0; /* Borde más sutil */
    background-color: #ffffff; 
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); 
    transition: background-color 0.2s, border-color 0.2s, transform 0.1s, box-shadow 0.2s;
    width: 100%;
    text-align: left;
}

.channel-option:hover {
    transform: translateY(-1px); 
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* Sombra más fuerte al hacer hover */
}

.whatsapp-channel:hover {
    border-color: var(--color-whatsapp);
    background-color: #eafaea;
}

.crm-form-channel:hover {
    border-color: var(--color-crm);
    background-color: #e6f2ff;
}

.channel-icon {
    margin-right: 15px;
    min-width: 24px; 
}

.channel-details {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.channel-name {
    font-weight: 600;
    font-size: 15px; 
    line-height: 1.2;
}

.channel-description {
    font-size: 0.8rem; /* Más pequeño */
    color: #777;
    margin-top: 2px;
}

/* --- Modal del CRM (Iframe) --- */

.crm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1010; 
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease;
}

.crm-modal.hidden {
    display: none;
}

.crm-modal-content {
    background: #fff;
    width: 90%;
    max-width: 900px; 
    height: 90%;
    border-radius: var(--border-radius-lg);
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.close-crm-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #fff;
    border: none;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    font-size: 24px;
    cursor: pointer;
    color: #333;
    z-index: 10;
    line-height: 35px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: background-color 0.1s;
}

.close-crm-modal:hover {
    background-color: #eee;
}

#crm-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* --- Lógica del Botón Principal --- */

/* Caso 1: Doble Acción (Ambos activos) */
.whatsapp-crm-main-button.is-double {
    background: linear-gradient(135deg, var(--color-crm) 50%, var(--color-whatsapp) 50%);
}
.whatsapp-crm-main-button.is-double .icon-ws {
    top: 10px;
    position: relative;
    right: -20px; /* Ajustado para que no se salga tanto */
}
.whatsapp-crm-main-button.is-double .icon-mail {
    position: relative;
    top: -10px;
    right: 20px; /* Ajustado */
}

/* Caso 2: Solo WhatsApp activo */
.whatsapp-crm-main-button.only-whatsapp {
    background: var(--color-whatsapp) !important;
}
.whatsapp-crm-main-button.only-whatsapp .icon-ws {
    transform: scale(1.5); /* Más grande al estar solo */
    top: 0;
    right: 0;
}

/* Caso 3: Solo CRM activo */
.whatsapp-crm-main-button.only-crm {
    background: var(--color-crm) !important;
}
.whatsapp-crm-main-button.only-crm .icon-mail {
    transform: scale(1.5); /* Más grande al estar solo */
    top: 0;
    right: 0;
}

/* Ajuste general para que los iconos centrados funcionen */
.main-button-icons {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}