* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #e0e0e0;
    background: #121212;
}

a {
    color: #90caf9;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

header {
    background: #1e1e1e;
    padding: 1rem 2rem;
    border-bottom: 1px solid #333;
}

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

nav h1 {
    font-size: 1.25rem;
}

nav ul {
    display: flex;
    list-style: none;
    gap: 1.5rem;
}

main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

footer {
    background: #1e1e1e;
    color: #888;
    text-align: center;
    padding: 1rem;
    margin-top: 2rem;
    border-top: 1px solid #333;
}

/* Search */
.search-box {
    margin-bottom: 1.5rem;
}

.search-box input {
    width: 100%;
    max-width: 500px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 4px;
    color: #e0e0e0;
}

.search-box input:focus {
    outline: none;
    border-color: #90caf9;
}

.search-box input::placeholder {
    color: #666;
}

/* Results */
.results-info {
    color: #888;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.no-results {
    color: #888;
    padding: 2rem;
    text-align: center;
}

/* Product Cards */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.product-card {
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 6px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.product-card:hover {
    border-color: #555;
}

.product-card a.card-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.product-card .image-container {
    position: relative;
    height: 180px;
    background: #2a2a2a;
}

.product-card .image-container > img:not(.source-logo) {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.product-card .source-logo {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    opacity: 0.8;
}

.product-card .info {
    padding: 1rem;
}

.product-card .name {
    font-weight: 500;
    margin-bottom: 0.5rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card .meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
}

.product-card .price {
    color: #4caf50;
    font-weight: 600;
    font-size: 1.1rem;
}

.product-card .price-starting {
    color: #4caf50;
    font-size: 0.9rem;
}

.product-card .price-group {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.product-card .price-original {
    color: #888;
    text-decoration: line-through;
    font-size: 0.85rem;
    font-weight: 400;
}

.product-card .price-discounted {
    color: #e53935;
}

.product-card .price-varies {
    color: #888;
    font-size: 0.9rem;
    font-weight: 400;
}

.product-card .price-unavailable {
    color: #666;
}

.product-card .availability {
    font-size: 0.8rem;
    color: #888;
}

.product-card .category {
    font-size: 0.75rem;
    color: #666;
    margin-top: 0.5rem;
}

/* Loading indicator for HTMX */
.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-indicator {
    display: none;
    color: #888;
    margin-left: 0.5rem;
}

/* Home page */
.home h2 {
    margin-bottom: 1rem;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.feature {
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 1.5rem;
    text-align: center;
}

.feature h3 {
    color: #90caf9;
    margin-bottom: 0.5rem;
}

/* Products Layout with Sidebar */
.products-layout {
    display: flex;
    gap: 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
}

.filters-sidebar {
    width: 250px;
    flex-shrink: 0;
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 1rem;
    height: fit-content;
    position: sticky;
    top: 1rem;
}

.filters-sidebar h3 {
    margin-bottom: 1rem;
    color: #e0e0e0;
    font-size: 1.1rem;
}

.products-main {
    flex: 1;
    min-width: 0;
}

/* Filter Groups */
.filter-group {
    margin-bottom: 1rem;
}

.filter-group label {
    display: block;
    margin-bottom: 0.4rem;
    color: #aaa;
    font-size: 0.85rem;
}

.filter-group input[type="search"],
.filter-group input[type="number"],
.filter-group select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 4px;
    color: #e0e0e0;
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: #90caf9;
}

.filter-group input::placeholder {
    color: #666;
}

.filter-group select {
    cursor: pointer;
}

/* Price Range Inputs */
.price-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.price-inputs input {
    flex: 1;
    min-width: 0;
}

.price-inputs span {
    color: #666;
}

/* Expandable Filter Groups */
.filter-group.expandable {
    margin-bottom: 1rem;
}

.filter-group.expandable summary {
    cursor: pointer;
    color: #aaa;
    font-size: 0.85rem;
    padding: 0.25rem 0;
}

.filter-group.expandable summary:hover {
    color: #e0e0e0;
}

.filter-group.expandable .checkbox-group {
    margin-top: 0.5rem;
}

.filter-count {
    color: #666;
    font-size: 0.8rem;
}

/* Checkbox Group */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.checkbox-group.scrollable {
    max-height: 200px;
    overflow-y: auto;
    flex-direction: column;
    flex-wrap: nowrap;
    padding-right: 0.5rem;
}

.checkbox-group.scrollable::-webkit-scrollbar {
    width: 6px;
}

.checkbox-group.scrollable::-webkit-scrollbar-track {
    background: #2a2a2a;
    border-radius: 3px;
}

.checkbox-group.scrollable::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}

/* Checkbox Label */
.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: #e0e0e0 !important;
    font-size: 0.9rem !important;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    cursor: pointer;
    accent-color: #4caf50;
}

/* Clear Filters Link */
.clear-filters {
    display: block;
    text-align: center;
    color: #888;
    font-size: 0.85rem;
    padding: 0.5rem;
    margin-top: 0.5rem;
}

.clear-filters:hover {
    color: #90caf9;
}

/* Chart Button on Product Card */
.product-card {
    position: relative;
}

.product-card .chart-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    transition: all 0.2s;
    z-index: 10;
}

.product-card .chart-btn:hover {
    background: #333;
    border-color: #90caf9;
    color: #90caf9;
    text-decoration: none;
}

.product-card .chart-btn svg {
    width: 18px;
    height: 18px;
}

/* Product Detail Page */
.product-detail {
    max-width: 1000px;
    margin: 0 auto;
}

.product-detail-header {
    margin-bottom: 1.5rem;
}

.back-link {
    color: #888;
    font-size: 0.9rem;
}

.back-link:hover {
    color: #90caf9;
}

.product-detail-content {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
}

.product-detail-image {
    flex: 0 0 400px;
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 6px;
    overflow: hidden;
}

.product-detail-image img {
    width: 100%;
    height: auto;
    object-fit: contain;
}

.product-detail-info {
    flex: 1;
}

.product-detail-info h1 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    line-height: 1.3;
}

.product-detail-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.detail-category {
    background: #2a2a2a;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #aaa;
}

.detail-availability {
    color: #888;
    font-size: 0.9rem;
}

.product-detail-price {
    margin-bottom: 1.5rem;
}

.product-detail-price .price-current {
    font-size: 1.75rem;
    font-weight: 600;
    color: #4caf50;
}

.product-detail-price .price-current.discounted {
    color: #e53935;
}

.product-detail-price .price-original {
    font-size: 1.1rem;
    color: #888;
    text-decoration: line-through;
    margin-right: 0.75rem;
}

.product-detail-price .price-unavailable {
    color: #666;
    font-size: 1.1rem;
}

.view-source-btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 4px;
    color: #e0e0e0;
    font-weight: 500;
    transition: all 0.2s;
}

.view-source-btn:hover {
    background: #333;
    border-color: #90caf9;
    text-decoration: none;
}

/* Price History Section */
.price-history-section {
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 1.5rem;
}

.price-history-section h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.chart-container {
    height: 300px;
}

.no-history {
    color: #888;
    text-align: center;
    padding: 2rem;
}

/* Responsive: Stack on mobile */
@media (max-width: 768px) {
    .products-layout {
        flex-direction: column;
    }

    .filters-sidebar {
        width: 100%;
        position: static;
    }

    .product-detail-content {
        flex-direction: column;
    }

    .product-detail-image {
        flex: none;
        width: 100%;
    }
}
