/**
 * DKMAG Shop Actions - Voucher System Styles
 * Material Design Enhanced
 * 
 * @version 2.2.0
 * @author Ali Amiri
 */

/* ==========================================
   CSS Variables - Material Design System
   ========================================== */
:root {
    /* Primary Colors */
    --voucher-primary: #ef4056;
    --voucher-primary-dark: #d63649;
    --voucher-primary-light: #ff6b7d;
    --voucher-secondary: #19bfd3;
    --voucher-accent: #ffd700;
    --voucher-text-light: #fff;
    --voucher-text-dark: #333;
    
    /* Border Radius */
    --voucher-border-radius-xs: 5px;
    --voucher-border-radius-sm: 5px;
    --voucher-border-radius: 5px;
    --voucher-border-radius-lg: 5px;
    --voucher-border-radius-pill: 5px;
    
    /* Material Design Elevation (Shadows) */
    --voucher-elevation-1: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    --voucher-elevation-2: 0 3px 6px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.12);
    --voucher-elevation-3: 0 10px 20px rgba(0, 0, 0, 0.15), 0 3px 6px rgba(0, 0, 0, 0.10);
    --voucher-elevation-4: 0 15px 25px rgba(0, 0, 0, 0.15), 0 5px 10px rgba(0, 0, 0, 0.05);
    --voucher-elevation-card: 0 8px 32px rgba(239, 64, 86, 0.25);
    --voucher-elevation-card-hover: 0 12px 40px rgba(239, 64, 86, 0.35);
    
    /* Material Design Motion */
    --voucher-motion-standard: cubic-bezier(0.4, 0.0, 0.2, 1);
    --voucher-motion-decelerate: cubic-bezier(0.0, 0.0, 0.2, 1);
    --voucher-motion-accelerate: cubic-bezier(0.4, 0.0, 1, 1);
    --voucher-transition-fast: 150ms var(--voucher-motion-standard);
    --voucher-transition: 250ms var(--voucher-motion-standard);
    --voucher-transition-slow: 350ms var(--voucher-motion-standard);
    
    /* Typography Scale */
    --voucher-font-size-xs: 12px;
    --voucher-font-size-sm: 14px;
    --voucher-font-size-base: 16px;
    --voucher-font-size-lg: 18px;
    --voucher-font-size-xl: 20px;
    --voucher-font-weight-regular: 400;
    --voucher-font-weight-medium: 500;
    --voucher-font-weight-semibold: 600;
    --voucher-font-weight-bold: 700;
    
    /* Material Design 8dp Grid Spacing */
    --voucher-spacing-xs: 4px;
    --voucher-spacing-sm: 8px;
    --voucher-spacing-md: 16px;
    --voucher-spacing-lg: 24px;
    --voucher-spacing-xl: 32px;
    --voucher-spacing-2xl: 48px;
}

/* ==========================================
   Container - Material Design Card
   ========================================== */
.voucher-container {
    position: relative;
    padding: var(--voucher-spacing-lg) var(--voucher-spacing-xl);
    margin: var(--voucher-spacing-xl) auto;
    box-shadow: var(--voucher-elevation-card);
    border-radius: var(--voucher-border-radius-lg);
    background: linear-gradient(135deg, var(--voucher-primary) 0%, var(--voucher-primary-dark) 50%, #a02535 100%);
    color: var(--voucher-text-light);
    font-size: var(--voucher-font-size-base);
    line-height: 1.8;
    overflow: hidden;
}

/* Decorative Elements */
.voucher-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -20%;
    width: 60%;
    height: 200%;
    background: radial-gradient(ellipse, rgba(255, 255, 255, 0.08) 0%, transparent 70%);
    pointer-events: none;
}

.voucher-container::after {
    content: '';
    position: absolute;
    bottom: -40px;
    right: -40px;
    width: 140px;
    height: 140px;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.15) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

/* ==========================================
   Loading State - Material Design Progress
   ========================================== */
.voucher-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    gap: var(--voucher-spacing-md);
    padding: var(--voucher-spacing-md);
}

