/**
 * Nickerson BurnRate Financial Planning Styles
 * Dark theme with cyan accents inspired by animals.handlebars
 */

/* Version badge — top left, hidden on mobile */
.version-badge {
    position: fixed;
    top: 4px;
    left: 6px;
    font-size: 10px;
    color: #555;
    z-index: 9999;
    pointer-events: none;
}
.dev-restart-btn {
    display: none;
    position: fixed;
    bottom: 10px;
    left: 10px;
    z-index: 9999;
    background: #333;
    color: #f39c12;
    border: 1px solid #555;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 16px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
}
.dev-restart-btn:hover {
    opacity: 1;
    background: #444;
}
@media (max-width: 768px) {
    .version-badge { display: none; }
}

body {
    font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: #1a1a1a;
    color: #dcdcdc;
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

/* Main Container — centers within available space (after left nav) */
.container {
    background-color: #333333;
    min-height: 100vh;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
    box-sizing: border-box;
    overflow: visible;
    min-width: min-content; /* Grow with table instead of clipping */
}

/* Header */
.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid #444;
}

.header-bar h1 {
    margin: 0;
    color: #66ccff;
    font-size: 2em;
}

.btn-logout {
    background-color: #444;
    color: #dcdcdc;
    padding: 10px 20px;
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.btn-logout:hover {
    background-color: #555;
}

/* Scenario Comparison Grid */
.scenario-comparison {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
    margin-bottom: 40px;
}

@media (max-width: 1400px) {
    .scenario-comparison {
        grid-template-columns: 1fr;
    }
}

/* Scenario Cards */
.scenario-card {
    position: relative;
    background-color: #232323;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.scenario-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(102, 204, 255, 0.2);
}

.card-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #444;
}

.card-header h2 {
    margin: 0 0 8px 0;
    color: #66ccff;
    font-size: 1.5em;
}

.card-subtitle {
    margin: 0;
    color: #999;
    font-size: 0.9em;
}

/* LTC Trigger Control */
.ltc-trigger-control {
    margin-bottom: 20px;
}

.ltc-trigger-control label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #66ccff;
}

/* Memory Care Control */
.memory-care-control {
    margin-bottom: 20px;
}

.memory-care-control label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #66ccff;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-container input[type="range"] {
    flex: 1;
    height: 6px;
    background: #444;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #66ccff;
    cursor: pointer;
    border-radius: 50%;
}

.slider-container input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #66ccff;
    cursor: pointer;
    border-radius: 50%;
    border: none;
}

.ltc-value, .memory-care-value, .param-value {
    min-width: 60px;
    text-align: right;
    font-weight: bold;
    color: #66ccff;
}

/* Sell Condo Checkbox */
.sell-condo-control {
    margin-bottom: 12px;
    padding: 10px 15px;
    background: #2a2a2a;
    border-radius: 4px;
    border-left: 3px solid #e6a040;
}

.sell-condo-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.95em;
    color: #dcdcdc;
}

.sell-condo-label:hover {
    color: #e6a040;
}

.sell-condo-toggle {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

/* Advanced Parameters */
.advanced-params-section {
    background-color: #2a2a2a;
    border-radius: 4px;
    margin-bottom: 20px;
    padding: 15px;
}

.param-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: bold;
    color: #66ccff;
}

.param-toggle-label:hover {
    color: #82b1ff;
}

.param-toggle {
    cursor: pointer;
}

.param-sliders {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #444;
}

.param-group {
    margin-bottom: 8px;
    border: 1px solid #444;
    border-radius: 4px;
    background: #252525;
}

.param-group summary {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    color: #aac8e4;
    user-select: none;
}

.param-group summary:hover {
    color: #82b1ff;
    background: #2e2e2e;
}

.param-group[open] summary {
    border-bottom: 1px solid #444;
}

.param-group-body {
    padding: 10px 12px 4px;
}

.param-row {
    margin-bottom: 15px;
}

.param-row label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9em;
    color: #dcdcdc;
}

/* Metrics */
.metrics {
    padding-top: 8px;
}

