/* ============================================
   Decking Calculator Styles
   ============================================ */

#decking-calculator {
    background-color: var(--bg-light);
    padding: 20px 0;
    overflow-x: hidden;
}

#decking-calculator > .row {
    margin-left: 0;
    margin-right: 0;
}

#decking-calculator #content {
    background-color: var(--bg-white);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

#decking-calculator h1 {
    color: var(--primary-blue);
    margin-bottom: 15px;
    font-size: 1.75rem;
}

.calculator-intro {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid var(--primary-blue);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.calculator-intro p {
    margin: 0;
    color: #555;
    font-size: 1rem;
}

/* Step Sections */
.calc-step {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 15px;
    overflow: hidden;
}

.step-header {
    background: linear-gradient(135deg, var(--primary-blue) 0%, #004494 100%);
    color: white;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.step-number {
    background: rgba(255,255,255,0.2);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
}

.step-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.optional-label {
    font-weight: 400;
    opacity: 0.8;
    font-size: 0.85rem;
}

.step-content {
    padding: 15px;
}

/* Deck Area Display */
.deck-area-display {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 10px;
}

.area-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.area-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
}

.area-unit {
    font-size: 1rem;
    opacity: 0.9;
}

/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    max-height: 280px;
    overflow-y: auto;
    padding: 5px;
}

.product-grid-small {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    max-height: 240px;
}

.product-card {
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    border-color: var(--primary-blue);
    box-shadow: 0 4px 15px rgba(0,86,179,0.15);
    transform: translateY(-2px);
}

.product-card.selected {
    border-color: var(--primary-blue);
    background: linear-gradient(135deg, #f0f7ff 0%, #e6f0ff 100%);
    box-shadow: 0 4px 15px rgba(0,86,179,0.2);
}

.product-card.selected .product-select {
    opacity: 1;
    transform: scale(1);
}

.product-image {
    width: 100%;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    background: #f8f9fa;
    border-radius: 4px;
    overflow: hidden;
}

.product-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.product-image .fa {
    color: #ccc;
}

.no-fascia .product-image {
    background: #f0f0f0;
}

.no-fascia .product-image .fa {
    color: #999;
}

.product-info {
    flex: 1;
}

.product-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #333;
    margin: 0 0 5px 0;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-blue);
}

.product-price small {
    font-weight: 400;
    font-size: 0.7rem;
    color: #888;
}

.product-select {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    background: var(--primary-blue);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s ease;
}

.product-select .fa {
    font-size: 11px;
}

/* Calculate Button */
#calculate-btn {
    background: linear-gradient(135deg, var(--primary-blue) 0%, #004494 100%);
    border: none;
    padding: 12px 30px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.2s;
    margin-top: 5px;
}

#calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,86,179,0.35);
}

/* Results Section */
.results-step {
    border: 2px solid var(--primary-blue);
}

.results-header {
    background: linear-gradient(135deg, var(--primary-blue) 0%, #004494 100%);
}

.results-header .step-number {
    background: rgba(255,255,255,0.2);
}

/* Deck Summary */
.deck-summary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 12px 18px;
    border-radius: 8px;
    margin-bottom: 15px;
    color: white;
}

.summary-stats {
    display: flex;
    gap: 30px;
}

.stat {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}

.stat-label {
    font-size: 0.8rem;
    opacity: 0.8;
    margin-top: 3px;
}

/* Results List */
.results-list {
    margin-bottom: 15px;
}

.result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 8px;
}

.result-image {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    background: #fff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.result-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.result-details {
    flex: 1;
    min-width: 0;
}

.result-name {
    font-weight: 600;
    color: #333;
    display: block;
    margin-bottom: 3px;
    text-decoration: none;
    font-size: 0.9rem;
}

.result-name:hover {
    color: var(--primary-blue);
    text-decoration: underline;
}

.result-meta {
    font-size: 0.85rem;
    color: #666;
}

.result-subtotal {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-blue);
    white-space: nowrap;
}

/* Results Totals */
.results-totals {
    margin-bottom: 15px;
}

.results-subtotal-row,
.results-vat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    background: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
}

.results-subtotal-row:first-child {
    border-radius: 8px 8px 0 0;
}

.results-vat-row .total-value,
.results-subtotal-row .total-value {
    font-size: 1.1rem;
}

.results-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: #333;
    color: white;
    border-radius: 0 0 8px 8px;
}

.total-label {
    font-size: 1rem;
    font-weight: 500;
}

.total-value {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Results Actions */
.results-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
}

