/* Probability of Running Out of Money Calculator - Enhanced Styles */
/* Scoped with .prc- to avoid theme collisions */

.prc-root {
    /* Color system - UK-focused palette */
    --prc-primary: #0d9488;
    --prc-primary-light: #14b8a6;
    --prc-primary-dark: #0f766e;
    --prc-success: #16a34a;
    --prc-success-light: #22c55e;
    --prc-warning: #f59e0b;
    --prc-danger: #dc2626;
    --prc-danger-light: #ef4444;
    --prc-info: #2563eb;
    --prc-border: #e5e7eb;
    --prc-border-dark: #d1d5db;
    --prc-bg: #ffffff;
    --prc-bg-light: #f9fafb;
    --prc-text: #111827;
    --prc-text-muted: #6b7280;
    --prc-text-light: #9ca3af;

    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--prc-text);
    max-width: 1100px;
    margin: 0 auto 3rem;
    padding: 1.5rem;
    background: var(--prc-bg);
    border: 1px solid var(--prc-border);
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    box-sizing: border-box;
}

.prc-root * {
    box-sizing: border-box;
}

.prc-inner {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.prc-header {
    border-bottom: 2px solid var(--prc-primary);
    padding-bottom: 1.5rem;
    margin-bottom: 0.5rem;
}

.prc-title {
    margin: 0 0 0.5rem;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--prc-text);
    line-height: 1.2;
}

.prc-subtitle {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--prc-text-muted);
}

.prc-intro {
    margin: 0;
    font-size: 0.95rem;
    color: var(--prc-text-muted);
    line-height: 1.6;
}

.prc-layout {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Steps */

.prc-steps {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.prc-step {
    background: var(--prc-bg);
    border-radius: 12px;
    border: 1px solid var(--prc-border);
    border-left: 4px solid var(--prc-primary);
    padding: 1.25rem 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.2s;
}

.prc-step:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.06);
}

.prc-step-title {
    margin: 0 0 0.5rem;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--prc-text);
}

.prc-step-desc {
    margin: 0 0 1rem;
    font-size: 0.9rem;
    color: var(--prc-text-muted);
    line-height: 1.5;
}

/* Grid */

.prc-grid {
    display: grid;
    gap: 0.75rem 1rem;
    margin-bottom: 0.75rem;
}

.prc-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.prc-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 900px) {
    .prc-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 720px) {
    .prc-grid-2,
    .prc-grid-3 {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Fields */

.prc-field {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.prc-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--prc-text);
    margin-bottom: 0.25rem;
}

.prc-input {
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--prc-border-dark);
    background: var(--prc-bg);
    width: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-height: 38px;
}

.prc-input:focus {
    outline: none;
    border-color: var(--prc-primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.prc-input:hover {
    border-color: var(--prc-primary-light);
}

.prc-help {
    font-size: 0.8rem;
    color: var(--prc-text-muted);
    line-height: 1.4;
    margin-top: 0.25rem;
}

.prc-input-wrapper {
    display: flex;
    align-items: center;
    position: relative;
}

.prc-input-wrapper--currency {
    position: relative;
}

.prc-input-wrapper--currency input {
    padding-left: 1.75rem;
}

.prc-input-prefix {
    position: absolute;
    left: 0.75rem;
    color: var(--prc-text-muted);
    font-weight: 500;
    pointer-events: none;
    z-index: 1;
    font-size: 0.9rem;
}

.prc-suffix {
    font-size: 0.8rem;
    color: var(--prc-text-muted);
    margin-left: 0.25rem;
}

/* Radios & checkboxes */

.prc-radio-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.875rem;
    padding: 0.5rem 0.875rem;
    border-radius: 8px;
    border: 1px solid var(--prc-border);
    background: var(--prc-bg-light);
    cursor: pointer;
    transition: all 0.2s;
}

.prc-radio-row:hover {
    background: #f3f4f6;
    border-color: var(--prc-primary-light);
}

.prc-radio-row:has(input:checked) {
    background: rgba(13, 148, 136, 0.1);
    border-color: var(--prc-primary);
}

.prc-radio {
    margin-top: 0.15rem;
    accent-color: var(--prc-primary);
    cursor: pointer;
}

.prc-radio-label {
    font-weight: 500;
    color: var(--prc-text);
    cursor: pointer;
    flex: 1;
}

.prc-checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    cursor: pointer;
}

.prc-checkbox {
    width: 14px;
    height: 14px;
}

.prc-checkbox-label {
    color: #374151;
}

.prc-mode-toggle {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-top: 0.5rem;
}

/* Summary */

