/* ===================================
   Modern HVAC Calculator Styles (OPTIMIZED VERSION)
   Design inspired by professional engineering tools
   Includes loading state animations
   =================================== */

/* Import Poppins font from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* CSS Variables for easy theme customization */
:root {
    --primary-color: #008871;      /* Teal/turquoise from branding */
    --primary-hover: #006d5a;
    --secondary-color: #F5F5F5;
    --accent-color: #2C3E50;
    --text-dark: #2C3E50;
    --text-medium: #555;
    --text-light: #777;
    --border-color: #E0E0E0;
    --background-light: #FAFAFA;
    --white: #FFFFFF;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* ===================================
   General Calculator Container
   =================================== */
.wm-calculator {
    position: relative;
    max-width: 1200px;
    margin: 40px auto;
    padding: 0;
    background: transparent;
    border: none;
    font-family: 'Poppins', sans-serif;
    color: var(--text-dark);
}

/* ===================================
   Loading State
   =================================== */
.wm-calculator.loading {
    pointer-events: none;
}

.wm-calculator.loading::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    z-index: 9998;
    backdrop-filter: blur(2px);
}

.wm-calculator.loading::after {
    content: '';
    position: fixed;
    top: 50%;
    left: 50%;
    width: 60px;
    height: 60px;
    margin: -30px 0 0 -30px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    z-index: 9999;
    animation: spinner 0.8s linear infinite;
}

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

/* Loading text */
.wm-calculator.loading .calculator-header::after {
    content: 'Loading...';
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, 50px);
    z-index: 10000;
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-color);
    white-space: nowrap;
}

/* ===================================
   Calculator Header Section
   =================================== */
.calculator-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #006d5a 100%);
    border-radius: 6px;
    color: white;
    box-shadow: var(--shadow-md);
}

.calculator-header h2 {
    margin: 0 0 10px 0;
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.calculator-header p {
    margin: 0;
    font-size: 15px;
    opacity: 0.95;
}

/* ===================================
   Main Form Container
   =================================== */
#calculator-form {
    display: grid;
    gap: 0;
    margin-bottom: 40px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

/* ===================================
   Form Section Groups
   =================================== */
.form-section {
    padding: 30px;
    border-bottom: 1px solid var(--border-color);
}

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

.form-section-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary-color);
}

.form-section-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
}

.form-section-icon {
    width: 24px;
    height: 24px;
    margin-right: 12px;
    color: var(--primary-color);
}

/* ===================================
   Form Fields Grid
   =================================== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
}

.form-field {
    display: flex;
    flex-direction: column;
}

/* ===================================
   Labels
   =================================== */
.form-field label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    letter-spacing: 0.2px;
}

.form-field label .required {
    color: #E74C3C;
    margin-left: 2px;
}

.label-hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-light);
}

/* ===================================
   Input Fields
   =================================== */
.form-field select,
.form-field input[type="text"],
.form-field input[type="number"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 15px;
    color: var(--text-dark);
    background: white;
    transition: all 0.2s ease;
    box-sizing: border-box;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23008871' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 40px;
}

.form-field input[type="text"],
.form-field input[type="number"] {
    background-image: none;
    padding-right: 16px;
}

.form-field select:hover,
.form-field input[type="text"]:hover,
.form-field input[type="number"]:hover {
    border-color: var(--primary-color);
}

.form-field select:focus,
.form-field input[type="text"]:focus,
.form-field input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 136, 113, 0.1);
}

.form-field select:disabled,
.form-field input[type="text"]:disabled,
.form-field input[type="number"]:disabled {
    background-color: var(--secondary-color);
    cursor: not-allowed;
    opacity: 0.6;
}

/* ===================================
   Elevation Checkbox Container
   =================================== */
#elevation-container,
#erv-container {
    padding: 24px;
    background: var(--background-light);
    border-radius: var(--radius-md);
    margin-top: 8px;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
}

.checkbox-wrapper input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 0 12px 0 0;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.checkbox-wrapper label {
    margin: 0;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

#elevation-input-container,
#erv-input-container {
    padding-left: 32px;
    animation: slideDown 0.3s ease;
}

#pdf-info-section {
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===================================
   Calculate Buttons
   =================================== */
.button-container {
    padding: 30px;
    background: var(--background-light);
    text-align: center;
    display: flex;
    gap: 16px;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
}

.button-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

#calculate-button {
    background: linear-gradient(135deg, var(--primary-color) 0%, #006d5a 100%);
    color: white;
    border: none;
    padding: 16px 48px;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
    letter-spacing: 0.3px;
    text-transform: none;
}

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

#calculate-button:active {
    transform: translateY(0);
}

#calculate-button:disabled {
    background: linear-gradient(135deg, #999 0%, #888 100%);
    cursor: not-allowed;
    transform: none;
    opacity: 0.7;
}

#calculate-and-export-button:disabled {
    background: linear-gradient(135deg, #999 0%, #888 100%);
    cursor: not-allowed;
    transform: none;
    opacity: 0.7;
}

#calculate-and-export-button {
    background: linear-gradient(135deg, var(--accent-color) 0%, #1a252f 100%);
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
    letter-spacing: 0.3px;
    text-transform: none;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

#calculate-and-export-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

#calculate-and-export-button:active {
    transform: translateY(0);
}

#calculate-and-export-button svg {
    flex-shrink: 0;
}

.pdf-checkbox {
    margin: 0;
}

