/* --- General & Layout --- */
.compare-fees h1 {
    text-align: center;
    color: var(--color-primary);
    margin-bottom: 10px;
}

.compare-fees .subtitle {
    text-align: center;
    color: var(--color-text-light);
    margin-bottom: 25px;
}

.hidden {
    display: none !important;
}

.card {
    background: var(--color-bg-white);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--color-border-light);
    border-radius: 8px;
    box-shadow: var(--shadow-light);
}

/* --- Input Form --- */
.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: var(--color-text-light);
}

.label-container {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 5px;
}

.input-group .label-container label {
    margin-bottom: 0;
}

.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltip-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--color-border-medium);
    color: var(--color-bg-white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
}

.tooltip .tooltip-text {
    visibility: hidden;
    width: 220px;
    background-color: #555;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -110px; /* Use half of the width to center the tooltip */
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.85em;
    font-weight: normal;
    line-height: 1.4;
}

.tooltip .tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #555 transparent transparent transparent;
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

.input-group input[type="number"],
.input-group input[type="range"] {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--color-border-medium);
    border-radius: 4px;
    box-sizing: border-box;
}

.input-group input[type="range"] {
    padding: 0;
}

#growth-rate-value {
    display: inline-block;
    margin-left: 10px;
    font-weight: bold;
    color: var(--color-primary);
}

.compare-fees .cta-button {
    display: block;
    width: 100%;
    padding: 12px;
    background-color: var(--color-primary);
    color: var(--color-bg-white);
    border: none;
    border-radius: 4px;
    font-size: 1.1em;
    cursor: pointer;
    transition: background-color 0.3s ease;
    box-sizing: border-box;
}

.compare-fees .cta-button:hover {
    background-color: var(--color-primary-hover);
}

.talk-to-broker-cta {
    text-align: center;
    text-decoration: none;
    margin: 20px 0;
}

/* --- Results Area --- */
.results-container {
    margin-top: 30px;
}

#results-area {
    min-height: 100vh; /* Prevent layout shift during re-calculation */
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.search-filter {
    flex-grow: 1;
    display: flex; /* Make search-filter a flex container */
    align-items: center;
    gap: 10px;
}

.search-label {
    font-weight: bold;
    color: var(--color-text-light);
    white-space: nowrap;
}

#search-input {
    flex-grow: 1;
    padding: 8px 12px;
    border: 1px solid var(--color-border-medium);
    border-radius: 4px;
    font-size: 1em;
    min-width: 0; /* Allow the input to shrink below its content size */
}

.sort-buttons {
    display: flex;
    align-items: center;
    gap: 5px;
}

.sort-label {
    font-weight: bold;
    color: var(--color-text-light);
    margin-right: 5px;
}

.sort-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-border-medium);
    background-color: var(--color-bg-white);
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s ease;
    color: var(--color-text); /* Added default text color */
}

.sort-btn:hover {
    background-color: var(--color-bg-light);
    border-color: var(--color-primary);
}

.sort-btn.active {
    background-color: var(--color-primary);
    color: var(--color-bg-white);
    border-color: var(--color-primary);
}

#loading {
    text-align: center;
    padding: 20px;
    font-size: 1.2em;
    color: var(--color-text-light);
}

/* --- Result List Item --- */
.result-item {
    display: flex;
    align-items: center;
    padding: 15px;
    margin-bottom: 10px;
    background: var(--color-bg-white);
    border: 1px solid var(--color-border-light);
    border-radius: 5px;
    cursor: pointer;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.result-item:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-light);
}

.result-item-logo {
    flex-shrink: 0;
    margin-right: 15px;
    width: 120px;
    text-align: center;
}

.result-item-logo img {
    width: 50px;
    height: auto;
    object-fit: contain;
}

.result-item-logo span {
    font-weight: bold;
    font-size: 0.9em;
}

.result-item-details {
    flex-grow: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.result-item-name {
    font-weight: bold;
    flex-basis: 50%;
    flex-grow: 1;
}

.result-item-metrics {
    display: flex;
    gap: 20px;
    text-align: right;
    flex-shrink: 0;
}

.result-item-metric {
    display: flex;
    flex-direction: column;
}

.metric-value {
    font-size: 1.2em;
    font-weight: bold;
}

.metric-label {
    font-size: 0.8em;
    color: var(--color-text-light);
}

.metric-value.negative {
    color: var(--color-red-general);
}

/* --- Detail View --- */
#detail-view .card {
    margin-top: 20px;
}

#detail-view h2 {
    display: flex;
    align-items: center;
    gap: 15px;
    color: var(--color-text);
}

#detail-view h2 img {
    max-height: 40px;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.back-to-results {
    background: none;
    border: 1px solid var(--color-border-medium);
    color: var(--color-text);
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
}

.back-to-results:hover {
    background-color: var(--color-bg-light);
}

.result-summary {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
}

@media (min-width: 600px) {
    .result-summary {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
    }
    .result-summary .result-column {
        flex: 1;
    }
}

.result-value {
    font-size: 1.8em;
    font-weight: bold;
    color: var(--color-primary);
    margin-bottom: 0;
}

.result-value-label {
    font-size: 0.8em;
    color: var(--color-text-light);
    margin-bottom: 10px;
    font-style: italic;
}

.result-fees-total {
    font-size: 1.8em;
    font-weight: bold;
    color: var(--color-red-general);
    margin-bottom: 0;
}

.result-fees-label, .website-notes {
    font-size: 0.8em;
    color: var(--color-text-light);
    margin-bottom: 10px;
    font-style: italic;
}

.result-fees-breakdown {
    font-size: 0.9em;
    color: var(--color-red-general);
    margin-left: 10px;
    padding-left: 10px;
    border-left: 2px solid var(--color-border-light);
}

.details-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85em;
    margin-top: 20px;
}

.details-table .mobile-col {
    display: none;
}

.details-table th, .details-table td {
    border: 1px solid var(--color-border-light);
    padding: 6px;
    text-align: right;
}

.details-table th {
    background-color: var(--color-bg-light);
    font-weight: bold;
}

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

.brokerage-warning {
    background-color: #fff3cd;
    color: #856404;
    padding: 8px 12px;
    margin-top: 15px;
    margin-bottom: 10px;
    border: 1px solid #ffeeba;
    border-radius: 4px;
    font-size: 0.85em;
}

.brokerage-warning strong {
    color: #664d03;
}

.brokerage-warning-list {
    flex-basis: 100%;
    font-size: 0.8em;
    color: var(--color-text-light);
    margin-top: 5px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .result-item-logo {
        width: 80px;
        margin-right: 10px;
    }
    .result-item-details {
        flex-direction: column;
        align-items: flex-start;
    }
    .result-item-metrics {
        width: 100%;
        justify-content: space-between;
        text-align: left;
    }
    .details-table .desktop-col {
        display: none;
    }
    .details-table .mobile-col {
        display: table-cell;
    }
    
    .sort-buttons {
        gap: 3px;
    }
    
    .sort-btn {
        width: 35px;
        height: 35px;
        font-size: 0.9em;
    }
}
