/**
 * BLOUSO BUILDER - STYLES
 * Clean, modern step-based UI
 * Design tokens: assets/css/style.css (loaded first from builder view).
 */

/* Builder Container */
.builder-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
    min-height: 100vh;
}

/* Progress Bar */
.builder-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 32px;
    padding: 16px;
    background: var(--panel);
    border-radius: 12px;
}

.progress-step {
    display: flex;
    align-items: center;
    gap: 8px;
}

.step-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 2px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.step-dot.active {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--bg);
}

.step-dot.completed {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.step-line {
    width: 40px;
    height: 2px;
    background: var(--border-light);
}

.step-line.completed {
    background: var(--success);
}

/* Builder Layout (full-width; sidebar try-on removed) */
.builder-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
    max-width: 100%;
}

@media (max-width: 968px) {
    .builder-layout {
        display: flex;
        flex-direction: column;
        gap: 32px;
    }

    /* Keep DOM order: step cards first, then preview + price (readable without scrolling past preview) */
    .builder-sidebar {
        position: static;
        width: 100%;
    }
}

/* Step Content */
.step-content {
    background: var(--panel);
    border-radius: 16px;
    padding: 32px;
    min-height: 500px;
}

.step-header {
    text-align: center;
    margin-bottom: 32px;
}

.step-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.75rem;
    color: var(--gold);
    margin-bottom: 8px;
}

.step-header p {
    color: var(--text-secondary);
}

/* Option Grid */
.option-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.option-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    position: relative;
}

.option-card:hover {
    border-color: var(--gold);
    transform: translateY(-4px);
}

.option-card.selected-gold-border {
    border-color: var(--gold);
    background: rgba(250, 190, 35, 0.1);
}

.option-icon {
    font-size: 2.5rem;
    margin-bottom: 16px;
}

.option-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.option-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.option-price {
    color: var(--gold);
    font-weight: 600;
    font-size: 1.1rem;
}

/* Addon Grid */
.addon-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.addon-card {
    text-align: left;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    min-height: auto;
    overflow: hidden;
}

.addon-checkbox {
    font-size: 1.25rem;
    color: var(--gold);
    flex-shrink: 0;
    width: 24px;
    text-align: center;
    margin-top: 2px;
}

.addon-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.addon-card h3 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.addon-card p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.addon-card .option-price {
    font-size: 0.85rem;
    margin-top: 4px;
}

/* Measurement Types */
.measurement-types {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.measurement-type-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
}

.measurement-type-card:hover {
    border-color: var(--gold);
}

.measurement-type-card.selected-gold-border {
    border-color: var(--gold);
    background: rgba(250, 190, 35, 0.1);
}

.measurement-type-card h3 {
    font-size: 1rem;
    margin-bottom: 4px;
}

.measurement-type-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.type-price {
    margin-top: 8px;
    color: var(--gold);
    font-weight: 600;
}

/* Measurement Form */
.measurement-form {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.measurement-form h4 {
    margin-bottom: 16px;
    color: var(--gold);
}

.measurement-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.measurement-field label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.input-with-unit {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    overflow: hidden;
}

.input-with-unit input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 10px 12px;
    color: var(--text);
    font-size: 14px;
}

.input-with-unit input:focus {
    outline: none;
}

.input-with-unit .unit {
    padding: 10px 12px;
    background: var(--panel);
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Delivery Options */
.delivery-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.delivery-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
}

.delivery-card:hover {
    border-color: var(--gold);
}

.delivery-card.selected-gold-border {
    border-color: var(--gold);
    background: rgba(250, 190, 35, 0.1);
}

.delivery-info h3 {
    font-size: 1rem;
    margin-bottom: 4px;
}

.delivery-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.delivery-price {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gold);
}

/* Final Preview */
.final-preview {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.final-preview h3 {
    color: var(--gold);
    margin-bottom: 16px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.summary-grid div {
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
    font-size: 0.9rem;
}

/* Sidebar */
.builder-sidebar {
    position: sticky;
    top: 24px;
    height: fit-content;
}

.sidebar-panel {
    background: var(--panel);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
}

.sidebar-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    color: var(--gold);
    margin-bottom: 20px;
}

.price-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 0.9rem;
}

.price-row .label {
    color: var(--text-secondary);
}

.price-row .value {
    font-weight: 500;
}

.price-row.total {
    border-top: 1px solid var(--border);
    margin-top: 8px;
    padding-top: 16px;
    font-size: 1.2rem;
}

.price-row.total .value {
    color: var(--gold);
    font-weight: 700;
}

/* Navigation Buttons */
.step-navigation {
    display: flex;
    gap: 12px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    border: none;
    transition: all 0.3s;
    font-family: 'Poppins', sans-serif;
}

.nav-btn-primary {
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    color: var(--bg);
}

.nav-btn-primary:hover {
    box-shadow: 0 8px 24px rgba(250, 190, 35, 0.3);
    transform: translateY(-2px);
}

.nav-btn-secondary {
    background: var(--panel-hover);
    color: var(--text);
    border: 1px solid var(--border-light);
}

.nav-btn-secondary:hover {
    border-color: var(--gold);
    color: var(--gold);
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nav-btn.full-width {
    width: 100%;
}

/* Preview Card */
.preview-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.preview-icon {
    font-size: 4rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

.preview-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Loading State */
.builder-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
/* ≤767px: matches v2 mobile sticky bar — hide duplicate Next / Add to cart (sticky handles them); keep Back in inline nav */
@media (max-width: 767px) {
    #inlineStepNav #nextBtn,
    #inlineStepNav #submitBtn,
    #inlineStepNav #navStepIndicator {
        display: none !important;
    }

    #inlineStepNav {
        justify-content: flex-start;
    }
}