#add-all-cart {
    flex: 1;
    background: linear-gradient(135deg, var(--primary-blue) 0%, #004494 100%);
    border: none;
    padding: 12px;
    font-weight: 600;
    font-size: 1rem;
    border-radius: 8px;
}

#add-all-cart:hover {
    box-shadow: 0 6px 20px rgba(0,86,179,0.35);
}

#print-list {
    padding: 12px 24px;
    font-weight: 600;
    border-radius: 8px;
}

/* Results Note */
.results-note {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.85rem;
    color: #856404;
}

.results-note i {
    color: #ffc107;
    margin-right: 5px;
}

/* Preview Panel */
.preview-panel {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
}

.preview-panel h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 0.95rem;
}

.preview-panel h4 .fa {
    margin-right: 8px;
    color: var(--primary-blue);
}

#deck-preview {
    background: #fff;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
}

#deck-canvas {
    max-width: 100%;
    height: auto;
}

.preview-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #666;
}

.legend-color {
    width: 18px;
    height: 10px;
    border-radius: 3px;
}

.legend-color.boards {
    background: #D2691E;
}

.legend-color.joists {
    background: #8B4513;
}

/* Form Styling */
.step-content .form-group label {
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.step-content .form-control {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px 15px;
    font-size: 15px;
    transition: border-color 0.2s;
}

.step-content .form-control:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(0,86,179,0.1);
}

.step-content .input-lg {
    font-size: 1.2rem;
    padding: 15px;
}

/* Print Styles */
@media print {
    header, footer, .step-header:not(.results-header), 
    .calc-step:not(.results-step), #menu, #cart,
    .results-actions, .preview-panel {
        display: none !important;
    }
    
    .results-step {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* Responsive */
@media (max-width: 991px) {
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
    
    .summary-stats {
        flex-wrap: wrap;
        gap: 20px;
    }
}

@media (max-width: 767px) {
    #decking-calculator.container {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 10px !important;
        padding-right: 10px !important;
        overflow-x: hidden;
        box-sizing: border-box;
    }
    
    #decking-calculator .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    #decking-calculator [class*="col-"] {
        padding-left: 0 !important;
        padding-right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    #decking-calculator #content {
        padding: 15px 10px;
        border-radius: 0;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }
    
    #decking-calculator .calculator-intro,
    #decking-calculator .calc-step,
    #decking-calculator .calculator-wrapper {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }
    
    #decking-calculator .breadcrumb {
        padding-left: 0;
        padding-right: 0;
    }
    
    #decking-calculator h1 {
        font-size: 1.5rem;
    }
    
    .calculator-intro {
        padding: 10px 12px;
        margin-bottom: 15px;
    }
    
    .calculator-intro p {
        font-size: 0.9rem;
    }
    
    .step-header {
        padding: 10px 12px;
    }
    
    .step-content {
        padding: 12px 10px;
    }
    
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .product-card {
        padding: 12px;
    }
    
    .product-image {
        height: 60px;
    }
    
    .product-name {
        font-size: 0.8rem;
    }
    
    .deck-area-display {
        padding: 15px 20px;
    }
    
    .area-value {
        font-size: 2rem;
    }
    
    .results-actions {
        flex-direction: column;
    }
    
    .result-item {
        flex-wrap: wrap;
    }
    
    .result-subtotal {
        width: 100%;
        text-align: right;
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid #e0e0e0;
    }
}

/* ── Fascia sides selector ─────────────────────────────── */
.fascia-sides-section {
    margin-bottom: 20px;
    padding: 16px 20px;
    background: #f0f4f8;
    border-radius: 8px;
    border: 1px solid #dde3ea;
}
.fascia-sides-section h5 {
    margin: 0 0 4px;
    font-weight: 700;
    font-size: 15px;
}
.fascia-sides-hint {
    color: #666;
    font-size: 13px;
    margin-bottom: 16px;
}
.deck-sides-selector {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    margin-bottom: 12px;
}
.sides-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}
.side-spacer {
    width: 110px; /* matches .deck-shape-box width + margins */
}
.side-toggle {
    padding: 7px 14px;
    border: 2px solid #1a3d7c;
    border-radius: 6px;
    background: #1a3d7c;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    min-width: 100px;
    text-align: center;
    line-height: 1.4;
}
.side-toggle.side-v {
    min-width: 72px;
    padding: 10px 8px;
}
.side-toggle.side-off {
    background: #e9ecef;
    border-color: #ced4da;
    color: #999;
    text-decoration: line-through;
}
.side-toggle .side-dim {
    font-weight: 400;
    font-size: 12px;
    display: inline-block;
}
.deck-shape-box {
    width: 110px;
    height: 70px;
    border: 3px solid #556;
    background: #dbc98a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #4a4520;
    font-size: 13px;
    margin: 0 4px;
    border-radius: 2px;
    letter-spacing: 1px;
}
.fascia-total-length {
    margin: 4px 0 0;
    font-size: 14px;
}

