/* ==========================================================================
   Enhanced CSS for Reolbygger v6.0 - Theme Integrated & Responsive
   ========================================================================== */

/* CSS Custom Properties for Theme Integration */
:root {
    --reolbygger-primary: var(--wp--preset--color--primary, #0073aa);
    --reolbygger-secondary: var(--wp--preset--color--secondary, #005177);
    --reolbygger-accent: var(--wp--preset--color--accent, #00a0d2);
    
    --reolbygger-text: var(--wp--preset--color--foreground, #2c3e50);
    --reolbygger-text-light: var(--wp--preset--color--tertiary, #6c757d);
    --reolbygger-background: var(--wp--preset--color--background, #ffffff);
    --reolbygger-surface: var(--wp--preset--color--base, #f8f9fa);
    
    --reolbygger-border: #e1e5e9;
    --reolbygger-border-light: #f1f3f4;
    --reolbygger-shadow: rgba(0, 0, 0, 0.08);
    --reolbygger-shadow-hover: rgba(0, 0, 0, 0.12);
    
    --reolbygger-success: #28a745;
    --reolbygger-warning: #ffc107;
    --reolbygger-error: #dc3545;
    
    --reolbygger-radius: 4px;
    --reolbygger-radius-lg: 6px;
    --reolbygger-spacing-xs: 0.5rem;
    --reolbygger-spacing-sm: 1rem;
    --reolbygger-spacing-md: 1.5rem;
    --reolbygger-spacing-lg: 2rem;
    
    --reolbygger-transition: all 0.2s ease;
}


/* Enhanced sticky behavior for sidebar sections */
#reolbygger-visual,
#pallet-visual,
#grenreol-visual {
    margin-bottom: 1.5em;
}

#reolbygger-summary-live,
#pallet-summary-live,
#grenreol-summary-live {
    background: white;
    padding: 1em;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-top: 1em;
}

/* Smooth scrolling within sticky sidebar */
.reolbygger-sidebar {
    scroll-behavior: smooth;
}

/* Fallback for browsers that don't support sticky */
@supports not (position: sticky) {
    .reolbygger-sidebar {
        position: relative;
        top: auto;
        max-height: none;
        overflow-y: visible;
    }
}

/* Step Progress Indicator */
.reolbygger-progress {
    margin-bottom: var(--reolbygger-spacing-sm);
    padding: var(--reolbygger-spacing-sm);
    background: var(--reolbygger-background);
    border-radius: var(--reolbygger-radius-lg);
    border: 1px solid var(--reolbygger-border);
    box-shadow: 0 1px 2px var(--reolbygger-shadow);
}

.progress-bar {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
    cursor: pointer;
    transition: var(--reolbygger-transition);
    flex: 1;
    max-width: 100px;
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--reolbygger-border-light);
    color: var(--reolbygger-text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 6px;
    transition: var(--reolbygger-transition);
    border: 1px solid var(--reolbygger-border);
    font-family: inherit;
}

.step-label {
    font-size: 11px;
    color: var(--reolbygger-text-light);
    text-align: center;
    font-weight: 500;
    transition: var(--reolbygger-transition);
    font-family: inherit;
}

/* Active step */
.progress-step.active .step-number {
    background: var(--reolbygger-primary);
    color: white;
    border-color: var(--reolbygger-primary);
    box-shadow: 0 2px 4px rgba(0, 115, 170, 0.2);
}

.progress-step.active .step-label {
    color: var(--reolbygger-primary);
    font-weight: 600;
}

/* Completed steps */
.progress-step.completed .step-number {
    background: var(--reolbygger-success);
    color: white;
    border-color: var(--reolbygger-success);
}

.progress-step.completed .step-label {
    color: var(--reolbygger-success);
}

/* Add checkmark for completed steps */
.progress-step.completed .step-number::before {
    content: "✓";
    font-size: 18px;
    font-weight: bold;
}

/* Progress line */
.progress-line {
    position: absolute;
    top: 16px;
    left: 50px;
    right: 50px;
    height: 2px;
    background: var(--reolbygger-border);
    z-index: 1;
    transition: var(--reolbygger-transition);
}

.progress-line::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--reolbygger-primary);
    transition: width 0.3s ease;
    width: var(--progress-width, 0%);
}

/* Hover effects */
.progress-step:hover .step-number {
    transform: scale(1.05);
    box-shadow: 0 2px 4px var(--reolbygger-shadow-hover);
}

.progress-step.active:hover .step-number,
.progress-step.completed:hover .step-number {
    transform: scale(1.02);
}

/* Base Styles */
#reolbygger-container,
#reolbygger-pallet-container,
#reolbygger-grenreol-container {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: var(--reolbygger-spacing-md);
    max-width: 1200px;
    margin: 0 auto;
    font-family: inherit;
    line-height: 1.6;
    color: var(--reolbygger-text);
    transition: var(--reolbygger-transition);
}

/* Reset styles to prevent theme conflicts */
#reolbygger-container *,
#reolbygger-pallet-container * {
    box-sizing: border-box;
}

#reolbygger-container select,
#reolbygger-container input,
#reolbygger-container textarea,
#reolbygger-pallet-container select,
#reolbygger-pallet-container input,
#reolbygger-pallet-container textarea {
    font-family: inherit;
    vertical-align: baseline;
}

