/**
 * Floopy APS Viewer — Frontend styles
 *
 * Diseñado para ser compatible con Blocksy Pro.
 * Usa CSS custom properties para que el tema pueda sobreescribir colores.
 */

/* ==========================================================================
   Custom properties (overridables)
   ========================================================================== */
:root {
    --floopy-primary: #3498db;
    --floopy-primary-dark: #2980b9;
    --floopy-success: #27ae60;
    --floopy-danger: #e74c3c;
    --floopy-warning: #f39c12;
    --floopy-text: #2c3e50;
    --floopy-text-light: #7f8c8d;
    --floopy-bg: #ffffff;
    --floopy-bg-alt: #f8f9fa;
    --floopy-border: #e1e4e8;
    --floopy-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --floopy-radius: 12px;
}

/* ==========================================================================
   Upload zone (shortcode [floopy_viewer] con type=upload)
   ========================================================================== */
.floopy-upload-zone {
    max-width: 720px;
    margin: 2rem auto;
    padding: 3rem 2rem;
    background: var(--floopy-bg);
    border: 2px dashed var(--floopy-border);
    border-radius: var(--floopy-radius);
    text-align: center;
    transition: border-color 0.2s ease, background 0.2s ease, filter 0.25s ease, opacity 0.25s ease;
    font-family: inherit;
}

.floopy-upload-zone.is-dragging {
    border-color: var(--floopy-primary);
    background: rgba(52, 152, 219, 0.05);
}

/* Cuando hay un modal abierto (validación, upload, cola, traducción, errores,
   paywall, anuncio de redirect), desenfocamos la zona de upload detrás y
   bloqueamos interacciones. Evita que el usuario arrastre un segundo archivo
   o haga clic en el botón de seleccionar mientras el flujo está en curso. */
body.floopy-modal-open .floopy-upload-zone {
    filter: blur(3px);
    opacity: 0.65;
    pointer-events: none;
    user-select: none;
}

.floopy-upload-zone h3 {
    margin: 0 0 0.5rem;
    color: var(--floopy-text);
    font-size: 1.5rem;
}

.floopy-upload-zone p.floopy-sub {
    margin: 0 0 1.5rem;
    color: var(--floopy-text-light);
    font-size: 0.95rem;
}

.floopy-upload-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 2rem;
    background: var(--floopy-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

.floopy-upload-btn:hover {
    background: var(--floopy-primary-dark);
}

.floopy-upload-btn:active {
    transform: translateY(1px);
}

.floopy-upload-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
}

.floopy-formats-block {
    margin-top: 1.25rem;
    text-align: center;
}

.floopy-formats {
    margin: 0;
    color: var(--floopy-text-light);
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    line-height: 1.6;
}

.floopy-formats--free {
    max-width: 640px;
    margin: 0 auto;
}

.floopy-formats--premium {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed rgba(0, 0, 0, 0.08);
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem 0.5rem;
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
}

.floopy-formats-premium__lock {
    width: 13px;
    height: 13px;
    color: #95a5a6;
    flex-shrink: 0;
    vertical-align: middle;
    margin-right: 0.15rem;
}

.floopy-formats-premium__label {
    color: #8e8e8e;
    font-weight: 600;
    letter-spacing: 0.06em;
}

.floopy-formats-premium__hint {
    color: #a0a0a0;
    font-style: italic;
    font-size: 0.72rem;
    text-transform: none;
    letter-spacing: 0;
    margin-left: 0.25rem;
}

.floopy-formats .floopy-format {
    display: inline-block;
}

.floopy-formats .floopy-format--premium {
    position: relative;
    color: #95a5a6;
    cursor: pointer;
    border: none;
    background: transparent;
    padding: 2px 4px;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    border-radius: 3px;
    text-decoration: underline dotted rgba(149, 165, 166, 0.5);
    text-underline-offset: 3px;
    transition: color 0.15s, background 0.15s, text-decoration-color 0.15s;
    outline: none;
}

.floopy-formats .floopy-format--premium:hover,
.floopy-formats .floopy-format--premium:focus-visible {
    color: #3498db;
    background: rgba(52, 152, 219, 0.08);
    text-decoration-color: #3498db;
}

