/* ------------------------------- */
/* 1. متغیرهای ریشه‌ای و تایپوگرافی
/* ------------------------------- */

:root {
    --gn-font: 'iransans', Tahoma, sans-serif;
    --gn-radius: 30px;
    --gn-transition: background-color 0.4s cubic-bezier(0.23, 1, 0.32, 1), transform 0.4s cubic-bezier(0.23, 1, 0.32, 1), filter 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    --gn-overlay-pad: clamp(10px, 2.5vh, 24px);
    --gn-card-pad: clamp(16px, 3vh, 36px);
    --gn-wheel-size: clamp(250px, min(52vw, 44vh), 500px);
    --gn-canvas-fill: 98%;
}

.gn-frontend-overlay,
.gn-frontend-overlay *,
.gn-floating-trigger,
.gn-trigger-text {
    font-family: var(--gn-font) !important;
}

/* ------------------------------- */
/* 2. پاپ‌آپ اصلی و کانتینرها
/* ------------------------------- */

.gn-frontend-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    background: rgba(0, 0, 0, 0.8) !important;
    z-index: 999999 !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    padding: var(--gn-overlay-pad) !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

body:has(.gn-frontend-overlay.open) {
    overflow: hidden !important;
}

.gn-frontend-overlay.open {
    display: flex !important;
}

.gn-popup-card {
    width: min(100%, 500px);
    max-width: 500px;
    background: #fff;
    border-radius: clamp(20px, 3vw, 32px);
    position: relative;
    max-height: calc(100vh - (var(--gn-overlay-pad) * 2)) !important;
    max-height: calc(100dvh - (var(--gn-overlay-pad) * 2)) !important;
    overflow: visible !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
}

.gn-frontend-overlay.open .gn-popup-card {
    transform: translateY(0);
}

.gn-popup-card::-webkit-scrollbar {
    display: none !important;
}

#gn_form_wrapper[style*="display: none"],
#gn_wheel_wrapper[style*="display: none"],
#gn_result_wrapper[style*="display: none"] {
    display: none !important;
}

/* ------------------------------- */
/* 3. سیستم تم‌های رنگی
/* ------------------------------- */

.gn-theme-1 {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
    color: #fff;
    border: 2px solid #3b82f6;
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.3);
}

.gn-theme-1 .gn-spin-button {
    background: #3b82f6;
    color: #fff;
}

.gn-theme-2 {
    background: linear-gradient(135deg, #450a0a 0%, #991b1b 100%);
    color: #fff;
    border: 2px solid #ef4444;
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.3);
}

.gn-theme-2 .gn-spin-button {
    background: #ef4444;
    color: #fff;
}

