/* ===== Finance Tools Styles ===== */

/* Results Summary */
.results-summary {
    background: linear-gradient(135deg, var(--success-color), #059669) !important;
    color: white;
}

.results-summary h3 {
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
}

.results-summary h3 i {
    color: white;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.summary-item {
    text-align: center;
}

.summary-label {
    display: block;
    font-size: 0.875rem;
    opacity: 0.9;
    margin-bottom: 0.25rem;
}

.summary-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 800;
}

.summary-value.highlight {
    color: #fef08a;
}

@media (max-width: 576px) {
    .summary-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .summary-value {
        font-size: 1.5rem;
    }
}

/* Formula Display */
.formula-display {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.formula-display code {
    display: block;
    font-family: var(--font-mono);
    font-size: 1.125rem;
    color: var(--primary-color);
    background: white;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    text-align: center;
    margin: 0.5rem 0;
}

.formula-legend {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.75rem;
    line-height: 1.6;
}

/* Schedule Table */
.schedule-table-container {
    overflow-x: auto;
    max-height: 400px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.schedule-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.schedule-table th,
.schedule-table td {
    padding: 0.75rem 1rem;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

.schedule-table th {
    background: var(--bg-secondary);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
}

.schedule-table th:first-child,
.schedule-table td:first-child {
    text-align: center;
}

.schedule-table tbody tr:hover {
    background: var(--bg-secondary);
}

.schedule-table tbody tr.highlight {
    background: rgba(99, 102, 241, 0.1);
}

.schedule-table .positive {
    color: var(--success-color);
}

/* Year Breakdown */
.year-breakdown-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 1.25rem;
}

.year-breakdown-card h4 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.breakdown-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
}

.breakdown-row:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

.breakdown-label {
    color: var(--text-secondary);
}

.breakdown-value {
    font-weight: 600;
    font-family: var(--font-mono);
}

.breakdown-value.positive {
    color: var(--success-color);
}

/* Chart Container */
#growthChart {
    max-height: 300px;
}

/* DCF Specific */
.dcf-timeline {
    display: flex;
    overflow-x: auto;
    gap: 1rem;
    padding: 1rem 0;
}

.dcf-period {
    flex-shrink: 0;
    min-width: 120px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: center;
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
}

.dcf-period.active {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(14, 165, 233, 0.1));
}

.dcf-period .period-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.dcf-period .cf-value {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary-color);
}

.dcf-period .pv-value {
    font-size: 0.875rem;
    color: var(--success-color);
    margin-top: 0.25rem;
}

/* Arrow between periods */
.dcf-arrow {
    display: flex;
    align-items: center;
    color: var(--text-light);
}

/* NPV Result */
.npv-result {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: var(--radius-xl);
    padding: 2rem;
    text-align: center;
    color: white;
    margin-top: 1.5rem;
}

.npv-result h4 {
    color: white;
    opacity: 0.9;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.npv-result .npv-value {
    font-size: 2.5rem;
    font-weight: 800;
}

.npv-result .npv-status {
    margin-top: 0.75rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-2xl);
    display: inline-block;
    font-weight: 600;
}

/* DP Table */
.dp-table-container {
    overflow-x: auto;
    padding: 1rem 0;
}

