/* Custom CSS for BC SR&ED Salary Arbitrage Calculator */

/* Color variables for modern design systems */
:root {
    /* Color tokens - Dark Theme (Default) */
    --bg-color: #0b0f19;
    --card-bg: rgba(22, 28, 45, 0.6);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-hover-border: rgba(255, 255, 255, 0.15);
    --text-color: #f3f4f6;
    --text-muted: #9ca3af;
    --text-inverse: #0b0f19;
    --divider-color: rgba(255, 255, 255, 0.1);
    --glow-opacity: 0.15;
    --slider-track: #1e293b;
    --shadow-color: rgba(0, 0, 0, 0.4);
    
    /* Shared accents (highly saturated) */
    --emerald-accent: #10b981;
    --emerald-glow: rgba(16, 185, 129, 0.35);
    --orange-accent: #f97316;
    --orange-glow: rgba(249, 115, 22, 0.35);
    --blue-accent: #3b82f6;
    --blue-glow: rgba(59, 130, 246, 0.35);
    --red-accent: #ef4444;
    --red-glow: rgba(239, 68, 68, 0.35);
    --neutral-grey: #64748b;
    
    /* Font families */
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-header: 'Outfit', sans-serif;
    
    /* Transition defaults */
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease-out;
}

/* Light Theme overrides */
body.light-theme {
    --bg-color: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.8);
    --card-border: rgba(0, 0, 0, 0.06);
    --card-hover-border: rgba(0, 0, 0, 0.12);
    --text-color: #0f172a;
    --text-muted: #64748b;
    --text-inverse: #ffffff;
    --divider-color: rgba(0, 0, 0, 0.08);
    --glow-opacity: 0.04;
    --slider-track: #e2e8f0;
    --shadow-color: rgba(15, 23, 42, 0.08);
    
    --emerald-glow: rgba(16, 185, 129, 0.15);
    --orange-glow: rgba(249, 115, 22, 0.15);
    --blue-glow: rgba(59, 130, 246, 0.15);
    --red-glow: rgba(239, 68, 68, 0.15);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow-x: hidden;
    padding: 1.5rem;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* Background Ambient Glows */
.background-glows {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: var(--glow-opacity);
    transition: var(--transition-smooth);
}

.glow-1 {
    top: -10%;
    right: 10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--emerald-accent) 0%, transparent 70%);
}

.glow-2 {
    bottom: -10%;
    left: 5%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--orange-accent) 0%, transparent 70%);
}

/* Main Container */
.app-container {
    width: 100%;
    max-width: 1200px;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--divider-color);
    padding-bottom: 1.25rem;
    transition: var(--transition-smooth);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, var(--emerald-accent) 0%, var(--blue-accent) 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.app-header h1 {
    font-family: var(--font-header);
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.badge-year {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    background-color: var(--blue-glow);
    color: var(--blue-accent);
    border: 1px solid rgba(59, 130, 246, 0.2);
    vertical-align: middle;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 0.25rem;
    font-weight: 400;
}

.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--card-border);
    background-color: var(--card-bg);
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 6px var(--shadow-color);
}

.theme-toggle:hover {
    transform: scale(1.05);
    border-color: var(--card-hover-border);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.1fr 1.3fr;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Panel columns styling */
.panel-left, .panel-right {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Card Styling */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 8px 32px var(--shadow-color);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: var(--transition-smooth);
}

.glass-card:hover {
    border-color: var(--card-hover-border);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.card-title-icon {
    font-size: 1.1rem;
    color: var(--blue-accent);
}

.card-header h2 {
    font-family: var(--font-header);
    font-size: 1.2rem;
    font-weight: 700;
}

/* Inputs Card */
.input-group {
    margin-bottom: 1.75rem;
}

.input-label-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.input-label-container label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
}

.value-display {
    font-family: var(--font-header);
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--blue-accent);
    background-color: var(--blue-glow);
    padding: 0.2rem 0.6rem;
    border-radius: 8px;
    transition: var(--transition-fast);
}

.slider-wrapper {
    position: relative;
}

.custom-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: var(--slider-track);
    outline: none;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.custom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--blue-accent);
    border: 3px solid var(--text-inverse);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    transition: var(--transition-fast);
}

.custom-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    background: var(--emerald-accent);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.6);
}