.voucher-loading-text {
    font-size: var(--voucher-font-size-lg);
    font-weight: var(--voucher-font-weight-medium);
    color: var(--voucher-text-light);
    display: flex;
    align-items: baseline;
    gap: 2px;
}

.voucher-loading-dots {
    display: inline-flex;
    width: 28px;
    direction: ltr;
}

.voucher-loading-dots span {
    animation: dotPulse 1.4s infinite var(--voucher-motion-standard);
    opacity: 0;
    font-weight: var(--voucher-font-weight-bold);
}

.voucher-loading-dots span:nth-child(1) {
    animation-delay: 0s;
}

.voucher-loading-dots span:nth-child(2) {
    animation-delay: 0.28s;
}

.voucher-loading-dots span:nth-child(3) {
    animation-delay: 0.56s;
}

@keyframes dotPulse {
    0%, 60%, 100% {
        opacity: 0;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

/* Material Design Circular Progress (fallback) */
.voucher-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--voucher-text-light);
    border-radius: 50%;
    animation: voucher-spin 0.9s var(--voucher-motion-standard) infinite;
}

@keyframes voucher-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================
   Initial Prompt - Material Design
   ========================================== */
.voucher-initial-prompt {
    text-align: center;
    position: relative;
    z-index: 1;
    padding: var(--voucher-spacing-sm) 0;
}

.voucher-initial-prompt-text {
    margin-bottom: var(--voucher-spacing-lg);
    font-size: var(--voucher-font-size-lg);
    font-weight: var(--voucher-font-weight-medium);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    line-height: 1.6;
}

.voucher-initial-prompt-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--voucher-spacing-md);
    flex-wrap: wrap;
}

.voucher-initial-countdown-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.voucher-initial-countdown-label {
    font-size: var(--voucher-font-size-xs);
    color: rgba(255, 255, 255, 0.9);
    font-weight: var(--voucher-font-weight-medium);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.voucher-initial-countdown {
    min-width: 100px;
}

.voucher-initial-countdown .countdown-label {
    font-size: var(--voucher-font-size-xs);
    color: var(--voucher-primary-dark);
    margin-bottom: 2px;
    display: block;
    text-align: center;
}

/* ==========================================
   Buttons - Material Design
   ========================================== */
.voucher-btn-buy-digikala,
.voucher-get-code-btn,
.voucher-login-btn,
.voucher-retry-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--voucher-spacing-sm);
    padding: var(--voucher-spacing-sm) var(--voucher-spacing-lg);
    min-height: 40px;
    font-size: var(--voucher-font-size-sm) !important;
    font-weight: var(--voucher-font-weight-semibold) !important;
    text-decoration: none;
    text-transform: none;
    color: var(--voucher-primary);
    background: #fff;
    border: none;
    border-radius: var(--voucher-border-radius-pill);
    cursor: pointer;
    box-shadow: var(--voucher-elevation-2);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* Focus State for Accessibility */
.voucher-btn-buy-digikala:focus-visible,
.voucher-get-code-btn:focus-visible,
.voucher-login-btn:focus-visible,
.voucher-retry-btn:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

/* Outlined Button Style - Get Code */
.voucher-get-code-btn {
    color: #fff !important;
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.9) !important;
    box-shadow: none;
}

/* ==========================================
   Login Prompt - Material Design
   ========================================== */
.voucher-login-prompt {
    text-align: center;
    position: relative;
    z-index: 1;
    padding: var(--voucher-spacing-sm) 0;
}

