/**
 * GRR Product Wizard — Frontend Styles
 *
 * Uses CSS custom properties from the theme where available,
 * with sensible fallbacks.
 */

:root {
    --grr-wiz-primary: var(--color-primary, #3B5DA7);
    --grr-wiz-primary-dark: var(--color-primary-dark, #2D4A8A);
    --grr-wiz-accent: var(--color-accent, #C5A855);
    --grr-wiz-text: var(--color-text, #1f2937);
    --grr-wiz-text-light: #6b7280;
    --grr-wiz-border: #e5e7eb;
    --grr-wiz-bg: #ffffff;
    --grr-wiz-bg-light: #f9fafb;
    --grr-wiz-radius: 12px;
    --grr-wiz-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --grr-wiz-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* ---------------------------------------------------------------
 * Container
 * ------------------------------------------------------------- */

.grr-wizard {
    position: relative;
    max-width: 960px;
    margin: 0 auto;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--grr-wiz-text);
    line-height: 1.5;
}

.grr-wizard *,
.grr-wizard *::before,
.grr-wizard *::after {
    box-sizing: border-box;
}

.grr-wizard-screen {
    animation: grrWizFadeIn 0.3s ease;
}

@keyframes grrWizFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------------------------------------------------------------
 * Typography
 * ------------------------------------------------------------- */

.grr-wizard-heading {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    color: var(--grr-wiz-text);
}

.grr-wizard-subheading {
    font-size: 1.0625rem;
    color: var(--grr-wiz-text-light);
    margin: 0 0 2rem;
}

.grr-wizard-intro {
    text-align: center;
    margin-bottom: 2rem;
}

/* ---------------------------------------------------------------
 * Buttons
 * ------------------------------------------------------------- */

.grr-wizard-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1.2;
}

.grr-wizard-btn-primary {
    background: var(--grr-wiz-accent);
    color: #fff;
}

.grr-wizard-btn-primary:hover {
    background: #b8993d;
    transform: translateY(-1px);
    box-shadow: var(--grr-wiz-shadow-hover);
}

.grr-wizard-btn-secondary {
    background: transparent;
    color: var(--grr-wiz-primary);
    border: 2px solid var(--grr-wiz-border);
}

.grr-wizard-btn-secondary:hover {
    border-color: var(--grr-wiz-primary);
    background: rgba(59, 93, 167, 0.04);
}

.grr-wizard-btn-sm {
    padding: 8px 16px;
    font-size: 0.875rem;
}

.grr-wizard-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ---------------------------------------------------------------
 * Scenario Cards
 * ------------------------------------------------------------- */

.grr-wizard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 2rem;
}

.grr-wizard-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 28px 20px;
    background: var(--grr-wiz-bg);
    border: 2px solid var(--grr-wiz-border);
    border-radius: var(--grr-wiz-radius);
    cursor: pointer;
    transition: all 0.2s;
}

.grr-wizard-card:hover {
    border-color: var(--grr-wiz-primary);
    box-shadow: var(--grr-wiz-shadow-hover);
    transform: translateY(-2px);
}

.grr-wizard-card-icon {
    font-size: 36px;
    width: 36px;
    height: 36px;
    color: var(--grr-wiz-primary);
    margin-bottom: 12px;
}

.grr-wizard-card-title {
    font-size: 1.0625rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--grr-wiz-text);
}

.grr-wizard-card-desc {
    font-size: 0.875rem;
    color: var(--grr-wiz-text-light);
    line-height: 1.4;
}

/* Expert mode toggle */
.grr-wizard-expert-toggle {
    text-align: center;
    padding-top: 1rem;
    border-top: 1px solid var(--grr-wiz-border);
}

.grr-wizard-expert-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: transparent;
    border: 1px solid var(--grr-wiz-border);
    border-radius: 8px;
    color: var(--grr-wiz-text-light);
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all 0.2s;
}

.grr-wizard-expert-btn:hover {
    color: var(--grr-wiz-primary);
    border-color: var(--grr-wiz-primary);
}

/* ---------------------------------------------------------------
 * Progress Bar
 * ------------------------------------------------------------- */

.grr-wizard-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 2rem;
}

.grr-wizard-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--grr-wiz-border);
    border-radius: 3px;
    overflow: hidden;
}

