/**
 * Tarokina Restriction - Frontend Styles
 * 
 * Estilos para el sistema de restricción de acceso a tarots.
 * Se encola solo cuando hay restricciones activas en la página.
 * 
 * @package Tarokina\Addons\Restriction
 * @since 1.0.0
 */

/* =============================================================================
   Contenedor Principal de Restricción
   ========================================================================== */

.tkina-restriction-container {
    position: relative;
    min-height: 400px;
    background: #f9f9f9;
}

.tkina-restriction-container .spread-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    padding: 2rem;
}

/* =============================================================================
   Mensaje de Bloqueo (Full Page)
   ========================================================================== */

.tkina-restriction-blocked-fullpage {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

/* =============================================================================
   Aviso de Expiración Inline
   ========================================================================== */

.tkina-expiring-notice-inline {
    margin: 1rem 0 2rem;
    animation: tkina-slideDown 0.3s ease-out;
}

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

/* =============================================================================
   Sistema Universal de Restricción - Compatible con TODOS los temas
   ========================================================================== */

/* Contenedor principal cuando está restringido */
.tkina-restricted-tarot {
    position: relative;
    min-height: 500px; /* Garantiza espacio mínimo para el mensaje */
}

/* UNIVERSAL: Bloquear interacción en todo el contenido del tarot EXCEPTO el mensaje */
.tkina-restricted-tarot > *:not(.tkina-restriction-message-container) {
    pointer-events: none;
    filter: grayscale(20%);
    transition: filter 0.3s ease;
}

/* Específico: Tablero con spread-wrap (temas con tablero) */
.tkina-restricted-tarot .spread-wrap {
    pointer-events: none;
    filter: grayscale(20%);
    transition: filter 0.3s ease;
}

/* Específico: D3 y otros temas sin spread-wrap */
.tkina-restricted-tarot .tablero_container,
.tkina-restricted-tarot .selector_container_d3,
.tkina-restricted-tarot .selector_container_d1,
.tkina-restricted-tarot .selector_container_d2 {
    pointer-events: none;
    filter: grayscale(20%);
    transition: filter 0.3s ease;
}

/* Contenedor del mensaje - Reemplaza al selector oculto */
.tkina-restriction-message-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    margin: 2rem auto 0;
    width: 100%;
    pointer-events: auto; /* IMPORTANTE: Permitir clicks en el contenedor */
}

/* Mensaje de restricción - Layout vertical: icono > botón > mensaje con borde */
.tkina-restriction-overlay-message {
    background: transparent;
    padding: 0;
    margin: 0;
    width: 100%; /* Mismo ancho que el tarot */
    max-width: 100%;
    text-align: center;
    animation: tkina-overlay-fadeIn 0.4s ease-out;
    pointer-events: auto; /* IMPORTANTE: Permitir clicks en el mensaje y enlaces */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

/* Asegurar que los enlaces dentro del mensaje son clickeables */
.tkina-restriction-overlay-message a {
    pointer-events: auto;
    cursor: pointer;
}

/* Icono de candado - FUERA del borde */
.tkina-restriction__icon {
    margin: 0;
    padding: 0;
    width: 48px;
    height: 48px;
    background-color: currentColor;
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='11' width='18' height='11' rx='2' ry='2'%3E%3C/rect%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'%3E%3C/path%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='11' width='18' height='11' rx='2' ry='2'%3E%3C/rect%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'%3E%3C/path%3E%3C/svg%3E");
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}

.tkina-restriction__icon svg {
    display: none; /* Ocultamos el SVG original ya que usamos mask-image */
}

/* Botón de Login - FUERA del borde, debajo del icono */
.tkina-restriction__login-btn {
    display: inline-block;
    padding: 12px 30px;
    background-color: #333;
    color: #fff !important;
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    border-radius: 4px;
    transition: background-color 0.3s ease;
    cursor: pointer;
    margin: 0;
}

.tkina-restriction__login-btn:hover {
    background-color: #000;
    color: #fff !important;
}

.tkina-restriction__login-btn:focus {
    outline: 2px solid #333;
    outline-offset: 2px;
}

/* Contenido del mensaje - CON borde dashed */
.tkina-restriction__content {
    width: 100%;
    border: 4px dashed;
    padding: 25px;
    margin: 0;
}

.tkina-restriction__message {
    margin: 0;
    font-size: 16px;
    line-height: 1.6;
}

.tkina-restriction__message p {
    margin: 0;
}

/* Acciones dentro del contenido con borde (si las hay) */
.tkina-restriction__actions {
    margin-top: 1rem;
}

@keyframes tkina-overlay-fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* =============================================================================
   Blur de Contenido (Alternativa al Overlay)
   ========================================================================== */

.tkina-restriction-blur {
    filter: blur(8px);
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
}

.tkina-restriction-blur-container {
    position: relative;
}

.tkina-restriction-blur-message {
    position: absolute;
    top: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    background: #fff;
    padding: 1.5rem 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-width: 90%;
    width: 500px;
    text-align: center;
}

/* =============================================================================
   Botones y Enlaces
   ========================================================================== */

/* Link del producto en mensaje de restricción */
.tkina-product-link {
    text-decoration: underline !important;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 8px;
    transition: opacity 0.2s ease;
    vertical-align: text-bottom;
    position: relative;
    top: 2px;
}

/* Icono de llave SVG - Compatible con todos los navegadores - Hereda color del padre */
.tkina-product-link::before {
    content: "";
    display: inline-block;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    background-color: currentColor;
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4'/%3E%3C/svg%3E");
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    vertical-align: middle;
}

.tkina-product-link:hover {
    opacity: 0.8;
}

.tkina-restriction-action-btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: #0073aa;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
    transition: background 0.2s ease;
}