.voucher-login-prompt p {
    margin: 0 0 var(--voucher-spacing-lg);
    color: var(--voucher-text-light) !important;
    line-height: 1.75;
    font-size: var(--voucher-font-size-lg);
    font-weight: var(--voucher-font-weight-regular);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* ==========================================
   Voucher Card - Material Design Surface
   ========================================== */
.voucher-card {
    width: 100%;
    position: relative;
    z-index: 1;
    animation: voucherCardEnter 0.4s var(--voucher-motion-decelerate);
}

@keyframes voucherCardEnter {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.voucher-message {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--voucher-spacing-lg);
}

.voucher-message-inner {
    flex: 1 1 100%;
    margin-bottom: var(--voucher-spacing-sm);
    font-size: var(--voucher-font-size-base);
    line-height: 1.875;
}

.voucher-message-inner strong {
    display: inline;
    margin-right: var(--voucher-spacing-sm);
    color: var(--voucher-accent);
    font-weight: var(--voucher-font-weight-semibold);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

/* ==========================================
   Voucher Code - Material Design Chip
   ========================================== */
.voucher-code {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: var(--voucher-spacing-xs);
    padding: var(--voucher-spacing-sm) var(--voucher-spacing-md);
    margin-right: var(--voucher-spacing-sm);
    font-size: var(--voucher-font-size-sm);
    font-weight: var(--voucher-font-weight-semibold);
    color: var(--voucher-primary);
    background: #fff;
    border-radius: var(--voucher-border-radius-sm);
    cursor: pointer;
    user-select: all;
    box-shadow: var(--voucher-elevation-1);
}



/* ==========================================
   Tooltip - Material Design Snackbar Style
   ========================================== */
.voucher-tooltip {
    position: absolute;
    top: -48px;
    left: 50%;
    transform: translateX(-50%);
    padding: var(--voucher-spacing-sm) var(--voucher-spacing-md);
    color: var(--voucher-text-light);
    background: #323232;
    border-radius: var(--voucher-border-radius-xs);
    z-index: 100;
    animation: voucherTooltipIn 0.25s var(--voucher-motion-decelerate);
    box-shadow: var(--voucher-elevation-3);
    display: block;
    width: max-content;
    min-width: 100%;
    font-size: var(--voucher-font-size-xs);
    font-weight: var(--voucher-font-weight-medium);
    text-align: center;
    white-space: nowrap;
}

.voucher-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 6px 0;
    border-style: solid;
    border-color: #323232 transparent transparent;
}

@keyframes voucherTooltipIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-8px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

/* ==========================================
   Countdown Timer - Material Design
   ========================================== */
#voucher-countdown,
.voucher-initial-countdown {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 150px;
    padding: var(--voucher-spacing-sm) var(--voucher-spacing-md);
    direction: ltr;
    font-size: var(--voucher-font-size-sm);
    font-weight: var(--voucher-font-weight-semibold);
    color: var(--voucher-primary);
    background: #fff;
    border-radius: var(--voucher-border-radius-sm);
    box-shadow: var(--voucher-elevation-2);
}

#voucher-countdown span,
.voucher-initial-countdown span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    text-align: center;
}

#voucher-countdown span:not(.countdown-separator),
.voucher-initial-countdown span:not(.countdown-separator) {
    background: rgba(239, 64, 86, 0.08);
    padding: 4px 6px;
    border-radius: var(--voucher-border-radius-xs);
    transition: background var(--voucher-transition-fast);
}

.countdown-separator {
    font-weight: var(--voucher-font-weight-bold);
    color: var(--voucher-primary-dark);
    min-width: 12px !important;
    animation: separatorBlink 1s var(--voucher-motion-standard) infinite;
}

@keyframes separatorBlink {
    0%, 45% {
        opacity: 1;
    }
    50%, 100% {
        opacity: 0.25;
    }
}

.countdown-expired {
    font-size: var(--voucher-font-size-sm);
    color: var(--voucher-primary-dark);
    font-weight: var(--voucher-font-weight-semibold);
}

/* ==========================================
   Action Button - Material Contained Button
   ========================================== */
.voucher-action {
    margin-right: auto;
}

.voucher-btn-buy-digikala {
    background: var(--voucher-accent);
    color: #1a1a1a;
    font-weight: var(--voucher-font-weight-bold) !important;
    padding: var(--voucher-spacing-sm) var(--voucher-spacing-xl);
    box-shadow: var(--voucher-elevation-2), 0 2px 8px rgba(255, 215, 0, 0.3);
}

/* ==========================================
   Error State - Material Design
   ========================================== */