.reolbygger-main {
    grid-column: 1;
    min-width: 0; /* Allow grid to shrink */
}

.reolbygger-sidebar {
    grid-column: 2;
    background-color: var(--reolbygger-surface);
    padding: var(--reolbygger-spacing-sm);
    border-radius: var(--reolbygger-radius-lg);
    border: 1px solid var(--reolbygger-border);
    box-shadow: 0 2px 8px var(--reolbygger-shadow);
    position: sticky;
    top: 20px;
    align-self: start;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

/* Step Navigation */
.reolbygger-step {
    display: none;
    border: 1px solid var(--reolbygger-border);
    padding: var(--reolbygger-spacing-sm);
    border-radius: var(--reolbygger-radius-lg);
    background-color: var(--reolbygger-background);
    box-shadow: 0 2px 4px var(--reolbygger-shadow);
    transition: var(--reolbygger-transition);
    margin-bottom: var(--reolbygger-spacing-xs);
}

.reolbygger-step.active {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

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

.reolbygger-step h2 {
    margin-top: 0;
    margin-bottom: var(--reolbygger-spacing-sm);
    color: var(--reolbygger-primary);
    border-bottom: 2px solid var(--reolbygger-border);
    padding-bottom: var(--reolbygger-spacing-xs);
    font-size: 1.25rem;
    font-weight: 600;
    font-family: inherit;
}

/* Form Fields */
.reolbygger-field {
    margin-bottom: var(--reolbygger-spacing-sm);
}

.reolbygger-field label {
    display: block;
    font-weight: 500;
    margin-bottom: var(--reolbygger-spacing-xs);
    color: var(--reolbygger-text);
    font-size: 0.9rem;
    font-family: inherit;
}

.reolbygger-field select,
.reolbygger-field input,
.reolbygger-field textarea {
    width: 100%;
    padding: 10px 12px;
    box-sizing: border-box;
    border: 1px solid var(--reolbygger-border);
    border-radius: var(--reolbygger-radius);
    font-size: 14px;
    line-height: 1.4;
    min-height: 44px;
    transition: var(--reolbygger-transition);
    background-color: var(--reolbygger-background);
    color: var(--reolbygger-text);
    font-family: inherit;
}

/* Focus states */
.reolbygger-field select:focus,
.reolbygger-field input:focus,
.reolbygger-field textarea:focus {
    outline: none;
    border-color: var(--reolbygger-primary);
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.15);
}

/* Specific fixes for select elements */
.reolbygger-field select {
    height: auto;
    min-height: 44px;
    padding-top: 10px;
    padding-bottom: 10px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 5"><path fill="%23666" d="M2 0L0 2h4zm0 5L0 3h4z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 36px;
}

/* Fix for Firefox */
.reolbygger-field select:-moz-focusring {
    color: transparent;
    text-shadow: 0 0 0 #2c3e50;
}

.reolbygger-field select:focus,
.reolbygger-field input:focus,
.reolbygger-field textarea:focus {
    outline: none;
    border-color: #005fcc;
    box-shadow: 0 0 0 3px rgba(0, 95, 204, 0.1);
}

.reolbygger-field textarea {
    resize: vertical;
    min-height: 100px;
}

/* Range Sliders */
.reolbygger-slider {
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    border-radius: 4px;
    background: #e0e0e0;
    outline: none;
    margin: 1em 0;
}

.reolbygger-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #005fcc;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.reolbygger-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.reolbygger-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #005fcc;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.slider-value {
    font-weight: bold;
    color: #005fcc;
    background-color: #eef4ff;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    min-width: 30px;
    text-align: center;
    font-size: 0.9em;
}

