/**
 * Price Widget for FluentCart - Frontend Widget Styles
 *
 * Self-contained with CSS variables for dark mode support.
 * Responds to system preference and Theme Switcher (html.dark/html.light).
 *
 * @version 0.9.7
 */

/* ==========================================================================
   CSS Variables — all at :root so Custom CSS overrides cascade everywhere.
   ========================================================================== */

:root {
    --pwfc-accent: #1a56db;
    --pwfc-accent-dark: #1e40af;
    --pwfc-border: #e5e7eb;
    --pwfc-border-hover: #c7d2fe;
    --pwfc-border-selected: #1e40af;
    --pwfc-text: #1f2937;
    --pwfc-text-secondary: #6b7280;
    --pwfc-text-muted: #9ca3af;
    --pwfc-text-feature: #4b5563;
    --pwfc-active: #059669;
    --pwfc-active-bg: #ecfdf5;
    --pwfc-sold-out: #ef4444;
    --pwfc-bg: inherit;
    --pwfc-card-bg: #ffffff;
    --pwfc-tab-bg: #f3f4f6;
    --pwfc-tab-active-bg: #ffffff;
    --pwfc-btn-bg: var(--pwfc-accent);
    --pwfc-btn-text: #fff;
    --pwfc-btn-bg-hover: var(--pwfc-accent-dark);
}

/* ==========================================================================
   Dark Mode
   ========================================================================== */

html.dark {
    --pwfc-accent: #60a5fa;
    --pwfc-accent-dark: #3b82f6;
    --pwfc-border: #4b5563;
    --pwfc-border-hover: #6366f1;
    --pwfc-border-selected: #60a5fa;
    --pwfc-text: #f3f4f6;
    --pwfc-text-secondary: #9ca3af;
    --pwfc-text-muted: #6b7280;
    --pwfc-text-feature: #d1d5db;
    --pwfc-active: #34d399;
    --pwfc-active-bg: #064e3b;
    --pwfc-sold-out: #f87171;
    --pwfc-card-bg: #1f2937;
    --pwfc-tab-bg: #374151;
    --pwfc-tab-active-bg: #4b5563;
    --pwfc-btn-bg: var(--pwfc-accent);
    --pwfc-btn-text: #fff;
    --pwfc-btn-bg-hover: var(--pwfc-accent-dark);
}

/* ==========================================================================
   Widget Container
   ========================================================================== */

