/* ============================================================
   Houzez Mortgage Calculator CR — calculator.css
   Design: profesional, limpio, paleta neutra con acento azul
   ============================================================ */

:root {
    --hmc-primary:    #1a56db;
    --hmc-primary-dk: #1240a8;
    --hmc-accent:     #0ea5e9;
    --hmc-green:      #059669;
    --hmc-surface:    #ffffff;
    --hmc-bg:         #f8fafc;
    --hmc-border:     #e2e8f0;
    --hmc-text:       #1e293b;
    --hmc-muted:      #64748b;
    --hmc-radius:     10px;
    --hmc-shadow:     0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.06);
}

/* ── Wrapper ─────────────────────────────────────────────── */
.hmc-calculator {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    color: var(--hmc-text);
    background: var(--hmc-bg);
    border: 1px solid var(--hmc-border);
    border-radius: var(--hmc-radius);
    padding: 24px;
    margin: 32px 0;
    max-width: 100%;
    box-shadow: var(--hmc-shadow);
}

/* ── Header ──────────────────────────────────────────────── */
.hmc-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 22px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--hmc-primary);
}
.hmc-icon {
    width: 28px;
    height: 28px;
    color: var(--hmc-primary);
    flex-shrink: 0;
}
.hmc-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--hmc-primary);
    letter-spacing: -.3px;
}

/* ── Loading ─────────────────────────────────────────────── */
.hmc-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 32px 0;
    color: var(--hmc-muted);
}
.hmc-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid var(--hmc-border);
    border-top-color: var(--hmc-primary);
    border-radius: 50%;
    animation: hmc-spin .7s linear infinite;
}
@keyframes hmc-spin { to { transform: rotate(360deg); } }

/* ── Inputs grid ─────────────────────────────────────────── */
.hmc-inputs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.hmc-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.hmc-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--hmc-muted);
}
.hmc-input-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}
.hmc-input-dual {
    flex-wrap: wrap;
}
.hmc-input, .hmc-currency-select {
    border: 1.5px solid var(--hmc-border);
    border-radius: 7px;
    padding: 8px 10px;
    font-size: 15px;
    font-weight: 500;
    color: var(--hmc-text);
    background: var(--hmc-surface);
    outline: none;
    transition: border-color .15s;
    min-width: 0;
    flex: 1;
}
.hmc-input:focus, .hmc-currency-select:focus {
    border-color: var(--hmc-primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,.15);
}
.hmc-currency-select {
    flex: 0 0 auto;
    cursor: pointer;
    font-weight: 600;
}
.hmc-sep { color: var(--hmc-muted); font-size: 12px; }
.hmc-unit { font-size: 13px; color: var(--hmc-muted); white-space: nowrap; }
.hmc-hint { font-size: 12px; color: var(--hmc-muted); }

/* Term months input */
.hmc-term-wrap {
    align-items: center;
    gap: 8px;
}
.hmc-term-input {
    width: 90px !important;
    flex: 0 0 auto !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    color: var(--hmc-primary) !important;
    text-align: center;
}
.hmc-term-years-hint {
    font-size: 12px;
    color: var(--hmc-muted);
    white-space: nowrap;
}

/* Toggle */
.hmc-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}
.hmc-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.hmc-toggle input { opacity: 0; width: 0; height: 0; }
.hmc-toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--hmc-border);
    border-radius: 24px;
    cursor: pointer;
    transition: background .2s;
}
.hmc-toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    left: 3px; top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.hmc-toggle input:checked + .hmc-toggle-slider { background: var(--hmc-primary); }
.hmc-toggle input:checked + .hmc-toggle-slider::before { transform: translateX(20px); }
.hmc-toggle-label { font-size: 13px; }

