/* WinFa Frontend CSS - Premium Redesign */

.winfa-modal,
.winfa-modal *,
.winfa-modal *::before,
.winfa-modal *::after {
    box-sizing: border-box !important;
}

:root {
    --winfa-font-title: 'Vazirmatn', 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
    --winfa-font-body: 'Vazirmatn', 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
    
    /* Core Colors */
    --winfa-primary: #ffb142;
    --winfa-primary-gradient: linear-gradient(135deg, #ffb142 0%, #cc8e35 100%);
    --winfa-danger: #ff5252;
    --winfa-success: #2ecc71;
    
    /* Neumorphic & Glassmorphism Variables */
    --winfa-bg-glass: rgba(255, 255, 255, 0.95);
    --winfa-shadow-soft: 0 10px 40px rgba(0,0,0,0.15);
    --winfa-border-radius: 24px;
}

/* Modal Overlay */
.winfa-modal {
    display: none;
    position: fixed;
    z-index: 999999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    background-color: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(12px);
    font-family: var(--winfa-font-body);
    padding-top: env(safe-area-inset-top, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
}

/* Inline Mode Fixes */
.winfa-modal.winfa-inline {
    display: block !important;
    position: relative !important;
    z-index: 10 !important;
    background: transparent !important;
    backdrop-filter: none !important;
    height: auto !important;
    overflow: visible !important;
    padding: 40px 12px;
}
.winfa-modal.winfa-inline .winfa-modal-content {
    margin: 0 auto !important;
    animation: none !important;
    box-shadow: 0 15px 50px rgba(0,0,0,0.1) !important;
}
.winfa-modal.winfa-inline .winfa-close {
    display: none !important;
}

/* Stacked shortcode: wheel visible on top, dense form + spin below */
.winfa-layout-stacked .winfa-modal-content {
    max-width: min(440px, calc(100vw - 24px));
    padding: 22px 18px 26px;
    box-sizing: border-box;
    overflow-x: clip;
}
.winfa-layout-stacked .winfa-modal-content h3 {
    font-size: 22px;
    margin: 0 0 8px;
    letter-spacing: 0;
}
.winfa-layout-stacked .winfa-modal-content p {
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.45;
}
.winfa-layout-stacked .winfa-stacked-wheel-wrap .winfa-wheel-wrapper {
    width: min(300px, 100%);
    max-width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    margin: 0 auto 10px;
    container-type: inline-size;
    --winfa-light-offset: 148px;
    --winfa-light-offset: calc(50cqw - 2px);
}
.winfa-layout-stacked .winfa-stacked-step-form .winfa-input-group {
    margin-bottom: 12px;
}
.winfa-layout-stacked .winfa-input {
    padding: 12px 14px;
    margin: 4px 0;
    border-radius: 12px;
    font-size: 15px;
}
.winfa-layout-stacked .winfa-btn {
    padding: 12px 16px;
    font-size: 17px;
    border-radius: 12px;
}
.winfa-layout-stacked .winfa-stacked-spin-wrap {
    margin-top: 8px;
}

/* Modal Content (The Card) */
.winfa-modal-content {
    background: var(--winfa-bg-glass);
    margin: 5vh auto;
    margin-bottom: max(5vh, env(safe-area-inset-bottom, 0px));
    padding: 40px;
    padding-bottom: max(40px, calc(24px + env(safe-area-inset-bottom, 0px)));
    width: 90%;
    max-width: min(500px, calc(100vw - 24px));
    border-radius: var(--winfa-border-radius);
    text-align: center;
    position: relative;
    box-shadow: var(--winfa-shadow-soft);
    border: 1px solid rgba(255,255,255,0.5);
    animation: winfaPopUp 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    box-sizing: border-box;
    overflow-x: clip;
}

@keyframes winfaPopUp {
    0% { transform: scale(0.8) translateY(20px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* Typography */
.winfa-modal-content h3 {
    font-family: var(--winfa-font-title);
    font-size: 32px;
    margin: 0 0 15px;
    color: #2d3436;
    letter-spacing: 0.5px;
}

.winfa-modal-content p {
    font-family: var(--winfa-font-body);
    font-size: 15px;
    color: #636e72;
    line-height: 1.6;
    margin-bottom: 30px;
    font-weight: 300;
}

/* Inputs */
.winfa-input-group {
    margin-bottom: 25px;
}

.winfa-input {
    width: 100%;
    padding: 16px 20px;
    margin: 8px 0;
    border: 2px solid #dfe6e9;
    border-radius: 16px;
    font-family: var(--winfa-font-body);
    font-size: 16px;
    transition: all 0.3s ease;
    background: #f7f9fa;
    color: #2d3436;
}

.winfa-input:focus {
    outline: none;
    border-color: var(--winfa-primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(255, 177, 66, 0.15);
    color: #2d3436;
}

.winfa-input::placeholder {
    color: #636e72 !important;
}

/* Buttons */
.winfa-btn {
    background: var(--winfa-primary-gradient);
    color: #fff;
    border: none;
    padding: 18px 30px;
    min-height: 48px;
    border-radius: 16px;
    width: 100%;
    font-family: var(--winfa-font-title);
    font-size: 22px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 10px 20px rgba(255, 177, 66, 0.3);
    position: relative;
    overflow: hidden;
    letter-spacing: 1px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.winfa-btn::after {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    transition: 0.5s;
}

.winfa-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 30px rgba(255, 177, 66, 0.4);
}

.winfa-btn:hover::after {
    left: 100%;
}

.winfa-btn:active {
    transform: scale(0.98);
}

/* Close Button */
.winfa-close {
    position: absolute;
    top: max(12px, env(safe-area-inset-top, 0px));
    left: max(12px, env(safe-area-inset-left, 0px));
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    line-height: 1;
    background: #f1f2f6;
    border-radius: 50%;
    color: #747d8c;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.winfa-close:hover {
    background: #ff5252;
    color: #fff;
    transform: rotate(90deg);
}

/* Wheel Wrapper — always fit parent card; square via aspect-ratio */
.winfa-wheel-wrapper {
    position: relative;
    width: min(340px, 100%);
    max-width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    margin: 0 auto 30px;
    container-type: inline-size;
    --winfa-light-offset: 168px;
    --winfa-light-offset: calc(50cqw - 2px);
    box-sizing: border-box;
}

/* Rim & Wheel Container */
.winfa-rim {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    position: relative;
    padding: 12px;
    background: #2d3436;
    box-shadow: 
        0 20px 50px rgba(0,0,0,0.3),
        inset 0 0 0 2px rgba(255,255,255,0.1);
    border: 4px solid #f1c40f;
}

.winfa-wheel {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    background: #fff;
    transition: transform 4s cubic-bezier(0.17, 0.67, 0.12, 0.99);
}

#winfa-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.winfa-fun .winfa-fun-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Pointer */
.winfa-pointer {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 60px;
    z-index: 20;
    filter: drop-shadow(0 5px 5px rgba(0,0,0,0.3));
}
.winfa-pointer::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    border-left: 25px solid transparent;
    border-right: 25px solid transparent;
    border-top: 50px solid #e74c3c;
}
.winfa-pointer::after {
    content: '';
    position: absolute;
    top: -10px; left: 50%; transform: translateX(-50%);
    width: 12px; height: 12px;
    background: #c0392b;
    border-radius: 50%;
}

/* Center Cap */
.winfa-center-cap {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 70px; height: 70px;
    background: #fff;
    border-radius: 50%;
    z-index: 10;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 4px solid #f1c40f;
}

.winfa-center-cap-inner {
    width: 50px; height: 50px;
    background: var(--winfa-primary-gradient);
    border-radius: 50%;
    box-shadow: inset 0 3px 6px rgba(255,255,255,0.4);
    animation: winfaPulse 2s infinite;
}

@keyframes winfaPulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 177, 66, 0.7); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(255, 177, 66, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 177, 66, 0); }
}

/* Lights Ring */
.winfa-lights-ring {
    position: absolute;
    top: -5px; left: -5px; right: -5px; bottom: -5px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 5;
}

.winfa-bulb {
    position: absolute;
    top: 50%; left: 50%;
    width: 12px; height: 12px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 10px #fff;
    transform: translate(-50%, -50%) rotate(calc(var(--i) * 22.5deg)) translateY(calc(-1 * var(--winfa-light-offset, 168px)));
    animation: winfaBlink 1s infinite alternate;
    animation-delay: calc(var(--i) * 0.05s);
}

.winfa-bulb:nth-child(even) {
    background: #f1c40f;
    box-shadow: 0 0 10px #f1c40f;
}

@keyframes winfaBlink {
    0% { opacity: 0.3; transform: translate(-50%, -50%) rotate(calc(var(--i) * 22.5deg)) translateY(calc(-1 * var(--winfa-light-offset, 168px))) scale(0.8); }
    100% { opacity: 1; transform: translate(-50%, -50%) rotate(calc(var(--i) * 22.5deg)) translateY(calc(-1 * var(--winfa-light-offset, 168px))) scale(1.2); }
}

/* ================= THEMES ================= */

/* 1. Dark Modern */
.winfa-theme-dark_modern .winfa-modal-content {
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid #444;
    color: #fff;
}
.winfa-theme-dark_modern h3 { color: #f1c40f; }
.winfa-theme-dark_modern p { color: #b2bec3; }
.winfa-theme-dark_modern .winfa-input {
    background: #2d3436;
    border-color: #444;
    color: #fff;
}
.winfa-theme-dark_modern .winfa-input:focus {
    background: #2d3436;
    border-color: #f1c40f;
    color: #fff;
    box-shadow: 0 0 0 4px rgba(241, 196, 15, 0.18);
}
.winfa-theme-dark_modern .winfa-input::placeholder {
    color: #95a5a6 !important;
}
.winfa-theme-dark_modern .winfa-input:-webkit-autofill,
.winfa-theme-dark_modern .winfa-input:-webkit-autofill:hover,
.winfa-theme-dark_modern .winfa-input:-webkit-autofill:focus {
    -webkit-text-fill-color: #fff;
    caret-color: #fff;
    transition: background-color 99999s ease-in-out 0s;
    box-shadow: 0 0 0 1000px #2d3436 inset;
}
.winfa-theme-dark_modern .winfa-rim { background: #000; border-color: #f1c40f; }

/* 2. Neon Cyberpunk */
.winfa-theme-neon .winfa-modal-content {
    background: rgba(10, 10, 30, 0.95);
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.2);
    border: 1px solid #00ffff;
}
.winfa-theme-neon h3 {
    color: #00ffff;
    text-shadow: 0 0 10px #00ffff;
}
.winfa-theme-neon .winfa-btn {
    background: linear-gradient(90deg, #ff00ff, #00ffff);
    box-shadow: 0 0 20px rgba(255, 0, 255, 0.5);
}
.winfa-theme-neon .winfa-input {
    background: rgba(255,255,255,0.05);
    border-color: #ff00ff;
    color: #fff;
}
.winfa-theme-neon .winfa-input:focus {
    background: rgba(255,255,255,0.08);
    border-color: #00ffff;
    color: #fff;
    box-shadow: 0 0 0 4px rgba(0, 255, 255, 0.15);
}
.winfa-theme-neon .winfa-input:-webkit-autofill,
.winfa-theme-neon .winfa-input:-webkit-autofill:hover,
.winfa-theme-neon .winfa-input:-webkit-autofill:focus {
    -webkit-text-fill-color: #fff;
    caret-color: #fff;
    transition: background-color 99999s ease-in-out 0s;
    box-shadow: 0 0 0 1000px #0a0a1e inset;
}
.winfa-theme-neon .winfa-bulb {
    background: #00ffff;
    box-shadow: 0 0 15px #00ffff;
}

/* 3. Luxury (Gold) */
.winfa-theme-luxury .winfa-modal-content {
    background: #111;
    border: 2px solid #D4AF37;
    background-image: linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 20px 20px;
}
.winfa-theme-luxury h3 {
    background: linear-gradient(to right, #D4AF37, #FDB931, #D4AF37);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.winfa-theme-luxury .winfa-btn {
    background: linear-gradient(45deg, #D4AF37, #C5A028);
    color: #000;
}
.winfa-theme-luxury .winfa-input {
    background: #222;
    border-color: #555;
    color: #D4AF37;
}
.winfa-theme-luxury .winfa-input:focus {
    background: #222;
    border-color: #D4AF37;
    color: #D4AF37;
    box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.18);
}
.winfa-theme-luxury .winfa-input:-webkit-autofill,
.winfa-theme-luxury .winfa-input:-webkit-autofill:hover,
.winfa-theme-luxury .winfa-input:-webkit-autofill:focus {
    -webkit-text-fill-color: #D4AF37;
    caret-color: #D4AF37;
    transition: background-color 99999s ease-in-out 0s;
    box-shadow: 0 0 0 1000px #222 inset;
}
.winfa-theme-luxury .winfa-rim { border-color: #D4AF37; }

/* 4. Minimal */
.winfa-theme-minimal .winfa-modal-content {
    background: #fff;
    box-shadow: 0 20px 60px rgba(0,0,0,0.05);
    border: none;
}
.winfa-theme-minimal .winfa-btn {
    background: #2d3436;
    color: #fff;
    box-shadow: none;
}
.winfa-theme-minimal .winfa-rim {
    background: #f1f2f6;
    border: none;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.05);
}
.winfa-theme-minimal .winfa-bulb { display: none; } /* No lights for minimal */

/* 5. Festive */
.winfa-theme-festive .winfa-modal-content {
    background: #fff0f5;
    border: 4px dashed #ff69b4;
}
.winfa-theme-festive h3 { color: #ff1493; }
.winfa-theme-festive .winfa-btn {
    background: linear-gradient(45deg, #ff69b4, #ff1493);
    border-radius: 50px;
}
.winfa-theme-festive .winfa-rim {
    background: #ff69b4;
    border: 4px solid #fff;
}

/* Result Area */
.winfa-result h3 {
    color: var(--winfa-success);
    font-size: 36px;
    margin-bottom: 10px;
}

#winfa-coupon-code {
    background: #e8f5e9;
    border: 2px dashed #27ae60;
    padding: 15px;
    font-size: 24px;
    font-weight: bold;
    color: #27ae60;
    margin-top: 20px;
    border-radius: 12px;
    font-family: monospace;
    letter-spacing: 2px;
}

/* Responsive */
@media (max-width: 480px) {
    .winfa-modal.winfa-inline {
        padding: 16px 8px;
    }
    .winfa-modal-content {
        padding: 22px 14px;
        padding-bottom: max(22px, calc(16px + env(safe-area-inset-bottom, 0px)));
        width: min(94%, calc(100vw - 16px));
        margin: 8vh auto;
        margin-bottom: max(8vh, env(safe-area-inset-bottom, 0px));
    }
    .winfa-wheel-wrapper {
        width: min(280px, 100%);
        max-width: 100%;
        margin-bottom: 20px;
    }
    .winfa-layout-stacked .winfa-stacked-wheel-wrap .winfa-wheel-wrapper {
        width: min(260px, 100%);
    }
    .winfa-pointer {
        top: -14px;
        transform: translateX(-50%) scale(0.88);
        transform-origin: top center;
    }
    .winfa-center-cap {
        width: 56px;
        height: 56px;
    }
    .winfa-center-cap-inner {
        width: 40px;
        height: 40px;
    }
    .winfa-modal-content h3 { font-size: clamp(1.15rem, 5vw, 1.5rem); }
    .winfa-result h3 {
        font-size: clamp(1.25rem, 6vw, 2rem);
    }
    #winfa-coupon-code {
        font-size: clamp(1rem, 4.5vw, 1.35rem);
        padding: 12px;
        word-break: break-all;
    }
}

@media (max-width: 350px) {
    .winfa-wheel-wrapper {
        width: 100%;
    }
    .winfa-modal-content {
        padding: 18px 10px;
        padding-bottom: max(18px, calc(12px + env(safe-area-inset-bottom, 0px)));
        border-radius: 18px;
    }
    .winfa-center-cap {
        width: 48px;
        height: 48px;
    }
    .winfa-center-cap-inner {
        width: 34px;
        height: 34px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .winfa-modal-content {
        animation: none;
    }
    /* Do NOT force .winfa-wheel transition to ~0s — that cancels the prize spin
       (inline 4s duration loses to !important) and looks like a mid-spin freeze. */
    .winfa-bulb {
        animation: none;
        opacity: 0.85;
    }
}
