/*
 * Hardware Comparison - Modern Light Theme
 * Version: 2.2
 */

/* ===================================================================
 *  1. CSS Variables (Customize Your Theme Here)
 * =================================================================== */
:root {
    --hwcp-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    
    /* -- Light Theme Colors -- */
    --hwcp-color-background: #f8f9fa;      /* Off-white page background */
    --hwcp-color-surface: #ffffff;         /* White for cards and containers */
    --hwcp-color-border: #dee2e6;          /* Standard light grey border */
    
    --hwcp-color-text-primary: #212529;    /* Near-black for primary text */
    --hwcp-color-text-secondary: #6c757d;   /* Medium grey for secondary text/labels */
    --hwcp-color-text-placeholder: #adb5bd; /* Lighter grey for input placeholders */

    --hwcp-color-accent: #007bff;           /* Vibrant blue for buttons, links, focus */
    --hwcp-color-accent-hover: #0056b3;     /* Darker blue for hover */

    --hwcp-color-winner: #198754;           /* Stronger Green for winning specs */
    --hwcp-color-loser: #6c757d;            /* Grey for losing specs */
    --hwcp-color-error: #dc3545;            /* Red for error messages */

    /* -- Sizing & Spacing -- */
    --hwcp-border-radius-sm: 4px;
    --hwcp-border-radius-md: 8px;
    --hwcp-spacing-unit: 1rem; /* Approx 16px */
}

/* ===================================================================
 *  2. General & Wrapper Styles
 * =================================================================== */
.hwcp-comparison,
.hwcp-calculator-wrapper {
    font-family: var(--hwcp-font-family);
    background-color: var(--hwcp-color-surface);
    color: var(--hwcp-color-text-primary);
    padding: calc(var(--hwcp-spacing-unit) * 1.5);
    border-radius: var(--hwcp-border-radius-md);
    border: 1px solid var(--hwcp-color-border);
    max-width: 900px;
    margin: var(--hwcp-spacing-unit) auto;
    box-shadow: 0 5px 20px rgba(0,0,0,0.08);
    box-sizing: border-box;
}

.hwcp-comparison *,
.hwcp-calculator-wrapper * {
    box-sizing: border-box;
}

h2, h3, h4 {
    color: var(--hwcp-color-text-primary);
    margin-top: 0;
}

h2 {
    font-size: 1.75rem;
    text-align: center;
    margin-bottom: var(--hwcp-spacing-unit);
    letter-spacing: -0.5px;
}

/* ===================================================================
 *  3. Search & Selection Components (Used by Both Tools)
 * =================================================================== */
.hwcp-product-select {
    position: relative;
    margin-bottom: var(--hwcp-spacing-unit);
    flex-grow: 1;
}

.hwcp-product-select label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--hwcp-color-text-secondary);
    margin-bottom: calc(var(--hwcp-spacing-unit) / 2);
}