/* Navigation */
.reolbygger-nav {
    margin-top: 2em;
    display: flex;
    justify-content: space-between;
    border-top: 1px solid #eee;
    padding-top: 1.5em;
    gap: 1em;
}

.reolbygger-nav-btn,
#reolbygger-add-to-cart,
#pallet-add-to-cart {
    background: var(--reolbygger-primary);
    color: white;
    border: 1px solid var(--reolbygger-primary);
    padding: 10px 20px;
    border-radius: var(--reolbygger-radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: var(--reolbygger-transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    font-family: inherit;
}

.reolbygger-nav-btn:hover,
#reolbygger-add-to-cart:hover,
#pallet-add-to-cart:hover {
    background: var(--reolbygger-secondary);
    border-color: var(--reolbygger-secondary);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px var(--reolbygger-shadow-hover);
}

.reolbygger-nav-btn:active,
#reolbygger-add-to-cart:active,
#pallet-add-to-cart:active {
    transform: translateY(0);
}

.reolbygger-nav-btn:disabled,
#reolbygger-add-to-cart:disabled,
#pallet-add-to-cart:disabled {
    background: var(--reolbygger-text-light);
    border-color: var(--reolbygger-text-light);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Visual Canvas */
.reolbygger-canvas-container {
    position: relative;
    width: 100%;
    height: 320px;
    background-color: var(--reolbygger-background);
    border: 1px solid var(--reolbygger-border);
    border-radius: var(--reolbygger-radius-lg);
    margin: var(--reolbygger-spacing-xs) 0 var(--reolbygger-spacing-xs) 60px;
    padding-bottom: 40px;
    overflow: visible;
    box-shadow: 0 1px 2px var(--reolbygger-shadow);
}

#reolbygger-canvas,
#pallet-canvas {
    position: relative;
    width: 100%;
    height: 100%;
}

