/* ============================================================
   AI Popup Promocional — Frontend Styles v3.0
   + Colores por tipo (Oferta, Promoción, Cupón, Ruleta)
   + Nuevos juegos: Slot, Sobres, Rasca y Gana
   ============================================================ */

/* --- Overlay --- */
#ai-popup-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.75);
    z-index: 2147483646;
    display: none;
    backdrop-filter: blur(3px);
}

/* --- Contenedor principal --- */
#ai-popup-container {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    padding: 28px 24px 22px;
    border-radius: 20px;
    box-shadow: 0 25px 80px rgba(0,0,0,0.4);
    z-index: 2147483647;
    max-width: 94%;
    width: 440px;
    max-height: 94vh;
    overflow-y: auto;
    text-align: center;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    animation: aiPopupIn .4s cubic-bezier(.34,1.56,.64,1) both;
}

@keyframes aiPopupIn {
    from { opacity:0; transform:translate(-50%,-50%) scale(.85); }
    to   { opacity:1; transform:translate(-50%,-50%) scale(1); }
}

/* --- Colores por tipo --- */
.ai-popup-tipo-oferta #ai-popup-container { border-top: 6px solid #f39c12; }
.ai-popup-tipo-promocion #ai-popup-container { border-top: 6px solid #8e44ad; }
.ai-popup-tipo-cupon #ai-popup-container { border-top: 6px solid #27ae60; }
.ai-popup-tipo-ruleta #ai-popup-container { border-top: 6px solid #e74c3c; }

/* --- Botón cerrar --- */
.ai-popup-btn-close {
    position: absolute;
    top: 10px; right: 14px;
    font-size: 28px;
    background: none; border: none;
    cursor: pointer; color: #bdc3c7;
    line-height: 1; padding: 0;
    width: 36px; height: 36px;
    border-radius: 50%;
    transition: all .2s;
}
.ai-popup-btn-close:hover { 
    color: #e74c3c; 
    background: rgba(231, 76, 60, 0.1);
    transform: rotate(90deg);
}

/* --- Encabezados --- */
#ai-popup-content h2 {
    font-size: 1.7em;
    margin: 0 0 14px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.ai-popup-brand {
    font-size: 12px;
    color: #7f8c8d;
    margin-bottom: 6px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

/* --- Contenedor resultado --- */
.ai-result-container {
    border: 2px solid;
    border-radius: 16px;
    padding: 20px;
    margin: 16px 0;
    background: #fff;
}

/* --- Resultado / mensaje --- */
.ai-popup-result {
    font-size: 15px;
    margin: 12px 0;
    padding: 14px 16px;
    border-radius: 12px;
    line-height: 1.6;
    text-align: center;
    font-weight: 500;
}
.ai-popup-result.ai-win-box {
    background: #d4edda; 
    border: 2px solid #c3e6cb; 
    color: #155724;
}
.ai-popup-result.ai-lose-box {
    background: #f8d7da; 
    border: 2px solid #f5c6cb; 
    color: #721c24;
}
.ai-popup-result.ai-lose-frase {
    font-style: italic;
    color: #7f8c8d;
    background: #f8f9fa;
    border: 1px dashed #dee2e6;
}

/* --- Premio revelado --- */
.ai-popup-premio-revelado {
    margin: 16px 0;
    padding: 16px;
    border-radius: 12px;
    background: rgba(255,255,255,0.5);
    border: 2px dashed currentColor;
}
.ai-premio-label {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
    opacity: 0.8;
}
.ai-premio-valor {
    font-size: 22px;
    font-weight: 800;
}

/* --- Info visitante --- */
.ai-popup-visitor-info {
    font-size: 13px; 
    color: #666;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 8px 14px;
    border-radius: 20px;
    display: inline-block;
}

/* --- Código --- */
.ai-popup-code {
    display: inline-block;
    font-size: 24px;
    font-weight: 900;
    color: #2c3e50;
    margin: 14px 0;
    padding: 12px 24px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 10px;
    letter-spacing: 4px;
    border: 3px dashed #bdc3c7;
    cursor: pointer;
    transition: all .2s;
    font-family: 'Courier New', monospace;
    text-shadow: 1px 1px 0 rgba(255,255,255,0.8);
}
.ai-popup-code:hover { 
    background: linear-gradient(135deg, #e8ecf1 0%, #b0c4de 100%);
    transform: scale(1.02);
}

/* --- Fecha validez --- */
.ai-popup-fecha-validez {
    display: inline-block;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: #fff;
    padding: 6px 16px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 12px;
    margin: 10px 0;
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

/* --- Instrucción --- */
.ai-popup-instruction {
    font-size: 12px;
    color: #666;
    margin: 10px 0;
    font-style: italic;
}

/* --- Botones --- */
.ai-popup-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 18px;
}
.ai-popup-btn {
    padding: 12px 22px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    font-size: 14px;
    transition: all .2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.ai-popup-btn:hover { 
    transform: translateY(-3px); 
    box-shadow: 0 6px 20px rgba(0,0,0,.25); 
}
.ai-popup-btn:active {
    transform: translateY(-1px);
}
.ai-popup-btn-copiar { 
    background: linear-gradient(135deg, #27ae60 0%, #229954 100%); 
    color: #fff; 
}
.ai-popup-btn-whatsapp { 
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%); 
    color: #fff; 
}

/* ============================================================
   RULETA
   ============================================================ */
.ai-roulette-container {
    position: relative;
    display: inline-block;
    margin: 10px 0;
}

#ai-popup-roulette {
    width: 280px; 
    height: 280px;
    margin: 0 auto;
    position: relative;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(0,0,0,.3), inset 0 0 20px rgba(0,0,0,.1);
    border: 24px solid #2c3e50;
    background: #fff;
    will-change: transform;
}

.ai-roulette-item {
    position: absolute;
    width: 50%; 
    height: 50%;
    transform-origin: 100% 100%;
    left: 0; 
    top: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: inset 0 0 10px rgba(0,0,0,.2);
}

.ai-roulette-item span {
    color: #fff;
    font-weight: 700;
    font-size: 12px;
    text-align: center;
    display: inline-block;
    width: 85%;
    padding: 4px;
    transform: rotate(-45deg);
    transform-origin: center;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.3;
    text-shadow: 1px 1px 3px rgba(0,0,0,.8);
    max-height: 50px;
    overflow: hidden;
}

.ai-roulette-pointer {
    position: absolute;
    top: -12px; 
    left: 50%;
    transform: translateX(-50%);
    width: 0; 
    height: 0;
    border-left: 16px solid transparent;
    border-right: 16px solid transparent;
    border-top: 32px solid #e74c3c;
    z-index: 100;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,.4));
}