.tkina-restriction-action-btn:hover {
    background: #005a87;
    color: #fff;
}

.tkina-restriction-action-btn:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Botón secundario */
.tkina-restriction-action-btn--secondary {
    background: #f0f0f0;
    color: #333;
}

.tkina-restriction-action-btn--secondary:hover {
    background: #e0e0e0;
    color: #333;
}

/* =============================================================================
   Estados de Carga
   ========================================================================== */

.tkina-restriction-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 115, 170, 0.2);
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: tkina-spin 0.8s linear infinite;
}

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

/* =============================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .tkina-restriction-container .spread-wrap {
        padding: 1rem;
        min-height: 300px;
    }

    .tkina-restriction-message-container {
        padding: 0;
        margin: 1rem auto 0;
    }

    .tkina-restriction-overlay-message {
        padding: 0;
        width: 100%;
        max-width: 100%;
        gap: 0.75rem;
    }
    
    .tkina-restriction-blur-message {
        padding: 1.5rem;
        width: auto;
        max-width: 95%;
    }

    .tkina-restriction__icon {
        width: 40px;
        height: 40px;
    }

    .tkina-restriction__login-btn {
        padding: 10px 24px;
        font-size: 14px;
    }

    .tkina-restriction__content {
        border-width: 3px;
        padding: 20px;
    }

    .tkina-restriction__message {
        font-size: 14px;
    }

    .tkina-restriction-action-btn {
        display: block;
        width: 100%;
        margin: 0.5rem 0;
    }
}



/* =============================================================================
   Placeholder de Carga AJAX (Sistema Anti-Caché)
   ========================================================================== */

.tkina-tarot-content-placeholder {
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
}

.tkina-loading-spinner {
    text-align: center;
}

.tkina-loading-spinner .spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: #000;
    border-radius: 50%;
    animation: tkina-spinner-rotate 1s linear infinite;
}

@keyframes tkina-spinner-rotate {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.tkina-loading-spinner p {
    margin-top: 1rem;
    color: #666;
    font-size: 14px;
}

/* Error de carga */
.tkina-tarot-load-error {
    text-align: center;
    padding: 2rem;
    color: #d32f2f;
}

.tkina-tarot-load-error h3 {
    margin-bottom: 0.5rem;
    color: #d32f2f;
}

/* =============================================================================
   Responsivo - Tablero Restringido
   ========================================================================== */

@media (max-width: 768px) {
    .tkina-restriction-overlay-message {
        padding: 1.5rem;
        width: 95%;
        border-radius: 8px;
    }
}

@media (max-width: 480px) {
    .tkina-restriction-message-container {
        padding: 0.75rem 0.25rem;
        margin: 0.75rem auto;
    }

    .tkina-restriction-overlay-message {
        padding: 1.25rem;
        font-size: 14px;
    }
}

/* =============================================================================
   Utilidades
   ========================================================================== */

.tkina-restriction-hidden {
    display: none !important;
}

.tkina-restriction-visible {
    display: block !important;
}

.tkina-restriction-text-center {
    text-align: center;
}

.tkina-restriction-mt-1 {
    margin-top: 0.5rem;
}

.tkina-restriction-mt-2 {
    margin-top: 1rem;
}

.tkina-restriction-mb-1 {
    margin-bottom: 0.5rem;
}

.tkina-restriction-mb-2 {
    margin-bottom: 1rem;
}