.metrics h3 {
    margin: 0 0 15px 0;
    font-size: 1.1em;
    color: #66ccff;
    border-bottom: 1px solid #444;
    padding-bottom: 8px;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #333;
}

.metric-row:last-child {
    border-bottom: none;
}

.metric-label {
    color: #999;
    font-size: 0.95em;
    cursor: help;
}

/* Card Footer */
.card-footer {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #444;
    text-align: center;
}

.btn-details {
    display: inline-block;
    padding: 10px 20px;
    background-color: #66ccff;
    color: #1a1a1a;
    text-decoration: none;
    border-radius: 4px;
    font-weight: bold;
    transition: background-color 0.3s;
}

.btn-details:hover {
    background-color: #82b1ff;
}

.metric-value {
    font-weight: bold;
    color: #66ccff;
    font-size: 1.05em;
    text-align: right;
    line-height: 1.4;
}

/* Loading State */
.scenario-card.loading {
    opacity: 0.6;
    pointer-events: none;
}

.scenario-card.loading::after {
    content: "Loading scenario metrics...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #2a2a2a;
    padding: 15px 30px;
    border-radius: 4px;
    border: 2px solid #66ccff;
    color: #66ccff;
    font-weight: bold;
    z-index: 2;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    white-space: nowrap;
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.mb-4 {
    margin-bottom: 40px;
}

/* Tooltips */
[title] {
    position: relative;
}

/* ===== PROJECTION TABLE STYLES ===== */

/* Projection table structure */
.projection-table-wrapper {
    margin-top: 20px;
    position: relative;
}

.projection-table {
    width: 100%;
    min-width: 900px;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
    background-color: #1a1a1a;
}

/* Sticky header — entire thead sticks to viewport top */
.projection-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Section headers (Assets, Cash Flow) */
.section-header {
    background: #34495e;
    color: white;
    padding: 15px;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    border: 1px solid #2c3e50;
}

/* Info icons in header cells — positioned out of text flow */
.projection-table th {
    position: relative;
}
.projection-table th .info-icon {
    position: absolute;
    top: 3px;
    right: 3px;
    font-size: 11px;
    opacity: 0.5;
    cursor: help;
}
.projection-table th .info-icon:hover {
    opacity: 1;
}

/* Table headers */
.projection-table th {
    background: #34495e;
    color: white;
    padding: 12px;
    border: 1px solid #2c3e50;
    text-align: left;
    font-weight: 600;
}

/* Table cells */
.projection-table td {
    padding: 10px;
    border: 1px solid #444;
    background-color: #333;
    color: #dcdcdc;
}

/* Alternating row colors */
.projection-table tbody tr:nth-child(even) td {
    background-color: #2a2a2a;
}

/* Tooltip-enabled cells */
.ira-cell,
.real-estate-cell,
.ltc-cell,
.income-cell,
.expenses-cell {
    cursor: help;
    position: relative;
}

/* Color coding for financial data */
.income-cell {
    color: #27ae60;
    font-weight: 500;
}

.expenses-cell {
    color: #e74c3c;
    font-weight: 500;
}

/* Emphasized cells */
.pool-close {
    font-weight: bold;
    color: #66ccff;
}

.total-assets {
    font-weight: bold;
    background-color: #3a3a3a !important;
    color: #66ccff;
}

/* Responsive table wrapper */
@media (max-width: 1600px) {
    .projection-table {
        font-size: 12px;
    }

    .projection-table th,
    .projection-table td {
        padding: 8px;
    }
}

/* ===== PARAMETER SIDEBAR (slide-out) ===== */

.sidebar-toggle {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    z-index: 1001;
    background-color: #34495e;
    color: #66ccff;
    border: 2px solid #66ccff;
    border-right: none;
    border-radius: 8px 0 0 8px;
    padding: 12px 10px;
    font-size: 22px;
    cursor: pointer;
    transition: background-color 0.3s, right 0.3s;
    line-height: 1;
}

.sidebar-toggle:hover {
    background-color: #3d566e;
}

.sidebar-toggle.shifted {
    right: 330px;
}

.param-sidebar {
    position: fixed;
    top: 0;
    right: -330px;
    width: 330px;
    height: 100%;
    background-color: #1e1e1e;
    border-left: 2px solid #66ccff;
    z-index: 1002;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
}

.param-sidebar.open {
    right: 0;
}

/* Wide screens: param sidebar pushes content */
@media (min-width: 1440px) {
    body.param-sidebar-open .main-content-wrapper {
        margin-right: 330px;
        transition: margin-right 0.3s ease;
    }
}

/* Narrow screens: param sidebar overlaps with transparency */
@media (max-width: 1439px) {
    .param-sidebar {
        background-color: rgba(30, 30, 30, 0.95) !important;
    }
}

.sidebar-header {
    background-color: #34495e;
    color: #66ccff;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #444;
    flex-shrink: 0;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: bold;
}

.sidebar-close {
    background: none;
    border: none;
    color: #66ccff;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.sidebar-close:hover {
    color: #fff;
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

/* Param groups inside sidebar reuse existing .param-group styles */
.param-sidebar .param-group {
    margin-bottom: 8px;
}

.param-sidebar .param-row label {
    font-size: 0.85em;
}

.param-sidebar .slider-container input[type="range"] {
    height: 5px;
}

.param-sidebar .year-of-passing-value {
    min-width: 40px;
    text-align: right;
    font-weight: bold;
    color: #66ccff;
}

/* ===== MOBILE TOOLTIP SIDEBAR ===== */

/* Sidebar overlay (dark background) */
.tooltip-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.tooltip-sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Sidebar panel */
.tooltip-sidebar {
    position: fixed;
    top: 0;
    right: -50vw;
    width: 90%;
    max-width: 400px;
    height: 100%;
    background-color: #2a2a2a;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.tooltip-sidebar.active {
    right: 0;
}

/* Sidebar header */
.tooltip-sidebar-header {
    background-color: #34495e;
    color: #66ccff;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #444;
}

.tooltip-sidebar-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: bold;
}

.tooltip-sidebar-close {
    background: none;
    border: none;
    color: #66ccff;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tooltip-sidebar-close:hover {
    color: #fff;
}

/* Sidebar content */
.tooltip-sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    color: #dcdcdc;
    font-size: 14px;
    line-height: 1.6;
}

