/* ==========================================================================
   Calculator Detail Page Styles
   ========================================================================== */

/* Calculator Header - Ultra Compact */
.calc-detail-header {
    /* Fix: Increased top padding to prevent navbar overlap with breadcrumb */
    padding: calc(80px + 1.5rem) 0 0.75rem 0;
    background: #FAFBFC;
    border-bottom: 1px solid #E5E7EB;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
}

.breadcrumb a {
    color: #6B7280;
    text-decoration: none;
    transition: var(--transition);
}

.breadcrumb a:hover {
    color: var(--primary);
}

.breadcrumb .separator {
    color: #9CA3AF;
}

.breadcrumb span:last-child {
    color: var(--dark);
    font-weight: 600;
}

.calc-title-section {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.calc-icon-compact {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    flex-shrink: 0;
}

.calc-title-content {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.calc-title-section h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--dark);
    margin: 0;
}

.calc-subtitle {
    font-size: 0.8125rem;
    color: #6B7280;
    margin: 0;
}

/* Meta tags removed - no longer needed */

/* Calculator Layout - Compact */
.calc-content {
    /* Fix: Add extra spacing at top to prevent ad label overlap with breadcrumb */
    padding: calc(var(--spacing-lg) + 1rem) 0 var(--spacing-lg) 0;
    background:
        linear-gradient(rgba(250, 251, 252, 0.97), rgba(250, 251, 252, 0.98)),
        url('../images/piping/30.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

/* Disable parallax on mobile for performance */
@media (max-width: 768px) {
    .calc-content {
        background-attachment: scroll;
    }
}

.calc-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--spacing-lg);
    align-items: start;
}

/* Responsive Layout Improvements */
@media (max-width: 1024px) {
    .calc-layout {
        grid-template-columns: 1fr;
        display: flex;
        flex-direction: column;
    }

    .calc-form-section {
        width: 100%;
        order: 1;
    }

    .calc-sidebar {
        width: 100%;
        order: 2;
    }

    .calc-results-section {
        position: static;
    }
    
    /* Ensure tables in sidebar are scrollable/readable */
    .calc-sidebar .table-container {
        overflow-x: auto;
    }
}

/* Table Styles */
.velocity-table, .maop-table, .combined-results-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.9rem;
}