.gn-theme-3 {
    background: linear-gradient(135deg, #422006 0%, #713f12 100%);
    color: #fde047;
    border: 2px solid #eab308;
    box-shadow: 0 0 30px rgba(234, 179, 8, 0.3);
}

.gn-theme-3 .gn-spin-button {
    background: #eab308;
    color: #422006;
}

.gn-theme-4 {
    background: linear-gradient(135deg, #2e1065 0%, #5b21b6 100%);
    color: #fff;
    border: 2px solid #8b5cf6;
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.3);
}

.gn-theme-4 .gn-spin-button {
    background: #8b5cf6;
    color: #fff;
}

.gn-theme-5 {
    background: linear-gradient(135deg, #064e3b 0%, #065f46 100%);
    color: #fff;
    border: 2px solid #10b981;
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.3);
}

.gn-theme-5 .gn-spin-button {
    background: #10b981;
    color: #fff;
}

/* ------------------------------- */
/* 4. چیدمان داخلی و گردونه
/* ------------------------------- */

.gn-form-section,
.gn-wheel-section {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.gn-wheel-section {
    background: rgba(0, 0, 0, 0.2);
}

.gn-modal-vertical-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-height: 100%;
    padding: var(--gn-card-pad);
    text-align: center;
    box-sizing: border-box;
}

.gn-row-title {
    width: 100%;
    margin-bottom: clamp(2px, 0.8vh, 8px);
}

.gn-row-title h2 {
    font-size: clamp(18px, 2.4vh, 26px);
    font-weight: 900;
    margin: 0;
    line-height: 1.35;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.gn-row-desc {
    width: 100%;
    margin-bottom: clamp(10px, 1.8vh, 20px);
}

.gn-row-desc p {
    font-size: clamp(13px, 1.7vh, 15px);
    margin: 0;
    opacity: 0.9;
    line-height: 1.7;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.gn-row-wheel {
    position: relative !important;
    width: 100% !important;
    min-height: 0 !important;
    height: auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: clamp(8px, 1.6vh, 18px) 0 !important;
    flex: 0 1 auto !important;
}

.gn-wheel-stage {
    position: relative !important;
    width: min(var(--gn-wheel-size), 100%) !important;
    height: auto !important;
    max-width: 100% !important;
    aspect-ratio: 1 / 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 0 0 auto !important;
}

.gardoonak-pointer img {
    width: 100% !important;
    height: auto !important;
}

.gn-row-action {
    width: 100%;
    max-width: 400px;
}

.gn-inputs-group {
    margin-bottom: 15px;
}

.gn-modal-vertical-wrapper,
.gn-row-title,
.gn-row-desc,
.gn-row-action,
.gn-row-result {
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
}

.gn-row-title h2,
.gn-row-desc p {
    margin: 0 !important;
    padding: 0 !important;
    text-align: center !important;
    width: 100% !important;
}

.gn-row-action {
    max-width: 420px !important;
    margin: 0 auto !important;
}

#gardoonak-canvas {
    position: relative !important;
    z-index: 5 !important;
    width: var(--gn-canvas-fill) !important;
    max-width: var(--gn-canvas-fill) !important;
    aspect-ratio: 1 / 1 !important;
    height: auto !important;
    background: transparent !important;
    flex: 0 0 auto !important;
}

.gn-wheel-lights-bg {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    z-index: 1 !important;
    pointer-events: none !important;
    opacity: 0.8;
}

.gardoonak-pointer {
    position: absolute !important;
    top: 5% !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 10 !important;
    width: clamp(32px, 10%, 52px) !important;
    height: auto !important;
    transition: transform 0.1s cubic-bezier(0.17, 0.67, 0.83, 0.67);
    pointer-events: none;
}

.gn-form-section h2,
.gn-form-section p {
    text-align: center;
}

/* ------------------------------- */
/* 5. فرم‌ها و دکمه‌ها
/* ------------------------------- */

.gn-input-field {
    width: 100%;
    padding: 16px;
    margin-bottom: 15px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    transition: 0.3s;
}

.gn-input-field:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: inherit;
    outline: none;
}

.gn-spin-button {
    width: 100%;
    min-height: 52px;
    padding: clamp(12px, 2vh, 18px);
    border-radius: 15px;
    border: none;
    font-size: clamp(16px, 2vh, 20px);
    font-weight: 900;
    cursor: pointer;
    transition: 0.3s;
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.gn-spin-button:hover {
    transform: scale(1.03);
    filter: brightness(1.2);
}

.gn-spin-button.is-loading {
    cursor: wait;
    opacity: 0.9;
}

.gn-btn-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: currentColor;
    border-radius: 50%;
    display: none;
    flex: 0 0 auto;
    animation: gn-spin-loader 0.8s linear infinite;
}

.gn-spin-button.is-loading .gn-btn-spinner {
    display: inline-flex;
}

.gn-input-field,
.gn-spin-button {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.gn-close-popup {
    position: absolute;
    top: clamp(12px, 2vh, 20px);
    left: clamp(12px, 2vh, 20px);
    width: clamp(34px, 5vh, 40px);
    height: clamp(34px, 5vh, 40px);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    transition: 0.3s;
}

.gn-close-popup:hover {
    background: #ef4444;
}

.gn-toast-layer,
.gn-toast-fallback {
    position: absolute;
    top: 18px;
    left: 18px;
    right: 18px;
    z-index: 20;
    pointer-events: none;
}

.gn-toast-fallback {
    position: fixed;
    top: 24px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(92vw, 420px);
    z-index: 9999999;
}

.gn-toast {
    background: rgba(15, 23, 42, 0.92);
    color: #fff;
    padding: 12px 18px;
    border-radius: 18px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.28);
    text-align: center;
    font-size: 14px;
    line-height: 1.7;
    direction: rtl;
}

.gn-toast--success {
    background: rgba(6, 95, 70, 0.94);
}

.gn-toast--error {
    background: rgba(153, 27, 27, 0.94);
}

/* ------------------------------- */
/* 6. دکمه شناور و پیام‌ها
/* ------------------------------- */

.gn-floating-trigger {
    z-index: 999998;
}

.gn-trigger-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.gn-trigger-text {
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    background: #ffffff;
    color: #1e293b;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
    z-index: 2;
    pointer-events: none;
    animation: gn-chat-bounce 2.5s infinite ease-in-out;
}

.gn-trigger-text::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 8px;
    border-style: solid;
    border-color: #ffffff transparent transparent transparent;
}

