/**
 * How Much Home Calculator - Premium Mobile-First Styles
 * Clean, professional, accessible design
 * No external frameworks
 */

:root {
    /* Light theme (default) */
    --hmhc-bg: #f8fafc;
    --hmhc-card-bg: #ffffff;
    --hmhc-text: #0f172a;
    --hmhc-text-muted: #475569;
    --hmhc-border: #e2e8f0;
    --hmhc-input-bg: #ffffff;
    --hmhc-input-border: #cbd5e1;
    --hmhc-accent: #4f46e5;
    --hmhc-accent-hover: #4338ca;
    --hmhc-success: #059669;
    --hmhc-warning: #d97706;
    --hmhc-shadow: 0 10px 15px -3px rgb(15 23 42 / 0.08), 0 4px 6px -4px rgb(15 23 42 / 0.08);
    --hmhc-radius: 12px;
    --hmhc-radius-sm: 8px;
}

[data-theme="dark"] {
    --hmhc-bg: #0f172a;
    --hmhc-card-bg: #1e293b;
    --hmhc-text: #f1f5f9;
    --hmhc-text-muted: #94a3b8;
    --hmhc-border: #334155;
    --hmhc-input-bg: #1e293b;
    --hmhc-input-border: #475569;
    --hmhc-accent: #6366f1;
    --hmhc-accent-hover: #818cf8;
    --hmhc-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
}

/* Base container */
.hmhc-calculator {
    max-width: 780px;
    margin: 40px auto;
    padding: 0 16px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    color: var(--hmhc-text);
    background: var(--hmhc-bg);
    box-sizing: border-box;
    line-height: 1.5;
}

/* Header */
.hmhc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 32px;
}

.hmhc-header-content {
    flex: 1;
}

.hmhc-title {
    font-size: clamp(1.75rem, 5vw, 2.25rem);
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 8px 0;
    color: var(--hmhc-text);
}

.hmhc-subtitle {
    font-size: 1.05rem;
    color: var(--hmhc-text-muted);
    margin: 0;
    max-width: 52ch;
}

/* Theme toggle */
.hmhc-theme-toggle {
    background: var(--hmhc-card-bg);
    border: 1px solid var(--hmhc-border);
    border-radius: 9999px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-shadow: var(--hmhc-shadow);
}

.hmhc-theme-toggle:hover {
    border-color: var(--hmhc-accent);
    transform: translateY(-1px);
}

.hmhc-theme-icon {
    display: none;
    color: var(--hmhc-text);
}

.hmhc-theme-toggle .hmhc-theme-icon.light {
    display: block;
}

[data-theme="dark"] .hmhc-theme-toggle .hmhc-theme-icon.light {
    display: none;
}

[data-theme="dark"] .hmhc-theme-toggle .hmhc-theme-icon.dark {
    display: block;
}

/* Section titles */
.hmhc-section-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 20px 0;
    color: var(--hmhc-text);
}

/* Form */
.hmhc-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.hmhc-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.hmhc-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--hmhc-text);
    display: flex;
    align-items: center;
    gap: 4px;
}

.hmhc-required {
    color: #ef4444;
    font-size: 1rem;
}

.hmhc-input-group {
    display: flex;
    align-items: center;
    background: var(--hmhc-input-bg);
    border: 1px solid var(--hmhc-input-border);
    border-radius: var(--hmhc-radius-sm);
    overflow: hidden;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.hmhc-input-group:focus-within {
    border-color: var(--hmhc-accent);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.hmhc-input-prefix,
.hmhc-input-suffix {
    padding: 14px 16px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 1rem;
    font-weight: 500;
    white-space: nowrap;
    user-select: none;
}

[data-theme="dark"] .hmhc-input-prefix,
[data-theme="dark"] .hmhc-input-suffix {
    background: #334155;
    color: #94a3b8;
}

.hmhc-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 14px 16px;
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--hmhc-text);
    min-width: 0;
    outline: none;
}

.hmhc-input[type="number"] {
    -moz-appearance: textfield;
}

.hmhc-input[type="number"]::-webkit-outer-spin-button,
.hmhc-input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.hmhc-input::placeholder {
    color: #94a3b8;
}

.hmhc-help-text {
    font-size: 0.875rem;
    color: var(--hmhc-text-muted);
    margin: 4px 0 0 0;
    line-height: 1.4;
}

/* Results */
.hmhc-result-section {
    margin-top: 40px;
    padding-top: 32px;
    border-top: 1px solid var(--hmhc-border);
}

.hmhc-result {
    background: var(--hmhc-card-bg);
    border: 1px solid var(--hmhc-border);
    border-radius: var(--hmhc-radius);
    padding: 28px 24px;
    box-shadow: var(--hmhc-shadow);
}

.hmhc-main-result {
    text-align: center;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--hmhc-border);
    margin-bottom: 24px;
}

.hmhc-main-result-label {
    font-size: 1rem;
    color: var(--hmhc-text-muted);
    margin-bottom: 8px;
}