.visual-gavl {
    position: absolute;
    bottom: 0;
    width: 8px;
    background: linear-gradient(135deg, #d0d0d0, #b0b0b0);
    border: 1px solid #a0a0a0;
    box-sizing: border-box;
    background-image: linear-gradient(to bottom, #c0c0c0 1px, transparent 1px);
    background-size: 100% 15px;
    border-radius: 2px 2px 0 0;
}

.visual-hylle {
    position: absolute;
    height: 12px;
    background: linear-gradient(135deg, #e8e8e8, #d0d0d0);
    border: 1px solid #a0a0a0;
    border-bottom: 2px solid #a0a0a0;
    box-sizing: border-box;
    border-radius: 2px;
}

.visual-ryggkryss {
    position: absolute;
    top: 40%;
    height: 55%;
    background-image: 
        linear-gradient(to top right, transparent 49.0%, #a0a0a0 49.0%, #a0a0a0 51.0%, transparent 51.0%),
        linear-gradient(to top left, transparent 49.0%, #a0a0a0 49.0%, #a0a0a0 51.0%, transparent 51.0%);
    background-size: 100% 100%;
    background-repeat: no-repeat;
    opacity: 0.8;
}

/* Pallet Visual Elements - Industrial Design */
.visual-pallet-upright {
    position: absolute;
    bottom: 0;
    background: linear-gradient(to right, #f0f0f0, #d0d0d0, #e8e8e8);
    border: 1px solid #b0b0b0;
    box-sizing: border-box;
    border-radius: 2px 2px 0 0;
    box-shadow: 2px 0 4px rgba(0,0,0,0.2);
}

.upright-slot {
    position: absolute;
    background-color: #666;
    border-radius: 1px;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.6);
}

.visual-pallet-beam-front {
    position: absolute;
    background: linear-gradient(to bottom, #FF8C00 0%, #FF6B00 30%, #E55A00 100%);
    border: 1px solid #CC4400;
    border-radius: 4px 4px 8px 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
    z-index: 2;
}


.beam-hook {
    position: absolute;
    background-color: #CC4400;
    border: 1px solid #AA3300;
    z-index: 3;
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}


.pallet-floor {
    position: absolute;
    background: linear-gradient(to bottom, #999, #777);
    z-index: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Visual Canvas - Gray Background for Technical Drawing Style */
.reolbygger-canvas-container {
    position: relative;
    width: 100%;
    height: 350px;
    background: linear-gradient(135deg, #f8f8f8, #f0f0f0);
    border: 2px solid #d0d0d0;
    border-radius: 8px;
    margin-top: 1em;
    overflow: hidden;
}

.dimensions-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#dimension-width,
#pallet-dimension-width {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: #555;
    background: #f9f9f9;
    padding: 2px 8px;
    border-radius: 3px;
    border: 1px solid #ddd;
    font-weight: 600;
}

#dimension-height,
#pallet-dimension-height {
    position: absolute;
    left: -60px;
    top: 50%;
    transform: translateY(-50%) rotate(-90deg);
    font-size: 12px;
    color: #555;
    background: #f9f9f9;
    padding: 2px 8px;
    border-radius: 3px;
    border: 1px solid #ddd;
    font-weight: 600;
}

#pallet-dimension-depth {
    position: absolute;
    right: -60px;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);
    font-size: 12px;
    color: #555;
    background: #f9f9f9;
    padding: 2px 8px;
    border-radius: 3px;
    border: 1px solid #ddd;
    font-weight: 600;
}

/* Visual dimension lines */
.dimension-line-height {
    position: absolute;
    left: -20px;
    top: 15%;
    height: 70%;
    width: 1px;
    background: var(--reolbygger-primary);
    z-index: 15;
}

.dimension-line-height::before,
.dimension-line-height::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 1px;
    background: var(--reolbygger-primary);
    left: -3px;
}

.dimension-line-height::before {
    top: 0;
}

.dimension-line-height::after {
    bottom: 0;
}

.dimension-line-width {
    position: absolute;
    bottom: -20px;
    left: 15%;
    width: 70%;
    height: 1px;
    background: var(--reolbygger-primary);
    z-index: 15;
}

.dimension-line-width::before,
.dimension-line-width::after {
    content: '';
    position: absolute;
    height: 8px;
    width: 1px;
    background: var(--reolbygger-primary);
    top: -3px;
}

.dimension-line-width::before {
    left: 0;
}

.dimension-line-width::after {
    right: 0;
}

/* Dimension labels */
.dimension-label-height {
    position: absolute;
    left: -50px;
    top: 50%;
    transform: translateY(-50%) rotate(-90deg);
    background: var(--reolbygger-background);
    border: 1px solid var(--reolbygger-primary);
    padding: 4px 8px;
    font-size: 10px;
    font-weight: 500;
    color: var(--reolbygger-primary);
    border-radius: var(--reolbygger-radius);
    white-space: nowrap;
    z-index: 16;
    box-shadow: 0 1px 2px var(--reolbygger-shadow);
    font-family: inherit;
}

.dimension-label-width {
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--reolbygger-background);
    border: 1px solid var(--reolbygger-primary);
    padding: 4px 8px;
    font-size: 10px;
    font-weight: 500;
    color: var(--reolbygger-primary);
    border-radius: var(--reolbygger-radius);
    white-space: nowrap;
    z-index: 16;
    box-shadow: 0 1px 2px var(--reolbygger-shadow);
    font-family: inherit;
}

/* Notices and Messages */
.reolbygger-notice {
    padding: 1em;
    border-radius: 4px;
    margin: 1em 0;
    border-left: 4px solid;
}

.reolbygger-notice-warning {
    background-color: #fff8e1;
    border-color: #ffb300;
    color: #e65100;
}

.reolbygger-error {
    color: var(--reolbygger-error);
    background-color: color-mix(in srgb, var(--reolbygger-error) 10%, transparent);
    border: 1px solid var(--reolbygger-error);
    padding: var(--reolbygger-spacing-xs) var(--reolbygger-spacing-sm);
    border-radius: var(--reolbygger-radius);
    margin: var(--reolbygger-spacing-xs) 0;
    border-left: 4px solid var(--reolbygger-error);
    font-family: inherit;
    font-size: 14px;
}

.reolbygger-success {
    color: var(--reolbygger-success);
    background-color: color-mix(in srgb, var(--reolbygger-success) 10%, transparent);
    border: 1px solid var(--reolbygger-success);
    padding: var(--reolbygger-spacing-xs) var(--reolbygger-spacing-sm);
    border-radius: var(--reolbygger-radius);
    margin: var(--reolbygger-spacing-xs) 0;
    border-left: 4px solid var(--reolbygger-success);
    font-family: inherit;
    font-size: 14px;
}

/* Loading States */
.reolbygger-loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.reolbygger-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: reolbygger-spin 1s ease-in-out infinite;
    margin-right: 8px;
}

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

/* Validation */
.reolbygger-validation-error {
    border-color: #d63638 !important;
    box-shadow: 0 0 0 2px rgba(214, 54, 56, 0.2) !important;
}

.character-counter {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
    text-align: right;
}

/* Pricing Display */
#live-price,
#pallet-live-price {
    font-size: 1.2em;
    color: #2c3e50;
}

#reolbygger-summary-details,
#pallet-summary-details {
    margin-top: 1em;
}

