/* ============================================
   Lucky Dip Module — Styles
   ============================================ */

/* Widget Container */
.lucky-dip-widget {
    --ld-bg: #0d0d0d;
    --ld-card: #1a1a1a;
    --ld-border: #2a2a2a;
    --ld-text: #ffffff;
    --ld-text-muted: #8a8a8a;
    --ld-accent: var(--color-content-primary);
    --ld-accent-hover: var(--color-content-primary);
    --ld-btn-bg: #1a1a1a;
    --ld-btn-hover: #2a2a2a;
    --ld-radius: 16px;
    --ld-radius-sm: 10px;
    --ld-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);

    max-width: 500px;
    margin: 0 auto;
    font-family: inherit;
}

.ld-inner {
    background: var(--ld-bg);
    border: 1px solid var(--ld-border);
    border-radius: var(--ld-radius);
    padding: 32px 28px;
    text-align: center;
    box-shadow: var(--ld-shadow);
}

/* Header */
.ld-header {
    margin-bottom: 24px;
}

.ld-title {
    font-size: 32px;
    font-weight: 900;
    color: var(--ld-text);
    margin: 0 0 8px 0;
    letter-spacing: 2px;
    text-transform: capitalize;
    line-height: 1.2;
}

.ld-highlight {
    color: var(--ld-accent);
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.ld-subtitle {
    font-size: 14px;
    color: var(--ld-text-muted);
    margin: 0;
    letter-spacing: 0.5px;
}

/* Budget Display */
.ld-budget-display {
    background: var(--ld-card);
    border: 1px solid var(--ld-border);
    border-radius: var(--ld-radius-sm);
    padding: 20px 24px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.ld-budget-display:focus-within {
    border-color: var(--ld-accent);
    box-shadow: 0 0 0 2px rgba(255, 215, 0, 0.15);
}

.ld-currency {
    font-size: 36px;
    font-weight: 800;
    color: var(--ld-accent);
    line-height: 1;
}

.ld-budget-input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--ld-text);
    font-size: 48px;
    font-weight: 800;
    width: 140px;
    text-align: left;
    line-height: 1;
    -moz-appearance: textfield;
    appearance: textfield;
}

.ld-budget-input::-webkit-outer-spin-button,
.ld-budget-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Preset Buttons */
.ld-presets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

/* Max Products Selector */
.ld-max-products {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--ld-card);
    border: 1px solid var(--ld-border);
    border-radius: var(--ld-radius-sm);
    padding: 12px 16px;
    margin-bottom: 20px;
}

.ld-max-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--ld-text-muted);
    letter-spacing: 0.3px;
}

.ld-stepper {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--ld-border);
    border-radius: 8px;
    overflow: hidden;
}

.ld-stepper-btn {
    background: var(--ld-bg);
    border: none;
    color: var(--ld-text);
    font-size: 18px;
    font-weight: 700;
    width: 36px;
    height: 36px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.ld-stepper-btn:hover {
    background: var(--ld-btn-hover);
    color: var(--ld-accent);
}

.ld-stepper-btn:active {
    transform: scale(0.92);
}

.ld-max-input {
    background: var(--ld-card);
    border: none;
    border-left: 1px solid var(--ld-border);
    border-right: 1px solid var(--ld-border);
    color: var(--ld-text);
    font-size: 16px;
    font-weight: 800;
    width: 44px;
    height: 36px;
    text-align: center;
    outline: none;
    -moz-appearance: textfield;
    appearance: textfield;
}

.ld-max-input::-webkit-outer-spin-button,
.ld-max-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.ld-preset-btn {
    background: var(--ld-card);
    border: 1px solid var(--ld-border);
    border-radius: var(--ld-radius-sm);
    color: var(--ld-text);
    font-size: 15px;
    font-weight: 700;
    padding: 12px 8px;
    cursor: pointer;
    transition: all 0.25s ease;
    outline: none;
    letter-spacing: 0.5px;
}

.ld-preset-btn:hover {
    background: var(--ld-btn-hover);
    border-color: #444;
    transform: translateY(-1px);
}

.ld-preset-btn.active {
    background: var(--ld-accent);
    color: #000;
    border-color: var(--ld-accent);
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.3);
}

/* Action Button */
.ld-action-btn {
    width: 100%;
    background: var(--ld-card);
    border: 1px solid var(--ld-border);
    border-radius: var(--ld-radius-sm);
    color: var(--ld-text);
    font-size: 16px;
    font-weight: 800;
    padding: 16px 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.ld-action-btn:hover {
    background: var(--ld-btn-hover);
    border-color: var(--ld-accent);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.15);
    transform: translateY(-1px);
}