.hmhc-main-result-value {
    font-size: clamp(2.25rem, 7vw, 3.25rem);
    font-weight: 700;
    line-height: 1.1;
    color: var(--hmhc-success);
    font-variant-numeric: tabular-nums;
    word-break: break-word;
}

.hmhc-result-status {
    margin-top: 8px;
    font-size: 0.95rem;
    font-weight: 500;
}

/* Breakdown */
.hmhc-breakdown {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 24px;
}

.hmhc-breakdown-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 4px 0;
    font-size: 0.95rem;
}

.hmhc-breakdown-row.highlight {
    background: rgba(79, 70, 229, 0.06);
    margin: 0 -8px;
    padding: 8px 12px;
    border-radius: var(--hmhc-radius-sm);
}

.hmhc-breakdown-row.total {
    border-top: 2px solid var(--hmhc-border);
    padding-top: 14px;
    margin-top: 8px;
    font-weight: 600;
    font-size: 1rem;
}

.hmhc-breakdown-label {
    color: var(--hmhc-text-muted);
    flex: 1;
}

.hmhc-breakdown-value {
    font-weight: 600;
    color: var(--hmhc-text);
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

/* Assumptions & Disclaimer */
.hmhc-assumptions,
.hmhc-disclaimer {
    font-size: 0.875rem;
    color: var(--hmhc-text-muted);
    background: var(--hmhc-bg);
    padding: 16px;
    border-radius: var(--hmhc-radius-sm);
    border: 1px solid var(--hmhc-border);
}

.hmhc-assumptions {
    margin-bottom: 16px;
}

.hmhc-assumptions-text {
    margin: 0;
}

.hmhc-disclaimer {
    margin-top: 8px;
}

.hmhc-disclaimer p {
    margin: 0;
}

/* Action Buttons */
.hmhc-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 28px;
}

.hmhc-btn {
    flex: 1 1 auto;
    min-width: 140px;
    padding: 14px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--hmhc-radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.hmhc-btn-primary {
    background: var(--hmhc-accent);
    color: white;
    box-shadow: 0 4px 6px -1px rgb(79 70 229 / 0.2);
}

.hmhc-btn-primary:hover {
    background: var(--hmhc-accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgb(79 70 229 / 0.25);
}

.hmhc-btn-secondary {
    background: var(--hmhc-card-bg);
    color: var(--hmhc-text);
    border: 1px solid var(--hmhc-border);
}

.hmhc-btn-secondary:hover {
    background: var(--hmhc-bg);
    border-color: var(--hmhc-accent);
}

/* Footer note */
.hmhc-footer-note {
    text-align: center;
    margin-top: 24px;
    font-size: 0.8rem;
    color: var(--hmhc-text-muted);
}

/* Toast for copy feedback */
.hmhc-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--hmhc-text);
    color: var(--hmhc-card-bg);
    padding: 12px 24px;
    border-radius: 9999px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--hmhc-shadow);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.hmhc-toast.show {
    opacity: 1;
}

/* Print styles - clean result for PDF */
@media print {
    .hmhc-calculator {
        margin: 0;
        padding: 0;
        max-width: 100%;
        background: white;
        color: black;
    }
    
    .hmhc-header,
    .hmhc-form-section,
    .hmhc-actions,
    .hmhc-footer-note,
    .hmhc-theme-toggle {
        display: none !important;
    }
    
    .hmhc-result-section {
        border-top: none;
        padding-top: 0;
        margin-top: 0;
    }
    
    .hmhc-result {
        box-shadow: none;
        border: 1px solid #ccc;
        padding: 20px;
    }
    
    .hmhc-main-result-value {
        color: #000;
    }
    
    .hmhc-breakdown-row.highlight,
    .hmhc-assumptions,
    .hmhc-disclaimer {
        background: #f9fafb;
        border-color: #e5e7eb;
    }
}

/* Mobile-first responsive */
@media (max-width: 480px) {
    .hmhc-calculator {
        margin: 24px auto;
        padding: 0 12px;
    }
    
    .hmhc-title {
        font-size: 1.6rem;
    }
    
    .hmhc-subtitle {
        font-size: 0.95rem;
    }
    
    .hmhc-main-result-value {
        font-size: 2.1rem;
    }
    
    .hmhc-actions {
        flex-direction: column;
    }
    
    .hmhc-btn {
        width: 100%;
        min-width: 0;
    }
    
    .hmhc-breakdown-row {
        font-size: 0.9rem;
    }
}

/* Accessibility & focus */
.hmhc-input:focus-visible,
.hmhc-btn:focus-visible,
.hmhc-theme-toggle:focus-visible {
    outline: 2px solid var(--hmhc-accent);
    outline-offset: 2px;
}

.hmhc-calculator a:focus-visible {
    outline: 2px solid var(--hmhc-accent);
}

/* High contrast support */
@media (prefers-contrast: more) {
    .hmhc-input-group {
        border-width: 2px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .hmhc-btn,
    .hmhc-theme-toggle,
    .hmhc-input-group {
        transition: none;
    }
}