#reolbygger-summary-details h4,
#pallet-summary-details h4 {
    color: #2c3e50;
    margin-bottom: 0.5em;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 0.3em;
}

#reolbygger-summary-details table,
#pallet-summary-details table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1em;
    font-size: 0.9em;
}

#reolbygger-summary-details th,
#pallet-summary-details th {
    background-color: #f5f5f5;
    font-weight: 600;
    text-align: left;
    padding: 10px 8px;
    border-bottom: 2px solid #1e40af;
}

#reolbygger-summary-details td,
#pallet-summary-details td {
    padding: 8px;
    border-bottom: 1px solid #e0e0e0;
}

#reolbygger-summary-details tr:hover,
#pallet-summary-details tr:hover {
    background-color: #f9f9f9;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    #reolbygger-container,
    #reolbygger-pallet-container,
    #reolbygger-grenreol-container {
        grid-template-columns: 1fr;
        gap: var(--reolbygger-spacing-sm);
        max-width: none;
        margin: 0;
        padding: 0 var(--reolbygger-spacing-xs);
    }
    
    .reolbygger-main,
    .reolbygger-sidebar {
        grid-column: 1;
    }
    
    .reolbygger-sidebar {
        order: -1; /* Show visual first on mobile */
    }
    
    .reolbygger-step {
        padding: var(--reolbygger-spacing-sm);
    }
    
    .reolbygger-step h2 {
        font-size: 1.1rem;
        margin-bottom: var(--reolbygger-spacing-xs);
    }
    
    .reolbygger-nav {
        flex-direction: column;
        gap: 0.5em;
    }
    
    .reolbygger-nav-btn,
    #reolbygger-add-to-cart {
        width: 100%;
        text-align: center;
    }
    
    .reolbygger-canvas-container {
        height: 220px;
        margin: var(--reolbygger-spacing-xs) 0 var(--reolbygger-spacing-xs) 30px;
        padding-bottom: 30px;
    }
    
    /* Adjust dimension labels for mobile */
    .dimension-label-height {
        left: -45px;
        font-size: 10px;
        padding: 1px 4px;
    }
    
    .dimension-label-width {
        bottom: -35px;
        font-size: 10px;
        padding: 1px 4px;
    }
    
    /* Adjust dimension lines for mobile */
    .dimension-line-height {
        left: -20px;
    }
    
    .dimension-line-width {
        bottom: -20px;
    }
    
    
    /* Disable sticky behavior on mobile */
    .reolbygger-sidebar {
        position: relative;
        top: auto;
        max-height: none;
        overflow-y: visible;
        align-self: auto;
    }
    
    /* Mobile progress indicator adjustments */
    .reolbygger-progress {
        padding: 1em;
        margin-bottom: 1em;
    }
    
    .progress-step {
        max-width: 80px;
    }
    
    .step-number {
        width: 32px;
        height: 32px;
        font-size: 14px;
        margin-bottom: 6px;
    }
    
    .step-label {
        font-size: 11px;
        line-height: 1.2;
    }
    
    .progress-line {
        top: 16px;
        left: 40px;
        right: 40px;
    }
    
    #dimension-width,
    #pallet-dimension-width {
        bottom: -25px;
        font-size: 11px;
    }
    
    #dimension-height,
    #pallet-dimension-height {
        left: -45px;
        font-size: 11px;
    }
    
    #reolbygger-summary-details,
    #pallet-summary-details {
        overflow-x: auto;
    }
    
    #reolbygger-summary-details table,
    #pallet-summary-details table {
        min-width: 300px;
    }
}

