/* Template Selector Styles - CON ESPACIO RESERVADO SIEMPRE */

.cst-template-selector-container {
    margin-bottom: 10px;
    padding: 8px 12px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    display: flex !important; /* SIEMPRE VISIBLE PARA RESERVAR ESPACIO */
    align-items: center;
    gap: 10px;
    min-height: 42px; /* RESERVAR ESPACIO MÍNIMO SIEMPRE */
    visibility: visible; /* Por defecto visible para reservar espacio */
}

/* Cuando está oculto con visibility: hidden, mantiene el espacio */
.cst-template-selector-container[style*="visibility: hidden"] {
    opacity: 0.3; /* Semi-transparente cuando no hay plantillas */
    pointer-events: none; /* No interactivo cuando está oculto */
}

.cst-template-label {
    font-size: 13px;
    font-weight: 600;
    color: #646970;
    margin: 0;
    white-space: nowrap;
}

.cst-template-selector {
    flex: 1;
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
    color: #1d2327;
    max-width: 300px;
    transition: border-color 0.3s ease;
}

.cst-template-selector:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1);
}

.cst-template-selector option {
    padding: 5px;
}

/* Estilos para admin */
.wp-admin .cst-template-selector-container {
    background: #f6f7f7;
    border: 1px solid #c3c4c7;
}

.wp-admin .cst-template-selector {
    border: 1px solid #8c8f94;
}

.wp-admin .cst-template-selector:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

/* Estilos para frontend */
.cst-user-panel .cst-template-selector-container {
    background: rgba(0, 124, 186, 0.05);
    border: 1px solid rgba(0, 124, 186, 0.2);
}

/* CRÍTICO: Asegurar que el área de mensajes tenga espacio fijo */
.cst-conversation-messages {
    margin-bottom: 180px !important; /* Espacio fijo grande desde el principio */
}

/* Área de respuesta con altura fija */
.cst-conversation-reply {
    min-height: 160px !important; /* Altura mínima fija */
}

/* Responsive */
@media screen and (max-width: 768px) {
    .cst-template-selector-container {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        min-height: 50px; /* Más espacio en móvil */
    }
    
    .cst-template-label {
        text-align: left;
    }
    
    .cst-template-selector {
        max-width: none;
    }
    
    /* Más espacio en móvil */
    .cst-conversation-messages {
        margin-bottom: 220px !important;
    }
    
    .cst-conversation-reply {
        min-height: 200px !important;
    }
}

@media screen and (max-width: 480px) {
    .cst-conversation-messages {
        margin-bottom: 250px !important;
    }
    
    .cst-conversation-reply {
        min-height: 230px !important;
    }
    
    .cst-template-selector-container {
        min-height: 60px;
    }
}

/* Animación cuando se hace completamente visible */
.cst-template-selector-container.cst-show {
    opacity: 1 !important;
    animation: cst-fade-in 0.3s ease-out;
}

@keyframes cst-fade-in {
    from {
        opacity: 0.3;
    }
    to {
        opacity: 1;
    }
}

/* Estado de carga */
.cst-template-selector.loading {
    background-image: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><circle cx="8" cy="8" r="7" fill="none" stroke="%23999" stroke-width="2" stroke-dasharray="10 3" stroke-linecap="round"><animateTransform attributeName="transform" type="rotate" values="0 8 8;360 8 8" dur="1s" repeatCount="indefinite"/></circle></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px 16px;
    padding-right: 35px;
}

/* Indicador de plantillas disponibles */
/* .cst-template-selector-container::before {
    content: "📝";
    font-size: 16px;
    opacity: 0.7;
} */

/* Hover effects solo cuando está visible */
.cst-template-selector-container.cst-show:hover {
    background: #f0f5ff;
    border-color: #007cba;
}

.wp-admin .cst-template-selector-container.cst-show:hover {
    background: #f0f6fc;
    border-color: #2271b1;
}

/* Focus within solo cuando está visible */
.cst-template-selector-container.cst-show:focus-within {
    background: #f0f5ff;
    border-color: #007cba;
}

.wp-admin .cst-template-selector-container.cst-show:focus-within {
    background: #f0f6fc;
    border-color: #2271b1;
}