/* General Body & Layout */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background-color: #f0f2f5;
    color: #1c1e21;
}

main {
    display: flex;
    padding: 20px;
    gap: 20px;
}

#filters-pane {
    flex: 0 0 250px;
    background-color: #ffffff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    height: fit-content;
}

#results-pane {
    flex-grow: 1;
}

/* Header */
header {
    background-color: #ffffff;
    padding: 10px 20px;
    border-bottom: 1px solid #dddfe2;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

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

header h1 {
    font-size: 1.5em;
    margin: 0;
    color: #095da3;
    font-family: "Roboto", sans-serif;
}

#search-form {
    display: flex;
    align-items: center;
    gap: 10px;
}

#search-bar {
    width: 300px;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
}

/* #environment-selector, header button {
    padding: 8px 15px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background-color: #e9ecef;
    cursor: pointer;
} */

header button[type="submit"] {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

#compare-selected-btn {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
}

/* Filters Pane */
#filters-pane h2 {
    margin-top: 0;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.facet {
    margin-bottom: 20px;
}

.facet h3 {
    font-size: 1em;
    margin-bottom: 8px;
}

.facet ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.facet li {
    display: flex;
    justify-content: space-between;
    font-size: 0.9em;
    padding: 4px 0;
}
.facet-count {
    color: #6c757d;
    background-color: #e9ecef;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 0.8em;
}


/* Results Grid & Product Cards */
#results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.product-card {
    background-color: #fff;
    border: 1px solid #dddfe2;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.product-card-img {
    width: 100%;
    height: 180px;
    object-fit: contain;
    background-color: #f8f9fa;
    border-bottom: 1px solid #eee;
}

.product-card-body {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-grow: 1;
}

.product-name {
    font-weight: 600;
    font-size: 1em;
    margin: 0;
}

.product-sku {
    font-size: 0.85em;
    color: #606770;
}

.product-scores {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.85em;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
    padding: 10px 0;
}
.product-scores .final-score {
    font-weight: bold;
    margin-bottom: 5px;
}
.product-scores .component-scores span {
    margin-right: 15px;
}

.product-card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.product-card-actions .view-btn {
    text-decoration: none;
    padding: 8px 12px;
    background-color: #f5f6f7;
    border: 1px solid #ccd0d5;
    border-radius: 6px;
    color: #4b4f56;
    font-weight: 600;
    font-size: 0.9em;
}

.product-card-actions .compare-control {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9em;
    cursor: pointer;
}


/* --- DETAILED COMPARISON VIEW STYLES --- */
#comparison-view-container {
    padding: 0 20px;
}
.comparison-view {
    background-color: #fff;
    border-radius: 8px;
    margin-top: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    border: 1px solid #ccc;
    overflow: hidden; /* Ensures child border-radius is respected */
}

.comparison-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 2px solid #ddd;
}
.comparison-header h2 {
    margin: 0;
}
.comparison-header .clear-btn {
    background: none;
    border: 1px solid #c00;
    color: #c00;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}

.comparison-grid {
    display: grid;
    grid-template-columns: 250px repeat(auto-fit, minmax(250px, 1fr));
}

.grid-cell {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    border-right: 1px solid #eee;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.9em;
    display: flex;
    flex-direction: column; /* Allow content to stack */
    justify-content: center;
}

.grid-cell:last-child {
    border-right: none;
}
.comparison-grid .grid-row:last-child .grid-cell {
    border-bottom: none;
}

.grid-row {
    display: contents; /* Makes this a logical container for grid cells */
}

.grid-label {
    font-weight: bold;
    background-color: #f7f7f7;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.grid-product-header {
    font-weight: bold;
    background-color: #f0f2f5;
    text-align: center;
}

.grid-product-header .product-name {
    font-size: 1em;
}
.grid-product-header .product-sku {
    font-size: 0.8em;
    color: #606770;
}
.grid-cell table {
    width: 100%;
    border-collapse: collapse;
}
.grid-cell table td {
    padding: 4px 0;
    font-size: 0.95em;
}
.grid-cell table td:first-child {
    font-weight: 500;
    color: #555;
}
.grid-cell table td:last-child {
    text-align: right;
    font-weight: bold;
}


/* --- MODIFIED ACCORDION & TOOLTIP STYLES --- */
.accordion {
    border: 1px solid #d1d9e6;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}
.accordion-item {
    border-bottom: 1px solid #d1d9e6;
}
.accordion-item:last-child {
    border-bottom: none;
}
.accordion-button {
    background-color: #ffffff;
    color: #2c3e50;
    cursor: pointer;
    padding: 12px 15px;
    width: 100%;
    border: none;
    outline: none;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.3s ease;
    /* Flexbox for alignment */
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
}
.accordion-button:hover, .accordion-button.active {
    background-color: #f8f9fa;
}

/* NEW: CSS-only arrow (chevron) */
.accordion-button::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-top: 2px solid #3498db;
    border-right: 2px solid #3498db;
    transform: rotate(45deg); /* Points right */
    transition: transform 0.3s ease;
    margin-left: 10px;
    flex-shrink: 0; /* Prevents arrow from shrinking */
}

.accordion-button.active::after {
    transform: rotate(135deg); /* Points down */
}

/* NEW: Styles for button content */
.accordion-title {
    margin-right: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.accordion-score {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-weight: bold;
    background-color: #eef2f5;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 13px;
    color: #095da3;
    /* MODIFICATION: Added for alignment */
    min-width: 70px;
    text-align: right;
}

.accordion-panel {
    padding: 0 15px;
    background-color: white;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out, padding 0.4s ease-out;
}
.equation-block {
    padding: 10px;
    margin: 10px 0;
    background-color: #fdfdfd;
    border: 1px solid #eee;
    border-radius: 5px;
    overflow-x: auto;
}
.variables-list {
    list-style-type: none;
    padding: 0;
    margin-bottom: 15px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.variables-list li {
    padding: 6px 0;
    border-bottom: 1px dashed #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}
.variables-list li:last-child {
    border-bottom: none;
}
.variables-list code {
    font-family: "SF Mono", "Fira Code", monospace;
    background: #eef2f5;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 12px;
}

/* NEW: Style for the total score row */
.accordion-total-score {
    background-color: #f0f2f5;
    padding: 12px 15px;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 2px solid #d1d9e6;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.accordion-total-score code {
    font-family: "SF Mono", "Fira Code", monospace;
    font-weight: bold;
    font-size: 14px;
    background: #dde3e9;
    padding: 4px 8px;
    border-radius: 4px;
}


.tooltip {
    position: relative;
    cursor: help;
    border-bottom: 1px dotted #3498db;
}
.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: normal;
    white-space: nowrap;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 10;
}
.tooltip:hover::after {
    visibility: visible;
    opacity: 1;
}

/* --- NEW: FINAL SCORE CALCULATION STYLES --- */
.final-score-calculation-container {
    padding: 10px;
    font-size: 0.95em;
    line-height: 1.9;
    word-wrap: break-word;
}
.formula-part {
    background-color: #e9f5ff;
    border-bottom: 2px solid #90caf9;
    padding: 2px 5px;
    border-radius: 4px;
    font-weight: bold;
    color: #0d47a1;
}
.formula-operator {
    color: #c62828;
    font-weight: bold;
    margin: 0 4px;
}
.formula-value {
    color: #2e7d32;
    font-weight: bold;
}