@media (max-width: 480px) {
    .reolbygger-step {
        padding: 1em 0.5em;
        margin: 0.5em 0;
    }
    
    .reolbygger-sidebar {
        padding: 1em;
    }
    
    .reolbygger-field select,
    .reolbygger-field input,
    .reolbygger-field textarea {
        font-size: 16px; /* Prevents zoom on mobile */
    }
    
    .reolbygger-canvas-container {
        height: 200px;
    }
    
    .slider-value {
        font-size: 0.8em;
        padding: 2px 6px;
    }
}

/* Print Styles */
@media print {
    .reolbygger-nav,
    .reolbygger-spinner,
    .reolbygger-error,
    .reolbygger-notice {
        display: none !important;
    }
    
    .reolbygger-step {
        border: none;
        box-shadow: none;
        page-break-inside: avoid;
    }
    
    #reolbygger-container,
    #reolbygger-pallet-container {
        flex-direction: column;
    }
}

/* High Contrast Support */
@media (prefers-contrast: high) {
    .reolbygger-step {
        border-width: 2px;
    }
    
    .reolbygger-field select,
    .reolbygger-field input,
    .reolbygger-field textarea {
        border-width: 2px;
    }
    
    .visual-gavl,
    .visual-hylle,
    .visual-ryggkryss {
        border-width: 2px;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .reolbygger-step,
    .reolbygger-nav-btn,
    #reolbygger-add-to-cart,
    .reolbygger-slider::-webkit-slider-thumb {
        transition: none;
        animation: none;
    }
    
    .reolbygger-spinner {
        animation: none;
        border: 2px solid #005fcc;
        border-radius: 50%;
    }
}

/* ==========================================================================
   Capacity Management Styles
   ========================================================================== */

.capacity-panel {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 1em;
    margin-bottom: 1em;
}

.capacity-panel h4 {
    margin: 0 0 0.5em 0;
    color: #495057;
    font-size: 1.1em;
}

.capacity-info {
    margin-bottom: 0.8em;
}

.capacity-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.3em;
    font-size: 0.9em;
}

.capacity-row span:first-child {
    color: #6c757d;
}

.capacity-row span:last-child {
    font-weight: 600;
}