.tooltip-sidebar-content pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Open Sans', sans-serif;
    margin: 0;
}

/* Mobile-friendly cell links */
@media (max-width: 768px) {
    .projection-table td[title] {
        cursor: pointer;
        position: relative;
    }

    .projection-table td[title]:hover {
        background-color: #3a3a3a;
    }

    /* Remove default tooltips on mobile */
    .projection-table td[title]:hover::before,
    .projection-table td[title]:hover::after {
        display: none;
    }

    /* Add tap indicator */
    .projection-table td[title]::after {
        content: ' ⓘ';
        font-size: 0.8em;
        color: #66ccff;
        opacity: 0.6;
        margin-left: 4px;
    }
}

/* Desktop: hide mobile tooltip sidebar by default, show when debug button activates it */
@media (min-width: 769px) {
    .tooltip-sidebar-overlay:not(.active),
    .tooltip-sidebar:not(.active) {
        display: none !important;
    }
    .tooltip-sidebar.active {
        width: 50vw;
        max-width: 50vw;
        right: 0;
        resize: none;
    }
}

/* Mobile: no debug info buttons */
@media (max-width: 768px) {
    .debug-cell, .debug-col {
        display: none !important;
    }
}

/* ===== STICKY SCENARIO NAVIGATION ===== */