.prc-results {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.prc-summary {
    background: var(--prc-bg);
    border-radius: 12px;
    border: 1px solid var(--prc-border);
    border-left: 4px solid var(--prc-primary);
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.prc-summary-title {
    margin: 0 0 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--prc-text);
}

.prc-summary-text {
    margin: 0 0 1.25rem;
    font-size: 0.9rem;
    color: var(--prc-text-muted);
    line-height: 1.6;
}

.prc-summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.prc-card {
    background: var(--prc-bg-light);
    border-radius: 10px;
    border: 1px solid var(--prc-border);
    padding: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.prc-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.prc-card-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--prc-text-muted);
    margin-bottom: 0.5rem;
}

.prc-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--prc-text);
    margin-bottom: 0.5rem;
}

.prc-card-value--success {
    color: var(--prc-success);
}

.prc-card-value--danger {
    color: var(--prc-danger);
}

.prc-card-note {
    font-size: 0.8rem;
    color: var(--prc-text-muted);
    line-height: 1.4;
}

/* Sections and tables */

.prc-section {
    background: var(--prc-bg);
    border-radius: 12px;
    border: 1px solid var(--prc-border);
    padding: 1.25rem 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
    margin-bottom: 1.5rem;
}

.prc-section-title {
    margin: 0 0 0.75rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--prc-text);
}

.prc-section-note {
    margin: 0 0 1rem;
    font-size: 0.85rem;
    color: var(--prc-text-muted);
    line-height: 1.5;
}

.prc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.prc-table th,
.prc-table td {
    border: 1px solid var(--prc-border);
    padding: 0.5rem 0.75rem;
    text-align: right;
}

.prc-table th:first-child,
.prc-table td:first-child {
    text-align: left;
}

.prc-table thead {
    background: var(--prc-bg-light);
}

.prc-table thead th {
    font-weight: 600;
    color: var(--prc-text);
}

.prc-table--compact tbody tr:nth-child(even) {
    background: var(--prc-bg-light);
}

.prc-table tbody tr:hover {
    background: rgba(13, 148, 136, 0.05);
}

/* Badges */

.prc-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
}

.prc-badge--success {
    background: rgba(22, 163, 74, 0.1);
    color: var(--prc-success);
    border: 1px solid rgba(22, 163, 74, 0.2);
}

.prc-badge--fail {
    background: rgba(220, 38, 38, 0.1);
    color: var(--prc-danger);
    border: 1px solid rgba(220, 38, 38, 0.2);
}

.prc-det-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

/* Charts */

.prc-chart-wrapper {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--prc-bg-light);
    border-radius: 8px;
    position: relative;
}

.prc-chart-container {
    position: relative;
    height: 400px;
    width: 100%;
}

.prc-chart-svg {
    width: 100%;
    height: auto;
    max-height: 400px;
}

.prc-axis {
    stroke: var(--prc-text-light);
    stroke-width: 1.5;
}

.prc-line {
    /* Colors are set inline in JavaScript, don't override */
}

.prc-tick {
    stroke: var(--prc-text-light);
    stroke-width: 1;
}

.prc-tick-label {
    font-size: 0.75rem;
    fill: var(--prc-text-muted);
    text-anchor: end;
    white-space: pre;
}

.prc-chart-caption {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--prc-text-muted);
    line-height: 1.6;
}

/* Loading */

.prc-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    background: var(--prc-bg);
    border-radius: 12px;
    border: 1px solid var(--prc-border);
    margin-top: 2rem;
}

.prc-loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--prc-border);
    border-top-color: var(--prc-primary);
    border-radius: 50%;
    animation: prc-spin 0.8s linear infinite;
    margin-bottom: 1rem;
}

@keyframes prc-spin {
    to {
        transform: rotate(360deg);
    }
}

.prc-loading p {
    margin: 0;
    color: var(--prc-text-muted);
    font-size: 0.9rem;
}

/* Responsive tweaks */

@media (max-width: 900px) {
    .prc-summary-cards {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

@media (max-width: 720px) {
    .prc-grid-2,
    .prc-grid-3 {
        grid-template-columns: minmax(0, 1fr);
    }
    
    .prc-summary-cards {
        grid-template-columns: minmax(0, 1fr);
    }
    
    .prc-chart-container {
        height: 300px;
    }
}

@media (max-width: 600px) {
    .prc-root {
        padding: 1rem;
        margin: 0 auto 2rem;
    }
    
    .prc-step {
        padding: 1rem;
    }
    
    .prc-section {
        padding: 1rem;
    }
}

/* Print */

@media print {
    .prc-root {
        border: none;
        box-shadow: none;
        max-width: 100%;
        padding: 0;
    }
    .prc-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}
