/* PC Parts Price Tracker - Custom Styles */

/* ── Dark mode overrides ── */
[data-theme="dark"] {
    --pico-background-color: #0f1117;
    --pico-card-background-color: #1a1d27;
    --pico-card-border-color: #2a2d37;
    --pico-nav-background-color: #1a1d27;
    --pico-table-border-color: #2a2d37;
    --pico-table-row-stripped-background-color: #1a1d27;
}

[data-theme="light"] {
    --pico-background-color: #f8f9fa;
    --pico-card-background-color: #ffffff;
    --pico-card-border-color: #dee2e6;
}

/* ── Layout ── */
body {
    min-height: 100vh;
}

.container-fluid {
    max-width: 1400px;
    margin: 0 auto;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ── Nav ── */
nav {
    background: var(--pico-card-background-color);
    border-bottom: 1px solid var(--pico-card-border-color);
    padding: 0.75rem 1rem;
    margin-bottom: 2rem;
}

nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 1rem;
    align-items: center;
}

nav a {
    text-decoration: none;
    color: var(--pico-muted-color);
    font-weight: 500;
    transition: color 0.2s;
}

nav a:hover,
nav a.active {
    color: var(--pico-primary);
}

#theme-toggle {
    cursor: pointer;
    border: none;
    background: transparent;
    font-size: 1.2rem;
    padding: 0.5rem;
}

/* ── Stats Cards ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-card-border-color);
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
}

.stat-card h3 {
    font-size: 2rem;
    margin: 0;
    color: var(--pico-primary);
}

.stat-card p {
    margin: 0;
    opacity: 0.7;
    font-size: 0.9rem;
}

/* ── Category Cards ── */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.category-card {
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-card-border-color);
    border-radius: 8px;
    padding: 1.5rem;
}

.category-card h4 {
    margin: 0 0 0.5rem;
    color: var(--pico-primary);
}

.category-card .stat-row {
    display: flex;
    justify-content: space-between;
    margin: 0.25rem 0;
    font-size: 0.9rem;
}

/* ── Products Table ── */
.products-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.products-table th {
    background: var(--pico-card-background-color);
    cursor: pointer;
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 10;
}

.products-table th:hover {
    opacity: 0.8;
}

.products-table td {
    vertical-align: middle;
}

.product-title {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.product-title a:hover {
    color: var(--pico-primary);
    text-decoration: underline;
}

.price-current {
    font-weight: 600;
    color: var(--pico-primary);
}

.price-original {
    text-decoration: line-through;
    opacity: 0.5;
    font-size: 0.85rem;
}

.discount-badge {
    background: #dc3545;
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.brand-badge {
    background: var(--pico-card-border-color);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

/* ── Filters ── */
.filters-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.filters-bar input,
.filters-bar select {
    max-width: 250px;
}

/* ── Product Detail ── */
.product-detail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 768px) {
    .product-detail {
        grid-template-columns: 1fr;
    }
}

.product-info {
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-card-border-color);
    border-radius: 8px;
    padding: 1.5rem;
}

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

.product-chart {
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-card-border-color);
    border-radius: 8px;
    padding: 1.5rem;
}

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

/* ── Alerts ── */
.alert-card {
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-card-border-color);
    border-left: 4px solid #dc3545;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-info h4 {
    margin: 0 0 0.25rem;
}

.alert-info p {
    margin: 0;
    opacity: 0.7;
    font-size: 0.9rem;
}

.alert-price {
    text-align: right;
}

.alert-price .drop {
    color: #dc3545;
    font-weight: 600;
    font-size: 1.1rem;
}

.alert-price .old-price {
    text-decoration: line-through;
    opacity: 0.5;
    font-size: 0.85rem;
}

/* ── Scrape Status ── */
.scrape-controls {
    margin-bottom: 2rem;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.log-table {
    font-size: 0.85rem;
}

.log-status-success {
    color: #28a745;
}

.log-status-error {
    color: #dc3545;
}

/* ── Loading ── */
.loading {
    text-align: center;
    padding: 2rem;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 2rem;
    height: 2rem;
    border: 3px solid var(--pico-card-border-color);
    border-top-color: var(--pico-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 3rem;
    opacity: 0.7;
}

.empty-state h3 {
    margin-bottom: 0.5rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .products-table {
        font-size: 0.8rem;
    }
    
    .products-table th:nth-child(n+5),
    .products-table td:nth-child(n+5) {
        display: none;
    }
}