.safe-capacity { color: #28a745; }
.near-capacity { color: #ffc107; }
.over-capacity { color: #dc3545; }

.capacity-meter {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.5em;
}

.capacity-bar {
    height: 100%;
    transition: width 0.3s ease;
}

.capacity-bar.safe-capacity { background: #28a745; }
.capacity-bar.near-capacity { background: #ffc107; }
.capacity-bar.over-capacity { background: #dc3545; }

.capacity-warnings {
    margin-top: 0.8em;
}

.capacity-warning {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
    padding: 0.5em;
    border-radius: 4px;
    margin-bottom: 0.3em;
    font-size: 0.85em;
}

.capacity-warning.overload {
    background: #f8d7da;
    border-color: #f1aeb5;
    color: #721c24;
}

/* Capacity Modal Styles */
.capacity-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(2px);
}

.capacity-modal {
    background: white;
    border-radius: 8px;
    padding: 2em;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.capacity-modal h3 {
    margin: 0 0 1em 0;
    color: #dc3545;
    font-size: 1.3em;
}

.capacity-modal h4 {
    margin: 1.5em 0 1em 0;
    color: #495057;
    font-size: 1.1em;
}

.solution-options {
    margin: 1em 0 1.5em 0;
}

.solution-option {
    display: flex;
    align-items: center;
    gap: 0.5em;
    padding: 0.8em;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-bottom: 0.5em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.solution-option:hover {
    background: #f8f9fa;
    border-color: #0066cc;
}

.solution-option input[type="radio"] {
    margin: 0;
}

.modal-actions {
    display: flex;
    gap: 0.5em;
    justify-content: flex-end;
    margin-top: 1.5em;
    flex-wrap: wrap;
}

.modal-actions button {
    padding: 0.6em 1.2em;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s ease;
}

.btn-apply-solution {
    background: #28a745;
    color: white;
}

.btn-apply-solution:hover {
    background: #218838;
}

.btn-manual-adjust {
    background: #6c757d;
    color: white;
}

.btn-manual-adjust:hover {
    background: #5a6268;
}

.btn-close-modal {
    background: #f8f9fa;
    color: #6c757d;
    border: 1px solid #dee2e6;
}

.btn-close-modal:hover {
    background: #e9ecef;
}

/* Custom Capacity Indicator */
.custom-capacity-indicator {
    margin-top: 0.3em;
    padding: 0.3em 0.5em;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 3px;
    font-size: 0.8em;
}

.custom-capacity-indicator small {
    display: block;
    font-weight: 500;
}

/* Mobile adjustments for capacity features */
@media (max-width: 768px) {
    .capacity-modal {
        width: 95%;
        padding: 1.5em;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .modal-actions button {
        width: 100%;
    }
}

/* ==========================================================================
   Grenreol (Cantilever Racking) Specific Styles
   ========================================================================== */

/* Base container for grenreol */
#reolbygger-grenreol-container {
    display: flex;
    flex-wrap: wrap;
    gap: 2em;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    line-height: 1.6;
}

/* Reset styles to prevent theme conflicts */
#reolbygger-grenreol-container * {
    box-sizing: border-box;
}

/* Grenreol canvas styling */
#grenreol-canvas {
    position: relative;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, #f8f9fa 0%, #e9ecef 100%);
}

/* Grenreol visual elements */
.grenreol-floor {
    position: absolute;
    bottom: 18px;
    left: 10px;
    width: calc(100% - 20px);
    height: 2px;
    background-color: #6c757d;
    z-index: 0;
}

.grenreol-upright {
    position: absolute;
    background: linear-gradient(to right, #2E5B8A 0%, #4A7BB7 50%, #2E5B8A 100%);
    border: 2px solid #1A3A5C;
    border-radius: 4px;
    box-shadow: 2px 0 4px rgba(0,0,0,0.2);
    z-index: 3;
}

.grenreol-upright::before {
    content: '';
    position: absolute;
    top: 0;
    left: 2px;
    right: 2px;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px,
        transparent 74px,
        #1A3A5C 74px,
        #1A3A5C 76px
    );
    border-radius: 2px;
}

.grenreol-arm-right,
.grenreol-arm-left {
    position: absolute;
    background: linear-gradient(to bottom, #FF8000 0%, #FF6600 50%, #CC4400 100%);
    border: 1px solid #AA3300;
    border-radius: 2px 0 0 2px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 2;
}

.grenreol-arm-left {
    border-radius: 0 2px 2px 0;
}

.grenreol-arm-right::after,
.grenreol-arm-left::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    background: linear-gradient(to top, transparent 0%, rgba(255,255,255,0.3) 100%);
    border-radius: 1px;
}

.grenreol-bracket-right,
.grenreol-bracket-left {
    position: absolute;
    background: linear-gradient(to bottom, #666 0%, #444 50%, #222 100%);
    border: 1px solid #000;
    border-radius: 1px;
    box-shadow: 1px 1px 2px rgba(0,0,0,0.3);
    z-index: 3;
}

.grenreol-bracing {
    position: absolute;
    background: linear-gradient(to bottom, #888 0%, #666 50%, #444 100%);
    border: 1px solid #333;
    border-radius: 1px;
    z-index: 1;
    opacity: 0.8;
}

/* Grenreol dimension labels */
#grenreol-dimension-width,
#grenreol-dimension-height,
#grenreol-dimension-depth {
    position: absolute;
    font-size: 11px;
    color: #495057;
    background: rgba(255,255,255,0.9);
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid #dee2e6;
    font-weight: 600;
    text-shadow: 0 1px 1px rgba(255,255,255,0.8);
}

#grenreol-dimension-width {
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
}

#grenreol-dimension-height {
    left: -55px;
    top: 50%;
    transform: translateY(-50%) rotate(-90deg);
}

#grenreol-dimension-depth {
    top: -25px;
    right: 10px;
}

/* Grenreol specific form styling */
#reolbygger-grenreol-container .reolbygger-field {
    margin-bottom: 1.5em;
}

#reolbygger-grenreol-container .reolbygger-info-box {
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    border: 1px solid #b39ddb;
    border-radius: 6px;
    padding: 1.2em;
    margin: 1.5em 0;
    font-size: 0.95em;
}

#reolbygger-grenreol-container .reolbygger-warning-box {
    background: linear-gradient(135deg, #fff3e0 0%, #ffebee 100%);
    border: 1px solid #ffb74d;
    border-radius: 6px;
    padding: 1.2em;
    margin: 1.5em 0;
    font-size: 0.95em;
}

#reolbygger-grenreol-container .reolbygger-warning-box strong {
    color: #d32f2f;
}