.voucher-error {
    text-align: center;
    position: relative;
    z-index: 1;
    padding: var(--voucher-spacing-sm) 0;
    animation: errorFadeIn 0.3s var(--voucher-motion-decelerate);
}
.voucher-error p{
    color: #fff !important;
}
.voucher-retry-btn {
	background-color: #fff !important;
}
@keyframes errorFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.voucher-error p {
    margin: 0 0 var(--voucher-spacing-lg);
    color: var(--voucher-text-light);
    font-size: var(--voucher-font-size-lg);
    font-weight: var(--voucher-font-weight-regular);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    line-height: 1.6;
}

/* ==========================================
   Responsive Design - Material Breakpoints
   ========================================== */
@media screen and (max-width: 768px) {
    .voucher-container {
        padding: var(--voucher-spacing-lg) var(--voucher-spacing-md);
        margin: var(--voucher-spacing-md) auto;
        border-radius: var(--voucher-border-radius);
    }

    .voucher-message {
        flex-direction: column;
        text-align: center;
        gap: var(--voucher-spacing-md);
    }

    .voucher-message-inner {
        order: 1;
    }

    #voucher-countdown {
        order: 2;
        width: 100%;
        max-width: 180px;
    }

    .voucher-action {
        order: 3;
        width: 100%;
        margin: var(--voucher-spacing-sm) 0 0;
    }

    .voucher-btn-buy-digikala {
        display: flex;
        width: 100%;
        text-align: center;
        padding: var(--voucher-spacing-sm) var(--voucher-spacing-md);
    }

    .voucher-code {
        margin: var(--voucher-spacing-sm) 0;
    }

    .voucher-container::after {
        display: none;
    }

    .voucher-initial-prompt-actions {
        flex-direction: column;
    }

    .voucher-initial-countdown-wrapper {
        flex-direction: row;
        gap: var(--voucher-spacing-sm);
    }

    .voucher-initial-countdown-label {
        font-size: var(--voucher-font-size-sm);
    }
}

@media screen and (max-width: 480px) {
    :root {
        --voucher-font-size-base: 14px;
        --voucher-font-size-sm: 13px;
        --voucher-font-size-lg: 16px;
    }

    .voucher-container {
        padding: var(--voucher-spacing-md);
        border-radius: var(--voucher-border-radius-sm);
    }

    .voucher-btn-buy-digikala,
    .voucher-get-code-btn,
    .voucher-login-btn,
    .voucher-retry-btn,
    .voucher-btn-digiclub {
        min-height: 44px;
        border-radius: var(--voucher-border-radius-sm);
    }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .voucher-container,
    .voucher-card,
    .voucher-code,
    .voucher-btn-buy-digikala,
    .voucher-get-code-btn,
    .voucher-login-btn,
    .voucher-retry-btn,
    .voucher-tooltip,
    .voucher-error,
    #voucher-countdown {
        transition: none;
        animation: none;
    }

    .countdown-separator {
        animation: none;
        opacity: 1;
    }

    .voucher-loading-dots span {
        animation: none;
        opacity: 1;
    }
}

/* ==========================================
   Unavailable State - Material Design
   ========================================== */
.voucher-unavailable {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--voucher-spacing-lg) var(--voucher-spacing-md);
    position: relative;
    z-index: 1;
    animation: unavailableFadeIn 0.35s var(--voucher-motion-decelerate);
}
.voucher-unavailable  p{
    color: #fff !important;
}