.velocity-table th, .velocity-table td,
.maop-table th, .maop-table td,
.combined-results-table th, .combined-results-table td {
    padding: 0.75rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.velocity-table th, .maop-table th, .combined-results-table th {
    background: #f5f5f5;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
    font-size: 0.8125rem;
    white-space: nowrap;
}

.velocity-table tbody tr:hover,
.maop-table tbody tr:hover,
.combined-results-table tbody tr:hover {
    background: #f9f9f9;
}

.combined-results-table td:nth-child(3),
.combined-results-table td:nth-child(5),
.combined-results-table td:nth-child(7) {
    text-align: right;
}

.table-container {
    max-height: 600px;
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.clickable-row {
    cursor: pointer;
}

.clickable-row.selected {
    background: #e3f2fd !important;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-safe { background: #d4edda; color: #155724; }
.status-caution { background: #fff3cd; color: #856404; }
.status-erosional { background: #f8d7da; color: #721c24; }
.status-critical { background: #721c24; color: white; }
.status-pass { background: #d4edda; color: #155724; }
.status-fail { background: #f8d7da; color: #721c24; }
.status-optimal { background: #cfe2ff; color: #084298; font-weight: 600; }

.recommended-badge {
    background: #0d6efd;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.warning-icon {
    color: #dc3545;
    margin-left: 0.25rem;
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #e0e0e0;
}

.tab-button {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-weight: 500;
    color: #666;
    transition: all 0.2s;
}

.tab-button.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-button:hover {
    color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Summary Grid */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.summary-item {
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid var(--primary);
}

.summary-label {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.summary-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: #333;
}

.calc-card {
    background: var(--white);
    border: 1px solid #E5E7EB;
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.calc-card h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: var(--spacing-sm);
    padding-bottom: var(--spacing-xs);
    border-bottom: 2px solid var(--primary);
}

.calc-card h3 {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: var(--spacing-xs);
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: var(--dark-600);
}

/* Info Banner - Calculator Description */
.info-banner {
    padding: 1rem;
    background: #e3f2fd;
    border-left: 4px solid #2196F3;
    border-radius: 4px;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.info-banner strong {
    color: #1976D2;
    font-weight: 600;
}

/* Form Sections - Compact */
.form-section {
    margin-bottom: var(--spacing-sm);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid #F3F4F6;
}

.form-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.form-group {
    margin-bottom: var(--spacing-sm);
}

.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 0.25rem;
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #D1D5DB;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-family: var(--font-family);
    transition: var(--transition);
    background: var(--white);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.form-control:disabled {
    background: var(--light);
    cursor: not-allowed;
}

select.form-control {
    cursor: pointer;
}

.form-help {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--dark-600);
    font-style: italic;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-sm);
}

/* Card Grid Layout for Input Sections */
.input-cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

/* Card Flex Layout - Side by Side (2 columns) */
.input-cards-flex {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.input-card {
    background: var(--white);
    border: 1px solid #E5E7EB;
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.input-card h3 {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: var(--spacing-sm);
    padding-bottom: var(--spacing-xs);
    border-bottom: 2px solid var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Input with Unit */
.input-with-unit {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-unit input {
    flex: 1;
    min-width: 0; /* Prevent input from overflowing */
}

/* Static unit label */
.input-with-unit .unit {
    position: absolute;
    right: var(--spacing-md);
    color: var(--dark-600);
    font-weight: 600;
    font-size: 0.875rem;
    pointer-events: none;
    white-space: nowrap;
}

/* When there's a static unit, add padding to input */
.input-with-unit:has(.unit:not(.unit-select)) input {
    padding-right: 70px;
}

/* Dropdown unit selector */
.input-with-unit .unit-select {
    position: absolute;
    right: 0.5rem;
    width: auto;
    min-width: 90px;
    max-width: 105px;
    padding: 0.375rem 0.5rem;
    border: 1px solid #D1D5DB;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--dark);
    background: var(--white);
    cursor: pointer;
    transition: var(--transition);
}

.input-with-unit .unit-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.1);
}

.input-with-unit .unit-select:hover {
    border-color: var(--primary);
}

/* When there's a dropdown unit, add padding to input (reduced to show more digits) */
.input-with-unit:has(.unit-select) input {
    padding-right: 110px;
}

/* Helper text below inputs */
.form-group small {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.75rem;
    color: var(--dark-600);
    font-style: italic;
    line-height: 1.4;
}

/* Checkbox Labels */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--dark);
    font-weight: 500;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    border-radius: 4px;
    border: 2px solid #D1D5DB;
    transition: var(--transition);
}

.checkbox-label input[type="checkbox"]:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.checkbox-label input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.checkbox-label:hover input[type="checkbox"] {
    border-color: var(--primary);
}

/* Button Group */
.button-group {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}

/* Buttons */
.btn-calculate {
    width: 100%;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    border: none;
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-md);
}

.btn-calculate:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-calculate:active {
    transform: translateY(0);
}

.btn-reset {
    width: 100%;
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--white);
    color: var(--dark-700);
    border: 2px solid var(--light);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
}

.btn-reset:hover {
    border-color: var(--dark-700);
    background: var(--light);
}

/* Results Card */
.results-card {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    border: none;
    box-shadow: var(--shadow-xl);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    position: sticky;
    top: calc(80px + var(--spacing-md));
}

.results-card h2,
.results-card h3 {
    color: var(--white);
    border-bottom-color: rgba(255, 255, 255, 0.2);
}

.results-card h4 {
    color: var(--white);
    font-size: 0.875rem;
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.results-header h3 {
    margin: 0;
    padding: 0;
    border: none;
    font-size: 1.125rem;
}

.results-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    background: rgba(255, 255, 255, 0.15);
    color: var(--white);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

.result-primary {
    text-align: center;
    padding: var(--spacing-xs);
    margin-bottom: var(--spacing-sm);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
}

.result-label {
    font-size: 0.75rem;
    opacity: 0.85;
    margin-bottom: 0.15rem;
}

.result-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0;
}

.result-unit {
    font-size: 0.9rem;
    opacity: 0.8;
}

.result-unit:empty {
    display: none;
}

.result-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-sm);
}

.result-item {
    background: rgba(255, 255, 255, 0.1);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.result-item-label {
    font-size: 0.75rem;
    opacity: 0.85;
}

.result-item-value {
    font-size: 1.125rem;
    font-weight: 700;
}

/* Results Detailed (for separator-sizing page) */
.results-detailed {
    margin-bottom: var(--spacing-md);
}

.results-detailed .result-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    margin-bottom: 0.375rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.results-detailed .result-item .label {
    font-size: 0.8125rem;
    opacity: 0.9;
}

.results-detailed .result-item .value {
    font-size: 0.9375rem;
    font-weight: 700;
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
}

/* Results Section (for internals, nozzles, etc.) */
.results-section {
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

/* Warning Messages */
.warning-messages {
    background: rgba(255, 235, 59, 0.2);
    border: 1px solid rgba(255, 235, 59, 0.4);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm);
    color: #FFF9C4;
    font-size: 0.8125rem;
    line-height: 1.5;
}

/* Info/Summary Boxes - High Contrast */
.info-box {
    background: #e3f2fd;
    border: 1px solid #90caf9;
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    color: #1a1a1a;
    font-size: 0.875rem;
    line-height: 1.6;
}

.info-box pre {
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-x: auto;
    color: inherit;
}

/* Warning/Alert Boxes - High Contrast Yellow */
.warning-box {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    color: #1a1a1a;
    font-size: 0.875rem;
    line-height: 1.6;
}

.result-actions {
    display: flex;
    gap: var(--spacing-xs);
}

.result-actions .btn-secondary {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: var(--white);
    color: var(--primary);
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.result-actions .btn-secondary svg {
    width: 14px;
    height: 14px;
}

.result-actions .btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Formula Card */
.formula-card {
    background: var(--white);
    border: 1px solid #E5E7EB;
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.formula-card h3 {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 2px solid var(--primary);
}

.formula-content {
    font-size: 0.875rem;
    line-height: 1.6;
}

.formula-content p {
    margin-bottom: var(--spacing-sm);
    color: var(--dark-700);
}

.formula-content p strong {
    color: var(--dark);
    font-weight: 600;
}

/* Formula Box - Compact */
.formula-box {
    background: #f8f9fa;
    border: 1px solid #E5E7EB;
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
    font-size: 0.9375rem;
    color: var(--primary);
    text-align: center;
    font-weight: 600;
}

.formula-note {
    font-size: 0.8125rem;
    color: var(--dark-600);
    font-style: italic;
    line-height: 1.5;
    margin-top: var(--spacing-sm);
    padding: var(--spacing-sm);
    background: #FFF9E6;
    border-left: 3px solid #FFD54F;
    border-radius: var(--radius-sm);
}

.formula-main {
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    padding: var(--spacing-sm);
    background: var(--white);
    border-radius: var(--radius-md);
    margin-bottom: 0;
    color: var(--primary);
}

.formula-legend {
    display: none; /* Hide legend - saves space, engineers know variables */
}

.legend-item {
    font-size: 0.75rem;
    color: var(--dark-700);
    line-height: 1.4;
}

.legend-item strong {
    color: var(--primary);
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

/* Reference List - Compact (Hidden by default) */
.reference-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.reference-list li {
    padding: var(--spacing-xs) var(--spacing-sm);
    margin-bottom: 0.25rem;
    background: var(--light);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary);
    font-size: 0.8125rem;
}

.reference-list li strong {
    color: var(--primary);
    display: inline;
    margin-right: 0.25rem;
}

/* Hide standards card - redundant with header tags */
.calc-card:has(.reference-list) {
    display: none;
}

/* Notes Card - Compact */
.notes-card {
    background: #FFF9E6;
    border-color: #FFE082;
}

.notes-card h3 {
    font-size: 0.75rem;
    margin-bottom: var(--spacing-xs);
}

.notes-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.notes-list li {
    padding-left: 1.25rem;
    margin-bottom: 0.375rem;
    position: relative;
    line-height: 1.4;
    color: var(--dark-700);
    font-size: 0.75rem;
}

.notes-list li::before {
    content: '⚠️';
    position: absolute;
    left: 0;
    font-size: 0.75rem;
}

/* Show only first 2 notes by default */
.notes-list li:nth-child(n+3) {
    display: none;
}

/* Related Calculators - Hidden (can enable later if needed) */
.related-calculators {
    display: none; /* Hide to reduce page length */
    padding: var(--spacing-xl) 0;
    background: var(--light);
}

.related-calculators h2 {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: var(--spacing-lg);
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-lg);
}

.related-card {
    background: var(--white);
    border: 2px solid transparent;
    border-radius: var(--radius-xl);
    padding: var(--spacing-lg);
    text-decoration: none;
    transition: var(--transition);
    display: block;
}

.related-card:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.related-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin-bottom: var(--spacing-md);
}

.related-card h4 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: var(--spacing-xs);
}

.related-card p {
    color: var(--dark-600);
    font-size: 0.9375rem;
    line-height: 1.6;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .calc-layout {
        grid-template-columns: 1fr;
    }

    .calc-form-section {
        order: 1;
    }

    .calc-results-section {
        order: 2;
    }

    .results-card {
        position: static; /* Remove sticky on tablets */
    }

    /* Stack input cards on tablets */
    .input-cards-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* Keep flex cards side-by-side on tablets */
    .input-cards-flex {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .calc-title-section {
        flex-direction: column;
    }

    .calc-icon-large {
        width: 64px;
        height: 64px;
        font-size: 2rem;
    }

    .calc-title-section h1 {
        font-size: 2rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .input-cards-grid {
        grid-template-columns: 1fr;
    }

    /* Stack flex cards on mobile */
    .input-cards-flex {
        grid-template-columns: 1fr;
    }

    .calc-layout {
        grid-template-columns: 1fr;
    }

    .result-details {
        grid-template-columns: 1fr;
    }

    .result-value {
        font-size: 1.75rem;
    }

    .related-grid {
        grid-template-columns: 1fr;
    }

    /* Adjust unit select width on mobile */
    .input-with-unit .unit-select {
        min-width: 85px;
        max-width: 100px;
        font-size: 0.75rem;
    }

    /* Adjust input padding on mobile */
    .input-with-unit:has(.unit-select) input {
        padding-right: 105px;
    }
}

@media (max-width: 480px) {
    .calc-detail-header {
        /* Fix: Increased top padding to prevent navbar overlap with breadcrumb */
        padding: calc(80px + 1.5rem) 0 var(--spacing-md) 0;
    }

    .calc-title-section h1 {
        font-size: 1.75rem;
    }

    .calc-subtitle {
        font-size: 1rem;
    }

    .formula-main {
        font-size: 1.125rem;
        padding: var(--spacing-md);
    }

    .result-actions {
        flex-direction: column;
    }

    /* Stack button group vertically on very small screens */
    .button-group {
        grid-template-columns: 1fr;
    }

    /* Smaller unit select on very small screens */
    .input-with-unit .unit-select {
        min-width: 75px;
        max-width: 90px;
        font-size: 0.7rem;
        padding: 0.25rem 0.375rem;
    }

    .input-with-unit:has(.unit-select) input {
        padding-right: 95px;
    }
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.results-card {
    animation: fadeIn 0.5s ease-out;
}

.results-card pre {
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Error states */
.form-control.error {
    border-color: var(--danger);
}

.form-control.error:focus {
    box-shadow: 0 0 0 3px rgba(244, 67, 54, 0.1);
}

.error-message {
    color: var(--danger);
    font-size: 0.8125rem;
    margin-top: var(--spacing-xs);
    display: none;
}

.error-message.show {
    display: block;
}

/* Loading state */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    border: 3px solid var(--primary-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Ad Container - Mimics the Info Cards */
.calc-card.ad-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 280px;
    background: #f8f9fa;
    padding: 1rem;
    margin-bottom: 1.5rem;
    overflow: hidden;
    box-sizing: border-box;
    width: 100%;
}

.ad-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #adb5bd;
    margin-bottom: 0.5rem;
}

/* Form Control Styling - Normalize inputs and selects */
.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #D1D5DB;
    border-radius: 6px;
    font-size: 0.9375rem;
    font-family: var(--font-family);
    transition: all 0.2s ease;
    background: var(--white);
    color: var(--dark);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.form-control:disabled {
    background: #F3F4F6;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Ensure selects have same appearance as inputs */
select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M10.293 3.293L6 7.586 1.707 3.293A1 1 0 00.293 4.707l5 5a1 1 0 001.414 0l5-5a1 1 0 10-1.414-1.414z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

/* ==========================================================================
   Warning Boxes for Blue Sidebar Results Cards
   High contrast colors optimized for blue gradient backgrounds
   ========================================================================== */

/* Base warning box styles */
.sidebar-warning {
    padding: 0.75rem;
    border-radius: 6px;
    margin: 0.75rem 0;
    font-size: 0.85rem;
    line-height: 1.5;
    border-width: 2px;
    border-style: solid;
    font-weight: 500;
}

/* DANGER WARNING - Red/Critical (e.g., unsafe conditions, exceeded limits) */
.sidebar-warning-danger {
    background: #fef2f2;
    border-color: #dc2626;
    color: #7f1d1d;
}

.sidebar-warning-danger strong {
    color: #991b1b;
    font-weight: 700;
}

.sidebar-warning-danger::before {
    content: "⚠️ ";
    font-size: 1rem;
}

/* CAUTION WARNING - Orange/Amber (e.g., approaching limits, needs attention) */
.sidebar-warning-caution {
    background: #fffbeb;
    border-color: #f59e0b;
    color: #78350f;
}

.sidebar-warning-caution strong {
    color: #92400e;
    font-weight: 700;
}

.sidebar-warning-caution::before {
    content: "⚠️ ";
    font-size: 1rem;
}

/* SUCCESS/GOOD - Green (e.g., within limits, safe conditions) */
.sidebar-warning-success {
    background: #f0fdf4;
    border-color: #16a34a;
    color: #14532d;
}

.sidebar-warning-success strong {
    color: #166534;
    font-weight: 700;
}

.sidebar-warning-success::before {
    content: "✓ ";
    font-size: 1rem;
    font-weight: 700;
}

/* EMPHASIS/INFO - Blue/Cyan (e.g., important notes, recommendations) */
.sidebar-warning-info {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #1e3a8a;
}

.sidebar-warning-info strong {
    color: #1e40af;
    font-weight: 700;
}

.sidebar-warning-info::before {
    content: "ℹ️ ";
    font-size: 1rem;
}

/* Warning list styling within sidebar */
.sidebar-warnings-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0.75rem 0;
}

.sidebar-warnings-list .sidebar-warning {
    margin: 0;
}
