/* frontend.css - نسخه نهایی و بهینه‌سازی شده */

/* --- تنظیمات کلی --- */
.lucky-grid-frontend {
    font-family: inherit; /* از فونت قالب پیروی می‌کند */
    max-width: 800px;
    margin: 0 auto;
    box-sizing: border-box;
}

.lucky-grid-frontend * {
    box-sizing: border-box;
}

/* --- باکس وضعیت و قیمت --- */
.lucky-grid-status-box {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 30px;
    text-align: center;
    color: white;
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
    transition: transform 0.3s ease;
    border: 1px solid rgba(255,255,255,0.1);
}

.lucky-grid-status-box:hover {
    transform: translateY(-2px);
}

/* --- کانتینر گرید --- */
.lucky-grid {
    display: grid;
    /* نکته: تعداد ستون‌ها (grid-template-columns) توسط PHP به صورت اینلاین اضافه می‌شود */
    gap: 12px;
    background: #34495e;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.05);
}

/* --- استایل سلول‌ها (خانه‌ها) --- */
.grid-cell {
    aspect-ratio: 1;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 3px solid transparent;
    box-shadow: 0 4px 6px rgba(0,0,0,0.15);
    background-size: cover; /* در صورتی که عکس پس‌زمینه ست شود */
}

/* لایه شیشه‌ای روی سلول‌ها برای زیبایی */
.cell-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(to bottom, rgba(255,255,255,0.1), transparent);
    pointer-events: none;
    z-index: 1;
}

/* هاور معمولی */
.grid-cell:hover {
    transform: scale(1.05);
    z-index: 5;
    box-shadow: 0 10px 20px rgba(0,0,0,0.25);
    border-color: rgba(255,255,255,0.3);
}

/* --- عکس و آیکون داخل سلول --- */
.cell-symbol {
    font-size: 28px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    z-index: 2;
}

.cell-image-icon {
    width: 65%;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    filter: drop-shadow(0 4px 4px rgba(0,0,0,0.2));
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 2;
}

.grid-cell:hover .cell-image-icon {
    transform: scale(1.15) rotate(5deg);
}

