/**
 * PopOut Vending - Frontend Styles
 * Mobile-first design unified with theme and PlaySign attract_mode
 * Version: 2.1.0
 */

/* ══════════════════════════════════════════════════════════════════
   CSS VARIABLES - Unified with theme design tokens
   ══════════════════════════════════════════════════════════════════ */

:root {
    /* Primary - Vibrant green matching theme */
    --popout-primary: #4ecca3;
    --popout-primary-dim: #3db892;
    --popout-primary-hover: #5fd9b0;
    --popout-primary-glow: rgba(78, 204, 163, 0.35);

    /* Secondary */
    --popout-secondary: #00c8e5;
    --popout-accent: #ffb84d;

    /* Dark Blue Theme - Matching main theme exactly */
    --popout-bg: #1a2035;
    --popout-bg-deep: #141a2e;
    --popout-bg-card: #232b45;
    --popout-bg-elevated: #2a3454;
    --popout-border: rgba(255, 255, 255, 0.08);
    --popout-border-light: rgba(255, 255, 255, 0.12);

    /* Gradients - Matching theme */
    --popout-gradient-bg: linear-gradient(165deg, #1a2035 0%, #141a2e 50%, #0f1422 100%);
    --popout-gradient-bg-radial: radial-gradient(ellipse at 30% 0%, rgba(78, 204, 163, 0.08) 0%, transparent 50%),
                                 radial-gradient(ellipse at 70% 100%, rgba(0, 200, 229, 0.05) 0%, transparent 50%),
                                 linear-gradient(165deg, #1a2035 0%, #141a2e 50%, #0f1422 100%);

    /* Text */
    --popout-text: #f0f2f5;
    --popout-text-muted: #8a94a6;
    --popout-text-dim: #5a6477;

    /* Status */
    --popout-danger: #ff6b6b;
    --popout-warning: #f7b32b;
    --popout-success: #4ecca3;

    /* Border Radius */
    --popout-radius-sm: 0.5rem;
    --popout-radius-md: 0.75rem;
    --popout-radius-lg: 1rem;
    --popout-radius-xl: 1.5rem;
    --popout-radius-full: 9999px;

    /* Touch Targets */
    --popout-touch-target: 52px;

    /* Typography */
    --popout-font-display: 'ABC Ginto Nord', 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --popout-font-primary: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --popout-font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ══════════════════════════════════════════════════════════════════
   GLOBAL PAGE STYLING - Match popout.se theme
   ══════════════════════════════════════════════════════════════════ */

/* Ensure consistent background on plugin pages */
.popout-vending-page,
.popout-machine-active {
    background: var(--popout-gradient-bg-radial) !important;
    background-attachment: fixed !important;
    min-height: 100vh;
}

/* ══════════════════════════════════════════════════════════════════
   MACHINE INFO BANNER - Mobile-first sticky design
   ══════════════════════════════════════════════════════════════════ */

.popout-machine-info {
    position: sticky;
    top: 60px;
    z-index: 40;
    background: var(--popout-bg-card);
    color: var(--popout-text);
    padding: 0.875rem 1rem;
    margin: 0 0.75rem 1rem;
    border-radius: var(--popout-radius-lg);
    border: 1px solid var(--popout-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.popout-machine-info p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--popout-text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.popout-machine-info p::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--popout-primary);
    border-radius: 50%;
    animation: popout-pulse 2s ease-in-out infinite;
}

@keyframes popout-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.9); }
}

.popout-machine-info strong {
    color: var(--popout-primary);
    font-weight: 700;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* Checkout machine info: theme-aligned (uses .machine-info-checkout, .vending-pickup-info from theme) */
.machine-info-checkout__subtitle {
    margin: var(--space-2, 0.5rem) 0 0;
    font-size: 0.875rem;
    color: var(--color-text-muted, var(--popout-text-muted));
    line-height: 1.4;
}

/* ══════════════════════════════════════════════════════════════════
   STOCK STATUS - Enhanced mobile visibility
   ══════════════════════════════════════════════════════════════════ */

/* Out of stock overlay */
.popout-out-of-stock {
    position: relative;
}

.popout-out-of-stock::after {
    content: 'Slutsåld';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-12deg);
    background: rgba(255, 82, 82, 0.95);
    color: white;
    padding: 0.625rem 1.25rem;
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: var(--popout-radius-md);
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 4px 16px rgba(255, 82, 82, 0.4);
}