.scenario-nav-sticky {
    position: fixed;
    top: 0;
    left: 0;
    background-color: #2a2a2a;
    border-bottom: 2px solid #66ccff;
    border-radius: 0 0 8px 0;
    z-index: 1000;
    padding: 6px 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.scenario-nav-sticky.visible {
    opacity: 1;
    pointer-events: auto;
}

.scenario-nav-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-back-link {
    color: #66ccff;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.3s;
}

.nav-back-link:hover {
    color: #82b1ff;
}

.scenario-nav-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.scenario-nav-title {
    margin: 0;
    color: #66ccff;
    font-size: 18px;
    font-weight: bold;
}

.nav-arrow {
    background-color: #444;
    color: #66ccff;
    border: 1px solid #66ccff;
    padding: 8px 15px;
    font-size: 18px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.3s, transform 0.1s;
}

.nav-arrow:hover:not(:disabled) {
    background-color: #555;
    transform: scale(1.05);
}

.nav-arrow:active:not(:disabled) {
    transform: scale(0.95);
}

.nav-arrow:disabled {
    cursor: not-allowed;
    opacity: 0.3;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .scenario-nav-content {
        flex-direction: column;
        gap: 10px;
    }

    .nav-back-link {
        font-size: 12px;
    }

    .scenario-nav-title {
        font-size: 16px;
        text-align: center;
    }

    .nav-arrow {
        padding: 6px 12px;
        font-size: 16px;
    }
}

/* ================================================================
   Left Navigation Sidebar (NAV-002, NAV-003, NAV-004, NAV-005)
   ================================================================ */

:root {
    --left-nav-width: 220px;
}

/* NAV-002: Nav panel — fixed vertically, but scrolls away with horizontal page scroll */
.left-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--left-nav-width);
    height: 100vh;
    background: #1a1a1a;
    border-right: 1px solid #333;
    overflow-y: auto;
    z-index: 1000;
    padding: 12px 0;
    transition: transform 0.1s ease;
}

.left-nav-title {
    font-size: 18px;
    font-weight: 700;
    color: #66ccff;
    padding: 8px 16px 16px;
    border-bottom: 1px solid #333;
    margin-bottom: 8px;
}

.left-nav-section h4 {
    color: #888;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 12px 16px 4px;
    margin: 0;
}

.left-nav-section ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.left-nav-section li a {
    display: block;
    padding: 6px 16px 6px 24px;
    color: #ccc;
    text-decoration: none;
    font-size: 13px;
    transition: background 150ms, color 150ms;
}

.left-nav-section li a:hover {
    background: #2a2a2a;
    color: #fff;
}

.left-nav-section li a.active {
    color: #66ccff;
    background: #222;
    border-left: 3px solid #66ccff;
    padding-left: 21px;
}

/* NAV-003: Toggle button — hidden on desktop, visible on mobile only */
.left-nav-toggle {
    display: none;
}

/* NAV-004: Main content offset by nav width on wide screens, overlay on narrow */
@media (min-width: 1440px) {
    .main-content-wrapper {
        margin-left: var(--left-nav-width);
    }
    .version-badge {
        left: calc(var(--left-nav-width) + 6px) !important;
    }
    .scenario-nav-sticky {
        left: var(--left-nav-width);
    }
}

/* Narrow desktop (1024-1439px): nav overlaps with transparency */
@media (min-width: 1024px) and (max-width: 1439px) {
    .left-nav {
        background: rgba(26, 26, 26, 0.92);
    }
    .main-content-wrapper {
        margin-left: 0;
    }
}

/* NAV-005: Mobile — nav hidden by default, toggle visible, slide-out behavior */
@media (max-width: 1023px) {
    .left-nav {
        left: calc(-1 * var(--left-nav-width));
        transition: left 250ms ease;
    }
    .left-nav.open {
        left: 0;
    }
    .left-nav-toggle {
        display: flex;
        position: fixed;
        top: 8px;
        left: 8px;
        z-index: 1001;
        background: none;
        border: none;
        color: #888;
        font-size: 22px;
        cursor: pointer;
        padding: 8px;
        min-width: 44px;
        min-height: 44px;
        align-items: center;
        justify-content: center;
        border-radius: 4px;
    }
    .left-nav-toggle:hover {
        color: #ccc;
        background: rgba(255,255,255,0.05);
    }
    .main-content-wrapper {
        margin-left: 0;
    }
    body.left-nav-open .main-content-wrapper {
        margin-left: var(--left-nav-width);
        transition: margin-left 250ms ease;
    }
    .version-badge {
        left: 6px !important;
    }
    .scenario-nav-sticky {
        left: 0;
    }
}
