/* shared.css — Common styles for both customer and provider pages */

:root {
    --sidebar-width: 340px;
    --bg: #f8fafc;
    --card-bg: #fff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --green: #16a34a;
    --red: #dc2626;
    --orange: #ea580c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* Header */
header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
header h1 { font-size: 18px; font-weight: 600; }
header .subtitle { color: var(--text-muted); font-size: 13px; }
header .badge {
    background: #dbeafe; color: var(--accent);
    padding: 3px 10px; border-radius: 12px;
    font-size: 12px; font-weight: 500;
}

/* Layout */
.layout {
    display: flex;
    height: calc(100vh - 52px);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    min-width: 0;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    transition: width 0.2s, padding 0.2s, opacity 0.2s;
}
.sidebar.collapsed {
    width: 0;
    padding: 0;
    opacity: 0;
    pointer-events: none;
}

/* Sidebar resize handle + collapse toggle */
.sidebar-handle {
    flex: none;
    width: 6px;
    cursor: ew-resize;
    background: var(--border);
    position: relative;
    transition: background 0.15s;
    z-index: 5;
}
.sidebar-handle:hover { background: var(--accent); }
.sidebar.collapsed + .sidebar-handle { cursor: default; }

.sidebar-toggle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--card-bg);
    cursor: pointer;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    z-index: 6;
    transition: all 0.15s;
    padding: 0;
}
.sidebar-toggle:hover {
    background: #f1f5f9;
    border-color: var(--accent);
    color: var(--accent);
}

.sidebar h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 20px 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.sidebar h2:first-child { margin-top: 0; }

.control-group {
    margin-bottom: 14px;
}

.control-group label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
}

.control-group .val {
    color: var(--accent);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.control-group select,
.control-group input[type="range"] {
    width: 100%;
}

select {
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    background: var(--card-bg);
    cursor: pointer;
}

input[type="range"] {
    -webkit-appearance: none;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    outline: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}

/* Checkbox row */
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
}
.checkbox-row input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--accent);
}

/* Scenario buttons */
.scenario-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 10px;
}
.scenario-buttons button {
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card-bg);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.scenario-buttons button:hover {
    background: #f1f5f9;
    border-color: var(--accent);
}

/* New scenario + seed */
.action-row {
    display: flex;
    gap: 8px;
    margin: 12px 0;
}
.action-row button {
    flex: 1;
    padding: 8px 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.action-row button:hover { background: var(--accent-hover); }

/* Advanced toggle */
.advanced-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-top: 1px solid var(--border);
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

/* Advanced panel */
#advanced-panel {
    display: none;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

/* Main area */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Summary cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    padding: 16px 20px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}
.card {
    text-align: center;
}
.card .card-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.card .card-value {
    font-size: 18px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Chart */
.chart-container {
    flex: 1;
    padding: 12px 20px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.chart-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}
.product-badge {
    background: #dbeafe;
    color: var(--accent);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.chart-hint {
    font-size: 12px;
    color: var(--text-muted);
}
#chart {
    width: 100%;
    flex: 1;
    min-height: 0;
}

/* Footer */
.footer {
    padding: 6px 20px;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
}

/* Provider Panel (legacy) */
.provider-panel {
    display: none;
    border-top: 2px solid var(--border);
    background: var(--card-bg);
}
.provider-panel.active {
    display: block;
}
.provider-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
}
.provider-panel-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}
.provider-actions {
    display: flex;
    gap: 8px;
}
.provider-actions button {
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card-bg);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.provider-actions button:hover {
    background: #f1f5f9;
    border-color: var(--accent);
}
.provider-table-wrap {
    max-height: 400px;
    overflow: auto;
    padding: 0 20px 12px;
    position: relative;
}
.provider-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-variant-numeric: tabular-nums;
}
.provider-table th {
    position: sticky;
    top: 0;
    background: var(--card-bg);
    border-bottom: 2px solid var(--border);
    padding: 6px 8px;
    text-align: right;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    z-index: 1;
}
.provider-table th:first-child { text-align: center; }
.provider-table td {
    padding: 3px 8px;
    text-align: right;
    border-bottom: 1px solid #f1f5f9;
    white-space: nowrap;
}
.provider-table td:first-child { text-align: center; font-weight: 500; }
.provider-table tbody tr:hover { background: #eff6ff; }
.provider-table tbody tr.highlighted {
    background: #dbeafe;
    outline: 1px solid var(--accent);
}
.provider-table tbody tr.anniversary td:first-child {
    border-left: 3px solid var(--accent);
}
.provider-table tbody tr.inactive td { opacity: 0.4; }

/* Highlight classes */
.hl-ratchet { background: #fff7ed; color: var(--orange); font-weight: 600; }
.hl-insurer-pays { background: #fef2f2; color: var(--red); font-weight: 600; }
.hl-wd-start { background: #eff6ff; color: var(--accent); font-weight: 600; }
.hl-annuitized { background: #f5f3ff; color: #7c3aed; font-weight: 600; }

/* Mobile */
@media (max-width: 900px) {
    .layout { flex-direction: column; height: auto; }
    .sidebar { width: 100%; min-width: 100%; border-right: none; border-bottom: 1px solid var(--border); max-height: 50vh; }
    .summary-cards { grid-template-columns: repeat(3, 1fr); }
    .chart-container { min-height: 400px; }
}

@media (max-width: 600px) {
    .summary-cards { grid-template-columns: repeat(2, 1fr); }
    .chart-container { min-height: 280px; padding: 8px 10px; }
    .chart-hint { display: none; }
    .footer { flex-direction: column; gap: 4px; text-align: center; font-size: 11px; }
    .sidebar { max-height: 40vh; }
    .card-label { font-size: 10px; }
    .card .card-value { font-size: 15px; }
}

/* GMWB-only / ratchet-only / gmib-only conditional */
.gmwb-only, .ratchet-only, .gmib-only { transition: opacity 0.2s; }

/* ── Tooltips ── */
[data-tip] { cursor: help; }

.ml-tooltip {
    position: fixed;
    z-index: 10000;
    max-width: 320px;
    padding: 6px 10px;
    background: #1e293b;
    color: #f1f5f9;
    font-size: 12px;
    line-height: 1.4;
    border-radius: 6px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}
.ml-tooltip.visible { opacity: 1; }
