/* Calculators CSS */
.calculator-container {
    background-color: var(--card-background);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    margin-bottom: var(--spacing-xl);
}

.calc-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
}

@media (min-width: 1024px) {
    .calc-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.calc-header {
    margin-bottom: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: var(--spacing-sm);
}

.calc-input-section {
    background-color: #f8fafc;
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.calc-results-section {
    background-color: #f0fdf4; /* Light green tint for success feel */
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    border: 1px solid #bbf7d0;
}

.result-row {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-sm) 0;
    border-bottom: 1px dashed #cbd5e1;
}
.result-row:last-child {
    border-bottom: none;
}

.result-label {
    font-weight: 500;
    color: var(--text-secondary);
}

.result-value {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.result-total {
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 2px solid var(--success-color);
    font-size: 1.5rem;
    color: var(--success-color);
    text-align: right;
    font-weight: 700;
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    margin-top: var(--spacing-lg);
}

/* Unit Toggle Switch */
.unit-toggle-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f1f5f9;
    padding: 0.5rem;
    border-radius: 999px;
    margin-bottom: var(--spacing-lg);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.unit-option {
    padding: 0.5rem 1.5rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.unit-option.active {
    background-color: var(--card-background);
    color: var(--primary-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Postmortem Stages UI */
.stage-card {
    background-color: var(--card-background);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    border-left: 4px solid var(--primary-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.stage-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stage-title svg {
    width: 16px;
    height: 16px;
    color: var(--primary-color);
}

.material-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
}

.material-item {
    background-color: #f8fafc;
    padding: var(--spacing-sm);
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.material-item .m-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    display: block;
}

.material-item .m-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.material-item .m-cost {
    font-size: 0.85rem;
    color: var(--success-color);
    margin-top: 0.25rem;
    display: block;
}

/* Quality Grid */
.quality-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}
@media (min-width: 768px) {
    .quality-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
.quality-card {
    position: relative;
    cursor: pointer;
}
.quality-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.quality-content {
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    background: white;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    height: 100%;
}
.quality-content svg {
    color: var(--text-secondary);
}
.q-title {
    font-weight: 600;
    color: var(--text-color);
}
.q-price {
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.quality-card input[type="radio"]:checked + .quality-content {
    border-color: #8b5cf6;
    background-color: #faf5ff;
    box-shadow: 0 4px 6px -1px rgba(139, 92, 246, 0.1);
}
.quality-card input[type="radio"]:checked + .quality-content svg {
    color: #8b5cf6;
}

/* Advanced Options */
.advanced-options-wrapper {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
}
.advanced-grid {
    display: none;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 1rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}
.advanced-grid.show {
    display: grid;
}
@media (min-width: 768px) {
    .advanced-grid.show {
        grid-template-columns: repeat(2, 1fr);
    }
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.95rem;
}

/* BOQ Table */
.table-responsive {
    overflow-x: auto;
}
.boq-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}
.boq-table th, .boq-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}
.boq-table th {
    background-color: rgba(0,0,0,0.02);
    font-weight: 600;
    color: var(--text-secondary);
}
.boq-table tr:last-child td {
    border-bottom: none;
}
.boq-cat {
    font-weight: 600;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.boq-qty {
    color: var(--text-secondary);
    font-size: 0.9rem;
}
.boq-cost {
    text-align: right;
    font-weight: 600;
    color: var(--text-color);
}

@media print {
    body * {
        visibility: hidden;
    }
    #construction-results, #construction-results * {
        visibility: visible;
    }
    #construction-results {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }
    .print-btn { display: none !important; }
}

/* Vibrant Premium Overrides */
.calculator-container {
    background: linear-gradient(145deg, #ffffff, #f3f4f6);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.calc-input-section {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.3);
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
    border: none;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

/* Expert Tips Section */
.calc-tips-section {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.tips-card {
    background: linear-gradient(180deg, #1e1b4b, #312e81);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    color: white;
    height: 100%;
    box-shadow: 0 10px 25px -5px rgba(49, 46, 129, 0.5);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.tips-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    color: #a5b4fc;
}

.tips-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: white;
}

.tip-item {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.tip-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: #4f46e5;
    color: white;
    border-radius: 50%;
    font-weight: bold;
    flex-shrink: 0;
    box-shadow: 0 0 10px rgba(79, 70, 229, 0.5);
}

.tip-content strong {
    display: block;
    font-size: 1rem;
    color: #e0e7ff;
    margin-bottom: 0.25rem;
}

.tip-content p {
    font-size: 0.85rem;
    color: #c7d2fe;
    margin: 0;
    line-height: 1.4;
}

.tips-footer {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
    color: #a5b4fc;
    text-align: center;
}

/* PDF Export Overrides */
.pdf-export-active {
    background: #ffffff !important;
    padding: 30px !important;
    border: none !important;
    box-shadow: none !important;
    width: 800px !important;
    max-width: none !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    margin: 0 !important;
    transform: none !important;
    z-index: 99999 !important;
}

.pdf-export-active .chart-container {
    width: 500px !important;
    margin: 0 auto !important;
}

/* PRO MOBILE UI OVERHAULS & OVERFLOW FIXES */
@media (max-width: 767px) {
    /* Smooth base typography for mobile */
    body {
        font-size: 15px;
    }
    
    /* Fix the BOQ Table Width and Layout */
    .table-responsive {
        width: 100%;
        max-width: 100vw;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
        box-shadow: inset 0 0 0 1px var(--border-color);
        margin-top: 1rem;
    }
    .boq-table th, .boq-table td {
        padding: 0.5rem;
        font-size: 0.85rem;
        white-space: nowrap; /* Prevent words from wrapping weirdly, table will scroll horizontally instead */
    }
    
    /* Lock Result Sections tightly */
    .calc-results-section {
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    /* Ensure massive numbers don't push the layout */
    .result-total {
        font-size: 1.8rem !important;
        word-break: break-word;
        overflow-wrap: break-word;
        line-height: 1.2;
    }
    
    /* Better styling for form inputs on mobile */
    .form-group label {
        font-size: 0.9rem;
    }
    .form-group input, .form-group select {
        padding: 0.8rem;
        font-size: 1rem;
    }
    
    /* Stage cards inside results */
    .stage-card {
        padding: 1rem;
        width: 100%;
        box-sizing: border-box;
    }
    .result-value {
        font-size: 1rem;
        text-align: right;
    }
    
    /* Restrict general overflow horizontally */
    html, body {
        max-width: 100vw;
        overflow-x: hidden;
    }
}


/* Symmetrical Styling */
.calc-results-section {
    background: rgba(255, 255, 255, 0.7) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    border: 1px solid rgba(255, 255, 255, 0.5) !important;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.3) !important;
    border-radius: var(--border-radius) !important;
    padding: var(--spacing-md) !important;
}