/* ── Plans list ──────────────────────────────────────────── */
.hmc-plan-selector { margin-bottom: 20px; }
.hmc-lender-group  { margin-bottom: 14px; }
.hmc-lender-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.hmc-lender-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 6px;
    border: 1px solid var(--hmc-border);
    background: #fff;
    padding: 2px;
}
.hmc-lender-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--hmc-text);
}
.hmc-plans-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.hmc-plan-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 12px 14px;
    border: 1.5px solid var(--hmc-border);
    border-radius: 8px;
    background: var(--hmc-surface);
    cursor: pointer;
    text-align: left;
    transition: border-color .15s, box-shadow .15s, background .15s;
    min-width: 180px;
    max-width: 260px;
}
.hmc-plan-btn:hover {
    border-color: var(--hmc-primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,.1);
}
.hmc-plan-btn.active {
    border-color: var(--hmc-primary);
    background: rgba(26,86,219,.05);
    box-shadow: 0 0 0 3px rgba(26,86,219,.15);
}
.hmc-plan-btn.hmc-highlighted { border-color: var(--hmc-accent); }
.hmc-plan-btn.hmc-highlighted.active { background: rgba(14,165,233,.07); }
.hmc-plan-name  { font-weight: 600; font-size: 13px; }
.hmc-plan-rate  { font-size: 12px; color: var(--hmc-primary); font-weight: 500; }
.hmc-plan-term  { font-size: 11px; color: var(--hmc-muted); }

/* Badge */
.hmc-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    background: var(--hmc-accent);
    color: #fff;
    letter-spacing: .3px;
    text-transform: uppercase;
    margin-bottom: 4px;
    width: fit-content;
}
.hmc-badge-best {
    background: var(--hmc-green);
}

/* ── Result ──────────────────────────────────────────────── */
.hmc-result {
    background: linear-gradient(135deg, var(--hmc-primary) 0%, var(--hmc-primary-dk) 100%);
    border-radius: var(--hmc-radius);
    padding: 24px;
    color: #fff;
    margin-bottom: 20px;
}
.hmc-result-primary {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-start;
}
.hmc-result-main {
    flex: 1 1 220px;
}
.hmc-result-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .6px;
    opacity: .8;
    margin-bottom: 4px;
}
.hmc-result-amount {
    display: block;
    font-size: 38px;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1.1;
}
.hmc-result-sublabel {
    display: block;
    font-size: 12px;
    opacity: .75;
    margin-top: 6px;
}
.hmc-result-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    flex: 1 1 240px;
}
.hmc-stat {
    background: rgba(255,255,255,.12);
    border-radius: 7px;
    padding: 10px 14px;
}
.hmc-stat-label {
    display: block;
    font-size: 11px;
    opacity: .75;
    margin-bottom: 3px;
}
.hmc-stat-val {
    display: block;
    font-size: 15px;
    font-weight: 700;
}

/* ── Card (insurance / fees) ─────────────────────────────── */
.hmc-card {
    background: var(--hmc-surface);
    border: 1px solid var(--hmc-border);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 14px;
}
.hmc-card-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--hmc-text);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.hmc-ins-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 5px 0;
    border-bottom: 1px dashed var(--hmc-border);
    color: var(--hmc-muted);
}
.hmc-ins-row:last-child { border-bottom: none; }
.hmc-ins-total {
    font-weight: 700;
    color: var(--hmc-text);
    padding-top: 8px;
}
.hmc-plan-notes {
    font-size: 13px;
    color: var(--hmc-muted);
}

/* ── Tabs ────────────────────────────────────────────────── */
.hmc-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--hmc-border);
    margin-bottom: 16px;
}
.hmc-tab {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: var(--hmc-muted);
    margin-bottom: -2px;
    border-radius: 6px 6px 0 0;
    transition: color .15s, border-color .15s;
}
.hmc-tab:hover   { color: var(--hmc-primary); }
.hmc-tab.active  { color: var(--hmc-primary); border-bottom-color: var(--hmc-primary); }