.hwcp-search,
.hwcp-additional-select select {
    width: 100%;
    padding: 12px 15px;
    background-color: var(--hwcp-color-background);
    border: 1px solid var(--hwcp-color-border);
    border-radius: var(--hwcp-border-radius-sm);
    color: var(--hwcp-color-text-primary);
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.hwcp-additional-select select {
    background-color: var(--hwcp-color-surface);
}

.hwcp-search:focus,
.hwcp-additional-select select:focus {
    outline: none;
    border-color: var(--hwcp-color-accent);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

.hwcp-search::placeholder {
    color: var(--hwcp-color-text-placeholder);
}

/* Loading Spinner on Search Input */
.hwcp-search.loading {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='xMidYMid' width='20' height='20' style='shape-rendering: auto; display: block; background: transparent;' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Cg%3E%3Ccircle cx='50' cy='50' r='32' stroke-width='8' stroke='%23007bff' stroke-dasharray='50.26548245743669 50.26548245743669' fill='none' stroke-linecap='round'%3E%3CanimateTransform attributeName='transform' type='rotate' dur='1s' repeatCount='indefinite' keyTimes='0;1' values='0 50 50;360 50 50'%3E%3C/animateTransform%3E%3C/circle%3E%3Cg%3E%3C/g%3E%3C/g%3E%3C!-- [ldio] generated by https://loading.io --%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 20px;
}

/* Search Results Dropdown */
.hwcp-results {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: var(--hwcp-color-surface);
    border: 1px solid var(--hwcp-color-border);
    border-top: none;
    border-radius: 0 0 var(--hwcp-border-radius-sm) var(--hwcp-border-radius-sm);
    z-index: 1000;
    max-height: 250px;
    overflow-y: auto;
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
}

.hwcp-result-item {
    padding: 12px 15px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.hwcp-result-item:hover {
    background-color: var(--hwcp-color-accent);
    color: var(--hwcp-color-surface);
}

.hwcp-result-item.hwcp-error {
    color: var(--hwcp-color-text-secondary);
    cursor: default;
}
.hwcp-result-item.hwcp-error:hover {
    background-color: transparent;
    color: var(--hwcp-color-text-secondary);
}


/* ===================================================================
 *  4. PSU Calculator Specific Styles
 * =================================================================== */
.hwcp-calculator-selections {
    display: flex;
    gap: var(--hwcp-spacing-unit);
    margin-bottom: calc(var(--hwcp-spacing-unit) * 1.5);
}

.hwcp-selected-product {
    margin-top: calc(var(--hwcp-spacing-unit) / 2);
    padding: 10px;
    background-color: var(--hwcp-color-background);
    border-radius: var(--hwcp-border-radius-sm);
    border-left: 3px solid var(--hwcp-color-accent);
}

.hwcp-selected-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.hwcp-selected-name {
    font-weight: 600;
}

.hwcp-change-component {
    color: var(--hwcp-color-accent);
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s ease;
}
.hwcp-change-component:hover {
    color: var(--hwcp-color-accent-hover);
    text-decoration: underline;
}

.hwcp-additional-components h4,
.hwcp-product-select label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background-color: var(--hwcp-color-accent);
    color: #fff;
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: 700;
}

.hwcp-additional-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--hwcp-spacing-unit);
    margin-top: var(--hwcp-spacing-unit);
}

.hwcp-calculator-action {
    text-align: center;
    margin: calc(var(--hwcp-spacing-unit) * 2) 0;
}

.hwcp-calculator-results-container {
    background-color: var(--hwcp-color-background);
    border-radius: var(--hwcp-border-radius-md);
    padding: var(--hwcp-spacing-unit) calc(var(--hwcp-spacing-unit) * 1.5);
    text-align: center;
}
.hwcp-calculator-results-container h3 {
    color: var(--hwcp-color-text-secondary);
    font-weight: 500;
}

.hwcp-wattage-result {
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--hwcp-color-accent);
    margin: 0.5rem 0;
}

.hwcp-calculator-disclaimer {
    font-size: 0.8rem;
    color: var(--hwcp-color-text-secondary);
    max-width: 500px;
    margin: var(--hwcp-spacing-unit) auto 0;
}

/* ===================================================================
 *  5. Comparison Tool Specific Styles
 * =================================================================== */
.hwcp-compare-container {
    display: flex;
    gap: var(--hwcp-spacing-unit);
    align-items: flex-start;
}

.hwcp-comparison-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--hwcp-spacing-unit);
}

.hwcp-comparison-header h1 {
    font-size: 1.5rem;
    margin: 0;
    text-align: center;
    flex-grow: 1;
}

.hwcp-product-header {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--hwcp-spacing-unit);
    text-align: center;
    margin-bottom: calc(var(--hwcp-spacing-unit) * 1.5);
}

.hwcp-product-item h2 {
    font-size: 1.2rem;
    margin-top: var(--hwcp-spacing-unit);
}

.hwcp-product-image {
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--hwcp-color-background);
    border-radius: var(--hwcp-border-radius-sm);
    padding: 10px;
}

.hwcp-product-photo, .hwcp-product-logo {
    max-height: 80px;
    max-width: 100%;
    object-fit: contain;
}

.hwcp-winner-summary {
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
    padding: var(--hwcp-spacing-unit);
    background-color: rgba(0,123,255,0.08);
    border: 1px solid var(--hwcp-color-accent);
    border-radius: var(--hwcp-border-radius-sm);
    margin-bottom: calc(var(--hwcp-spacing-unit) * 1.5);
}

