/* Spin Wheel Frontend Styles */

.spin-wheel-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
}

.spin-wheel-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
}

.spin-wheel-container {
    position: relative;
    width: 88%;
    max-width: 760px;
    min-height: 420px;
    background: #FFFFFF;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    animation: popupSlideIn 0.5s ease-out;
    overflow: hidden;
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-50px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Close button removed - users close via overlay click */

.spin-wheel-content {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.spin-wheel-header { text-align: center; padding: 16px 30px 8px; border-bottom: 1px solid #E5E5E5; }

.spin-wheel-title {
    font-size: 24px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #000000;
    letter-spacing: -0.5px;
}

.spin-wheel-description {
    font-size: 14px;
    line-height: 1.4;
    margin: 0;
    color: #666666;
}

.spin-wheel-main {
    display: grid;
    grid-template-columns: 50% 50%;
    flex: 1;
    height: calc(100% - 60px);
    min-height: 400px;
    position: relative;
}

/* Left Column - Wheel Only */
.spin-wheel-left { 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    padding: 20px; 
    background: #F5F5F5; 
    border-right: 1px solid #E5E5E5;
    min-height: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* Ensure background extends to full height */
.spin-wheel-left::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #F5F5F5;
    z-index: -1;
}

/* Ensure both columns stretch to equal height of container */
.spin-wheel-content,
.spin-wheel-main,
.spin-wheel-left,
.spin-wheel-right {
    height: 100%;
}

.spin-wheel-container { display: flex; flex-direction: column; }
.spin-wheel-content { flex: 1; }

/* Right Column - Content */
.spin-wheel-right { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 24px 40px; gap: 16px; }

/* Wheel Container */
.wheel-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 320px;
    max-height: 320px;
    transform-origin: center center;
    transition: transform 0.1s ease-out;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 20px; /* Space for pointer */
}

#spin-wheel-canvas {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.wheel-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70px;
    height: 70px;
    background: #FFFFFF;
    border: 2px solid #E5E5E5;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 5;
}

.wheel-logo {
    max-width: 50px;
    max-height: 50px;
    object-fit: contain;
}

.wheel-pointer {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 16px solid #000000;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.1));
    z-index: 10;
}

/* Form Styles */
.spin-wheel-form {
    width: 100%;
    max-width: 280px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group input[type="email"] {
    width: 100%;
    padding: 16px 20px;
    background: #FFFFFF;
    border: 1px solid #E5E5E5;
    border-radius: 8px;
    font-size: 14px;
    color: #000000;
    transition: all 0.3s ease;
    box-sizing: border-box;
    font-family: inherit;
}

.form-group input[type="email"]:focus {
    outline: none;
    border-color: #000000;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.form-group input[type="email"].error {
    border-color: #dc3232;
}

.email-error {
    color: #dc3232;
    font-size: 14px;
    margin-top: 8px;
    text-align: center;
}

.spin-button {
    width: 100%;
    padding: 16px 24px;
    background: transparent;
    border: 2px solid #000000;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #000000;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: 'Montserrat', sans-serif;
}

.spin-button:hover:not(:disabled) {
    background: #000000;
    color: #FFFFFF;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.spin-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Ensure spin button remains static during wheel animation */
.spin-button.spinning {
    /* No rotation animation */
}

/* Terms */
.spin-wheel-terms {
    text-align: center;
    padding: 20px 30px;
    border-top: 1px solid #E5E5E5;
    background: #FAFAFA;
}

.spin-wheel-terms small {
    font-size: 11px;
    line-height: 1.4;
    color: #666666;
}

/* Result Display - In-place replacement */
.spin-result-content {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 0;
    max-width: 280px;
    text-align: center;
    animation: resultSlideIn 0.4s ease-out;
}

.result-body { margin: 0; }

#result-message {
    font-size: 14px;
    line-height: 1.4;
    margin: 0;
    color: #666666;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.result-header h3 {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    color: #000000;
    letter-spacing: -0.5px;
}

@keyframes resultSlideIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(30px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.result-header h3 {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 20px 0;
    color: #333;
}

.result-body {
    margin-bottom: 25px;
}

#result-message { font-size: 14px; line-height: 1.4; margin: 0; color: #666; }

/* Coupon Section */
.coupon-code {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.coupon-code label {
    font-size: 12px;
    font-weight: 600;
    color: #000000;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.coupon-display {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #FFFFFF;
    border: 1px solid #E5E5E5;
    border-radius: 8px;
    padding: 14px 16px;
}

#coupon-code-text {
    font-family: 'Courier New', monospace;
    font-size: 15px;
    font-weight: 600;
    color: #000000;
    letter-spacing: 0.5px;
}

.copy-button {
    background: #FFFFFF;
    border: 1px solid #E5E5E5;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.3s ease;
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.copy-button:hover {
    background: #F8F8F8;
    transform: scale(1.05);
}

.copy-button .dashicons {
    font-size: 14px;
    color: #666666;
}

.copy-button {
    width: 100%;
    padding: 16px 24px;
    background: #FFFFFF;
    border: 1px solid #000000;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #000000;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: 'Montserrat', sans-serif;
}

.copy-button:hover {
    background: #F8F8F8;
    transform: scale(1.01);
}

.copy-button.copied {
    background: #28a745;
    color: #ffffff;
    border-color: #28a745;
}

.copy-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.close-result-button {
    background: #FFFFFF;
    color: #000000;
    border: 1px solid #000000;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: inherit;
}

.result-footer {
    display: flex;
    gap: 12px;
    justify-content: center;
    width: 100%;
}

.close-result-button:hover {
    background: #F8F8F8;
    transform: scale(1.01);
}

/* Wheel Animation */
.wheel-spinning {
    animation: wheelSpin 3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes wheelSpin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(1440deg); /* 4 full rotations */
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Keep within viewport and disable internal scrolling */
    .spin-wheel-container {
        max-height: 92vh;
        overflow: hidden;
    }
    .spin-wheel-container {
        width: 92%;
        height: auto;
        min-height: 480px;
        margin: 15px;
    }
    
    .spin-wheel-header {
        padding: 12px 20px 8px;
    }
    
    .spin-wheel-title {
        font-size: 18px;
    }
    
    .spin-wheel-description {
        font-size: 12px;
    }
    
    .spin-wheel-main {
        grid-template-columns: 1fr;
        height: auto;
        min-height: auto;
    }
    
    .spin-wheel-left {
        order: 1;
        padding: 20px 15px;
        min-height: auto;
    }
    
    .spin-wheel-right {
        order: 2;
        padding: 12px 12px;
        gap: 10px;
    }
    
    .wheel-container {
        max-width: 320px;
        max-height: 320px;
        margin-top: 10px; /* Reduce top space for pointer */
    }
    #spin-wheel-canvas {
        max-width: 320px;
        max-height: 320px;
    }
    
    .wheel-center {
        width: 60px;
        height: 60px;
    }
    
    .wheel-logo {
        max-width: 40px;
        max-height: 40px;
    }
    
    .spin-wheel-form {
        max-width: 100%;
    }
    
    .spin-result-content {
        max-width: 100%;
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .spin-wheel-container {
        width: 96%;
        margin: 8px;
        min-height: 440px;
    }
    
    .spin-wheel-content {
        padding: 12px;
    }
    
    .wheel-container {
        max-width: 280px;
        max-height: 280px;
        margin-top: 8px; /* Even less space on smaller screens */
    }
    #spin-wheel-canvas {
        max-width: 280px;
        max-height: 280px;
    }
    
    .wheel-center {
        width: 55px;
        height: 55px;
    }
    
    .wheel-logo {
        max-width: 35px;
        max-height: 35px;
    }
    
    .spin-wheel-title {
        font-size: 16px;
    }
    
    .spin-button {
        padding: 14px 18px;
        font-size: 14px;
    }
}

/* Loading States */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Success Animation */
.success-animation {
    animation: successPulse 0.6s ease-out;
}

@keyframes successPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .spin-wheel-container,
    .result-content,
    .wheel-spinning,
    .spin-button,
    .apply-button {
        animation: none;
        transition: none;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .spin-wheel-container {
        border: 2px solid #000;
    }
    
    .spin-button,
    .apply-button {
        border: 2px solid #000;
    }
}

/* Post-win disclaimer styling */
.post-win-disclaimer {
    text-align: center;
    font-size: 11px;
    line-height: 1.4;
    color: #666666;
    margin-top: 12px;
    padding: 8px 12px;
    background: #f8f8f8;
    border-radius: 6px;
    font-family: 'Montserrat', sans-serif;
}

/* Print Styles */
@media print {
    .spin-wheel-popup {
        display: none !important;
    }
}

/* Success Notification */
.spin-success-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #28a745;
    color: #ffffff;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000000;
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    font-weight: 600;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 300px;
}

.spin-success-notification.show {
    transform: translateX(0);
    opacity: 1;
}

/* Mobile responsive for notifications */
@media (max-width: 768px) {
    .spin-success-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        transform: translateY(-100%);
    }
    
    .spin-success-notification.show {
        transform: translateY(0);
    }
}



/* Result Buttons */
.result-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.result-button {
    flex: 1;
    width: calc(50% - 5px);
    min-width: 120px;
    padding: 12px 20px;
    border: 2px solid #000;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: #000;
}

.copy-coupon-btn {
    background: transparent;
    color: #000;
    border: 2px solid #000;
}

.copy-coupon-btn:hover {
    background: #000;
    color: #fff;
    border-color: #000;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.go-to-shop-btn {
    background: transparent;
    color: #000;
    border: 2px solid #000;
}

.go-to-shop-btn:hover {
    background: #000;
    color: #fff;
    border-color: #000;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.result-button:active {
    transform: translateY(0);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .result-buttons {
        flex-direction: row;
        gap: 10px;
    }
    
    .result-button {
        min-width: auto;
        width: calc(50% - 5px);
        padding: 12px 16px;
        font-size: 14px;
    }
}

@media (max-width: 768px) {
    .wheel-container {
        max-width: 300px;
        max-height: 300px;
        margin-top: 10px; /* Reduce top space for pointer */
    }
    #spin-wheel-canvas {
        max-width: 300px;
        max-height: 300px;
    }

    .spin-result-content {
        padding: 12px !important;
        gap: 8px !important;
    }

    .result-header h3 {
        font-size: clamp(14px, 4.4vw, 18px) !important; /* Smaller, responsive for single-line fit */
        margin: 4px 0 6px 0 !important;
        line-height: 1.15 !important;
        white-space: nowrap !important;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .result-body {
        margin: 4px 0 !important;
    }

    .coupon-code {
        margin: 4px 0 !important;
    }

    .coupon-code label {
        font-size: 0.85rem !important;
        margin-bottom: 2px !important;
    }

    .coupon-display {
        padding: 6px !important;
        font-size: 0.9rem !important;
    }

    .result-buttons {
        gap: 6px !important;
        margin-top: 6px !important;
        margin-bottom: 2px !important; /* Reduce extra bottom whitespace */
    }

    .result-button {
        padding: 8px 8px !important;
        font-size: 0.85rem !important;
    }

    .post-win-disclaimer {
        font-size: 0.8rem !important;
        margin-top: 4px !important;
        padding: 6px !important;
        max-height: 110px !important; /* Keep small so it doesn't dominate screen */
        overflow: hidden !important;
    }
}

@media (max-width: 480px) {
    /* Further tighten on very small screens */
    .spin-wheel-container {
        max-height: 90vh;
        overflow: hidden;
    }
    .wheel-container {
        max-width: 360px;
        max-height: 360px;
    }
    #spin-wheel-canvas {
        max-width: 360px;
        max-height: 360px;
    }

    .spin-result-content {
        padding: 10px !important;
        gap: 6px !important;
    }

    .result-header h3 {
        font-size: clamp(13px, 4.2vw, 16px) !important; /* Even smaller to fit single line */
        margin: 3px 0 5px 0 !important;
        line-height: 1.1 !important;
        white-space: nowrap !important;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .result-body { margin: 3px 0 !important; }
    .coupon-code { margin: 3px 0 !important; }

    .result-buttons { gap: 6px !important; margin-top: 4px !important; margin-bottom: 2px !important; }

    .result-button { padding: 7px 6px !important; font-size: 0.8rem !important; }

    .post-win-disclaimer {
        font-size: 0.78rem !important;
        margin-top: 3px !important;
        padding: 5px !important;
        max-height: 95px !important;
        overflow: hidden !important;
    }
}

/* Checkout Coupon Field Styles - Optimized */
.woocommerce-form-coupon-toggle {
    display: none !important;
}

#spin-wheel-coupon-container {
    margin-top: 10px;
}

