/* Tools CSS - Styles for Financial Calculators and Tools */

/* Common Tool Input Styles */
.input-group {
    margin-bottom: 1rem;
}

.input-group-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.input-group-col {
    display: flex;
    flex-direction: column;
}

.input-group-col label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-weight: 500;
    position: relative;
}

.input-group-col input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--gray-medium);
    border-radius: var(--border-radius);
    font-size: 1rem;
}

.input-group label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-weight: 500;
    position: relative;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--gray-medium);
    border-radius: var(--border-radius);
    font-size: 1rem;
}

/* Help Icon with Tooltip */
.help-icon {
    cursor: help;
    font-size: 1rem;
    margin-left: auto;
    display: inline-block;
    vertical-align: middle;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    position: relative;
}

.help-icon:hover {
    opacity: 1;
}

.help-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    top: calc(100% + 8px);
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.95rem;
    line-height: 1.4;
    white-space: nowrap;
    width: auto;
    max-width: none;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-weight: normal;
}

.help-icon::before {
    content: '';
    position: absolute;
    left: 50%;
    top: calc(100% + 2px);
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: #333;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 1001;
}

.help-icon:hover::after,
.help-icon:hover::before {
    opacity: 1;
    transition-delay: 0.1s;
}

/* Wide tooltip for multi-line content with fixed width */
.help-icon-wide::after {
    white-space: pre-line;
    width: 350px;
    max-width: 350px;
    text-align: left;
}

/* Show tooltip above for last row in plan tables */
.plan-table tbody tr:last-child .help-icon::after {
    top: auto;
    bottom: calc(100% + 8px);
}

.plan-table tbody tr:last-child .help-icon::before {
    top: auto;
    bottom: calc(100% + 2px);
    border-bottom-color: transparent;
    border-top-color: #333;
}

/* Show tooltip on the left for last column */
.plan-table td:last-child .help-icon::after {
    left: auto;
    right: 0;
    transform: translateX(0);
}

.plan-table td:last-child .help-icon::before {
    left: auto;
    right: 12px;
    transform: translateX(0);
}

/* Unit Selector Input */
.unit-selector-input {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    align-items: center;
}

.unit-selector-input input {
    flex: 1;
    font-size: 1.1rem;
    font-weight: normal;
}

.unit-buttons {
    display: flex;
    gap: 0.5rem;
}