@keyframes unavailableFadeIn {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.voucher-unavailable-icon {
    font-size: 48px;
    line-height: 1;
    margin-bottom: var(--voucher-spacing-md);
    opacity: 0.9;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.voucher-unavailable-message {
    margin: 0;
    font-size: var(--voucher-font-size-base);
    font-weight: var(--voucher-font-weight-regular);
    line-height: 1.75;
    opacity: 0.95;
}

.voucher-unavailable-digiclub {
    margin: var(--voucher-spacing-md) 0;
    font-size: var(--voucher-font-size-sm);
    font-weight: var(--voucher-font-weight-regular);
    line-height: 1.6;
    opacity: 0.85;
}

.voucher-btn-digiclub {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--voucher-spacing-sm);
    padding: var(--voucher-spacing-sm) var(--voucher-spacing-lg);
    min-height: 40px;
    font-size: var(--voucher-font-size-sm) !important;
    font-weight: var(--voucher-font-weight-semibold) !important;
    text-decoration: none;
    text-transform: none;
    color: var(--voucher-primary);
    background: #fff;
    border: none;
    border-radius: var(--voucher-border-radius-pill);
    cursor: pointer;
    box-shadow: var(--voucher-elevation-2);
    margin-top: var(--voucher-spacing-sm);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.voucher-btn-digiclub:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

/* ==========================================
   Cooldown Timer - Material Design
   ========================================== */
.voucher-cooldown-timer-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--voucher-spacing-sm);
    margin: var(--voucher-spacing-md) 0;
    padding: var(--voucher-spacing-md);
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--voucher-border-radius);
    backdrop-filter: blur(4px);
}

.voucher-cooldown-label {
    margin: 0;
    font-size: var(--voucher-font-size-sm);
    font-weight: var(--voucher-font-weight-medium);
    color: rgba(255, 255, 255, 0.95);
    text-align: center;
}

.voucher-cooldown-countdown {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--voucher-spacing-xs);
    direction: ltr;
    padding: var(--voucher-spacing-sm) var(--voucher-spacing-md);
    background: #fff;
    border-radius: var(--voucher-border-radius-sm);
    box-shadow: var(--voucher-elevation-2);
}

.cooldown-time-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 40px;
}

.cooldown-time-unit > span:first-child {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    padding: var(--voucher-spacing-xs) var(--voucher-spacing-sm);
    font-size: var(--voucher-font-size-lg);
    font-weight: var(--voucher-font-weight-bold);
    color: var(--voucher-primary);
    background: rgba(239, 64, 86, 0.08);
    border-radius: var(--voucher-border-radius-xs);
}

.cooldown-time-label {
    font-size: 10px;
    font-weight: var(--voucher-font-weight-medium);
    color: var(--voucher-text-dark);
    opacity: 0.7;
    text-align: center;
}

.voucher-cooldown-countdown .countdown-separator {
    font-size: var(--voucher-font-size-lg);
    font-weight: var(--voucher-font-weight-bold);
    color: var(--voucher-primary-dark);
    margin: 0 2px;
    align-self: flex-start;
    padding-top: var(--voucher-spacing-xs);
}

.cooldown-ready {
    display: block;
    padding: var(--voucher-spacing-sm) var(--voucher-spacing-md);
    font-size: var(--voucher-font-size-sm);
    font-weight: var(--voucher-font-weight-semibold);
    color: #2e7d32;
    background: #e8f5e9;
    border-radius: var(--voucher-border-radius-sm);
    animation: cooldownReadyPulse 0.5s var(--voucher-motion-decelerate);
}

@keyframes cooldownReadyPulse {
    0% {
        opacity: 0;
        transform: scale(0.95);
    }
    50% {
        transform: scale(1.02);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Responsive - Cooldown Timer */
@media screen and (max-width: 480px) {
    .voucher-cooldown-timer-wrapper {
        padding: var(--voucher-spacing-sm);
    }

    .voucher-cooldown-countdown {
        gap: 2px;
        padding: var(--voucher-spacing-xs) var(--voucher-spacing-sm);
    }

    .cooldown-time-unit {
        min-width: 32px;
    }

    .cooldown-time-unit > span:first-child {
        min-width: 28px;
        font-size: var(--voucher-font-size-base);
        padding: 2px 4px;
    }

    .cooldown-time-label {
        font-size: 9px;
    }

    .voucher-cooldown-countdown .countdown-separator {
        font-size: var(--voucher-font-size-base);
        margin: 0 1px;
    }
}

/* Reduce motion for users who prefer it - Cooldown */
@media (prefers-reduced-motion: reduce) {
    .cooldown-ready {
        animation: none;
    }
}
