/* ============================================
   Fencing Calculator Styles
   ============================================ */

#fencing-calculator {
    background-color: var(--bg-light);
    padding: 20px 0;
    overflow-x: hidden;
}

#fencing-calculator > .row {
    margin-left: 0;
    margin-right: 0;
}

#fencing-calculator #content {
    background-color: var(--bg-white);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

#fencing-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;
}

.help-text {
    background: #e7f5ff;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 12px;
    color: #1971c2;
    font-size: 0.9rem;
}

.help-text .fa {
    margin-right: 6px;
}

/* Fence Stats Display */
.fence-stats {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.stat-box {
    background: linear-gradient(135deg, var(--primary-blue) 0%, #004494 100%);
    color: white;
    padding: 10px 18px;
    border-radius: 8px;
    text-align: center;
    flex: 1;
}

.stat-box .stat-label {
    display: block;
    font-size: 0.8rem;
    opacity: 0.9;
    margin-bottom: 3px;
}

.stat-box .stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}

/* 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-postcrete .product-image,
.no-caps .product-image {
    background: #f0f0f0;
}

.no-postcrete .product-image .fa,
.no-caps .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);
}

/* Fence Summary */
.fence-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);
}

#fence-preview {
    background: #87CEEB;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
}

#fence-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.panels {
    background: #DEB887;
}

.legend-color.posts {
    background: #654321;
}

/* 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;
    }
    
    .fence-stats {
        flex-direction: column;
    }
}

@media (max-width: 767px) {
    #fencing-calculator.container {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 10px !important;
        padding-right: 10px !important;
        overflow-x: hidden;
        box-sizing: border-box;
    }
    
    #fencing-calculator .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    #fencing-calculator [class*="col-"] {
        padding-left: 0 !important;
        padding-right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    #fencing-calculator #content {
        padding: 15px 10px;
        border-radius: 0;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }
    
    #fencing-calculator .calculator-intro,
    #fencing-calculator .calc-step,
    #fencing-calculator .calculator-wrapper {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }
    
    #fencing-calculator .breadcrumb {
        padding-left: 0;
        padding-right: 0;
    }
    
    #fencing-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;
    }
    
    .stat-box .stat-value {
        font-size: 1.5rem;
    }
    
    .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;
    }
}
