/* 4WD Product Price Tracker Styles */

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

:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --light-bg: #ecf0f1;
    --card-bg: #ffffff;
    --text-color: #2c3e50;
    --text-muted: #7f8c8d;
    --border-color: #dfe6e9;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--light-bg);
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Layout with Sidebar */
.layout-with-sidebar {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 2rem;
    margin-top: 2rem;
}

/* Category Sidebar */
.category-sidebar {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    height: fit-content;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    position: sticky;
    top: 20px;
}

.category-sidebar h3 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.category-list {
    list-style: none;
}

.category-list li {
    margin-bottom: 0.5rem;
}

.category-list details {
    margin-bottom: 0.5rem;
}

.category-list summary {
    cursor: pointer;
    user-select: none;
    list-style: none;
}

.category-list summary::-webkit-details-marker {
    display: none;
}

.category-list summary::before {
    content: '▶';
    display: inline-block;
    margin-right: 0.5rem;
    transition: transform 0.3s;
    font-size: 0.8rem;
}

.category-list details[open] > summary::before {
    transform: rotate(90deg);
}

.category-parent {
    display: block;
    padding: 0.75rem 1rem;
    border-radius: 5px;
    transition: all 0.3s;
}

.category-parent a {
    color: var(--text-color);
    text-decoration: none;
}

.category-parent:hover {
    background: var(--light-bg);
}

.category-parent:hover a {
    color: var(--secondary-color);
}

.category-parent.active {
    background: var(--secondary-color);
}

.category-parent.active a {
    color: white;
    font-weight: 500;
}

.category-sublist {
    list-style: none;
    padding-left: 1.5rem;
    margin-top: 0.5rem;
}

.category-sublist li {
    margin-bottom: 0.25rem;
}

.category-link {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-color);
    text-decoration: none;
    border-radius: 5px;
    transition: all 0.3s;
}

.category-link:hover {
    background: var(--light-bg);
    color: var(--secondary-color);
}

.category-link.active {
    background: var(--secondary-color);
    color: white;
    font-weight: 500;
}

.main-content {
    min-width: 0;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-color), #34495e);
    color: white;
    padding: 2rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.tagline {
    opacity: 0.9;
    font-size: 1rem;
}

.tagline a {
    color: white;
    text-decoration: none;
    border-bottom: 1px solid rgba(255,255,255,0.5);
}

.tagline a:hover {
    border-bottom-color: white;
}