/* ── Table controls ──────────────────────────────────────── */
.hmc-table-controls {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.hmc-btn-secondary {
    background: none;
    border: 1.5px solid var(--hmc-primary);
    color: var(--hmc-primary);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.hmc-btn-secondary:hover { background: rgba(26,86,219,.07); }
.hmc-amort-view {
    border: 1.5px solid var(--hmc-border);
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 13px;
    background: var(--hmc-surface);
}

/* ── Amortization table ──────────────────────────────────── */
.hmc-amort-table-wrap {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--hmc-border);
}
.hmc-amort-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.hmc-amort-table th {
    background: var(--hmc-primary);
    color: #fff;
    font-weight: 600;
    padding: 10px 12px;
    text-align: right;
    font-size: 12px;
    white-space: nowrap;
}
.hmc-amort-table th:first-child { text-align: left; }
.hmc-amort-table td {
    padding: 8px 12px;
    text-align: right;
    border-bottom: 1px solid var(--hmc-border);
    color: var(--hmc-text);
    white-space: nowrap;
}
.hmc-amort-table td:first-child  { text-align: left; font-weight: 600; }
.hmc-amort-table tbody tr:last-child td { border-bottom: none; }
.hmc-amort-table tbody tr:nth-child(even) { background: var(--hmc-bg); }
.hmc-more-rows {
    text-align: center !important;
    color: var(--hmc-muted);
    font-style: italic;
    padding: 14px !important;
}

/* ── Comparison grid ─────────────────────────────────────── */
.hmc-compare-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
}
.hmc-compare-card {
    background: var(--hmc-surface);
    border: 1.5px solid var(--hmc-border);
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: box-shadow .15s;
}
.hmc-compare-card:hover { box-shadow: var(--hmc-shadow); }
.hmc-compare-best {
    border-color: var(--hmc-green);
    box-shadow: 0 0 0 3px rgba(5,150,105,.12);
}
.hmc-compare-highlighted { border-color: var(--hmc-accent); }
.hmc-compare-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.hmc-cmp-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 5px;
    border: 1px solid var(--hmc-border);
    background: #fff;
    padding: 2px;
}
.hmc-cmp-lender { font-weight: 700; font-size: 13px; }
.hmc-cmp-plan   { font-size: 12px; color: var(--hmc-muted); }
.hmc-cmp-rate   { font-size: 12px; color: var(--hmc-primary); font-weight: 600; }
.hmc-cmp-body   { display: flex; flex-direction: column; gap: 6px; }
.hmc-cmp-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    border-bottom: 1px dashed var(--hmc-border);
    padding-bottom: 4px;
}
.hmc-cmp-row span { color: var(--hmc-muted); }
.hmc-cmp-row strong { font-weight: 700; }
.hmc-cmp-footer {
    font-size: 13px;
    font-weight: 700;
    color: var(--hmc-green);
    text-align: center;
    padding: 6px;
    background: rgba(5,150,105,.07);
    border-radius: 6px;
}

/* ── Disclaimer ──────────────────────────────────────────── */
.hmc-disclaimer {
    font-size: 11px;
    color: var(--hmc-muted);
    margin: 16px 0 0;
    font-style: italic;
}

/* ── Error ───────────────────────────────────────────────── */
.hmc-error { color: #dc2626; padding: 12px 0; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 600px) {
    .hmc-calculator  { padding: 16px; }
    .hmc-result-amount { font-size: 28px; }
    .hmc-result-stats  { grid-template-columns: 1fr 1fr; gap: 8px; }
    .hmc-plan-btn      { min-width: 150px; }
    .hmc-inputs-grid   { grid-template-columns: 1fr; }
}

/* ── TITA (Costo efectivo total) ─────────────────────────── */
.hmc-plan-tita {
    font-size: 11px;
    color: #059669;
    font-weight: 600;
    letter-spacing: .2px;
}
.hmc-tita-badge {
    display: block;
    font-size: 12px;
    background: rgba(255,255,255,.18);
    border-radius: 5px;
    padding: 5px 10px;
    margin-top: 10px;
    font-weight: 600;
    letter-spacing: .2px;
}
.hmc-cmp-tita {
    background: #eff6ff !important;
    font-weight: 700;
    color: #1a56db !important;
}
.hmc-cmp-tita span { color: #1a56db !important; }

/* ── Formatted number inputs ─────────────────────────────── */
.hmc-formatted-wrap {
    display: contents; /* transparente en el layout */
}
.hmc-price-display,
.hmc-down-display {
    /* Hereda todos los estilos de .hmc-input */
    flex: 1;
    min-width: 0;
    font-variant-numeric: tabular-nums;
    letter-spacing: .02em;
}
/* Cursor de texto en lugar de flecha numérica */
.hmc-price-display:focus,
.hmc-down-display:focus {
    font-variant-numeric: normal;
    letter-spacing: normal;
}

/* Nota en header de tabla de amortización */
.hmc-th-note {
    display: block;
    font-size: 10px;
    font-weight: 400;
    opacity: .75;
    letter-spacing: 0;
    text-transform: none;
}

/* ── Nota de conversión de moneda ────────────────────────── */
.hmc-conversion-note {
    display: block;
    margin-top: 4px;
    color: #059669;
    font-size: 11px;
    font-weight: 500;
    transition: opacity .5s;
}