.grr-wizard-progress-fill {
    height: 100%;
    background: var(--grr-wiz-primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.grr-wizard-progress-text {
    font-size: 0.8125rem;
    color: var(--grr-wiz-text-light);
    white-space: nowrap;
}

/* ---------------------------------------------------------------
 * Step Content
 * ------------------------------------------------------------- */

.grr-wizard-step-content {
    min-height: 200px;
}

.grr-wizard-question {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

/* Radio / Checkbox option cards */
.grr-wizard-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.grr-wizard-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    background: var(--grr-wiz-bg);
    border: 2px solid var(--grr-wiz-border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
}

.grr-wizard-option:hover {
    border-color: var(--grr-wiz-primary);
    background: rgba(59, 93, 167, 0.02);
}

.grr-wizard-option.is-selected {
    border-color: var(--grr-wiz-primary);
    background: rgba(59, 93, 167, 0.06);
}

.grr-wizard-option input[type="radio"],
.grr-wizard-option input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
    accent-color: var(--grr-wiz-primary);
}

.grr-wizard-option-content {
    flex: 1;
}

.grr-wizard-option-label {
    font-weight: 600;
    font-size: 1rem;
    display: block;
}

.grr-wizard-option-desc {
    font-size: 0.875rem;
    color: var(--grr-wiz-text-light);
    margin-top: 2px;
}

/* Number inputs */
.grr-wizard-number-inputs {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.grr-wizard-number-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--grr-wiz-bg);
    border: 1px solid var(--grr-wiz-border);
    border-radius: 8px;
}

.grr-wizard-number-label {
    flex: 1;
    font-weight: 500;
}

.grr-wizard-number-input {
    width: 80px;
    padding: 8px 12px;
    border: 2px solid var(--grr-wiz-border);
    border-radius: 6px;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
}

.grr-wizard-number-input:focus {
    border-color: var(--grr-wiz-primary);
    outline: none;
}

/* ---------------------------------------------------------------
 * Navigation
 * ------------------------------------------------------------- */

.grr-wizard-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--grr-wiz-border);
}

.grr-wizard-nav .grr-wizard-btn[data-action="next"] {
    margin-left: auto;
}

/* ---------------------------------------------------------------
 * Results — Product List
 * ------------------------------------------------------------- */

.grr-wizard-results-header {
    margin-bottom: 1.5rem;
}

.grr-wizard-product-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--grr-wiz-border);
    border: 1px solid var(--grr-wiz-border);
    border-radius: var(--grr-wiz-radius);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.grr-wizard-group-header {
    padding: 10px 16px;
    background: var(--grr-wiz-bg-light);
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--grr-wiz-primary);
}

.grr-wizard-product-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--grr-wiz-bg);
}

.grr-wizard-product-thumb {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
}

.grr-wizard-product-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.grr-wizard-product-info {
    flex: 1;
    min-width: 0;
}

.grr-wizard-product-name {
    font-weight: 600;
    font-size: 0.9375rem;
}

.grr-wizard-product-name a {
    color: var(--grr-wiz-text);
    text-decoration: none;
}

.grr-wizard-product-name a:hover {
    color: var(--grr-wiz-primary);
}

.grr-wizard-product-meta {
    font-size: 0.8125rem;
    color: var(--grr-wiz-text-light);
    margin-top: 2px;
}

.grr-wizard-product-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 4px;
}

.grr-wizard-badge-optional {
    background: #fef3c7;
    color: #92400e;
}

.grr-wizard-badge-oos {
    background: #fee2e2;
    color: #991b1b;
}

.grr-wizard-product-price {
    font-size: 0.9375rem;
    color: var(--grr-wiz-text-light);
    white-space: nowrap;
    min-width: 70px;
    text-align: right;
}

.grr-wizard-product-qty-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    gap: 4px;
}

.grr-wizard-product-qty {
    display: flex;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
}

.grr-wizard-qty-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--grr-wiz-border);
    background: var(--grr-wiz-bg-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--grr-wiz-text);
    transition: background 0.1s;
    user-select: none;
}

.grr-wizard-qty-btn:hover {
    background: var(--grr-wiz-border);
}

.grr-wizard-qty-btn:first-child {
    border-radius: 6px 0 0 6px;
}

.grr-wizard-qty-btn:last-child {
    border-radius: 0 6px 6px 0;
}

.grr-wizard-qty-input {
    width: 48px;
    height: 32px;
    border: 1px solid var(--grr-wiz-border);
    border-left: none;
    border-right: none;
    text-align: center;
    font-size: 0.9375rem;
    font-weight: 600;
    -moz-appearance: textfield;
}

.grr-wizard-qty-input::-webkit-inner-spin-button,
.grr-wizard-qty-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
}

.grr-wizard-product-subtotal {
    font-weight: 600;
    font-size: 0.8125rem;
    text-align: center;
    white-space: nowrap;
    color: var(--grr-wiz-text-light);
}

.grr-wizard-product-remove {
    background: none;
    border: none;
    color: #d1d5db;
    cursor: pointer;
    padding: 4px;
    flex-shrink: 0;
    transition: color 0.15s;
}

.grr-wizard-product-remove:hover {
    color: #ef4444;
}

/* ---------------------------------------------------------------
 * Total Bar (sticky)
 * ------------------------------------------------------------- */

.grr-wizard-total-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--grr-wiz-bg);
    border: 2px solid var(--grr-wiz-border);
    border-radius: var(--grr-wiz-radius);
    position: sticky;
    bottom: 16px;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
    z-index: 10;
}

