/* CSS Variables - Texas Theme (Dark default) */
:root {
    --bg-primary: #0a0d12;
    --bg-secondary: #111827;
    --bg-card: #1f2937;
    --bg-input: #0d1117;

    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --accent-blue: #3b82f6;
    --accent-blue-light: #60a5fa;
    --accent-blue-dark: #1d4ed8;

    --texas-red: #bf2a45;
    --texas-red-light: #dc2626;
    --texas-gold: #f59e0b;

    --color-pi: #3b82f6;
    --color-tax: #ef4444;
    --color-insurance: #f59e0b;
    --color-pmi: #8b5cf6;
    --color-hoa: #06b6d4;

    --gradient-texas: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 50%, #dc2626 100%);

    --border-color: #374151;
    --border-radius: 12px;

    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app {
    max-width: 640px;
    margin: 0 auto;
    padding: 24px 16px 60px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 24px;
}

.texas-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--texas-red);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.texas-badge .star {
    font-size: 1rem;
    color: var(--texas-gold);
}

.title {
    font-size: 2rem;
    font-weight: 800;
    background: var(--gradient-texas);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
}

/* Info Box */
.info-box {
    background: linear-gradient(135deg, rgba(29, 78, 216, 0.15) 0%, rgba(220, 38, 38, 0.1) 100%);
    border: 1px solid var(--accent-blue-dark);
    padding: 16px 20px;
    margin-bottom: 32px;
    border-radius: var(--border-radius);
}

.info-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.info-text strong {
    color: var(--accent-blue-light);
}

/* Sections */
.section {
    margin-bottom: 32px;
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Inputs Grid */
.inputs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group.full-width {
    grid-column: 1 / -1;
}

.input-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper input {
    width: 100%;
    padding: 14px 16px;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: inherit;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrapper.currency input {
    padding-left: 32px;
}

.input-wrapper.percent input {
    padding-right: 40px;
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.input-wrapper .prefix,
.input-wrapper .suffix {
    position: absolute;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 500;
    pointer-events: none;
}

.input-wrapper .prefix {
    left: 12px;
}

.input-wrapper .suffix {
    right: 12px;
}

select {
    width: 100%;
    padding: 14px 16px;
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

select:focus {
    outline: none;
    border-color: var(--accent-blue);
}

/* Checkbox Styles */
.exemption-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 22px;
    height: 22px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-input);
    position: relative;
    transition: all 0.2s;
    flex-shrink: 0;
}

.checkbox-label input:checked + .checkmark {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
}

.checkbox-label input:checked + .checkmark::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 6px;
    height: 12px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.exemption-savings {
    background: var(--bg-card);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.exemption-savings strong {
    color: var(--texas-gold);
}

/* Results Section */
.results-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 24px;
    margin-bottom: 32px;
}

.result-cards {
    margin-bottom: 24px;
}

.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.result-card.total {
    background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 100%);
    border-color: var(--accent-blue);
    text-align: center;
}

.result-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.result-card.total .result-label {
    color: var(--accent-blue-light);
}

.result-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.result-card.total .result-value {
    font-size: 2.5rem;
    color: white;
}

/* Breakdown Bars */
.breakdown-bars {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.breakdown-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.breakdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.breakdown-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.breakdown-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.breakdown-bar {
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}

.breakdown-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.breakdown-fill.pi { background: var(--color-pi); }
.breakdown-fill.tax { background: var(--color-tax); }
.breakdown-fill.insurance { background: var(--color-insurance); }
.breakdown-fill.pmi { background: var(--color-pmi); }
.breakdown-fill.hoa { background: var(--color-hoa); }

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px;
    text-align: center;
}

.summary-card.highlight {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.15) 0%, rgba(239, 68, 68, 0.1) 100%);
    border-color: var(--texas-red);
}

.summary-label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.summary-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.summary-card.highlight .summary-value {
    color: var(--texas-red-light);
}

/* Chart */
.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
}

.chart-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 16px;
    text-align: center;
}

.chart-container canvas {
    max-height: 250px;
}

/* Amortization Table */
.amortization-section {
    display: flex;
    flex-direction: column;
}

.amortization-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.amortization-toggle:hover {
    background: var(--bg-input);
    border-color: var(--accent-blue);
}

.amortization-toggle svg {
    transition: transform 0.2s;
}

.amortization-toggle.open svg {
    transform: rotate(180deg);
}

.amortization-wrapper {
    display: none;
    margin-top: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    max-height: 400px;
    overflow-y: auto;
}

.amortization-wrapper.open {
    display: block;
}

.amortization-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.amortization-table th {
    background: var(--bg-secondary);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
}

.amortization-table td {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    color: var(--text-primary);
}

.amortization-table tr:hover td {
    background: var(--bg-secondary);
}

/* Comparison Section */
.comparison-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 24px;
    margin-bottom: 32px;
}

.comparison-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.comparison-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.comparison-row.header {
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.comparison-row.total {
    border-bottom: none;
    padding-top: 16px;
    font-weight: 700;
}

.comparison-row span:first-child {
    color: var(--text-secondary);
}

.texas-value {
    color: var(--texas-red-light);
    font-weight: 600;
}

.texas-value.good {
    color: #22c55e;
}

.national-value {
    color: var(--text-muted);
}

/* Share Section */
.share-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 32px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
}

.share-section p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.share-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--accent-blue);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.share-btn:hover {
    background: var(--accent-blue-light);
    transform: translateY(-1px);
}

.share-btn.copied {
    background: #22c55e;
}

/* FAQ Section */
.faq-section {
    margin-bottom: 32px;
}

.faq-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 24px;
    text-align: center;
}

.faq-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.faq-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: border-color 0.2s;
}

.faq-item:hover {
    border-color: var(--accent-blue-dark);
}

.faq-item[open] {
    border-color: var(--accent-blue);
}

.faq-question {
    padding: 18px 20px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.faq-question::-webkit-details-marker {
    display: none;
}

.faq-question::after {
    content: '+';
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--accent-blue);
    transition: transform 0.2s;
}

.faq-item[open] .faq-question::after {
    content: '-';
}

.faq-question:hover {
    background: var(--bg-secondary);
}

.faq-answer {
    padding: 0 20px 20px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
}

.faq-answer p {
    margin-bottom: 12px;
}

.faq-answer p:last-child {
    margin-bottom: 0;
}

.faq-answer ul {
    margin: 12px 0;
    padding-left: 24px;
}

.faq-answer li {
    margin-bottom: 6px;
}

.faq-answer strong {
    color: var(--accent-blue-light);
}

/* Footer */
.footer {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.footer-note {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.7;
}

/* Responsive */
@media (max-width: 480px) {
    .inputs-grid {
        grid-template-columns: 1fr;
    }

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

    .comparison-row {
        grid-template-columns: 1.2fr 0.9fr 0.9fr;
        font-size: 0.8rem;
    }

    .result-card.total .result-value {
        font-size: 2rem;
    }
}

@media (min-width: 480px) {
    .app {
        padding: 40px 24px 80px;
    }

    .title {
        font-size: 2.5rem;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue-dark);
}

/* Number input arrows */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    opacity: 1;
    height: 30px;
}