.floopy-formats .floopy-format--premium:focus-visible {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* Mobile: reducir tamaño y espaciado */
@media (max-width: 600px) {
    .floopy-formats--free,
    .floopy-formats--premium {
        font-size: 0.72rem;
    }
    .floopy-formats-premium__hint {
        display: block;
        width: 100%;
        margin-left: 0;
        margin-top: 0.25rem;
    }
}

.floopy-upload-zone input[type="file"] {
    display: none;
}

/* ==========================================================================
   Upload progress modal
   ========================================================================== */
.floopy-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    font-family: inherit;
}

.floopy-modal.is-active {
    display: flex;
    opacity: 1;
}

.floopy-modal__content {
    background: var(--floopy-bg);
    padding: 2rem;
    border-radius: var(--floopy-radius);
    box-shadow: var(--floopy-shadow);
    max-width: 500px;
    width: 90%;
    text-align: center;
    animation: floopyModalShow 0.3s ease;
}

@keyframes floopyModalShow {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.floopy-modal__title {
    margin: 0 0 0.5rem;
    font-size: 1.2rem;
    color: var(--floopy-text);
    font-weight: 600;
}

.floopy-modal__subtitle {
    margin: 0 0 1.5rem;
    color: var(--floopy-text-light);
    font-size: 0.9rem;
}

.floopy-spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    border: 4px solid var(--floopy-bg-alt);
    border-top-color: var(--floopy-primary);
    border-radius: 50%;
    animation: floopySpin 0.9s linear infinite;
}

@keyframes floopySpin {
    to { transform: rotate(360deg); }
}

.floopy-progress {
    background: var(--floopy-bg-alt);
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    margin: 1rem 0 0;
}

.floopy-progress__bar {
    background: linear-gradient(90deg, var(--floopy-primary) 0%, var(--floopy-primary-dark) 100%);
    height: 100%;
    width: 0;
    border-radius: 999px;
    transition: width 0.4s ease;
}

.floopy-progress__text {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--floopy-text-light);
    font-variant-numeric: tabular-nums;
}

.floopy-modal__error {
    background: #fdecea;
    border: 1px solid var(--floopy-danger);
    color: #a53125;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    font-size: 0.9rem;
}

.floopy-modal__actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.floopy-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.15s ease;
    text-decoration: none;
    font-family: inherit;
}

.floopy-btn--primary {
    background: var(--floopy-primary);
    color: #fff;
}

.floopy-btn--primary:hover {
    background: var(--floopy-primary-dark);
    color: #fff;
}

.floopy-btn--secondary {
    background: var(--floopy-bg-alt);
    color: var(--floopy-text);
    border: 1px solid var(--floopy-border);
}

.floopy-btn--secondary:hover {
    background: #e9ecef;
    color: var(--floopy-text);
}

.floopy-btn--upgrade {
    background: var(--floopy-warning);
    color: #fff;
}

.floopy-btn--upgrade:hover {
    background: #e67e22;
    color: #fff;
}

/* ==========================================================================
   Queue countdown (free tier)
   ========================================================================== */
.floopy-queue {
    margin: 1rem 0;
    padding: 1rem;
    background: var(--floopy-bg-alt);
    border-radius: 8px;
    border: 1px solid var(--floopy-border);
}

.floopy-queue__timer {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--floopy-primary);
    font-variant-numeric: tabular-nums;
    display: block;
    margin: 0.5rem 0;
}

.floopy-queue__hint {
    font-size: 0.85rem;
    color: var(--floopy-text-light);
    margin: 0.5rem 0 0;
}

/* Modal "archivo subido → redirect" mostrado por [floopy_upload_box] */
.floopy-redirect {
    text-align: center;
    padding: 0.5rem 0 0.25rem;
}

.floopy-redirect__check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(40, 167, 69, 0.12);
    color: #28a745;
    margin: 0 auto 1rem;
}

.floopy-redirect__body {
    font-size: 1rem;
    color: var(--floopy-text);
    margin: 0 0 0.5rem;
    line-height: 1.4;
}

