/* EzeCalc Mobile-First Styles */

:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Calculator Container */
.calculator-container {
    max-width: 900px;
    margin: 0 auto;
    background: var(--bg-primary);
    min-height: 100vh;
}

/* Header */
.calc-header {
    background: var(--primary-color);
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-md);
}

.header-logo-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-logo {
    height: 40px;
    width: auto;
    display: block;
}

.calc-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

@media (max-width: 768px) {
    .calc-header {
        padding: 0.75rem;
    }
    
    .header-logo {
        height: 32px;
    }
    
    .calc-header h1 {
        font-size: 1.25rem;
    }
    
    /* Hide user greeting on mobile/tablet to save space */
    .user-greeting {
        display: none !important;
    }
    
    /* Make mode buttons more compact on mobile */
    .mode-btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }
    
    /* Reduce gap between buttons on mobile */
    .calc-mode-toggle {
        gap: 0.35rem;
    }
}

.calc-mode-toggle {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.user-greeting {
    color: white;
    margin-right: 0.5rem;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.mode-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.2s;
    white-space: nowrap;
}

.mode-btn.active {
    background: white;
    color: var(--primary-color);
}

/* Progress Bar */
.progress-bar {
    height: 4px;
    background: var(--border-color);
    position: relative;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
}

/* Progress Steps */
.progress-steps {
    display: flex;
    justify-content: space-around;
    padding: 1rem 0.5rem;
    background: white;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}

.step {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
    padding: 0.25rem 0.5rem;
    white-space: nowrap;
    position: relative;
}

.step.active {
    color: var(--primary-color);
    font-weight: 600;
}

.step.completed {
    color: var(--success-color);
}

/* Form */
.calc-form {
    padding: 1rem;
}

.form-section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.form-section.active {
    display: block;
}

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

.form-section h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.form-section h3 {
    font-size: 1.125rem;
    margin: 1.5rem 0 0.75rem;
    color: var(--text-primary);
}

/* Form Groups */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.hint {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    display: block;
}

/* Form Rows */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

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

@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }
    .form-row.triple {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 0.5rem;
    }
    .form-row.triple input {
        max-width: 5rem;
        font-size: 1rem;
    }
}

/* Checkbox Groups */
.checkbox-group {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 0.5rem;
}

.checkbox-group label {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    font-weight: normal;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    margin-top: 0.25rem;
    flex-shrink: 0;
}

/* Calc Preview */
.calc-preview {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 0.5rem;
    display: flex;
    justify-content: space-around;
    margin: 1rem 0;
}

.preview-item {
    text-align: center;
}

.preview-item span {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.preview-item strong {
    font-size: 1.25rem;
    color: var(--primary-color);
}

/* Insulation Groups */
.insulation-group {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.insulation-group h3 {
    margin-top: 0;
    font-size: 1rem;
}

/* Walls */
.walls-container {
    margin-top: 1.5rem;
}

.wall-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

@media (max-width: 640px) {
    .wall-grid {
        grid-template-columns: 1fr;
    }
}

.wall-card {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
}

.wall-card h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    color: var(--text-primary);
}

/* Windows */
.wall-windows {
    margin-bottom: 1.5rem;
}

.wall-windows h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.windows-list {
    margin-bottom: 0.75rem;
}

.window-item {
    background: var(--bg-secondary);
    padding: 0.75rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-start;
}

.window-item .window-header {
    width: 100%;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.window-item .form-group {
    margin: 0;
    flex: 1;
}

.window-item .form-group label {
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
}

.window-item .form-group input,
.window-item .form-group select {
    padding: 0.75rem;
    font-size: 1rem;
    min-height: 50px;
    width: 100%;
}

/* Mobile - make window type dropdown full width on its own row */
@media (max-width: 768px) {
    .window-item {
        flex-wrap: wrap;
    }
    
    .window-item .form-group:has(select) {
        width: 100%;
        flex: 0 0 100%;
        order: 10; /* Move to bottom */
    }
    
    .window-item .form-group select {
        padding: 1rem;
        font-size: 1.1rem;
        min-height: 55px;
        width: 100%;
    }
    
    .window-item button {
        order: 11; /* Keep delete button at end */
    }
}

.window-item button {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    margin-top: 1.5rem;
}

.btn-add-window {
    width: 100%;
    padding: 0.75rem;
    background: white;
    border: 2px dashed var(--border-color);
    color: var(--text-secondary);
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.btn-add-window:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Buttons */
button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.btn-next,
.btn-calculate {
    background: var(--primary-color);
    color: white;
    width: 100%;
}

.btn-next:active,
.btn-calculate:active {
    background: var(--primary-dark);
    transform: scale(0.98);
}

.btn-back {
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-save {
    background: var(--success-color);
    color: white;
}

.btn-duplicate {
    background: var(--warning-color);
    color: white;
}

.btn-new {
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-remove {
    background: var(--danger-color);
    color: white;
    font-size: 1.25rem;
    padding: 0.5rem;
}

/* Form Actions */
.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 2rem;
}

.form-actions button {
    flex: 1;
}

@media (max-width: 640px) {
    .form-actions {
        flex-direction: column;
    }
}

/* Results */
.results-grid {
    display: grid;
    gap: 1rem;
}

.result-card {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
}

.result-card.highlight {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.result-card.highlight.heating {
    background: linear-gradient(135deg, #dc2626, #991b1b);
    color: white;
}

.result-card h3 {
    font-size: 0.875rem;
    margin: 0 0 0.5rem 0;
    opacity: 0.9;
}

.result-card .value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

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

.result-breakdown {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.result-breakdown h4 {
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.breakdown-item span:first-child {
    color: var(--text-secondary);
}

.breakdown-item span:last-child {
    font-weight: 600;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 2rem;
}

.spinner {
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

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

/* Tablet & Desktop */
@media (min-width: 768px) {
    .calculator-container {
        margin-top: 2rem;
        border-radius: 0.5rem;
        box-shadow: var(--shadow-lg);
        min-height: auto;
    }
    
    .calc-header {
        border-radius: 0.5rem 0.5rem 0 0;
    }
    
    .calc-form {
        padding: 2rem;
    }
    
    .results-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Print Styles */
@media print {
    .calc-header,
    .progress-bar,
    .progress-steps,
    .form-actions,
    .btn-add-window {
        display: none;
    }
    
    .form-section {
        display: block;
    }
}