.popout-out-of-stock .woocommerce-loop-product__link {
    opacity: 0.4;
    pointer-events: none;
    filter: grayscale(0.3);
}

/* Stock indicator badge */
.popout-stock-badge {
    position: absolute;
    top: 0.625rem;
    left: 0.625rem;
    padding: 0.25rem 0.625rem;
    border-radius: var(--popout-radius-sm);
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.popout-stock-badge.in-stock {
    background: rgba(0, 229, 153, 0.9);
    color: var(--popout-bg);
    display: none;
}

.popout-stock-badge.low-stock {
    background: rgba(255, 171, 64, 0.95);
    color: var(--popout-bg);
    animation: popout-badge-pulse 2s ease-in-out infinite;
    display: none;
}

@keyframes popout-badge-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 171, 64, 0.4); }
    50% { box-shadow: 0 0 0 4px rgba(255, 171, 64, 0); }
}

.popout-stock-badge.out-of-stock {
    background: rgba(255, 82, 82, 0.95);
    color: white;
    display: none;
}

/* ══════════════════════════════════════════════════════════════════
   LOADING STATE
   ══════════════════════════════════════════════════════════════════ */

.popout-loading {
    position: relative;
    pointer-events: none;
}

.popout-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 12, 16, 0.8);
    border-radius: var(--radius-lg);
    z-index: 100;
}

.popout-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2rem;
    height: 2rem;
    margin: -1rem 0 0 -1rem;
    border: 3px solid var(--dark-border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: popout-spin 0.8s linear infinite;
    z-index: 101;
}

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

/* ══════════════════════════════════════════════════════════════════
   DISPENSE STATUS NOTIFICATION
   ══════════════════════════════════════════════════════════════════ */

.popout-dispense-status {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--dark-card);
    color: var(--text);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--dark-border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    max-width: 320px;
    animation: popout-slide-in 0.3s ease-out;
}

@keyframes popout-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.popout-dispense-status.success {
    border-left: 4px solid var(--success);
}

.popout-dispense-status.pending {
    border-left: 4px solid var(--warning);
}

.popout-dispense-status.error {
    border-left: 4px solid var(--danger);
}

.popout-dispense-status h4 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.popout-dispense-status p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.popout-dispense-status .icon {
    width: 1.25rem;
    height: 1.25rem;
}

/* ══════════════════════════════════════════════════════════════════
   QR CODE DISPLAY (Kiosk Mode) - Matching attract_mode.html
   ══════════════════════════════════════════════════════════════════ */

.popout-qr-display {
    text-align: center;
    padding: 3rem;
    background: var(--dark-card);
    border: 1px solid var(--dark-border);
    border-radius: var(--radius-lg);
    margin: 2rem 0;
}

.popout-qr-display h2 {
    color: var(--text);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.popout-qr-display .qr-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.popout-qr-display .qr-code {
    background: #ffffff;
    padding: 1rem;
    display: inline-block;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    box-shadow: 0 0 30px rgba(0, 229, 153, 0.15);
    border: 2px solid var(--primary);
}

.popout-qr-display .qr-code img,
.popout-qr-display .qr-code canvas {
    display: block;
    max-width: 200px;
    height: auto;
}

.popout-qr-display .scan-prompt {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--primary);
    border-radius: var(--radius-full);
    color: var(--dark);
    font-weight: 700;
    font-size: 0.85rem;
}

.popout-qr-display .instructions {
    color: var(--text-muted);
    font-size: 0.9375rem;
    margin-top: 1rem;
}

.popout-qr-display .instructions strong {
    color: var(--primary);
}

/* ══════════════════════════════════════════════════════════════════
   THANK YOU PAGE - Matching attract_mode.html dispensing style
   ══════════════════════════════════════════════════════════════════ */

.woocommerce-order-received .popout-dispense-message {
    background: var(--dark-card);
    border: 1px solid var(--primary);
    color: var(--text);
    padding: 2rem;
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    text-align: center;
}

.popout-dispense-message h3 {
    margin: 0 0 1rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.popout-dispense-message p {
    margin: 0;
    color: var(--text-muted);
}

.popout-dispense-message .machine-id {
    font-family: monospace;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    display: inline-block;
    margin-top: 1rem;
    border: 1px solid var(--dark-border);
    color: var(--text-muted);
}

/* ══════════════════════════════════════════════════════════════════
   REFRESH BUTTON - Mobile touch-friendly
   ══════════════════════════════════════════════════════════════════ */

.popout-refresh-stock-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    min-height: 44px;
    min-width: 44px;
    background: var(--popout-bg-elevated) !important;
    color: var(--popout-text) !important;
    border: 1px solid var(--popout-border) !important;
    padding: 0.5rem 0.875rem !important;
    font-size: 0.8125rem !important;
    font-weight: 600 !important;
    border-radius: var(--popout-radius-md) !important;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    white-space: nowrap;
}