/* Grenreol capacity info */
#grenreol-capacity-info {
    background: linear-gradient(135deg, #f1f8e9 0%, #e8f5e8 100%);
    border: 1px solid #aed581;
    border-radius: 6px;
    padding: 1em;
    margin-top: 1em;
}

#grenreol-capacity-info p {
    margin: 0.5em 0;
    font-size: 0.95em;
}

/* System type information styling */
#grenreol-type-info {
    background: linear-gradient(135deg, #e1f5fe 0%, #f0f4c3 100%);
    border: 1px solid #81c784;
    border-radius: 6px;
    padding: 1.2em;
    margin: 1.5em 0;
}

#type-description {
    font-weight: 600;
    color: #2e7d32;
    margin-bottom: 0.5em;
}

#type-use-case {
    color: #558b2f;
    font-style: italic;
}

/* Responsive adjustments for grenreol */
@media (max-width: 768px) {
    #reolbygger-grenreol-container {
        flex-direction: column;
        gap: 1.5em;
    }
    
    #reolbygger-grenreol-container .reolbygger-canvas-container {
        height: 280px;
    }
    
    #grenreol-dimension-height {
        left: -45px;
    }
    
    #grenreol-dimension-depth {
        top: -20px;
        right: 5px;
        font-size: 10px;
    }
}