@media (max-width: 600px) {
    .builder-progress {
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .step-line {
        display: none;
    }
    
    .option-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .step-content {
        padding: 20px;
    }
    
    .step-navigation {
        flex-direction: column;
    }
    
    .nav-btn {
        width: 100%;
    }
}

/* Selected card — enhanced gold glow */
.option-card.selected-gold-border {
    border-color: var(--gold) !important;
    background: rgba(250, 190, 35, 0.08);
    box-shadow: 0 0 0 3px rgba(250, 190, 35, 0.18),
                0 4px 20px rgba(250, 190, 35, 0.12);
}

/* Card hover — upgraded lift + glow */
.option-card {
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.option-card:hover {
    border-color: var(--gold);
    transform: translateY(-5px) scale(1.01);
    box-shadow: 0 10px 30px rgba(250, 190, 35, 0.15);
}

/* Animated price display */
.live-price-display {
    text-align: center;
    padding: 12px 0 4px;
}

.live-price-amount {
    font-family: 'Playfair Display', serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--gold);
    display: inline-block;
    line-height: 1;

    /* Pop animation on update */
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.live-price-amount.price-pop {
    transform: scale(1.18);
}

.live-price-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-top: 2px;
}

/* Selection badge on cards */
.option-card.selected-gold-border::after {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    background: var(--gold);
    color: var(--bg);
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 20px;
    text-align: center;
    animation: badge-pop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes badge-pop {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

/* Step transition animation */
.builder-step-section {
    animation: step-slide-in 0.3s ease forwards;
}

@keyframes step-slide-in {
    from {
        opacity: 0;
        transform: translateX(16px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@media (max-width: 600px) {
    .live-price-amount {
        font-size: 1.3rem;
    }
}

/* ============================================
   STEP CONTENT WRAPPER + INLINE NAVIGATION
   Appended — Zero Overwrite
   ============================================ */

/* Wrapper replaces bare step-content in layout */
.step-content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Inline navigation bar — below selection cards */
.inline-step-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--panel);
    border-top: 1px solid var(--border-light);
    border-radius: 0 0 16px 16px;
    padding: 18px 28px;
}

/* Step indicator text in the center */
.nav-step-indicator {
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    flex: 1;
    text-align: center;
}

/* Remove top border from step-content (nav bar provides visual separation) */
.step-content {
    border-radius: 16px 16px 0 0;
}

/* ============================================
   CARD DESIGN IMAGES
   Appended — Zero Overwrite
   ============================================ */

/* Image container inside option card */
.card-img-wrap {
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
    background: var(--bg);
    border: 1px solid var(--border-light);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Actual design image */
.card-design-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    display: block;
}

.option-card:hover .card-design-img {
    transform: scale(1.05);
}

/* Fallback emoji — shown when image 404s */
.card-img-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.8rem;
    background: linear-gradient(135deg, var(--bg-secondary), var(--panel));
}

/* Fabric card image already circular — keep its own style */
.fabric-card .card-img-wrap {
    aspect-ratio: unset;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto 12px;
}

/* Mobile: tighter card images */
@media (max-width: 600px) {
    .card-img-wrap {
        aspect-ratio: 3 / 2;
    }

    .inline-step-nav {
        padding: 14px 16px;
    }

    .nav-step-indicator {
        display: none; /* save space on small screens */
    }
}

/* ============================================
   PHASE 3 ENHANCEMENTS
   ============================================ */

/* Price breakdown row styling (used where breakdown UI is rendered) */
.price-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 0.9rem;
    transition: background 0.2s ease;
}

.price-row.updated {
    background: rgba(250, 190, 35, 0.1);
    border-radius: 4px;
    padding-left: 8px;
    padding-right: 8px;
}

/* Progress bar enhanced styles */
.builder-progress {
    user-select: none;
}

.progress-step {
    position: relative;
}

.progress-step::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: transparent;
    transition: background 0.2s ease;
}

.progress-step:not(.disabled):hover::after {
    background: rgba(250, 190, 35, 0.1);
}

/* Error state */
.progress-step.error {
    animation: progress-error-pulse 0.5s ease;
}

@keyframes progress-error-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Mobile drawer enhancements */
.mobile-drawer {
    padding-bottom: env(safe-area-inset-bottom, 20px);
}

/* Improved focus states */
.option-card:focus-visible,
.measurement-mode-card:focus-visible,
.size-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--gold), 0 0 0 6px rgba(250, 190, 35, 0.3);
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .builder-step-section {
        transition: none;
    }
    
    .option-card {
        transition: border-color 0.1s ease, background 0.1s ease;
    }
    
    .option-card:hover {
        transform: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .option-card {
        border-width: 3px;
    }
    
    .option-card.selected-gold-border {
        border-width: 4px;
    }
    
    .step-dot {
        border-width: 3px;
    }
}

/* Print styles */
@media print {
    .builder-progress,
    .inline-step-nav,
    .mobile-sticky-bar,
    .toast-container {
        display: none !important;
    }
    
    .builder-layout {
        display: block;
    }
    
    .step-content {
        page-break-inside: avoid;
    }
}

/* Builder v2: transient price flash chips — full layout/animation in views/builder/v2.php (inline styles). */