.ai-roulette-center {
    position: absolute;
    top: 50%; 
    left: 50%;
    transform: translate(-50%,-50%);
    width: 56px; 
    height: 56px;
    background: linear-gradient(135deg, #2c3e50 0%, #1a252f 100%);
    border-radius: 50%;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 10px;
    cursor: pointer;
    box-shadow: 0 0 0 4px #fff, 0 0 0 6px #2c3e50, 0 4px 15px rgba(0,0,0,.4);
    transition: all .2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.ai-roulette-center:hover { 
    background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
    transform: translate(-50%,-50%) scale(1.1);
}

.ai-roulette-title {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: #fff;
    padding: 8px 20px;
    border-radius: 25px;
    font-size: 1.15em;
    font-weight: 800;
    display: inline-block;
    margin-bottom: 15px;
    box-shadow: 0 4px 15px rgba(243,156,18,.4);
}

/* ============================================================
   SLOT MACHINE (Para Ofertas)
   ============================================================ */
.ai-slot-title {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: #fff;
    padding: 10px 24px;
    border-radius: 25px;
    font-size: 1.2em;
    font-weight: 800;
    display: inline-block;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(243,156,18,.4);
}

.ai-slot-machine {
    position: relative;
    background: linear-gradient(135deg, #2c3e50 0%, #1a252f 100%);
    border-radius: 20px;
    padding: 30px 20px 20px;
    margin: 15px auto;
    max-width: 320px;
    box-shadow: 0 10px 40px rgba(0,0,0,.3);
}

.ai-slot-reels {
    display: flex;
    justify-content: center;
    gap: 10px;
    background: #000;
    padding: 15px;
    border-radius: 10px;
    border: 4px solid #f39c12;
    box-shadow: inset 0 0 20px rgba(243,156,18,.3);
}

.ai-slot-reel {
    width: 70px;
    height: 80px;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 10px rgba(0,0,0,.3);
}

.ai-slot-symbols {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
}

.ai-slot-symbol {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    background: linear-gradient(180deg, #fff 0%, #f0f0f0 100%);
    border-bottom: 1px solid #ddd;
}

.ai-slot-lever-container {
    position: absolute;
    right: -30px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 100px;
}

.ai-slot-lever {
    position: relative;
    width: 12px;
    height: 80px;
    background: linear-gradient(90deg, #95a5a6 0%, #7f8c8d 100%);
    border-radius: 6px;
    cursor: pointer;
    transform-origin: bottom center;
    transition: transform 0.3s;
    margin: 0 auto;
}

.ai-slot-lever.pulled {
    transform: rotateX(45deg);
}

.ai-slot-lever-handle {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    background: #e74c3c;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
}

.ai-slot-lever-ball {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 28px;
    background: radial-gradient(circle at 30% 30%, #e74c3c, #c0392b);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,.4);
    border: 2px solid #a93226;
}

.ai-slot-spin-btn {
    margin-top: 20px;
    padding: 14px 40px;
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    border: none;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
    transition: all .2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.ai-slot-spin-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(231, 76, 60, 0.5);
}
.ai-slot-spin-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================================
   3 SOBRES (Para Promociones)
   ============================================================ */
.ai-envelopes-title {
    background: linear-gradient(135deg, #8e44ad 0%, #9b59b6 100%);
    color: #fff;
    padding: 10px 24px;
    border-radius: 25px;
    font-size: 1.2em;
    font-weight: 800;
    display: inline-block;
    margin-bottom: 25px;
    box-shadow: 0 4px 15px rgba(142,68,173,.4);
}

.ai-envelopes-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 20px 0;
    perspective: 1000px;
}

.ai-envelope {
    width: 90px;
    height: 120px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.ai-envelope:hover:not(.opened) {
    transform: translateY(-10px) rotateY(5deg);
}

.ai-envelope-body {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #ecf0f1 0%, #bdc3c7 100%);
    border-radius: 0 0 8px 8px;
    position: relative;
    box-shadow: 0 8px 20px rgba(0,0,0,.2);
    transition: all 0.4s;
}

.ai-envelope-flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background: linear-gradient(135deg, #d5dbdb 0%, #aeb6bf 100%);
    clip-path: polygon(0 0, 50% 40%, 100% 0, 100% 100%, 0 100%);
    transform-origin: top;
    transition: transform 0.4s;
    border-radius: 8px 8px 0 0;
    z-index: 2;
}

.ai-envelope-content {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

.ai-envelope-number {
    font-size: 36px;
    font-weight: 900;
    color: #8e44ad;
    text-shadow: 2px 2px 4px rgba(0,0,0,.2);
}

.ai-envelope.opened {
    transform: scale(1.1);
    z-index: 10;
}

.ai-envelope.opened .ai-envelope-flap {
    transform: rotateX(180deg);
    opacity: 0;
}

.ai-envelope.opened .ai-envelope-body {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    box-shadow: 0 12px 30px rgba(0,0,0,.3);
}

.ai-envelope-result {
    font-size: 50px;
    animation: bounceIn 0.6s;
}

@keyframes bounceIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.ai-envelopes-instruction {
    color: #7f8c8d;
    font-size: 14px;
    margin-top: 15px;
    font-style: italic;
}

/* ============================================================
   RASCA Y GANA (Para Cupones)
   ============================================================ */
.ai-scratch-title {
    background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
    color: #fff;
    padding: 10px 24px;
    border-radius: 25px;
    font-size: 1.2em;
    font-weight: 800;
    display: inline-block;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(39,174,96,.4);
}

.ai-scratch-container {
    position: relative;
    width: 300px;
    height: 150px;
    margin: 20px auto;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0,0,0,.2);
}

#ai-scratch-canvas {
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 12px;
    cursor: crosshair;
    touch-action: none;
}

.ai-scratch-prize {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #fff 0%, #f0f0f0 100%);
    border-radius: 12px;
    z-index: 1;
}

.ai-scratch-reveal {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    padding: 20px;
    color: #2c3e50;
}

.ai-scratch-instruction {
    color: #7f8c8d;
    font-size: 13px;
    margin-top: 12px;
    font-style: italic;
}

/* ============================================================
   EFECTOS VISUALES — CELEBRACIÓN
   ============================================================ */
.ai-popup-celebration {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 2147483648;
    overflow: hidden;
}
.ai-popup-celebration-item {
    position: absolute;
    opacity: 0;
    animation: aiPopupFloat 4.5s ease-in-out forwards;
}
@keyframes aiPopupFloat {
    0%   { transform: translateY(100vh) rotate(0deg);   opacity: 1; }
    100% { transform: translateY(-120px) rotate(400deg); opacity: 0; }
}

#ai-popup-sad {
    position: fixed;
    top: 25%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 90px;
    z-index: 2147483648;
    pointer-events: none;
    animation: aiSadPulse 2.5s ease-in-out forwards;
    filter: drop-shadow(0 10px 20px rgba(0,0,0,.2));
}
@keyframes aiSadPulse {
    0%   { opacity: 0; transform: translateX(-50%) scale(.5); }
    30%  { opacity: 1; transform: translateX(-50%) scale(1.2); }
    70%  { opacity: 1; transform: translateX(-50%) scale(1); }
    100% { opacity: 0; transform: translateX(-50%) scale(.7); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 480px) {
    #ai-popup-container {
        width: 96%; 
        padding: 22px 16px 18px;
        max-height: 96vh;
    }
    
    #ai-popup-roulette { 
        width: 240px; 
        height: 240px; 
        border-width: 18px; 
    }
    
    .ai-roulette-item span { font-size: 10px; }
    
    .ai-slot-reel { width: 55px; height: 65px; }
    .ai-slot-symbol { height: 65px; font-size: 32px; }
    
    .ai-envelope { width: 70px; height: 95px; }
    .ai-envelope-number { font-size: 28px; }
    
    .ai-scratch-container { width: 280px; height: 140px; }
    #ai-scratch-canvas { width: 280px; height: 140px; }
    
    .ai-popup-code  { font-size: 20px; letter-spacing: 2px; }
    .ai-popup-btn   { padding: 10px 16px; font-size: 13px; }
}