.custom-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--blue-accent);
    border: 3px solid var(--text-inverse);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    transition: var(--transition-fast);
}

.custom-slider::-moz-range-thumb:hover {
    transform: scale(1.15);
    background: var(--emerald-accent);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.6);
}

.slider-ticks {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
    position: relative;
    height: 15px;
}

.tick-cap {
    position: absolute;
    transform: translateX(-50%);
    font-weight: 700;
    color: var(--emerald-accent);
    cursor: help;
    border-bottom: 1px dashed var(--emerald-accent);
}

/* Presets */
.presets-section {
    margin-top: 1.25rem;
    border-top: 1px solid var(--divider-color);
    padding-top: 1.25rem;
}

.presets-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
    font-weight: 600;
}

.presets-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.preset-btn {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    color: var(--text-color);
    padding: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.preset-btn:hover {
    background-color: var(--blue-glow);
    border-color: var(--blue-accent);
    color: var(--text-color);
}

.preset-btn.active {
    background-color: var(--blue-accent);
    color: white;
    border-color: var(--blue-accent);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

/* Collapsible Detailed Calculations Card */
.collapsible-card {
    cursor: pointer;
}

.collapsible-card .card-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0, 1, 0, 1); /* Quick slide transition */
    cursor: default;
}

.collapsible-card.open .card-body {
    max-height: 1000px; /* Expand fully */
    transition: max-height 0.5s cubic-bezier(1, 0, 1, 0);
}

.toggle-icon {
    margin-left: auto;
    font-size: 0.9rem;
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

.collapsible-card.open .toggle-icon {
    transform: rotate(180deg);
}

.math-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 500;
}

.math-value {
    font-family: var(--font-header);
    font-weight: 700;
    font-size: 1rem;
}

.math-subtext {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    line-height: 1.4;
}

.formula-text {
    font-family: monospace;
    font-size: 0.75rem;
    background-color: rgba(255, 255, 255, 0.05);
    padding: 0.05rem 0.2rem;
    border-radius: 4px;
    border: 1px solid var(--card-border);
}

.divider {
    border: none;
    border-top: 1px solid var(--divider-color);
    margin: 0.85rem 0;
}

.highlight-green {
    color: var(--emerald-accent);
}

.highlight-orange {
    color: var(--orange-accent);
}

.tax-bracket-list {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    background-color: rgba(0, 0, 0, 0.15);
    padding: 0.6rem;
    border-radius: 8px;
    border: 1px solid var(--card-border);
}

body.light-theme .tax-bracket-list {
    background-color: rgba(0, 0, 0, 0.02);
}

.tax-bracket-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.tax-bracket-row.active-bracket {
    color: var(--text-color);
    font-weight: 600;
}

/* Metric Hero (Top Right) */
.metric-hero {
    display: flex;
    flex-direction: column;
    padding: 1.75rem;
    position: relative;
    overflow: hidden;
    transition: var(--transition-smooth);
}

.metric-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    transition: var(--transition-smooth);
}

.metric-hero.positive::before {
    background-color: var(--emerald-accent);
}

.metric-hero.negative::before {
    background-color: var(--red-accent);
}

.metric-hero.positive {
    box-shadow: 0 8px 32px var(--emerald-glow), inset 0 0 12px rgba(16, 185, 129, 0.05);
}

.metric-hero.negative {
    box-shadow: 0 8px 32px var(--red-glow), inset 0 0 12px rgba(239, 68, 68, 0.05);
}