.unit-buttons button {
    padding: 0.5rem;
    border: 2px solid var(--gray-medium);
    background: white;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.unit-buttons button:hover {
    border-color: var(--secondary-color);
    background: #f8f9fa;
}

.unit-buttons button.active {
    border-color: var(--secondary-color);
    background: var(--secondary-color);
    color: white;
}

/* Mode Toggle Styles */
.mode-toggle {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.mode-toggle button {
    flex: 1;
    padding: 0.5rem 0.875rem;
    border: 2px solid var(--gray-medium);
    background: white;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.mode-toggle button:hover {
    border-color: var(--secondary-color);
    background: #f8f9fa;
}

.mode-toggle button.active {
    border-color: var(--secondary-color);
    background: var(--secondary-color);
    color: white;
}

/* Share Button */
.share-button {
    padding: 0.5rem 1rem;
    border: 2px solid var(--secondary-color);
    background: white;
    color: var(--secondary-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.share-button:hover:not(:disabled) {
    background: var(--secondary-color);
    color: white;
}

.share-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Multi-Unit Input */
.multi-unit-input {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.unit-box {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.unit-box input {
    text-align: center;
    font-weight: 600;
}

.unit-label {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.combo-input {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
}

.combo-input input {
    width: 100%;
}

.combo-input select {
    width: auto;
    min-width: 120px;
}

/* Button Row for Start Month and Calculate */
.button-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    margin-top: 1rem;
}

.start-month-selector {
    flex: 1;
}

.start-month-selector label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: #333;
}

.start-month-selector input[type="month"] {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
}

.calculate-btn,
.view-slides,
.use-tool {
    background: var(--secondary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    margin-top: 0;
    transition: var(--transition);
    flex-shrink: 0;
}

.calculate-btn:hover,
.view-slides:hover,
.use-tool:hover {
    background: var(--primary-color);
}

.calculate-btn:disabled {
    background: var(--gray-medium);
    cursor: not-allowed;
}

/* Results and Summary Styles */
.results {
    background: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    margin-top: 1rem;
    border-left: 4px solid var(--secondary-color);
}

.results h4 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.summary-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.summary-table td {
    padding: 0.75rem;
    border-bottom: 1px solid #eee;
}

.summary-table td:first-child {
    font-weight: 500;
    color: var(--text-color);
}

.summary-table td.highlight {
    font-weight: bold;
    color: var(--secondary-color);
    font-size: 1.2rem;
}

/* Target Fields Background */
.target-group {
    background-color: #e3f2fd;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #90caf9;
    margin-bottom: 20px;
}

/* Investment Parameters Background */
.investment-params-group {
    background-color: #fff3e0;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ffb74d;
}

/* Placeholder Content */
.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: var(--border-radius);
    text-align: center;
}

.placeholder-content h4 {
    color: var(--gray-medium);
    margin-bottom: 1rem;
}

.placeholder-content p {
    color: var(--gray-medium);
    margin-bottom: 1.5rem;
}

.placeholder-features p {
    color: #6c757d;
    margin: 0.5rem 0;
    font-size: 0.9rem;
}

/* Investment Plan Table */
.investment-plan {
    margin-top: 2rem;
}

.investment-plan h4 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.plan-table-wrapper {
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.plan-table {
    width: 100%;
    border-collapse: collapse;
    display: table;
}

.plan-table thead {
    position: sticky;
    top: -1px;
    background: var(--secondary-color);
    color: white;
    z-index: 10;
}

.plan-table thead th {
    border-bottom: 2px solid #ddd;
    background: inherit;
}

.plan-table th,
.plan-table td {
    padding: 0.35rem 0.5rem;
    vertical-align: middle;
    border-bottom: 1px solid #ddd;
}

.plan-table th {
    font-weight: bold;
    text-align: center;
}

.plan-table tbody tr:hover {
    background: #f5f5f5;
}

/* First column (Year/Period) - center aligned */
.plan-table td:first-child {
    text-align: center;
}

/* All other columns (numbers) - right aligned */
.plan-table td:not(:first-child) {
    text-align: right;
}

/* Chart Container */
.chart-section {
    margin-top: 2rem;
}

.chart-container {
    margin-top: 1rem;
}

#sip-chart {
    width: 100%;
    height: 350px;
    min-height: 300px;
}

/* RealValue SIP Engine - Two Column Layout */
.sip-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.sip-inputs {
    background: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border-left: 4px solid #f7b733;
}

.sip-inputs h4 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    font-size: 1.2rem;
}

.sip-outputs {
    background: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border-left: 4px solid #27ae60;
}

.sip-outputs h4 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    font-size: 1.2rem;
}

.sip-summary {
    margin-bottom: 1.5rem;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #eee;
}

.summary-item:last-child {
    border-bottom: none;
}

.summary-item .label {
    font-weight: 500;
    color: var(--text-color);
}

.summary-item .value {
    font-weight: bold;
    color: var(--primary-color);
}

.summary-item .value.highlight {
    color: var(--secondary-color);
    font-size: 1.2rem;
}

/* Emergency Fund Tool - Two Column Layout */
.ef-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.ef-inputs {
    background: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border-left: 4px solid #f7b733;
}

.ef-inputs h4 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    font-size: 1.2rem;
}

.ef-outputs {
    background: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border-left: 4px solid #27ae60;
}

.ef-outputs h4 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    font-size: 1.2rem;
}

/* Input Summary Styling */
.input-summary {
    background: #e8f5e8;
    padding: 1rem;
    border-radius: var(--border-radius);
    margin: 1rem 0;
    border-left: 3px solid #27ae60;
}

.input-summary p {
    margin: 0;
    color: #2c5530;
    font-weight: 500;
}

/* Fund Summary Styling */
.fund-summary {
    margin-bottom: 1.5rem;
}

/* Progress Bar Styling */
.progress-bar-container {
    margin: 1.5rem 0;
    position: relative;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background-color: #f0f0f0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #27ae60, #2ecc71);
    border-radius: 10px;
    transition: width 0.5s ease-in-out;
    animation: progressPulse 2s ease-in-out infinite alternate;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #333;
    font-weight: bold;
    font-size: 0.875rem;
}

@keyframes progressPulse {
    0% {
        box-shadow: 0 0 5px rgba(46, 204, 113, 0.7);
    }

    100% {
        box-shadow: 0 0 20px rgba(46, 204, 113, 0.3);
    }
}

/* Savings Timeline Styling */
.savings-timeline {
    margin-top: 1.5rem;
}

.savings-timeline h5 {
    margin-bottom: 1rem;
    color: var(--primary-color);
    font-size: 1rem;
}

.timeline {
    position: relative;
    padding-left: 1.5rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, var(--secondary-color), var(--accent-color));
}

.timeline-item {
    position: relative;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    border-radius: var(--border-radius);
    border-left: 3px solid var(--secondary-color);
    transition: var(--transition);
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -1.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background: var(--secondary-color);
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 0 2px var(--secondary-color);
}

.timeline-item.goal-achieved {
    background: linear-gradient(135deg, #e8f5e8, #d4edda);
    border-left-color: #27ae60;
    animation: goalAchieved 0.6s ease-in-out;
}

.timeline-item.goal-achieved::before {
    background: #27ae60;
    box-shadow: 0 0 0 2px #27ae60;
}

@keyframes goalAchieved {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.02);
    }

    100% {
        transform: scale(1);
    }
}