/* Specs Table */
.hwcp-specs-table {
    width: 100%;
    border-collapse: collapse;
}

.hwcp-specs-table tr {
    border-bottom: 1px solid var(--hwcp-color-border);
}
.hwcp-specs-table tr:last-child {
    border-bottom: none;
}
.hwcp-specs-table tr:nth-child(even) {
    background-color: var(--hwcp-color-background);
}
.hwcp-specs-table td {
    padding: 12px 15px;
    vertical-align: middle;
}

.hwcp-feature-col {
    font-weight: 600;
    color: var(--hwcp-color-text-secondary);
    width: 25%;
}

.hwcp-values-col-cell {
    width: 50%;
}

.hwcp-values-col {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.hwcp-value-item {
    text-align: center;
    flex: 1;
    font-weight: 500;
}
.hwcp-value-item.hwcp-winner {
    font-weight: 700;
    color: var(--hwcp-color-winner);
}
.hwcp-value-item.hwcp-loser {
    color: var(--hwcp-color-loser);
    opacity: 0.9;
}

/* --- VS BADGE STYLE --- */
.hwcp-vs-badge {
    display: inline-block;
    background-color: #e9ecef;
    color: #495057;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.hwcp-winner-col {
    text-align: center;
    font-weight: 600;
    width: 25%;
    display: none; /* Hidden by default on mobile */
}


/* ===================================================================
 *  6. Buttons
 * =================================================================== */
.hwcp-compare-button,
#hwcp-calculate-psu-btn,
.hwcp-back-button {
    background-color: var(--hwcp-color-accent);
    color: #fff;
    border: none;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--hwcp-border-radius-sm);
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    display: inline-block;
}

.hwcp-compare-button:hover,
#hwcp-calculate-psu-btn:hover {
    background-color: var(--hwcp-color-accent-hover);
}

.hwcp-compare-button:active,
#hwcp-calculate-psu-btn:active {
    transform: scale(0.98);
}

.hwcp-compare-button:disabled,
#hwcp-calculate-psu-btn:disabled {
    background-color: var(--hwcp-color-border);
    color: var(--hwcp-color-text-secondary);
    cursor: not-allowed;
}
.hwcp-back-button {
    background-color: transparent;
    color: var(--hwcp-color-text-secondary);
    border: 1px solid var(--hwcp-color-border);
    padding: 8px 16px;
}
.hwcp-back-button:hover {
    background-color: var(--hwcp-color-border);
    color: var(--hwcp-color-text-primary);
}

/* ===================================================================
 *  7. Responsive Design
 * =================================================================== */
@media (max-width: 768px) {
    .hwcp-comparison,
    .hwcp-calculator-wrapper {
        padding: var(--hwcp-spacing-unit);
    }
    
    .hwcp-compare-container,
    .hwcp-calculator-selections {
        flex-direction: column;
    }

    .hwcp-comparison-header {
        flex-direction: column;
        gap: var(--hwcp-spacing-unit);
    }

    .hwcp-product-header {
        grid-template-columns: 1fr;
    }
    
    .hwcp-feature-col {
        width: 100%;
        display: block;
        padding-bottom: 0;
    }

    /* Stack values on mobile and hide the VS badge */
    .hwcp-specs-table .hwcp-values-col {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    .hwcp-values-col-cell {
        display: block;
        width: 100%;
    }
    .hwcp-vs-badge {
        display: none;
    }

    /* Style stacked values on mobile */
    .hwcp-value-item {
        text-align: left;
        width: 100%;
        padding: 5px 8px;
        border-radius: var(--hwcp-border-radius-sm);
    }
    .hwcp-value-item.hwcp-winner {
        background-color: rgba(25, 135, 84, 0.1); /* Winner bg */
    }
    .hwcp-value-item.hwcp-loser {
        background-color: rgba(108, 117, 125, 0.1); /* Loser bg */
    }
    
    .hwcp-wattage-result {
        font-size: 2.5rem;
    }
}

@media (min-width: 769px) {
    /* --- THE FIX IS HERE --- */
    /* Show winner column on larger screens by changing display property */
    .hwcp-winner-col {
        display: table-cell;
    }
}