#spin-wheel-coupon-container .coupon.wd-coupon-form {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 10px;
}

#spin-wheel-coupon-container .coupon.wd-coupon-form input[type="text"] {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

#spin-wheel-coupon-container .coupon.wd-coupon-form .button {
    padding: 8px 16px;
    background: #C3B35D;
    color: white;
    border: 1px solid #C3B35D;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: inline-block !important;
}

#spin-wheel-coupon-container .coupon.wd-coupon-form .button:hover {
    background: #a89b4a;
    border-color: #a89b4a;
}

#spin-wheel-coupon-container .coupon.wd-coupon-form .button:disabled {
    background: #ccc;
    border-color: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Coupon message styling */
.coupon-message {
    margin: 10px 0;
    padding: 10px;
    border-radius: 4px;
    font-size: 14px;
}

.coupon-message.woocommerce-error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.coupon-message.woocommerce-message {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.coupon-message ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.coupon-message li {
    margin: 0;
    padding: 0;
}

/* Responsive styles */
@media (max-width: 768px) {
    #spin-wheel-coupon-container .coupon.wd-coupon-form {
        flex-direction: column;
        gap: 8px;
    }
    
    #spin-wheel-coupon-container .coupon.wd-coupon-form input[type="text"],
    #spin-wheel-coupon-container .coupon.wd-coupon-form .button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    #spin-wheel-coupon-container .coupon.wd-coupon-form .button,
    #spin-wheel-coupon-container .coupon.wd-coupon-form input[type="text"] {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}