.grr-wizard-total {
    display: flex;
    align-items: center;
    gap: 8px;
}

.grr-wizard-total-label {
    font-size: 1rem;
    color: var(--grr-wiz-text-light);
}

.grr-wizard-total-amount {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--grr-wiz-text);
}

.grr-wizard-total-actions {
    display: flex;
    gap: 10px;
}

/* ---------------------------------------------------------------
 * Expert Mode
 * ------------------------------------------------------------- */

.grr-wizard-expert-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.grr-wizard-expert-header .grr-wizard-heading {
    margin-bottom: 0;
}

.grr-wizard-expert-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--grr-wiz-border);
}

.grr-wizard-filter-btn {
    padding: 8px 16px;
    border: 1px solid var(--grr-wiz-border);
    border-radius: 20px;
    background: var(--grr-wiz-bg);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--grr-wiz-text);
}

.grr-wizard-filter-btn:hover {
    border-color: var(--grr-wiz-primary);
    color: var(--grr-wiz-primary);
}

.grr-wizard-filter-btn.is-active {
    background: var(--grr-wiz-primary);
    border-color: var(--grr-wiz-primary);
    color: #fff;
}

.grr-wizard-expert-products {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--grr-wiz-border);
    border: 1px solid var(--grr-wiz-border);
    border-radius: var(--grr-wiz-radius);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

/* ---------------------------------------------------------------
 * Success State
 * ------------------------------------------------------------- */

.grr-wizard-success-content {
    text-align: center;
    padding: 3rem 2rem;
}

.grr-wizard-success-icon {
    font-size: 64px;
    width: 64px;
    height: 64px;
    color: #22c55e;
    margin-bottom: 1rem;
}

.grr-wizard-success-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 2rem;
}

/* ---------------------------------------------------------------
 * Loading Overlay
 * ------------------------------------------------------------- */

.grr-wizard-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.9);
    z-index: 50;
    border-radius: var(--grr-wiz-radius);
}

.grr-wizard-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--grr-wiz-border);
    border-top-color: var(--grr-wiz-primary);
    border-radius: 50%;
    animation: grrWizSpin 0.6s linear infinite;
}

@keyframes grrWizSpin {
    to { transform: rotate(360deg); }
}

.grr-wizard-loading-text {
    font-size: 0.9375rem;
    color: var(--grr-wiz-text-light);
}

/* ---------------------------------------------------------------
 * Product List Page (/shop/list)
 * ------------------------------------------------------------- */

.grr-product-list-page {
    max-width: 100%;
}

.grr-product-list-nav {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--grr-wiz-border);
    position: sticky;
    top: var(--grr2-header-height, 80px);
    background: var(--grr-wiz-bg-light);
    z-index: 9;
    padding-top: 0.75rem;
}

.grr-product-list-nav a {
    text-decoration: none;
}

.grr-product-list-nav-count {
    color: var(--grr-wiz-text-light);
    font-size: 0.8125rem;
}

.grr-product-list-section {
    margin-bottom: 2rem;
    scroll-margin-top: calc(var(--grr2-header-height, 80px) + 60px);
}

.grr-product-list-category-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 0.75rem;
}

.grr-product-list-category-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--grr-wiz-primary);
    margin: 0;
}

.grr-product-list-category-count {
    font-size: 0.8125rem;
    color: var(--grr-wiz-text-light);
}

.grr-product-list-unavailable {
    color: var(--grr-wiz-text-light);
    font-size: 0.875rem;
    text-align: center;
    min-width: 112px;
}

.grr-product-list-empty {
    text-align: center;
    padding: 3rem;
    color: var(--grr-wiz-text-light);
}

.grr-product-list-total-bar {
    bottom: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    margin: 0 -1rem;
    padding: 16px 2rem;
}

.grr-product-list-success {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.95);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---------------------------------------------------------------
 * Responsive
 * ------------------------------------------------------------- */

@media (max-width: 768px) {
    .grr-wizard-cards {
        grid-template-columns: 1fr;
    }

    .grr-wizard-heading {
        font-size: 1.375rem;
    }

    .grr-wizard-product-row {
        flex-wrap: wrap;
        gap: 10px;
    }

    .grr-wizard-product-info {
        flex-basis: calc(100% - 70px);
    }

    .grr-wizard-product-price {
        text-align: left;
    }

    .grr-wizard-product-qty-wrap {
        margin-left: 64px;
    }

    .grr-wizard-total-bar {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .grr-wizard-total-actions {
        width: 100%;
    }

    .grr-wizard-total-actions .grr-wizard-btn {
        flex: 1;
        justify-content: center;
    }

    .grr-wizard-expert-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .grr-wizard-product-qty-wrap {
        margin-left: 0;
    }

    .grr-wizard-nav {
        gap: 8px;
    }

    .grr-wizard-btn {
        padding: 10px 18px;
        font-size: 0.9375rem;
    }
}
