:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #10b981;
    --accent-light: #34d399;
    --accent-dark: #059669;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --border: #334155;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -4px rgba(0,0,0,0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
    --maxi-color: #10b981;
    --libertad-color: #3b82f6;
    --masonline-color: #f59e0b;
    --yaguar-color: #ef4444;
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e2e8f0;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.05);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Header */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.header-content {
    display: flex;
    align-items: center;
    height: 64px;
    gap: 1.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: -0.02em;
    flex-shrink: 0;
}

.logo-icon { font-size: 1.75rem; }

.logo-text {
    background: linear-gradient(135deg, var(--accent-light), var(--info));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Search Bar in Header */
.search-bar {
    display: flex;
    flex: 1;
    max-width: 560px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
}

.search-bar:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
}

.search-input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0.65rem 1rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
}

.search-input::placeholder { color: var(--text-muted); }

.search-btn {
    background: var(--accent);
    border: none;
    color: white;
    padding: 0 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: var(--transition);
}

.search-btn:hover { background: var(--accent-dark); }

.theme-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
    font-size: 1rem;
}

.theme-toggle:hover { color: var(--text-primary); transform: scale(1.05); }

/* Filters */
.filters-section {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 64px;
    background: var(--bg-primary);
    z-index: 90;
}

.filters-bar {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-group label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.filter-select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.45rem 2rem 0.45rem 0.7rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    min-width: 140px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
}

.filter-select:focus { outline: none; border-color: var(--accent); }

.results-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0.45rem 0;
}

/* Main */
.main {
    padding: 1.5rem 0 3rem;
    min-height: 60vh;
}

/* Products Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
}

/* Product Card - E-commerce Style */
.product-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent);
}

/* Image Area */
.card-image {
    width: 100%;
    height: 160px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.card-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.card-image .no-image {
    font-size: 3rem;
    opacity: 0.3;
}

.card-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background: var(--accent);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
}

/* Card Body */
.card-body {
    padding: 0.875rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-name {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 0.35rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-brand {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent);
    background: rgba(16,185,129,0.1);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    margin-bottom: 0.75rem;
}

/* Prices in Card */
.card-prices {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1;
}

.price-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    background: var(--bg-primary);
    transition: var(--transition);
}

.price-item.best {
    background: rgba(16,185,129,0.08);
    border: 1px solid rgba(16,185,129,0.2);
}

.price-item .super-info {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
}

.super-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.super-name {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.price-amount {
    font-weight: 700;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    margin-left: 0.5rem;
}

.price-item.best .price-amount {
    color: var(--accent);
}

.price-item .best-tag {
    font-size: 0.55rem;
    font-weight: 700;
    color: var(--accent);
    background: rgba(16,185,129,0.15);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    margin-left: 0.3rem;
}

/* Buy Button */
.card-actions {
    padding: 0 0.875rem 0.875rem;
}

.buy-btn {
    display: block;
    width: 100%;
    padding: 0.5rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: var(--transition);
}

.buy-btn:hover {
    background: var(--accent-dark);
    color: white;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2rem;
    padding-bottom: 1rem;
}

.page-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.5rem 0.875rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.page-btn:hover { border-color: var(--accent); color: var(--text-primary); }
.page-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.page-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0 0.5rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-width: 640px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 10;
}

.modal-close:hover { background: var(--danger); color: white; }

.modal-body { padding: 1.5rem; }

.modal-image {
    width: 100%;
    max-height: 200px;
    object-fit: contain;
    background: white;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    padding-right: 2.5rem;
}

.modal-brand {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
}

.modal-prices-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.modal-price-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    background: var(--bg-primary);
    border: 1px solid transparent;
    transition: var(--transition);
}

.modal-price-item:hover { border-color: var(--border); }

.modal-price-item.best {
    border-color: var(--accent);
    background: rgba(16,185,129,0.05);
}

.modal-price-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.modal-price-super {
    font-weight: 600;
    font-size: 0.9rem;
}

.modal-price-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.modal-price-value {
    font-size: 1.1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.modal-price-item.best .modal-price-value { color: var(--accent); }

.modal-buy-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--accent);
    color: white;
    text-decoration: none;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
    transition: var(--transition);
}

.modal-buy-btn:hover { background: var(--accent-dark); }

.best-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--accent);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    text-transform: uppercase;
}

/* History Chart */
.history-chart {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.history-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.history-bars {
    display: flex;
    align-items: flex-end;
    gap: 0.35rem;
    height: 120px;
    padding-bottom: 1.5rem;
    position: relative;
}

.history-bar-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    position: relative;
}

.history-bar {
    width: 100%;
    border-radius: 3px 3px 0 0;
    min-height: 2px;
    transition: height 0.5s ease;
    position: relative;
}

.history-bar:hover::after {
    content: attr(data-price);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    z-index: 5;
    border: 1px solid var(--border);
}

.history-date {
    font-size: 0.65rem;
    color: var(--text-muted);
    white-space: nowrap;
    position: absolute;
    bottom: -1.25rem;
    transform: rotate(-35deg);
    transform-origin: left center;
}

.history-legend {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

/* Loading */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.7);
    backdrop-filter: blur(2px);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Footer */
.footer {
    border-top: 1px solid var(--border);
    padding: 1.5rem 0;
    background: var(--bg-secondary);
}

.footer-content {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.footer-small {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content { gap: 0.75rem; }
    .logo-text { display: none; }
    .products-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
    .filters-bar { gap: 0.5rem; }
    .filter-select { min-width: 110px; font-size: 0.75rem; }
    .card-image { height: 120px; }
    .card-name { font-size: 0.8rem; }
    .super-name { display: none; }
}

@media (max-width: 480px) {
    .container { padding: 0 0.75rem; }
    .products-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .card-image { height: 100px; }
    .card-body { padding: 0.5rem; }
    .card-actions { padding: 0 0.5rem 0.5rem; }
    .price-item { padding: 0.3rem 0.4rem; }
    .price-amount { font-size: 0.75rem; }
    .modal { max-height: 95vh; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