/* ── Y/N optional step toggles ── */
.yn-section { margin-bottom: 16px; }
.yn-section p { margin-bottom: 8px; color: #555; font-size: 14px; }
.yn-buttons { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.yn-btn { padding: 8px 22px; border: 2px solid #ced4da; background: #fff; color: #555; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 600; transition: all 0.15s; }
.yn-btn:hover { border-color: #aaa; background: #f8f8f8; }
.yn-btn.active[data-val="yes"] { border-color: #1a3d7c; background: #1a3d7c; color: #fff; }
.yn-btn.active[data-val="no"] { border-color: #6c757d; background: #6c757d; color: #fff; }
.optional-step-section { margin-top: 12px; }
.optional-label { font-size: 13px; font-weight: 400; color: #888; }

/* ── Deck height guide ── */
.height-guide-alert { padding: 10px 14px; font-size: 13px; margin: 0; border-radius: 6px; line-height: 1.5; }

/* ── Step count info box ── */
.step-count-info { padding: 12px 16px; background: #e8f4f8; border-radius: 6px; font-size: 14px; margin-bottom: 16px; border: 1px solid #b8dcea; color: #2c6f8a; }

/* ── Y/N optional step toggles ── */
.yn-section { margin-bottom: 16px; }
.yn-section p { margin-bottom: 8px; color: #555; font-size: 14px; }
.yn-buttons { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.yn-btn { padding: 8px 22px; border: 2px solid #ced4da; background: #fff; color: #555; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 600; transition: all 0.15s; }
.yn-btn:hover { border-color: #aaa; background: #f8f8f8; }
.yn-btn.active[data-val="yes"] { border-color: #1a3d7c; background: #1a3d7c; color: #fff; }
.yn-btn.active[data-val="no"] { border-color: #6c757d; background: #6c757d; color: #fff; }
.optional-step-section { margin-top: 12px; }
.optional-label { font-size: 13px; font-weight: 400; color: #888; }

/* ── Deck height guide ── */
.height-guide-alert { padding: 10px 14px; font-size: 13px; margin: 0; border-radius: 6px; line-height: 1.5; }

/* ── Step count info box ── */
.step-count-info { padding: 12px 16px; background: #e8f4f8; border-radius: 6px; font-size: 14px; margin-bottom: 16px; border: 1px solid #b8dcea; color: #2c6f8a; }

/* ── Step width selector ── */
.steps-board-note { font-size: 13px; color: #555; margin-bottom: 14px; }
.step-width-selector { margin-bottom: 4px; }
.step-width-selector .control-label { font-weight: 600; font-size: 14px; margin-bottom: 8px; display: block; }
.step-width-options { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.step-width-btn { padding: 7px 18px; border: 2px solid #ced4da; background: #fff; color: #555; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; transition: all 0.15s; }
.step-width-btn small { font-weight: 400; color: #999; }
.step-width-btn:hover { border-color: #aaa; background: #f8f8f8; }
.step-width-btn.active { border-color: #1a3d7c; background: #1a3d7c; color: #fff; }
.step-width-btn.active small { color: #aac4ff; }
.step-board-estimate { font-size: 13px; color: #444; background: #f0f4ff; border: 1px solid #c5d3f0; border-radius: 6px; padding: 8px 12px; margin-top: 8px; }

/* ── Step width selector ── */
.steps-board-note { font-size: 13px; color: #555; margin-bottom: 14px; }
.step-width-selector { margin-bottom: 4px; }
.step-width-selector .control-label { font-weight: 600; font-size: 14px; margin-bottom: 8px; display: block; }
.step-width-options { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.step-width-btn { padding: 7px 18px; border: 2px solid #ced4da; background: #fff; color: #555; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; transition: all 0.15s; }
.step-width-btn small { font-weight: 400; color: #999; }
.step-width-btn:hover { border-color: #aaa; background: #f8f8f8; }
.step-width-btn.active { border-color: #1a3d7c; background: #1a3d7c; color: #fff; }
.step-width-btn.active small { color: #aac4ff; }
.step-board-estimate { font-size: 13px; color: #444; background: #f0f4ff; border: 1px solid #c5d3f0; border-radius: 6px; padding: 8px 12px; margin-top: 8px; }