/* Search Section */
.search-section {
    background: white;
    padding: 2rem;
    margin: 2rem 0;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.search-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.search-box {
    display: flex;
    gap: 0.5rem;
}

.search-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.search-input:focus {
    outline: none;
    border-color: var(--secondary-color);
}

.search-button {
    padding: 0.75rem 2rem;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.3s;
}

.search-button:hover {
    background: #2980b9;
}

.clear-search {
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    transition: all 0.3s;
}

.clear-search:hover {
    background: var(--light-bg);
}

.sort-options {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sort-options select {
    padding: 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
}

.filter-options {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

.filter-badge {
    background: var(--success-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Statistics Section */
.stats-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--secondary-color);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* Results Info */
.results-info {
    margin: 1rem 0;
    color: var(--text-muted);
}

.search-scope {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Products Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin: 2rem 0;
}

.product-card {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.product-image {
    width: 100%;
    height: 250px;
    overflow: hidden;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.product-info {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-name {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.product-name a {
    color: var(--text-color);
    text-decoration: none;
}

.product-name a:hover {
    color: var(--secondary-color);
}

.product-sku {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.price-info {
    margin-top: auto;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--light-bg);
    border-radius: 5px;
}

.price-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.price-row:last-child {
    margin-bottom: 0;
}

.price-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.price-value {
    font-weight: bold;
}

.price-value.current {
    color: var(--secondary-color);
    font-size: 1.1rem;
}

.price-value.lowest {
    color: var(--success-color);
}

.price-value.average {
    color: var(--text-muted);
}

.savings-badge {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: var(--warning-color);
    color: white;
    border-radius: 5px;
    font-size: 0.85rem;
    text-align: center;
}

.best-price-badge {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: var(--success-color);
    color: white;
    border-radius: 5px;
    font-size: 0.85rem;
    text-align: center;
}

.product-meta {
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.product-actions {
    display: flex;
    gap: 0.5rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 5px;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9rem;
    display: inline-block;
}

.btn-primary {
    background: var(--secondary-color);
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: var(--light-bg);
    color: var(--text-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

/* Product Detail Page */
.product-detail {
    background: white;
    padding: 2rem;
    margin: 2rem 0;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.product-header {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.product-image-large {
    background: white;
    border-radius: 10px;
    padding: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-image-large img {
    max-width: 100%;
    height: auto;
}

.product-main-info h2 {
    margin-bottom: 1rem;
}

.product-meta-info {
    margin-bottom: 2rem;
    color: var(--text-muted);
}

.product-meta-info p {
    margin-bottom: 0.5rem;
}

.price-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin: 2rem 0;
}

.price-stat {
    background: var(--light-bg);
    padding: 1.5rem;
    border-radius: 10px;
    text-align: center;
}

.price-stat-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.price-stat-value {
    font-size: 1.8rem;
    font-weight: bold;
}

.current-large {
    color: var(--secondary-color);
}

.lowest-large {
    color: var(--success-color);
}

.average-large {
    color: var(--text-muted);
}

.highest-large {
    color: var(--danger-color);
}

.original-price {
    text-decoration: line-through;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.best-price-indicator {
    color: var(--success-color);
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.alert {
    padding: 1rem;
    border-radius: 5px;
    margin: 1rem 0;
}

.alert-info {
    background: #e3f2fd;
    color: #1976d2;
    border-left: 4px solid #2196f3;
}

.alert-success {
    background: #e8f5e9;
    color: #388e3c;
    border-left: 4px solid #4caf50;
}

.action-buttons {
    margin: 2rem 0;
}

.product-description {
    margin: 2rem 0;
    padding: 2rem;
    background: var(--light-bg);
    border-radius: 10px;
}

.product-description h3 {
    margin-bottom: 1rem;
}

/* Price History */
.price-history-section {
    margin: 2rem 0;
}

.price-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.price-history-header h3 {
    margin: 0;
}

.chart-info {
    display: flex;
    gap: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.chart-info-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-info-item strong {
    color: var(--text-color);
}

.trend-up {
    color: var(--danger-color);
    font-weight: 600;
}

.trend-down {
    color: var(--success-color);
    font-weight: 600;
}

.trend-neutral {
    color: var(--text-muted);
    font-weight: 600;
}

.date-filter-buttons {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.date-filter-btn {
    padding: 0.6rem 1.2rem;
    background: white;
    color: var(--text-color);
    border: 2px solid var(--border-color);
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
    font-weight: 500;
}

.date-filter-btn:hover {
    background: var(--light-bg);
    border-color: var(--secondary-color);
}

.date-filter-btn.active {
    background: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
}

.price-history-chart {
    margin: 2rem 0;
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.chart-canvas-container {
    position: relative;
    height: 400px;
    width: 100%;
}

.chart-container {
    position: relative;
    height: 200px;
    background: var(--light-bg);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.chart-point {
    position: absolute;
    width: 10px;
    height: 10px;
}

.point-marker {
    display: block;
    width: 10px;
    height: 10px;
    background: var(--secondary-color);
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.chart-legend {
    display: flex;
    gap: 2rem;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.price-history-table {
    overflow-x: auto;
    margin-top: 2rem;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--light-bg);
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    font-weight: 600;
}

.price-cell {
    font-weight: bold;
}

.price-up {
    color: var(--danger-color);
}

.price-down {
    color: var(--success-color);
}

.price-same {
    color: var(--text-muted);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin: 2rem 0;
}

.page-link {
    padding: 0.75rem 1.5rem;
    background: white;
    color: var(--text-color);
    text-decoration: none;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: all 0.3s;
}

.page-link:hover {
    background: var(--secondary-color);
    color: white;
}

.page-info {
    color: var(--text-muted);
}

/* No Results */
.no-results {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

/* Footer */
footer {
    background: var(--primary-color);
    color: white;
    padding: 2rem 0;
    margin-top: 4rem;
    text-align: center;
}

footer a {
    color: white;
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
    .layout-with-sidebar {
        grid-template-columns: 1fr;
    }

    .category-sidebar {
        position: static;
    }

    .product-header {
        grid-template-columns: 1fr;
    }

    .price-summary {
        grid-template-columns: 1fr;
    }

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

    .search-box {
        flex-direction: column;
    }

    .stats-section {
        grid-template-columns: repeat(2, 1fr);
    }

    .price-history-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .chart-info {
        flex-direction: column;
        gap: 0.5rem;
    }

    .chart-canvas-container {
        height: 300px;
    }

    .date-filter-buttons {
        width: 100%;
    }

    .date-filter-btn {
        flex: 1;
        min-width: 80px;
        font-size: 0.85rem;
        padding: 0.5rem 0.8rem;
    }

    .rrp-large {
        font-size: 1.4rem;
    }

    .savings-indicator {
        font-size: 0.85rem;
    }
}