.floopy-redirect__countdown {
    font-size: 0.85rem;
    color: var(--floopy-text-light);
    margin: 0.25rem 0 0;
    font-variant-numeric: tabular-nums;
}

.floopy-redirect__countdown [data-floopy-redirect-countdown] {
    font-weight: 600;
    color: var(--floopy-primary);
}

/* ==========================================================================
   Viewer stage
   ========================================================================== */
.floopy-viewer-stage {
    position: relative;
    width: 100%;
    height: 75vh;
    min-height: 500px;
    background: #1a1a1a;
    border-radius: var(--floopy-radius);
    overflow: hidden;
    margin: 2rem 0;
}

#floopy-viewer-canvas {
    position: absolute;
    inset: 0;
}

/* Watermark */
.floopy-watermark {
    position: absolute;
    bottom: 12px;
    right: 16px;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    border-radius: 4px;
    letter-spacing: 0.02em;
    pointer-events: none;
    z-index: 10;
    backdrop-filter: blur(4px);
}

/* ==========================================================================
   Info banner (arriba del viewer cuando está free)
   ========================================================================== */
.floopy-free-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(90deg, #fff9e6 0%, #fff5d7 100%);
    border: 1px solid #f0c674;
    border-radius: 8px;
    margin: 0 0 1rem;
    font-size: 0.9rem;
    color: #8a6d3b;
}

.floopy-free-banner__icon {
    flex-shrink: 0;
    font-size: 1.2rem;
}

.floopy-free-banner__text {
    flex-grow: 1;
}

.floopy-free-banner__upgrade {
    flex-shrink: 0;
    padding: 0.4rem 0.9rem;
    background: var(--floopy-warning);
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.2s ease;
}

.floopy-free-banner__upgrade:hover {
    background: #e67e22;
    color: #fff;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 640px) {
    .floopy-upload-zone {
        padding: 2rem 1rem;
        margin: 1rem;
    }

    .floopy-upload-zone h3 {
        font-size: 1.2rem;
    }

    .floopy-viewer-stage {
        height: 60vh;
        min-height: 400px;
        border-radius: 0;
        margin: 1rem -15px;
    }

    .floopy-modal__content {
        padding: 1.5rem;
    }

    .floopy-queue__timer {
        font-size: 2rem;
    }

    .floopy-free-banner {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ==========================================================================
   Toast de checkout (post-pago) - Fase 6.2e
   ========================================================================== */
.floopy-checkout-toast {
    position: fixed;
    top: 24px;
    right: 24px;
    padding: 1rem 1.25rem 1rem 3rem;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    z-index: 99999;
    font-size: 0.95rem;
    font-weight: 500;
    max-width: 380px;
    min-width: 280px;
    opacity: 0;
    transform: translateX(120%);
    transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    background-repeat: no-repeat;
    background-position: 1rem center;
    background-size: 20px 20px;
}

.floopy-checkout-toast.is-visible {
    opacity: 1;
    transform: translateX(0);
}

.floopy-checkout-toast--success {
    background-color: #e8f5e9;
    color: #1b5e20;
    border-left: 4px solid #43a047;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2343a047' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 11.08V12a10 10 0 1 1-5.93-9.14'/%3E%3Cpolyline points='22 4 12 14.01 9 11.01'/%3E%3C/svg%3E");
}

.floopy-checkout-toast--warning {
    background-color: #fff8e1;
    color: #8a6d3b;
    border-left: 4px solid #ffa726;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffa726' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z'/%3E%3Cline x1='12' y1='9' x2='12' y2='13'/%3E%3Cline x1='12' y1='17' x2='12.01' y2='17'/%3E%3C/svg%3E");
}

.floopy-checkout-toast--info {
    background-color: #e3f2fd;
    color: #0d47a1;
    border-left: 4px solid #1e88e5;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231e88e5' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='1 4 1 10 7 10'/%3E%3Cpath d='M3.51 15a9 9 0 1 0 2.13-9.36L1 10'/%3E%3C/svg%3E");
}

@media (max-width: 640px) {
    .floopy-checkout-toast {
        top: 12px;
        right: 12px;
        left: 12px;
        max-width: none;
        min-width: 0;
    }
}
