/**
 * Qualifier Mortgage Calculator — Stylesheet
 * Namespaced with qc- prefix.  Mobile-first, accessible.
 */

/* ------------------------------------------------------------------ */
/*  Reset & Container                                                 */
/* ------------------------------------------------------------------ */
.qc-calculator {
    --qc-primary: #1a5276;
    --qc-primary-light: #2980b9;
    --qc-accent: #27ae60;
    --qc-accent-hover: #219a52;
    --qc-danger: #c0392b;
    --qc-bg: #ffffff;
    --qc-bg-alt: #f8f9fa;
    --qc-border: #dee2e6;
    --qc-text: #212529;
    --qc-text-muted: #6c757d;
    --qc-radius: 8px;
    --qc-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --qc-transition: 0.2s ease;

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    color: var(--qc-text);
    max-width: 720px;
    margin: 2rem auto;
    padding: 0 1rem;
    box-sizing: border-box;
}

.qc-calculator *, .qc-calculator *::before, .qc-calculator *::after {
    box-sizing: inherit;
}

/* ------------------------------------------------------------------ */
/*  Title                                                             */
/* ------------------------------------------------------------------ */
.qc-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--qc-primary);
    margin: 0 0 1.25rem;
    text-align: center;
}

/* ------------------------------------------------------------------ */
/*  Panel                                                             */
/* ------------------------------------------------------------------ */
.qc-panel {
    background: var(--qc-bg);
    border: 1px solid var(--qc-border);
    border-radius: var(--qc-radius);
    box-shadow: var(--qc-shadow);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}

.qc-panel-legend {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--qc-primary);
    padding: 0 0.5rem;
}

/* ------------------------------------------------------------------ */
/*  Fields                                                            */
/* ------------------------------------------------------------------ */
.qc-field {
    margin-bottom: 1rem;
}

.qc-label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
    color: var(--qc-text);
}

.qc-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.qc-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    font-size: 1rem;
    border: 2px solid var(--qc-border);
    border-radius: var(--qc-radius);
    background: var(--qc-bg);
    color: var(--qc-text);
    transition: border-color var(--qc-transition), box-shadow var(--qc-transition);
    outline: none;
}

.qc-input:focus {
    border-color: var(--qc-primary-light);
    box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.2);
}

.qc-input-error {
    border-color: var(--qc-danger) !important;
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.15) !important;
}

.qc-input-solved {
    border-color: var(--qc-accent) !important;
    background: #eafaf1;
}

/* ------------------------------------------------------------------ */
/*  Badge                                                             */
/* ------------------------------------------------------------------ */
.qc-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: var(--qc-accent);
    color: #fff;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ------------------------------------------------------------------ */
/*  Validation messages                                               */
/* ------------------------------------------------------------------ */
.qc-msg {
    display: block;
    font-size: 0.82rem;
    color: var(--qc-danger);
    margin-top: 0.25rem;
    min-height: 1.2em;
}

.qc-global-msg {
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--qc-danger);
    padding: 0.5rem;
    margin-top: 0.5rem;
    border-radius: var(--qc-radius);
    background: rgba(192, 57, 43, 0.07);
}

/* ------------------------------------------------------------------ */
/*  Buttons                                                           */
/* ------------------------------------------------------------------ */
.qc-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

.qc-btn {
    padding: 0.65rem 1.4rem;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: var(--qc-radius);
    cursor: pointer;
    transition: background var(--qc-transition), transform 0.1s;
    white-space: nowrap;
}

.qc-btn:active {
    transform: scale(0.97);
}

.qc-btn:focus-visible {
    outline: 3px solid var(--qc-primary-light);
    outline-offset: 2px;
}

.qc-btn-primary {
    background: var(--qc-primary);
    color: #fff;
    flex: 1;
}

.qc-btn-primary:hover {
    background: var(--qc-primary-light);
}

.qc-btn-secondary {
    background: var(--qc-bg-alt);
    color: var(--qc-text-muted);
    border: 1px solid var(--qc-border);
}

.qc-btn-secondary:hover {
    background: #e9ecef;
}

.qc-btn-accent {
    background: var(--qc-accent);
    color: #fff;
}

.qc-btn-accent:hover {
    background: var(--qc-accent-hover);
}

/* ------------------------------------------------------------------ */
/*  Results summary                                                   */
/* ------------------------------------------------------------------ */
.qc-results-title,
.qc-amort-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--qc-primary);
    margin: 0 0 1rem;
}

.qc-summary {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    margin: 0;
    padding: 0;
}

.qc-summary-item {
    background: var(--qc-bg-alt);
    border-radius: var(--qc-radius);
    padding: 0.75rem 1rem;
}

.qc-summary-item dt {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--qc-text-muted);
    margin: 0 0 0.25rem;
}

.qc-summary-item dd {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--qc-text);
    margin: 0;
}

/* ------------------------------------------------------------------ */
/*  Amortization table                                                */
/* ------------------------------------------------------------------ */
.qc-amort-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.qc-amort-header .qc-amort-title {
    margin: 0;
}

.qc-amort-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-height: 420px;
    overflow-y: auto;
    border: 1px solid var(--qc-border);
    border-radius: var(--qc-radius);
}

.qc-amort-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    white-space: nowrap;
}

.qc-amort-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.qc-amort-table th {
    background: var(--qc-primary);
    color: #fff;
    font-weight: 600;
    padding: 0.55rem 0.75rem;
    text-align: right;
}

.qc-amort-table th:first-child {
    text-align: center;
}

.qc-amort-table td {
    padding: 0.45rem 0.75rem;
    text-align: right;
    border-bottom: 1px solid var(--qc-border);
}

.qc-amort-table td:first-child {
    text-align: center;
    font-weight: 600;
    color: var(--qc-text-muted);
}

.qc-amort-table tbody tr:nth-child(even) {
    background: var(--qc-bg-alt);
}

.qc-amort-table tbody tr:hover {
    background: #e8f4fd;
}

/* ------------------------------------------------------------------ */
/*  Utility                                                           */
/* ------------------------------------------------------------------ */
.qc-hidden {
    display: none !important;
}

/* ------------------------------------------------------------------ */
/*  Responsive                                                        */
/* ------------------------------------------------------------------ */
@media (max-width: 480px) {
    .qc-calculator {
        padding: 0 0.5rem;
    }

    .qc-panel {
        padding: 1rem;
    }

    .qc-title {
        font-size: 1.3rem;
    }

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

    .qc-btn {
        width: 100%;
        text-align: center;
    }

    .qc-summary {
        grid-template-columns: 1fr;
    }

    .qc-amort-header {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ------------------------------------------------------------------ */
/*  Print styles                                                      */
/* ------------------------------------------------------------------ */
@media print {
    .qc-calculator {
        max-width: 100%;
        box-shadow: none;
    }

    .qc-btn, .qc-actions {
        display: none !important;
    }

    .qc-amort-scroll {
        max-height: none;
        overflow: visible;
    }
}

/* ------------------------------------------------------------------ */
/*  High contrast / prefers-reduced-motion                            */
/* ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
    .qc-calculator, .qc-calculator * {
        transition: none !important;
    }
}

@media (forced-colors: active) {
    .qc-input {
        border: 2px solid ButtonText;
    }

    .qc-btn {
        border: 1px solid ButtonText;
    }

    .qc-badge {
        border: 1px solid ButtonText;
    }
}
