:root {
    --primary: #22c55e;
    --primary-dark: #16a34a;
    --bg: #f9fafb;
    --surface: #ffffff;
    --text: #1f2937;
    --text-light: #6b7280;
    --border: #e5e7eb;
}

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

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-dark);
}

main {
    padding: 2rem 1rem;
}

.filters {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filters input,
.filters select,
.filters button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.filters input {
    flex: 1;
    min-width: 200px;
}

.filters input:focus,
.filters select:focus {
    outline: none;
    border-color: var(--primary);
}

.filters button {
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

.filters button:hover {
    background: var(--primary-dark);
}

.results-info {
    margin-bottom: 1rem;
    color: var(--text-light);
    font-size: 0.875rem;
}

.products-table {
    width: 100%;
    background: var(--surface);
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    border-collapse: collapse;
    overflow: hidden;
}

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

.products-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.products-table th.sortable:hover {
    background: #e5e7eb;
}

.products-table th .sort-icon {
    margin-left: 0.25rem;
    opacity: 0.3;
}

.products-table th.sorted .sort-icon {
    opacity: 1;
}

.products-table th.sorted-asc .sort-icon::after {
    content: '↑';
}

.products-table th.sorted-desc .sort-icon::after {
    content: '↓';
}

.products-table th {
    background: #f3f4f6;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
}

.products-table tbody tr:hover {
    background: #f9fafb;
}

.products-table .loading {
    text-align: center;
    color: var(--text-light);
    padding: 2rem;
}

.site-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.site-badge.itesco {
    background: #dbeafe;
    color: #1d4ed8;
}

.site-badge.kosik {
    background: #fef3c7;
    color: #b45309;
}

.site-badge.rohlik {
    background: #dcfce7;
    color: #15803d;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.pagination button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination #page-info {
    font-size: 0.875rem;
    color: var(--text-light);
}

footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-light);
    font-size: 0.875rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

@media (max-width: 640px) {
    .products-table th:nth-child(4),
    .products-table td:nth-child(4) {
        display: none;
    }
}

/* Product Detail Page */
.back-link {
    display: inline-block;
    margin-bottom: 1.5rem;
    color: var(--primary-dark);
    text-decoration: none;
    font-weight: 500;
}

.back-link:hover {
    text-decoration: underline;
}

.product-detail {
    background: var(--surface);
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    padding: 1.5rem;
}

.product-detail .loading,
.product-detail .error {
    text-align: center;
    padding: 3rem;
    color: var(--text-light);
}

.product-detail .error h2 {
    color: #dc2626;
    margin-bottom: 0.5rem;
}

.product-detail .error a {
    color: var(--primary-dark);
    margin-top: 1rem;
    display: inline-block;
}

.product-header {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.product-image {
    flex-shrink: 0;
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border-radius: 0.5rem;
    overflow: hidden;
}

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

.product-image .no-image {
    color: var(--text-light);
}

.product-info {
    flex: 1;
    min-width: 250px;
}

.product-info h2 {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.product-info .site-badge {
    margin-bottom: 1.5rem;
}

.current-prices {
    margin: 1rem 0;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 0.375rem;
}

.price-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.price-row:last-child {
    border-bottom: none;
}

.price-row .label {
    color: var(--text-light);
}

.price-row .value {
    font-weight: 600;
    font-size: 1.125rem;
}

.product-url {
    margin-top: 1rem;
}

.product-url .label {
    display: block;
    color: var(--text-light);
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.product-link {
    color: var(--primary-dark);
    word-break: break-all;
    text-decoration: none;
}

.product-link:hover {
    text-decoration: underline;
}

.no-url {
    color: var(--text-light);
    font-style: italic;
}

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

.price-history h3 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
    color: var(--text);
}

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

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

.history-table th {
    background: #f3f4f6;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-light);
}

.history-table tbody tr:hover {
    background: #f9fafb;
}

.no-history {
    color: var(--text-light);
    text-align: center;
    padding: 2rem;
}

/* Product name link on list */
.product-name {
    color: var(--primary-dark);
    text-decoration: none;
    font-weight: 500;
}

.product-name:hover {
    text-decoration: underline;
}

@media (max-width: 640px) {
    .product-header {
        flex-direction: column;
    }
    
    .product-image {
        width: 100%;
        height: 200px;
    }
}

/* Price Chart */
.time-range-buttons {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.time-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text);
    transition: all 0.15s ease;
}

.time-btn:hover {
    border-color: var(--primary);
    color: var(--primary-dark);
}

.time-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

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

#priceChart {
    width: 100% !important;
    height: 100% !important;
}