/* --- حالت فعال (چرخش روی خانه‌ها) --- */
.grid-cell.active {
    background: linear-gradient(145deg, #e74c3c, #c0392b) !important;
    border-color: #f1c40f !important;
    transform: scale(1.1);
    z-index: 10;
    box-shadow: 0 0 25px rgba(241, 196, 15, 0.5) !important;
}

/* --- حالت برنده نهایی (Winning State) --- */
/* این کلاس زمانی اضافه می‌شود که گردونه روی جایزه می‌ایستد */
.grid-cell.winner {
    background: linear-gradient(135deg, #f1c40f, #f39c12) !important;
    border-color: #fff !important;
    transform: scale(1.15) !important;
    z-index: 20;
    box-shadow: 0 0 30px rgba(241, 196, 15, 0.8), 
                inset 0 0 10px rgba(255, 255, 255, 0.5) !important;
    animation: winner-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes winner-pulse {
    0% { transform: scale(1.15); filter: brightness(100%); }
    100% { transform: scale(1.2); filter: brightness(115%); }
}

/* --- دکمه‌ها --- */
.btn-lucky {
    border: none;
    padding: 12px 28px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.btn-lucky:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.25);
}

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

.btn-start { background: #27ae60; color: white; }
.btn-play { background: #e74c3c; color: white; }
.btn-test { background: #f39c12; color: white; }
.btn-guest { background: #f1c40f; color: #2c3e50; }

/* انیمیشن پالس دکمه شروع */
.pulse-animation {
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(39, 174, 96, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(39, 174, 96, 0); }
    100% { box-shadow: 0 0 0 0 rgba(39, 174, 96, 0); }
}

/* --- سیستم پاپ‌آپ --- */
.lucky-grid-popup {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: transparent; /* مدیریت پس‌زمینه در کانتنت یا جاوااسکریپت */
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none; /* کلیک پشت پاپ‌آپ آزاد است مگر روی محتوا */
}

/* کانتنت پاپ‌آپ عمومی */
.lucky-grid-popup .popup-content {
    pointer-events: auto;
    background: white;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 450px;
    text-align: center;
    position: relative;
    animation: popupSlideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    border: 1px solid rgba(0,0,0,0.05);
}

.popup-content.dark {
    background: linear-gradient(135deg, #2c3e50, #3498db);
    color: white;
}

/* دکمه بستن پاپ‌آپ */
.popup-close {
    position: absolute;
    top: 15px; left: 15px; /* پیش‌فرض چپ */
    width: 30px; height: 30px;
    line-height: 30px;
    text-align: center;
    border-radius: 50%;
    background: rgba(0,0,0,0.05);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-close:hover { 
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
    transform: rotate(90deg); 
}

.popup-content.dark .popup-close:hover {
    background: rgba(255,255,255,0.2);
    color: white;
}

/* --- استایل اختصاصی پاپ‌آپ نتیجه (Winning Popup) --- */
#grid-result-popup {
    pointer-events: auto; /* برای پاپ‌آپ نتیجه کل صفحه بلاک شود بهتر است */
    background: rgba(0,0,0,0.6); /* تاریکی پشت صفحه */
    backdrop-filter: blur(5px);
}

#grid-result-popup .popup-content {
    max-width: 700px !important;
    width: 95% !important;
    padding: 50px 40px !important;
    border-radius: 25px !important;
    
    /* افکت شیشه‌ای مدرن */
    background: rgba(44, 62, 80, 0.9);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    
    box-shadow: 0 25px 80px rgba(0,0,0,0.4);
    animation: popup-zoom 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}

#grid-result-popup h2 {
    font-size: 2em;
    margin-bottom: 15px;
    color: #f1c40f;
    text-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

#grid-result-popup p {
    font-size: 1.2em;
    line-height: 1.6;
    color: #ecf0f1;
}

/* دکمه بستن پاپ‌آپ نتیجه (سمت راست طبق کد شما) */
#grid-result-popup .popup-close {
    left: auto; 
    right: 20px;
    top: 20px;
    background: rgba(255,255,255,0.1);
    color: white;
    width: 40px; height: 40px;
    font-size: 24px;
}
#grid-result-popup .popup-close:hover {
    background: #e74c3c;
}

/* --- فرم ورودی مهمان --- */
.guest-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    margin-bottom: 15px;
    font-family: inherit;
    font-size: 14px;
    transition: 0.3s;
    background: #f9f9f9;
}

.guest-input:focus {
    border-color: #667eea;
    background: white;
    outline: none;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

/* --- لیست جوایز --- */
.prizes-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 25px;
}

.prize-item {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    padding: 15px;
    border-radius: 12px;
    width: 120px;
    text-align: center;
    transition: 0.2s;
}
.prize-item:hover {
    background: rgba(255,255,255,0.2);
}

/* --- انیمیشن‌های عمومی --- */
@keyframes popupSlideIn {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes popup-zoom {
    from { transform: scale(0.7); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* --- ریسپانسیو (موبایل) --- */
@media (max-width: 600px) {
    .lucky-grid {
        gap: 8px;
        padding: 12px;
    }
    
    .cell-symbol {
        font-size: 20px;
    }
    
    .cell-image-icon {
        width: 75%; /* در موبایل آیکون بزرگتر */
    }

    .btn-lucky {
        width: 100%;
        margin: 5px 0;
        padding: 14px;
    }
    
    .lucky-grid-status-box {
        padding: 20px;
    }
    
    /* تنظیمات پاپ‌آپ نتیجه برای موبایل */
    #grid-result-popup .popup-content {
        padding: 30px 20px !important;
        width: 90% !important;
    }
    
    #grid-result-popup h2 {
        font-size: 1.6em;
    }
}