.dp-table {
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.dp-table th,
.dp-table td {
    min-width: 50px;
    height: 50px;
    text-align: center;
    border: 1px solid var(--border-color);
    padding: 0.5rem;
}

.dp-table th {
    background: var(--bg-secondary);
    font-weight: 600;
}

.dp-table td.current {
    background: linear-gradient(135deg, var(--warning-color), #d97706);
    color: white;
    font-weight: 700;
}

.dp-table td.computed {
    background: rgba(99, 102, 241, 0.1);
}

.dp-table td.final {
    background: linear-gradient(135deg, var(--success-color), #059669);
    color: white;
    font-weight: 700;
}

/* Recursion Tree */
.recursion-tree {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
    min-height: 300px;
}

.tree-node {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.25rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.tree-node.active {
    background: linear-gradient(135deg, var(--warning-color), #d97706);
    border-color: var(--warning-color);
    color: white;
}

.tree-node.computed {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.tree-node.returning {
    background: linear-gradient(135deg, var(--success-color), #059669);
    border-color: var(--success-color);
    color: white;
}

.tree-level {
    display: flex;
    gap: 2rem;
    justify-content: center;
}

.tree-connector {
    width: 2px;
    height: 20px;
    background: var(--border-color);
}

/* NPV Tool Styles */
.cash-flow-inputs {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.cash-flow-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.cash-flow-row label {
    min-width: 60px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.cash-flow-row input {
    flex: 1;
    padding: 0.625rem 0;
    font-family: var(--font-mono);
    text-align: right;
}

.cash-flow-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.cash-flow-actions .btn {
    flex: 1;
}

/* Steps Container */
.steps-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.step-item {
    display: flex;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.step-item:hover {
    transform: translateX(5px);
    box-shadow: var(--shadow-sm);
}

.step-item.summary {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(14, 165, 233, 0.1));
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.step-item .step-number {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.step-item .step-content {
    flex: 1;
}

.step-item .step-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.step-item .step-formula {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.step-item .step-calculation {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.step-item .step-calculation strong {
    color: var(--primary-color);
}

.step-item .step-calculation strong.positive {
    color: var(--success-color);
}

.step-item .step-calculation strong.negative {
    color: var(--error-color);
}

.step-item .step-explanation {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* Results Container */
.results-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.result-item.highlight {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(14, 165, 233, 0.1));
    border: 1px solid rgba(99, 102, 241, 0.2);
}

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

.result-value {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 600;
}

.result-value.positive {
    color: var(--success-color);
}

.result-value.negative {
    color: var(--error-color);
}

/* Decision Box */
.decision-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border-left: 4px solid var(--text-light);
}

.decision-box i {
    font-size: 1.5rem;
}

.decision-box.accept {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--success-color);
}

.decision-box.accept i {
    color: var(--success-color);
}

.decision-box.reject {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--error-color);
}

.decision-box.reject i {
    color: var(--error-color);
}

.decision-box.warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: var(--warning-color);
}

.decision-box.warning i {
    color: var(--warning-color);
}

.decision-box.neutral {
    background: rgba(107, 114, 128, 0.1);
    border-color: var(--text-light);
}

.decision-box.neutral i {
    color: var(--text-light);
}

/* Timeline Container */
.timeline-container {
    padding: 1rem 0;
}

.timeline {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    overflow-x: auto;
    padding: 1rem 0;
}

.timeline-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
    text-align: center;
}

.timeline-year {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.timeline-bar {
    width: 40px;
    min-height: 20px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    margin-bottom: 0.5rem;
}

.timeline-bar.positive {
    background: linear-gradient(180deg, var(--primary-color), var(--secondary-color));
}

.timeline-bar.negative {
    background: linear-gradient(180deg, var(--error-color), #ef4444);
}

.timeline-value {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
}

.timeline-value.negative {
    color: var(--error-color);
}

.timeline-pv {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

/* Payback Progress */
.step-progress {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 0.5rem 0;
}

.progress-bar-wrapper {
    flex: 1;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 4px;
    transition: width 0.3s ease;
}

.step-item.complete .step-number {
    background: linear-gradient(135deg, var(--success-color), #059669);
}

.step-item.complete .progress-bar-fill {
    background: linear-gradient(90deg, var(--success-color), #059669);
}

.step-item.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.step-item.error .step-number {
    background: var(--error-color);
}

.step-explanation.success {
    color: var(--success-color);
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: linear-gradient(135deg, var(--success-color), #059669);
    color: white;
    border-radius: var(--radius-2xl);
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

/* Recovery Chart */
.progress-chart-container {
    padding: 1rem 0;
}

.recovery-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    height: 200px;
    position: relative;
    padding-top: 30px;
}

.chart-target-line {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 2px dashed var(--error-color);
}

.chart-target-line .target-label {
    position: absolute;
    right: 0;
    top: -20px;
    font-size: 0.75rem;
    color: var(--error-color);
    background: white;
    padding: 0 0.5rem;
}

.chart-bar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.chart-bar {
    width: 40px;
    background: linear-gradient(180deg, var(--primary-color), var(--secondary-color));
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: all 0.3s ease;
}

.chart-bar.exceeds {
    background: linear-gradient(180deg, var(--success-color), #059669);
}

.chart-bar.payback {
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3);
}

.chart-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.chart-value {
    font-size: 0.7rem;
    font-family: var(--font-mono);
    color: var(--text-light);
}