.hero-label {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.hero-value-container {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.hero-value {
    font-family: var(--font-header);
    font-size: 3.25rem;
    font-weight: 900;
    letter-spacing: -0.03em;
    line-height: 1;
    transition: var(--transition-fast);
}

.metric-hero.positive .hero-value {
    color: var(--emerald-accent);
    text-shadow: 0 0 15px rgba(16, 185, 129, 0.2);
}

.metric-hero.negative .hero-value {
    color: var(--red-accent);
    text-shadow: 0 0 15px rgba(239, 68, 68, 0.2);
}

.hero-badge {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: 8px;
    transition: var(--transition-smooth);
}

.metric-hero.positive .hero-badge {
    background-color: var(--emerald-glow);
    color: var(--emerald-accent);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.metric-hero.negative .hero-badge {
    background-color: var(--red-glow);
    color: var(--red-accent);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.hero-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
    line-height: 1.5;
}

.hero-desc strong {
    color: var(--text-color);
}

/* Visualization Card */
.visualization-card {
    display: flex;
    flex-direction: column;
}

.chart-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Dual Bar Visualizer */
.dual-bar-container {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    background-color: rgba(0, 0, 0, 0.15);
    padding: 1.25rem;
    border-radius: 16px;
    border: 1px solid var(--card-border);
}

body.light-theme .dual-bar-container {
    background-color: rgba(0, 0, 0, 0.02);
}

.bar-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
}

.bar-label strong {
    font-family: var(--font-header);
    font-size: 0.95rem;
    font-weight: 700;
}

.tax-color {
    color: var(--orange-accent);
}

.sred-color {
    color: var(--emerald-accent);
}

.bar-track {
    height: 12px;
    background-color: var(--slider-track);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.bar-fill {
    height: 100%;
    border-radius: 6px;
    width: 0; /* Updated via JS */
    transition: width 0.4s cubic-bezier(0.1, 0.8, 0.3, 1);
}

.tax-bar {
    background: linear-gradient(90deg, var(--orange-accent) 0%, #ea580c 100%);
    box-shadow: 0 0 10px rgba(249, 115, 22, 0.3);
}

.sred-bar {
    background: linear-gradient(90deg, var(--emerald-accent) 0%, #059669 100%);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

.bar-percentage {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
    align-self: flex-end;
}

/* Trend Line Chart Section */
.trend-chart-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

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

.trend-chart-header h3 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-color);
}

.legend-items {
    display: flex;
    gap: 0.75rem;
}

.legend-item {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.tax-dot {
    background-color: var(--orange-accent);
}

.sred-dot {
    background-color: var(--emerald-accent);
}

.surplus-dot {
    background-color: var(--blue-accent);
}

.svg-container {
    position: relative;
    width: 100%;
    height: 160px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    border: 1px solid var(--card-border);
    padding: 5px;
}

body.light-theme .svg-container {
    background-color: rgba(0, 0, 0, 0.01);
}

#trendSvg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.trend-chart-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    position: relative;
    height: 15px;
}

.capped-label-indicator {
    position: absolute;
    transform: translateX(-50%);
    color: var(--text-muted);
    font-weight: 600;
}

/* Tooltip on Line Chart */
.chart-tooltip {
    position: absolute;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    color: white;
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    transition: opacity 0.15s ease, transform 0.1s ease;
    transform: translate(-50%, -105%);
}

body.light-theme .chart-tooltip {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(0, 0, 0, 0.1);
    color: #0f172a;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

/* Optimal Range Indicator Widget */
.optimal-indicator-container {
    border-top: 1px solid var(--divider-color);
    padding-top: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.indicator-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-color);
}

.indicator-header i {
    color: var(--blue-accent);
}

.optimal-slider-track {
    height: 8px;
    background-color: var(--slider-track);
    border-radius: 4px;
    position: relative;
    margin: 0.5rem 0;
}

.optimal-zone-highlight {
    position: absolute;
    height: 100%;
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.15) 0%, rgba(16, 185, 129, 0.3) 50%, rgba(59, 130, 246, 0.15) 100%);
    border-left: 1.5px solid var(--emerald-accent);
    border-right: 1.5px solid var(--emerald-accent);
    border-radius: 2px;
    /* Position set in JS based on calculations */
}

body.light-theme .optimal-zone-highlight {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.05) 0%, rgba(16, 185, 129, 0.2) 50%, rgba(59, 130, 246, 0.05) 100%);
}

.current-position-dot {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: var(--blue-accent);
    border: 3px solid var(--text-inverse);
    top: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 8px var(--blue-accent);
    transition: left 0.4s cubic-bezier(0.1, 0.8, 0.3, 1);
}

.optimal-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

#optimalRangeText {
    color: var(--emerald-accent);
    font-weight: 700;
}

#optimalDeltaText {
    font-weight: 600;
}

/* Footer styling */
.app-footer {
    text-align: center;
    border-top: 1px solid var(--divider-color);
    padding-top: 1.25rem;
    padding-bottom: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Transitions for dynamic layout classes */
.card-body, .hero-value, .hero-badge, .preset-btn {
    will-change: transform, opacity, max-height;
}