.gn-close-float {
    position: absolute;
    top: -12px;
    left: -12px;
    width: 24px;
    height: 24px;
    background: #ef4444;
    color: #ffffff;
    border-radius: 20%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.4);
    z-index: 3;
    transition: all 0.2s ease;
}

.gn-close-float:hover {
    background: #dc2626;
    transform: scale(1.15);
}

.gn-empty-state {
    width: min(100%, 360px);
    padding: 24px 22px;
    border-radius: 24px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    text-align: center;
    color: #0f172a;
}

.gn-empty-state__title {
    font-size: 18px;
    font-weight: 800;
    line-height: 1.8;
    text-wrap: balance;
}

.gn-empty-state__desc {
    margin: 8px 0 0;
    color: #475569;
    font-size: 14px;
    line-height: 1.9;
}

.gn-empty-popup {
    max-width: 420px;
    width: min(92vw, 420px);
    background: transparent;
    border: 0;
    box-shadow: none;
    max-height: none !important;
    overflow: visible !important;
}

.gn-empty-popup .gn-modal-vertical-wrapper {
    min-height: 240px;
    justify-content: center !important;
    padding: 20px 16px;
}

.gn-empty-popup .gn-close-popup {
    background: rgba(15, 23, 42, 0.08);
    color: #0f172a;
}

.gn-empty-popup .gn-close-popup:hover {
    background: #ef4444;
    color: #fff;
}

/* ------------------------------- */
/* 7. انیمیشن‌ها
/* ------------------------------- */

.gn-anim-pulse {
    animation: gn-pulse 2s infinite;
}

.gn-anim-swing {
    animation: gn-swing 2s ease-in-out infinite;
    transform-origin: top center;
}

.gn-anim-float {
    animation: gn-float 3s ease-in-out infinite;
}

.gn-anim-wobble {
    animation: gn-wobble 1.5s infinite;
}

@keyframes gn-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.4);
    }

    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 20px rgba(255, 255, 255, 0);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes gn-swing {

    0%,
    100% {
        transform: rotate(10deg);
    }

    50% {
        transform: rotate(-10deg);
    }
}

@keyframes gn-float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-15px);
    }
}

@keyframes gn-wobble {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px) rotate(-5deg);
    }

    75% {
        transform: translateX(5px) rotate(5deg);
    }
}

@keyframes gn-chat-bounce {

    0%,
    100% {
        transform: translate(-50%, 0);
    }

    50% {
        transform: translate(-50%, -6px);
    }
}

@keyframes gn-confetti-fall {
    0% {
        transform: translateY(-10vh) rotate(0deg) scale(1);
        opacity: 1;
    }

    100% {
        transform: translateY(110vh) rotate(720deg) scale(0.6);
        opacity: 0;
    }
}

/* ------------------------------- */
/* 8. استایل‌های ریسپانسیو
/* ------------------------------- */