.popout-refresh-stock-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.popout-refresh-stock-btn:hover {
    border-color: var(--popout-primary) !important;
    color: var(--popout-primary) !important;
    box-shadow: 0 0 16px var(--popout-primary-glow);
}

.popout-refresh-stock-btn:active {
    transform: scale(0.98);
}

.popout-refresh-stock-btn.is-loading svg {
    animation: popout-spin 0.8s linear infinite;
}

/* ══════════════════════════════════════════════════════════════════
   AGE NOTICE - Matching attract_mode.html
   ══════════════════════════════════════════════════════════════════ */

.popout-age-notice {
    background: rgba(255, 82, 82, 0.15);
    border: 1px solid rgba(255, 82, 82, 0.25);
    border-radius: var(--radius-full);
    padding: 0.5rem 1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
}

.popout-age-notice i {
    color: var(--warning);
}

/* ══════════════════════════════════════════════════════════════════
   SWISH PAYMENT BADGE - Matching attract_mode.html
   ══════════════════════════════════════════════════════════════════ */

.swish-badge {
    background: linear-gradient(135deg, #58a843, #4a9039);
    color: #ffffff;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.75rem;
}

/* ══════════════════════════════════════════════════════════════════
   MOBILE OPTIMIZATIONS
   ══════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .popout-machine-info {
        margin: 0 0.5rem 0.75rem;
        padding: 0.75rem;
    }

    .popout-machine-info p {
        font-size: 0.8125rem;
    }

    .popout-dispense-status {
        left: 0.75rem;
        right: 0.75rem;
        bottom: calc(0.75rem + env(safe-area-inset-bottom, 0));
        max-width: none;
    }

    .popout-qr-display {
        padding: 1.5rem 1rem;
        margin: 1rem 0.75rem;
    }

    .popout-qr-display h2 {
        font-size: 1.125rem;
    }
}

/* Very small screens */
@media (max-width: 360px) {
    .popout-machine-info {
        flex-direction: column;
        text-align: center;
        gap: 0.625rem;
    }

    .popout-machine-info p::before {
        display: none;
    }

    .popout-refresh-stock-btn {
        width: 100%;
    }
}

/* ══════════════════════════════════════════════════════════════════
   SAFE AREA SUPPORT (iPhone notch, etc.)
   ══════════════════════════════════════════════════════════════════ */

@supports (padding: env(safe-area-inset-top)) {
    .popout-machine-info {
        margin-left: max(0.75rem, env(safe-area-inset-left));
        margin-right: max(0.75rem, env(safe-area-inset-right));
    }
}

/* ══════════════════════════════════════════════════════════════════
   DARK MODE & REDUCED MOTION
   ══════════════════════════════════════════════════════════════════ */

@media (prefers-color-scheme: dark) {
    .popout-loading::before {
        background: rgba(8, 10, 14, 0.92);
    }
}

@media (prefers-reduced-motion: reduce) {
    .popout-loading::after,
    .popout-dispense-status,
    .popout-stock-badge.low-stock,
    .popout-machine-info p::before,
    .popout-refresh-stock-btn.is-loading svg {
        animation: none;
    }

    .popout-stock-badge.low-stock,
    .popout-stock-badge.out-of-stock,
    .popout-stock-badge.in-stock {
        display: none;
    }

    .popout-refresh-stock-btn:active {
        transform: none;
    }
}

/* ══════════════════════════════════════════════════════════════════
   PULL TO REFRESH INDICATOR (Optional enhancement)
   ══════════════════════════════════════════════════════════════════ */

.popout-pull-indicator {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    background: var(--popout-bg-card);
    border: 1px solid var(--popout-border);
    border-radius: 0 0 var(--popout-radius-lg) var(--popout-radius-lg);
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--popout-text-muted);
    transition: transform 0.3s ease;
    z-index: 100;
}

.popout-pull-indicator.is-visible {
    transform: translateX(-50%) translateY(0);
}

.popout-pull-indicator svg {
    width: 18px;
    height: 18px;
    color: var(--popout-primary);
}