/* Recommendations Section */
.recommendations-section {
    grid-column: 1 / -1;
    margin-top: 1rem;
}

.recommendations {
    background: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border-left: 4px solid #f39c12;
}

.recommendations h4 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    font-size: 1.2rem;
}

.recommendations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.recommendation-card {
    background: #fff8e1;
    padding: 1rem;
    border-radius: var(--border-radius);
    border-left: 3px solid #f39c12;
    transition: var(--transition);
}

.recommendation-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Contribution Table Section */
.contribution-table-section {
    margin-top: 2rem;
    margin-bottom: 0;
}

.contribution-grid {
    font-size: 0.9rem;
}

/* Building Wealth theme color for contribution table header */
.contribution-grid thead {
    background: #f39c12 !important;
    color: #2c3e50 !important;
}

/* Investment Plan table header styling */
.investment-plan .plan-table thead {
    background: #f39c12 !important;
    color: #2c3e50 !important;
}

/* Remove extra padding/margin from investment plan section */
.investment-plan {
    margin-top: 2rem;
}

.investment-plan h3 {
    margin-top: 0;
    margin-bottom: 0;
}

/* Contribution table tooltip with auto width */
.contribution-grid .help-icon::after {
    width: auto;
    max-width: none;
    white-space: nowrap;
}

/* Summary table tooltip with auto width */
.summary-table .help-icon::after {
    width: auto;
    max-width: none;
    white-space: nowrap;
}

/* Responsive Design for Tools */
@media (max-width: 768px) {
    .ef-container,
    .sip-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .recommendations-grid {
        grid-template-columns: 1fr;
    }

    .summary-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .timeline {
        padding-left: 1rem;
    }

    .timeline-item {
        margin-left: 0.5rem;
    }

    .input-group-row {
        grid-template-columns: 1fr;
    }
}