.pwfc-pricing-widget {
    width: fit-content;
    margin: 0 auto;
    background: var(--pwfc-bg);
    border: 1px solid var(--pwfc-border);
    border-radius: 12px;
    padding: 16px;
    font-family: inherit;
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.pwfc-pricing-widget.pwfc-size-large {
    max-width: 500px;
    padding: 20px;
}

.pwfc-pricing-widget * {
    box-sizing: border-box;
}

/* ==========================================================================
   Header
   ========================================================================== */

.pwfc-pricing-widget-title {
    text-align: center;
    color: var(--pwfc-text);
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 12px 0;
}

.pwfc-pricing-widget-product-name {
    text-align: center;
    color: var(--pwfc-text);
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

/* ==========================================================================
   Tabs
   ========================================================================== */

.pwfc-pricing-tabs {
    display: flex;
    width: fit-content;
    gap: 4px;
    background: var(--pwfc-tab-bg);
    border-radius: 8px;
    padding: 4px;
    margin: 0 auto 12px;
}

.pwfc-pricing-tab {
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--pwfc-text-secondary);
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.pwfc-pricing-tab:hover {
    color: var(--pwfc-text);
}

.pwfc-pricing-tab.active {
    color: var(--pwfc-text);
    background: var(--pwfc-tab-active-bg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.pwfc-pricing-tab-content {
    display: none;
}

.pwfc-pricing-tab-content.active {
    display: block;
}

/* ==========================================================================
   Pricing Options (Radio Cards)
   ========================================================================== */

.pwfc-pricing-options {
    background: transparent;
    border-radius: 12px;
    overflow: visible;
}

.pwfc-pricing-option {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--pwfc-border);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
    background: var(--pwfc-card-bg);
}

.pwfc-pricing-option:last-child {
    margin-bottom: 0;
}

.pwfc-pricing-option:hover {
    border-color: var(--pwfc-border-hover);
}

.pwfc-pricing-option.selected {
    border: 2px solid var(--pwfc-border-selected);
    padding: 9px 11px;
}

.pwfc-pricing-option input[type="radio"] {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    accent-color: var(--pwfc-accent-dark);
}

.pwfc-pricing-option-label {
    flex: 1;
    font-size: 14px;
    color: var(--pwfc-text);
    white-space: normal;
    word-wrap: break-word;
}

/* ==========================================================================
   Price Display
   ========================================================================== */

.pwfc-pricing-display {
    text-align: center;
    padding: 16px 0 12px;
}

.pwfc-pricing-display-compare {
    font-size: 18px;
    color: var(--pwfc-text-muted);
    text-decoration: line-through;
    min-height: 28px;
}

.pwfc-pricing-display-price {
    font-size: 52px;
    font-weight: 700;
    color: var(--pwfc-text);
    line-height: 1;
    min-height: 52px;
}

.pwfc-pricing-display-price sup {
    font-size: 24px;
    vertical-align: super;
}

.pwfc-price-suffix {
    font-size: 20px;
    font-weight: 500;
    color: var(--pwfc-text-secondary);
}

.pwfc-pricing-display-label {
    font-size: 13px;
    color: var(--pwfc-text-secondary);
    margin-top: 4px;
    min-height: 20px;
}

/* ==========================================================================
   Buy Button
   ========================================================================== */

.pwfc-pricing-buy-btn {
    display: block;
    width: fit-content;
    background: var(--pwfc-btn-bg, var(--pwfc-accent));
    color: var(--pwfc-btn-text, #fff);
    text-decoration: none !important;
    padding: 11px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    margin: 10px auto;
    transition: transform 0.2s, background 0.2s;
    box-shadow: none;
    white-space: nowrap;
    overflow: hidden;
}

.pwfc-pricing-buy-btn:hover {
    background: var(--pwfc-btn-bg-hover, var(--pwfc-accent-dark));
    box-shadow: none;
    transform: translateY(-1px);
}

/* ==========================================================================
   Features
   ========================================================================== */

.pwfc-pricing-features {
    margin-top: 12px;
}

.pwfc-pricing-feature {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
    color: var(--pwfc-text-feature);
}

.pwfc-pricing-feature-icon {
    color: var(--pwfc-accent);
    font-weight: bold;
}

/* ==========================================================================
   Guarantee
   ========================================================================== */

.pwfc-pricing-guarantee {
    background: transparent;
    border: 1px solid var(--pwfc-border);
    border-radius: 8px;
    padding: 10px 14px;
    text-align: center;
    margin-top: 10px;
    font-size: 12px;
    color: var(--pwfc-text-feature);
}

.pwfc-pricing-guarantee strong {
    color: var(--pwfc-text);
}

/* ==========================================================================
   Wide Layout - Card Grid
   ========================================================================== */

.pwfc-pricing-widget.pwfc-layout-wide {
    width: 100%;
    max-width: 800px;
    padding: 20px;
}

/* Card Grid */
.pwfc-wide-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

/* Individual Card */
.pwfc-wide-card {
    border: 1px solid var(--pwfc-border);
    border-radius: 8px;
    padding: 20px 16px;
    background: var(--pwfc-card-bg);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.pwfc-wide-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--pwfc-text);
    margin-bottom: 12px;
}

.pwfc-wide-card-compare {
    font-size: 16px;
    color: var(--pwfc-text-muted);
    text-decoration: line-through;
    margin-bottom: 4px;
    min-height: 25px;
}

.pwfc-wide-card-price {
    font-size: 32px;
    font-weight: 700;
    color: var(--pwfc-text);
    line-height: 1.2;
    margin-bottom: 8px;
    min-height: 38px;
}

.pwfc-wide-card-installment {
    font-size: 13px;
    color: var(--pwfc-accent);
    margin-bottom: 12px;
}

/* Button in wide card - push to bottom of flex column */
.pwfc-wide-card .pwfc-pricing-buy-btn {
    margin-top: auto;
    margin-bottom: 0;
}

/* Features inside grid cards */
.pwfc-wide-card-features {
    margin-top: 16px;
    text-align: left;
    width: 100%;
}

.pwfc-wide-card-feature {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 12px;
    color: var(--pwfc-text-feature);
}

.pwfc-wide-card-feature .pwfc-pricing-feature-icon {
    color: var(--pwfc-accent);
    font-size: 11px;
}

/* Wide Features - horizontal layout */
.pwfc-wide-features {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 24px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--pwfc-border);
}

.pwfc-wide-features .pwfc-pricing-feature {
    padding: 4px 0;
}

/* Featured Section */
.pwfc-wide-featured {
    margin-top: 20px;
    padding: 20px;
    background: var(--pwfc-card-bg);
    border: 1px solid var(--pwfc-border);
    border-radius: 12px;
    position: relative;
}

.pwfc-wide-featured::before {
    content: attr(data-badge);
    position: absolute;
    top: -10px;
    left: 20px;
    background: var(--pwfc-accent);
    color: white;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 10px;
    border-radius: 4px;
}

.pwfc-wide-featured-header {
    font-size: 22px;
    font-weight: 700;
    color: var(--pwfc-text);
    text-align: center;
    margin-bottom: 8px;
}

.pwfc-wide-featured-subheader {
    font-size: 14px;
    color: var(--pwfc-text-secondary);
    text-align: center;
    margin-bottom: 16px;
    line-height: 1.5;
}

.pwfc-wide-featured-cards {
    display: grid;
    gap: 16px;
}

/* Single featured card = full width */
.pwfc-wide-featured-cards.pwfc-featured-count-1 {
    grid-template-columns: 1fr;
}

/* Two featured cards = side by side */
.pwfc-wide-featured-cards.pwfc-featured-count-2 {
    grid-template-columns: repeat(2, 1fr);
}

.pwfc-wide-card-featured {
    background: transparent;
    border: none;
}

.pwfc-wide-card-featured .pwfc-wide-card-title {
    color: var(--pwfc-accent);
}

/* Wide Layout Responsive */
@media (max-width: 782px) {
    .pwfc-wide-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .pwfc-wide-featured-cards.pwfc-featured-count-2 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .pwfc-wide-cards {
        grid-template-columns: 1fr;
    }

    .pwfc-pricing-widget.pwfc-layout-wide {
        padding: 16px;
    }

    .pwfc-wide-features {
        flex-direction: column;
        align-items: center;
        gap: 4px;
    }

    .pwfc-wide-featured {
        padding: 16px;
        padding-top: 20px;
    }
}

/* ==========================================================================
   Responsive Mobile Switch
   When enabled, wide layout switches to compact layout on mobile (<768px)
   ========================================================================== */

/* Compact fallback - hidden by default in wide layout */
.pwfc-pricing-widget.pwfc-layout-wide .pwfc-compact-fallback {
    display: none;
}

@media (max-width: 767px) {
    /* Hide wide-specific elements */
    .pwfc-pricing-widget.pwfc-layout-wide.pwfc-mobile-compact .pwfc-wide-cards,
    .pwfc-pricing-widget.pwfc-layout-wide.pwfc-mobile-compact .pwfc-wide-featured,
    .pwfc-pricing-widget.pwfc-layout-wide.pwfc-mobile-compact .pwfc-wide-features {
        display: none;
    }

    /* Show compact fallback */
    .pwfc-pricing-widget.pwfc-layout-wide.pwfc-mobile-compact .pwfc-compact-fallback {
        display: block;
    }

    /* Reset to compact layout styling */
    .pwfc-pricing-widget.pwfc-layout-wide.pwfc-mobile-compact {
        max-width: 320px;
        padding: 16px;
    }

    /* Compress tabs in compact view — fits 2-3 per row, wraps at 4+ */
    .pwfc-pricing-widget.pwfc-mobile-compact .pwfc-pricing-tabs {
        width: 100%;
        flex-wrap: wrap;
    }

    .pwfc-pricing-widget.pwfc-mobile-compact .pwfc-pricing-tab {
        padding: 6px 12px;
        font-size: 12px;
        flex: 1;
        text-align: center;
        white-space: nowrap;
    }
}

/* ==========================================================================
   Coming Soon Mode
   Overlays unpublished products with blur and message
   ========================================================================== */

/* Container needs relative positioning for overlay */
.pwfc-pricing-widget.pwfc-coming-soon {
    position: relative;
}

/* Light blur on structure (3px) - visible but not interactive */
.pwfc-pricing-widget.pwfc-coming-soon .pwfc-pricing-tabs,
.pwfc-pricing-widget.pwfc-coming-soon .pwfc-pricing-options,
.pwfc-pricing-widget.pwfc-coming-soon .pwfc-pricing-features,
.pwfc-pricing-widget.pwfc-coming-soon .pwfc-pricing-guarantee,
.pwfc-pricing-widget.pwfc-coming-soon .pwfc-pricing-buy-btn,
.pwfc-pricing-widget.pwfc-coming-soon .pwfc-wide-cards,
.pwfc-pricing-widget.pwfc-coming-soon .pwfc-wide-featured,
.pwfc-pricing-widget.pwfc-coming-soon .pwfc-wide-features {
    filter: blur(3px);
    pointer-events: none;
}

/* Heavy blur on prices (8px) - unreadable, prevents price anchoring */
.pwfc-pricing-widget.pwfc-coming-soon .pwfc-pricing-display,
.pwfc-pricing-widget.pwfc-coming-soon .pwfc-wide-card-price,
.pwfc-pricing-widget.pwfc-coming-soon .pwfc-wide-card-compare {
    filter: blur(8px);
}

/* Overlay - sits above blurred content */
.pwfc-coming-soon-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    z-index: 10;
}

.pwfc-coming-soon-icon {
    font-size: 48px;
    margin-bottom: 8px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.pwfc-coming-soon-message {
    font-size: 24px;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* ==========================================================================
   Stock badges & sold-out states
   ========================================================================== */

/* Stock badge — shared between wide cards and compact options */
.pwfc-stock-badge {
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    margin-top: 4px;
}

.pwfc-stock-badge--active {
    color: var(--pwfc-active);
}

.pwfc-stock-badge--sold-out {
    color: var(--pwfc-sold-out);
}

.pwfc-stock-badge--upcoming {
    color: var(--pwfc-text-muted, #6b7280);
    font-weight: 400;
}

/* FOMO ladder spacing inside cards */
.pwfc-wide-card .pwfc-fomo {
    margin-bottom: 12px;
}

/* Wide card — sold-out state */
.pwfc-wide-card--sold-out {
    opacity: 0.55;
}

.pwfc-wide-card--sold-out .pwfc-wide-card-price {
    text-decoration: line-through;
    color: var(--pwfc-text-muted, #9ca3af);
}

/* Disabled buy button for sold-out */
.pwfc-pricing-buy-btn--disabled {
    display: block;
    text-align: center;
    padding: 10px 24px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    background: var(--pwfc-text-muted, #9ca3af);
    color: #fff;
    cursor: not-allowed;
    pointer-events: none;
}

/* Compact option — sold-out state */
.pwfc-pricing-option--sold-out {
    opacity: 0.55;
    cursor: not-allowed;
}

.pwfc-pricing-option--sold-out .pwfc-pricing-option-label {
    text-decoration: line-through;
}

/* Compact option — stock badge inline */
.pwfc-pricing-option .pwfc-stock-badge {
    margin-top: 0;
    margin-left: auto;
    font-size: 11px;
    white-space: nowrap;
}

/* Mobile compact fallback - no relative positioning needed,
   parent widget container handles the overlay */