.ld-action-btn:active {
    transform: translateY(0);
}

.ld-action-btn.loading {
    pointer-events: none;
    opacity: 0.8;
}

.ld-btn-icon {
    font-size: 20px;
    animation: ld-dice-idle 3s ease-in-out infinite;
}

@keyframes ld-dice-idle {

    0%,
    100% {
        transform: rotate(0deg);
    }

    25% {
        transform: rotate(10deg);
    }

    75% {
        transform: rotate(-10deg);
    }
}

.ld-action-btn.loading .ld-btn-icon {
    animation: ld-dice-roll 0.3s linear infinite;
}

@keyframes ld-dice-roll {
    0% {
        transform: rotate(0deg) scale(1);
    }

    25% {
        transform: rotate(90deg) scale(1.1);
    }

    50% {
        transform: rotate(180deg) scale(1);
    }

    75% {
        transform: rotate(270deg) scale(1.1);
    }

    100% {
        transform: rotate(360deg) scale(1);
    }
}

/* Spinner */
.ld-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--ld-accent);
    border-radius: 50%;
    animation: ld-spin 0.6s linear infinite;
    vertical-align: middle;
}

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

/* Error Message */
.ld-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
    padding: 10px 16px;
    border-radius: 8px;
    margin-top: 12px;
    font-size: 13px;
    font-weight: 500;
}

/* ─── Popup ─── */
.ld-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: ld-fade-in 0.3s ease;
}

@keyframes ld-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.ld-popup {
    background: var(--ld-bg);
    border: 1px solid var(--ld-border);
    border-radius: var(--ld-radius);
    max-width: 460px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 28px 24px;
    position: relative;
    z-index: 99999;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: ld-popup-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes ld-popup-in {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.ld-popup-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: var(--ld-text-muted);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    transition: color 0.2s;
}

.ld-popup-close:hover {
    color: var(--ld-text);
}

.ld-popup-header {
    text-align: center;
    margin-bottom: 20px;
}

.ld-popup-emoji {
    font-size: 40px;
    display: block;
    margin-bottom: 8px;
}

.ld-popup-header h3 {
    font-size: 22px;
    font-weight: 800;
    color: var(--ld-text);
    margin: 0;
}

/* Bundle Items */
.ld-bundle-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--ld-border);
}

.ld-bundle-item:last-child {
    border-bottom: none;
}

.ld-bundle-img {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--ld-card);
}

.ld-bundle-info {
    flex: 1;
    text-align: left;
}

.ld-bundle-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--ld-text);
    margin-bottom: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ld-bundle-qty {
    font-size: 12px;
    color: var(--ld-text-muted);
}

.ld-bundle-price {
    font-size: 15px;
    font-weight: 800;
    color: var(--ld-accent);
    flex-shrink: 0;
}

/* Bundle Total */
.ld-bundle-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0 0;
    margin-top: 4px;
    border-top: 1px solid var(--ld-border);
}

.ld-bundle-total-label {
    font-size: 15px;
    font-weight: 700;
    color: var(--ld-text);
}

.ld-bundle-total-amount {
    font-size: 20px;
    font-weight: 900;
    color: var(--ld-accent);
}

/* Popup Footer */
.ld-popup-footer {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.ld-popup-btn {
    flex: 1;
    padding: 14px 16px;
    border-radius: var(--ld-radius-sm);
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    text-decoration: none;
    display: inline-block;
    line-height: 1.2;
    border: none;
}

.ld-btn-secondary {
    background: var(--ld-card);
    border: 1px solid var(--ld-border);
    color: var(--ld-text);
}

.ld-btn-secondary:hover {
    background: var(--ld-btn-hover);
    border-color: #444;
}

.ld-btn-primary {
    background: var(--ld-accent);
    color: #000;
    border: 1px solid var(--ld-accent);
}

.ld-btn-primary:hover {
    background: var(--ld-accent-hover);
    color: #000 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(255, 215, 0, 0.3);
}

/* ─── Responsive ─── */
@media (max-width: 480px) {
    .ld-inner {
        padding: 24px 18px;
    }

    .ld-title {
        font-size: 26px;
    }

    .ld-currency {
        font-size: 28px;
    }

    .ld-budget-input {
        font-size: 38px;
        width: 110px;
    }

    .ld-presets {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }

    .ld-preset-btn {
        padding: 10px 4px;
        font-size: 13px;
    }

    .ld-popup-footer {
        flex-direction: column;
    }
}