/**
 * Prendible Avisame - Shortcode CSS
 *
 * ARQUITECTURA UNIFICADA:
 * 1. Este archivo: ESTRUCTURA y ANIMACIONES (layout, posiciones, animaciones)
 * 2. PHP (wp_add_inline_style): VALORES DINÁMICOS (colores, fuentes, tamaños)
 * 3. Custom CSS: Se aplica DESPUÉS con máxima prioridad
 */

/* ============================================
   1. CONTENEDORES - ESTRUCTURA BASE
   ============================================ */

.prendible-stock-notification,
.prendible-price-notification,
.prendible-avisame-container {
    box-sizing: border-box;
    clear: both;
}

/* ============================================
   2. BOTONES - SOLO ESTRUCTURA
   (Valores visuales vienen de PHP)
   ============================================ */

.prendible-stock-button,
.prendible-price-button,
.prendible-avisame-button {
    display: inline-block;
    border-style: solid;
    text-decoration: none;
    cursor: pointer;
    outline: none;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

/* Efecto ripple en botones */
.prendible-stock-button::before,
.prendible-price-button::before,
.prendible-avisame-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.prendible-stock-button:active::before,
.prendible-price-button:active::before,
.prendible-avisame-button:active::before {
    width: 300px;
    height: 300px;
}

/* Botones con iconos */
button[data-has-icon="true"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.prendible-button-icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    fill: currentColor;
    transition: transform 0.3s ease;
}

.prendible-button-text {
    display: inline-block;
}

/* Estados del botón */
.prendible-stock-button.loading {
    cursor: not-allowed;
}

/* ============================================
   3. MODAL - ESTRUCTURA Y POSICIONAMIENTO
   ============================================ */

/* Overlay */
.prendible-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(0px);
}

.prendible-modal-overlay.active {
    opacity: 1;
    visibility: visible;
    backdrop-filter: blur(4px);
}