@media (max-height: 700px) {
    :root {
        --gn-overlay-pad: 10px;
        --gn-card-pad: clamp(12px, 2vh, 18px);
        --gn-wheel-size: clamp(220px, min(48vw, 38vh), 360px);
    }

    .gn-modal-vertical-wrapper {
        gap: 0;
    }

    .gn-row-title h2 {
        font-size: 1.1rem;
        margin-bottom: 5px;
    }

    .gn-row-desc p {
        font-size: 0.9rem;
    }

    .gn-input-field {
        padding: 12px 14px;
        margin-bottom: 10px;
    }

    .gn-spin-button {
        min-height: 48px;
        margin-top: 6px;
    }
}

@media (max-width: 768px) {
    :root {
        --gn-overlay-pad: 10px;
        --gn-card-pad: clamp(14px, 4vw, 22px);
        --gn-wheel-size: clamp(220px, min(86vw, 42vh), 360px);
    }

    .gn-popup-card {
        flex-direction: column;
        width: min(94vw, 500px);
        height: auto;
        max-height: calc(100vh - 20px) !important;
        max-height: calc(100dvh - 20px) !important;
        overflow: visible !important;
    }

    .gn-empty-popup {
        width: min(92vw, 360px);
        height: auto !important;
        max-height: none !important;
    }

    .gn-empty-popup .gn-modal-vertical-wrapper {
        min-height: auto;
        padding: 18px 12px;
    }

    .gn-empty-state {
        width: 100%;
        padding: 22px 18px;
    }

    .gn-empty-state__title,
    .gn-empty-state__desc {
        max-width: 100%;
        white-space: normal;
        word-break: break-word;
    }
}

@media (max-width: 480px) {
    :root {
        --gn-wheel-size: clamp(200px, min(88vw, 40vh), 320px);
    }

    .gn-row-title h2 {
        font-size: clamp(17px, 5vw, 22px);
    }

    .gn-row-desc p {
        font-size: 13px;
    }

    .gn-row-action {
        max-width: 100% !important;
    }
}

@media (max-height: 560px) {
    :root {
        --gn-overlay-pad: 6px;
        --gn-card-pad: 10px;
        --gn-wheel-size: clamp(150px, min(42vw, 32vh), 250px);
    }

    .gn-row-desc {
        margin-bottom: 6px;
    }

    .gn-row-desc p {
        line-height: 1.45;
        -webkit-line-clamp: 1;
    }

    .gn-row-wheel {
        margin: 4px 0 !important;
    }

    .gn-input-field {
        padding: 10px 12px;
        margin-bottom: 8px;
    }

    .gn-spin-button {
        min-height: 44px;
        padding: 10px 14px;
    }
}

@media (max-height: 480px) {
    :root {
        --gn-overlay-pad: 4px;
        --gn-card-pad: 8px;
        --gn-wheel-size: clamp(120px, min(38vw, 28vh), 210px);
    }

    .gn-popup-card {
        overflow: visible !important;
    }

    .gn-row-title {
        margin-bottom: 2px;
    }

    .gn-row-title h2 {
        font-size: 15px;
        line-height: 1.25;
        -webkit-line-clamp: 1;
    }

    .gn-row-desc {
        margin-bottom: 4px;
    }

    .gn-row-desc p {
        font-size: 12px;
        line-height: 1.35;
    }

    .gn-row-wheel {
        margin: 2px 0 !important;
    }

    .gn-input-field {
        padding: 8px 10px;
        margin-bottom: 6px;
        min-height: 36px;
    }

    .gn-spin-button {
        min-height: 40px;
        padding: 8px 12px;
        margin-top: 4px;
        font-size: 14px;
    }

    .gn-close-popup {
        width: 30px;
        height: 30px;
        font-size: 20px;
    }
}

@media (max-height: 400px) {
    :root {
        --gn-wheel-size: clamp(96px, min(34vw, 24vh), 170px);
    }

    .gn-row-desc {
        display: none !important;
    }
}

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