.pdf-checkbox label {
    font-size: 13px;
    color: var(--text-medium);
}

/* ===================================
   Results Section
   =================================== */
#results,
#erv-results {
    margin-top: 40px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    animation: fadeIn 0.5s ease;
}

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

.results-header {
    padding: 24px 30px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #006d5a 100%);
    border-bottom: 3px solid #006d5a;
}

.results-header h3 {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    color: white;
    letter-spacing: -0.3px;
}

.results-header p {
    margin: 8px 0 0 0;
    font-size: 15px;
    font-weight: 400;
    color: white;
    opacity: 0.95;
}

/* ===================================
   Input Summary Section
   =================================== */
.input-summary {
    padding: 20px 30px;
    background: var(--background-light);
    border-bottom: 1px solid var(--border-color);
}

.input-summary h4 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
}

.input-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px 24px;
}

.input-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.input-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-medium);
    white-space: nowrap;
}

.input-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-color);
}

/* ===================================
   Results Table
   =================================== */
.results-content {
    padding: 30px;
    overflow-x: auto;
}

#results table,
#erv-results table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

/* Table Header */
#results thead th,
#erv-results thead th {
    background: var(--primary-color);
    color: white;
    padding: 16px 12px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    position: sticky;
    top: 0;
    z-index: 10;
}

#results thead th:first-child,
#erv-results thead th:first-child {
    text-align: left;
    padding-left: 24px;
    border-radius: var(--radius-md) 0 0 0;
}

#results thead th:last-child,
#erv-results thead th:last-child {
    border-radius: 0 var(--radius-md) 0 0;
}

#results thead th small,
#erv-results thead th small {
    display: block;
    font-size: 11px;
    font-weight: 400;
    margin-top: 4px;
    opacity: 0.9;
    text-transform: none;
    letter-spacing: 0;
}

/* Table Body */
#results tbody tr,
#erv-results tbody tr {
    transition: background 0.2s ease;
}

#results tbody tr:hover,
#erv-results tbody tr:hover {
    background: var(--background-light);
}

#results tbody td,
#erv-results tbody td {
    padding: 16px 12px;
    text-align: center;
    font-size: 15px;
    color: var(--text-dark);
    border-bottom: 1px solid var(--border-color);
}

#results tbody tr:last-child td,
#erv-results tbody tr:last-child td {
    border-bottom: none;
}

#results tbody td:first-child,
#erv-results tbody td:first-child {
    text-align: left;
    font-weight: 600;
    color: var(--accent-color);
    padding-left: 24px;
    background: var(--background-light);
}

#results tbody td span,
#erv-results tbody td span {
    display: inline-block;
    font-weight: 500;
}

/* Boost Column Highlight */
#results thead th:nth-child(5) {
    background: var(--accent-color);
}

#results tbody td:nth-child(5) {
    background: rgba(44, 62, 80, 0.05);
    font-weight: 600;
    color: var(--accent-color);
}

/* ===================================
   Responsive Design
   =================================== */
@media (max-width: 768px) {
    .wm-calculator {
        margin: 20px auto;
    }
    
    .calculator-header {
        padding: 20px 16px;
        margin-bottom: 24px;
    }
    
    .calculator-header h2 {
        font-size: 22px;
    }
    
    .form-section {
        padding: 20px;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .button-container {
        flex-direction: column;
        padding: 20px;
    }
    
    .button-group {
        width: 100%;
    }
    
    #calculate-button,
    #calculate-and-export-button {
        width: 100%;
        justify-content: center;
    }
    
    .pdf-checkbox {
        width: 100%;
    }
    
    .results-content {
        padding: 20px 16px;
    }
    
    .input-summary {
        padding: 16px 20px;
    }
    
    .input-summary h4 {
        font-size: 15px;
        margin-bottom: 12px;
    }
    
    .input-summary-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    #results table,
    #erv-results table {
        font-size: 13px;
    }
    
    #results thead th,
    #results tbody td,
    #erv-results thead th,
    #erv-results tbody td {
        padding: 12px 8px;
    }
    
    #results tbody td:first-child,
    #results thead th:first-child,
    #erv-results tbody td:first-child,
    #erv-results thead th:first-child {
        padding-left: 12px;
    }
    
    #calculate-button {
        width: 100%;
        padding: 14px 24px;
    }
    
    .wm-calculator.loading .calculator-header::after {
        font-size: 14px;
        white-space: normal;
        max-width: 80%;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .calculator-header h2 {
        font-size: 20px;
    }
    
    .results-content {
        padding: 16px 8px;
    }
    
    #results table,
    #erv-results table {
        font-size: 12px;
    }
    
    #results thead th,
    #results tbody td,
    #erv-results thead th,
    #erv-results tbody td {
        padding: 10px 6px;
    }
    
    #results thead th small,
    #erv-results thead th small {
        font-size: 10px;
    }
}

/* ===================================
   ERV Warning Messages
   =================================== */
.erv-warning {
    display: block;
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
}

.erv-warning.warning {
    background: #FFF3CD;
    color: #856404;
    border: 1px solid #FFE69C;
}

.erv-warning.error {
    background: #F8D7DA;
    color: #721C24;
    border: 1px solid #F5C6CB;
}

/* ===================================
   ERV Results Table Styling
   =================================== */
/* ERV Results now uses the same styling as regular results above */
/* Additional ERV-specific styling can go here if needed */

/* ===================================
   Utility Classes
   =================================== */
.text-center {
    text-align: center;
}

.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}