/* Modal container */
.prendible-modal {
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-sizing: border-box;
    position: relative;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Animación por defecto: scale */
.prendible-modal-overlay[data-animation="overlay"] .prendible-modal {
    transform: scale(0.95);
}

.prendible-modal-overlay[data-animation="overlay"].active .prendible-modal {
    transform: scale(1);
}

/* Animación: slide */
.prendible-modal-overlay[data-animation="slide"] .prendible-modal {
    transform: translateY(-100%);
}

.prendible-modal-overlay[data-animation="slide"].active .prendible-modal {
    transform: translateY(0);
}

/* Animación: float */
.prendible-modal-overlay[data-animation="float"] .prendible-modal {
    transform: translateY(20px) scale(0.95);
    opacity: 0;
}

.prendible-modal-overlay[data-animation="float"].active .prendible-modal {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Estados del modal - MEJORADO */
.prendible-modal.loading {
    pointer-events: none;
}

/* IMPORTANTE: Cambiar el overlay de loading para no tapar mensajes */
.prendible-modal.loading .prendible-avisame-form {
    opacity: 0.6;
    pointer-events: none;
    filter: grayscale(0.3);
}

/* Estado de éxito */
.prendible-modal.success-state {
    animation: prendible-success-pulse 0.6s ease;
}

.prendible-modal.success-state .prendible-avisame-form {
    opacity: 0.7;
}

/* Shake animation para errores */
.prendible-modal.error-shake {
    animation: prendible-error-shake 0.5s ease;
}

/* ============================================
   4. COMPONENTES DEL MODAL
   ============================================ */

/* Header */
.prendible-modal-header {
    position: relative;
    box-sizing: border-box;
}

.prendible-modal-title {
    margin: 0;
}

.prendible-modal-close {
    position: absolute;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.prendible-modal-close:hover {
    transform: rotate(90deg) scale(1.1);
}

/* Body */
.prendible-modal-body {
    box-sizing: border-box;
}

/* ============================================
   5. FORMULARIO
   ============================================ */

.prendible-avisame-form {
    margin: 0;
    transition: opacity 0.3s ease, filter 0.3s ease;
}

.prendible-avisame-form.validating {
    pointer-events: none;
    opacity: 0.8;
}

.prendible-form-field {
    margin-bottom: 20px;
    position: relative;
}

.prendible-form-field label {
    display: block;
    margin-bottom: 8px;
}

.prendible-form-field .required {
    margin-left: 4px;
}

.prendible-form-field input,
.prendible-form-field select {
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease;
}

.prendible-form-field input:focus,
.prendible-form-field select:focus {
    outline: none;
    transform: scale(1.01);
}

.prendible-form-field input.error,
.prendible-form-field select.error {
    animation: prendible-input-error 0.3s ease;
}

/* Select para variaciones */
.prendible-form-field select {
    cursor: pointer;
    border-radius: 0;
}

/* Mensajes de error de campo */
.prendible-field-error {
    font-size: 12px;
    margin-top: 4px;
    display: none;
    opacity: 0;
    transform: translateY(-5px);
    transition: all 0.3s ease;
}

.prendible-field-error.visible {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* ============================================
   6. BOTÓN DE ENVÍO
   ============================================ */

.prendible-submit-button {
    width: 100%;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

.prendible-submit-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.prendible-submit-button:active:not(:disabled) {
    transform: translateY(0);
}

.prendible-submit-button:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

/* Botón en estado de éxito */
.prendible-submit-button.success-button {
    animation: prendible-button-success 0.6s ease;
}

/* Iconos del submit button */
.prendible-submit-button .prendible-button-icon {
    fill: currentColor;
    transition: transform 0.3s ease;
}

.prendible-submit-button:hover:not(:disabled) .prendible-button-icon {
    transform: scale(1.1);
}

/* Icono de check en éxito */
.prendible-check-icon {
    display: inline-block;
    animation: prendible-check-pop 0.4s ease;
}

/* ============================================
   7. MENSAJES DE RESPUESTA - MEJORADO
   ============================================ */

.prendible-form-message {
    margin-bottom: 20px;
    padding: 16px 20px;
    border-width: 2px;
    border-style: solid;
    border-radius: 8px;
    display: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

/* Efecto de brillo en mensajes */
.prendible-form-message::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    transform: rotate(45deg);
    animation: prendible-message-shine 2s infinite;
}

.prendible-form-message.visible {
    display: flex;
    align-items: center;
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.prendible-form-message.success {
    border-color: #28a745;
    animation: prendible-message-bounce-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.prendible-form-message.error {
    border-color: #dc3545;
    animation: prendible-message-bounce-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
               prendible-error-shake 0.3s ease 0.2s;
}

.prendible-form-message.info {
    border-color: #0066cc;
    animation: prendible-message-bounce-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Iconos de mensajes - MEJORADOS */
.prendible-form-message.success::before {
    content: '✓';
    display: inline-block;
    width: 28px;
    height: 28px;
    margin-right: 12px;
    background-color: #28a745;
    border-radius: 50%;
    color: white;
    text-align: center;
    line-height: 28px;
    font-weight: bold;
    font-size: 16px;
    flex-shrink: 0;
    animation: prendible-check-pop 0.5s ease 0.3s backwards;
}

.prendible-form-message.error::before {
    content: '✗';
    display: inline-block;
    width: 28px;
    height: 28px;
    margin-right: 12px;
    background-color: #dc3545;
    border-radius: 50%;
    color: white;
    text-align: center;
    line-height: 28px;
    font-weight: bold;
    font-size: 16px;
    flex-shrink: 0;
    animation: prendible-error-pulse 0.5s ease 0.3s backwards;
}

.prendible-form-message.info::before {
    content: 'ℹ';
    display: inline-block;
    width: 28px;
    height: 28px;
    margin-right: 12px;
    background-color: #0066cc;
    border-radius: 50%;
    color: white;
    text-align: center;
    line-height: 28px;
    font-weight: bold;
    font-size: 16px;
    flex-shrink: 0;
    animation: prendible-info-bounce 0.5s ease 0.3s backwards;
}

/* ============================================
   8. ANIMACIONES Y KEYFRAMES - MEJORADAS
   ============================================ */

/* Spinner mejorado */
.prendible-loader {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: prendible-spin 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes prendible-spin {
    to { transform: rotate(360deg); }
}

/* Fade in */
.prendible-fade-in {
    animation: prendible-fadeIn 0.5s ease;
}

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

/* Success pulse mejorado */
@keyframes prendible-success-pulse {
    0%, 100% {
        transform: scale(1);
    }
    25% {
        transform: scale(1.02);
    }
    50% {
        transform: scale(0.98);
    }
    75% {
        transform: scale(1.01);
    }
}

/* Message bounce mejorado */
@keyframes prendible-message-bounce-in {
    0% {
        transform: translateY(-20px) scale(0.8);
        opacity: 0;
    }
    60% {
        transform: translateY(5px) scale(1.05);
        opacity: 1;
    }
    80% {
        transform: translateY(-2px) scale(0.98);
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Check pop animation */
@keyframes prendible-check-pop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.3);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Error pulse para icono */
@keyframes prendible-error-pulse {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Info bounce para icono */
@keyframes prendible-info-bounce {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    60% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0);
        opacity: 1;
    }
}

/* Error shake */
@keyframes prendible-error-shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

/* Button success animation */
@keyframes prendible-button-success {
    0% {
        transform: scale(1);
    }
    20% {
        transform: scale(0.95);
    }
    40% {
        transform: scale(1.05);
    }
    60% {
        transform: scale(0.98);
    }
    80% {
        transform: scale(1.02);
    }
    100% {
        transform: scale(1);
    }
}

/* Input error animation */
@keyframes prendible-input-error {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-4px);
    }
    75% {
        transform: translateX(4px);
    }
}

/* Message shine effect */
@keyframes prendible-message-shine {
    0% {
        transform: translateX(-100%) rotate(45deg);
    }
    100% {
        transform: translateX(100%) rotate(45deg);
    }
}

/* ============================================
   9. ESTADOS ESPECIALES
   ============================================ */

/* Oculto */
.prendible-stock-notification.hidden,
.prendible-price-notification.hidden {
    display: none;
}

/* Debug mode */
.prendible-debug {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 10px;
    margin-top: 10px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
}

/* ============================================
   10. RESPONSIVE
   ============================================ */

@media (max-width: 600px) {
    .prendible-modal-overlay {
        padding: 10px;
    }

    .prendible-modal {
        max-width: 100%;
    }

    /* En móvil, los mensajes son más pequeños */
    .prendible-form-message {
        font-size: 14px;
        padding: 14px 16px;
    }
}

@media (max-width: 400px) {
    .prendible-stock-button,
    .prendible-price-button {
        width: 100%;
        text-align: center;
    }
}

/* ============================================
   FIN DEL CSS BASE
   Los valores visuales (colores, fuentes, tamaños)
   se aplican desde PHP via wp_add_inline_style()
   ============================================ */
