/* ─────────────────────────────────────────────────────────────────────────────
   ninjaCompare Dashboard – styles
   ───────────────────────────────────────────────────────────────────────────── */

:root {
    --color-bg: #f8f9fa;
    --color-surface: #ffffff;
    --color-border: #dee2e6;
    --color-primary: #2563eb;
    --color-text: #212529;
    --color-muted: #6c757d;
    --color-billa: #e63946;
    --color-spar: #2a9d8f;
    --color-hofer: #f97316;
    --color-ninja: #f4a261;
    --color-velofood: #457b9d;
    --color-alfies-graz: #7c3aed;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header -------------------------------------------------------------------- */
header {
    background: var(--color-primary);
    color: #fff;
    padding: 1.5rem 2rem;
    text-align: center;
}
header h1 { font-size: 2rem; font-weight: 700; }
header .subtitle { margin-top: 0.25rem; opacity: 0.85; }

/* Main ---------------------------------------------------------------------- */
main {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

/* Controls ------------------------------------------------------------------ */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
}

.controls input[type="text"] {
    flex: 1 1 220px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
}

.controls select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    background: var(--color-surface);
}

.reload-btn {
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    background: var(--color-surface);
    color: var(--color-primary);
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.15s, box-shadow 0.15s;
}
.reload-btn:hover:not(:disabled) {
    background: #eef2ff;
    box-shadow: var(--shadow);
}
.reload-btn:disabled {
    color: var(--color-muted);
    cursor: default;
    opacity: 0.6;
}

.store-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.store-filters label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    border: 2px solid transparent;
    font-size: 0.875rem;
    cursor: pointer;
    user-select: none;
    font-weight: 500;
}
.store-filters label.billa  { background: #fce4e6; color: var(--color-billa); border-color: var(--color-billa); }
.store-filters label.spar   { background: #d8f0ed; color: var(--color-spar);  border-color: var(--color-spar); }
.store-filters label.hofer  { background: #ffedd5; color: var(--color-hofer); border-color: var(--color-hofer); }
.store-filters label.ninja  { background: #fdf0e2; color: var(--color-ninja); border-color: var(--color-ninja); }
.store-filters label.velofood { background: #d6e8f0; color: var(--color-velofood); border-color: var(--color-velofood); }
.store-filters label.alfies-graz { background: #ede9fe; color: var(--color-alfies-graz); border-color: var(--color-alfies-graz); }

/* Stats --------------------------------------------------------------------- */
.stats {
    font-size: 0.875rem;
    color: var(--color-muted);
    margin-bottom: 0.75rem;
}

/* Table --------------------------------------------------------------------- */
.table-wrapper {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead th {
    background: #f1f3f5;
    padding: 0.65rem 0.85rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
}

tbody tr:nth-child(even) { background: #fafafa; }
tbody tr:hover { background: #eef2ff; }

tbody td {
    padding: 0.55rem 0.85rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.product-name { font-weight: 500; }
.product-name a { color: var(--color-primary); text-decoration: none; }
.product-name a:hover { text-decoration: underline; }

.store-badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.store-badge.billa   { background: #fce4e6; color: var(--color-billa); }
.store-badge.spar    { background: #d8f0ed; color: var(--color-spar); }
.store-badge.hofer   { background: #ffedd5; color: var(--color-hofer); }
.store-badge.ninja   { background: #fdf0e2; color: var(--color-ninja); }
.store-badge.velofood { background: #d6e8f0; color: var(--color-velofood); }
.store-badge.alfies-graz { background: #ede9fe; color: var(--color-alfies-graz); }

.bio-badge {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    font-size: 0.75rem;
    background: #d1fae5;
    color: #065f46;
    font-weight: 600;
}

.loading, .error, .no-results {
    text-align: center;
    padding: 2rem;
    color: var(--color-muted);
}
.error { color: #dc2626; }

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

.pagination button {
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-primary);
    font-size: 0.9rem;
    cursor: pointer;
    font-weight: 600;
}

.pagination button:hover:not(:disabled) {
    background: #eef2ff;
}

.pagination button:disabled {
    color: var(--color-muted);
    cursor: default;
}

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

/* Footer -------------------------------------------------------------------- */
footer {
    text-align: center;
    padding: 1rem;
    font-size: 0.8rem;
    color: var(--color-muted);
    border-top: 1px solid var(--color-border);
}
footer a { color: var(--color-muted); }

/* ─────────────────────────────────────────────────────────────────────────────
   Basket & Comparison Feature
   ───────────────────────────────────────────────────────────────────────────── */

/* Utility */
.hidden { display: none !important; }
body.modal-open { overflow: hidden; }

/* Basket column in product table ------------------------------------------- */
.basket-col-header { width: 3rem; }

.basket-cell { text-align: center; width: 3rem; }

.basket-btn {
    width: 2rem;
    height: 2rem;
    border: 2px solid var(--color-border);
    border-radius: 50%;
    background: var(--color-surface);
    color: var(--color-muted);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
}

.basket-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: #eef2ff;
    transform: scale(1.1);
}

.basket-btn.in-basket {
    border-color: #16a34a;
    background: #dcfce7;
    color: #16a34a;
}

.basket-btn.in-basket:hover {
    border-color: #dc2626;
    background: #fef2f2;
    color: #dc2626;
}

tr.row-in-basket {
    background: #f0fdf4 !important;
}
tr.row-in-basket:hover {
    background: #dcfce7 !important;
}

/* Basket FAB (floating action button) -------------------------------------- */
.basket-fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 900;
    animation: fab-enter 0.3s ease;
}

@keyframes fab-enter {
    from { opacity: 0; transform: translateY(20px) scale(0.9); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.basket-fab button {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: 999px;
    background: var(--color-primary);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
    transition: transform 0.15s, box-shadow 0.15s;
}

.basket-fab button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45);
}

.basket-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4rem;
    height: 1.4rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: #fff;
    color: var(--color-primary);
    font-size: 0.8rem;
    font-weight: 700;
}

/* Comparison modal --------------------------------------------------------- */
.comparison-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem 1rem;
    overflow-y: auto;
    animation: modal-fade-in 0.2s ease;
}

@keyframes modal-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.comparison-content {
    background: var(--color-bg);
    border-radius: 12px;
    width: 100%;
    max-width: 1280px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: modal-slide-in 0.25s ease;
}

@keyframes modal-slide-in {
    from { opacity: 0; transform: translateY(-20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.comparison-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
    border-radius: 12px 12px 0 0;
}

.comparison-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

.comparison-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.comparison-action-btn {
    padding: 0.4rem 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.comparison-action-btn:hover { background: #f1f3f5; }
.comparison-action-btn.danger { color: #dc2626; }
.comparison-action-btn.danger:hover { background: #fef2f2; }

.comparison-close-btn {
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--color-muted);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.comparison-close-btn:hover {
    background: #f1f3f5;
    color: var(--color-text);
}

.comparison-body {
    padding: 1.5rem;
}

/* Comparison: empty state */
.comparison-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-muted);
}
.comparison-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}
.comparison-empty-hint {
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* Comparison: summary bar */
.comparison-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding: 0.85rem 1rem;
    background: var(--color-surface);
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
}

.comparison-summary-count {
    font-size: 0.9rem;
    color: var(--color-muted);
    font-weight: 500;
}

.comparison-summary-savings {
    font-size: 0.9rem;
    color: #16a34a;
    font-weight: 500;
}

/* Comparison: store baskets grid */
.comparison-stores {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.comparison-store {
    background: var(--color-surface);
    border-radius: var(--radius);
    border: 2px solid var(--color-border);
    overflow: hidden;
    transition: border-color 0.2s;
}

.comparison-store.cheapest {
    border-color: #16a34a;
    box-shadow: 0 0 0 1px rgba(22, 163, 74, 0.1), 0 2px 8px rgba(22, 163, 74, 0.1);
}

.comparison-store-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--color-border);
    background: #fafafa;
}

.comparison-store-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cheapest-badge {
    font-size: 0.75rem;
    font-weight: 600;
    color: #16a34a;
    background: #dcfce7;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
}

.comparison-store-total {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text);
}

.comparison-products {
    padding: 0.5rem 0;
}

.comparison-product {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    transition: background 0.1s;
}
.comparison-product:hover {
    background: #f8f9fa;
}

.comparison-product-info {
    flex: 1;
    min-width: 0;
}

.comparison-product-name {
    display: block;
    font-size: 0.88rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.comparison-product-detail {
    display: block;
    font-size: 0.78rem;
    color: var(--color-muted);
    margin-top: 0.1rem;
}

.comparison-product-price {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

.comparison-remove-btn {
    width: 1.5rem;
    height: 1.5rem;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--color-muted);
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}
.comparison-remove-btn:hover {
    background: #fef2f2;
    color: #dc2626;
}

.comparison-total-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-top: 2px solid var(--color-border);
    font-weight: 600;
    font-size: 0.95rem;
}

.comparison-total-price {
    font-size: 1.05rem;
}

.comparison-savings-note {
    padding: 0.5rem 1rem;
    background: #f0fdf4;
    color: #16a34a;
    font-size: 0.82rem;
    font-weight: 500;
    text-align: center;
    border-top: 1px solid #dcfce7;
}

/* Comparison: price history */
.comparison-history {
    margin-top: 0.5rem;
}

.comparison-history h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.main-chart-container {
    background: var(--color-surface);
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    padding: 1rem;
    height: 320px;
    margin-bottom: 1.5rem;
}

.no-chart-data {
    text-align: center;
    color: var(--color-muted);
    font-size: 0.9rem;
    padding: 2rem 1rem;
}

.product-charts-container h4 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    color: var(--color-muted);
}

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

.product-chart-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.product-chart-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.6rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 500;
    border-bottom: 1px solid var(--color-border);
    background: #fafafa;
}
.product-chart-title span:first-child {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.product-chart-canvas-wrap {
    padding: 0.5rem;
    height: 140px;
}

/* Toast notification ------------------------------------------------------- */
.toast {
    position: fixed;
    bottom: 5rem;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    padding: 0.65rem 1.25rem;
    background: #1e293b;
    color: #fff;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 500;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Normalize-by-weight toggle ---------------------------------------------- */
.normalize-toggle {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    cursor: pointer;
    user-select: none;
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.15s, border-color 0.15s;
}

.normalize-toggle:hover {
    background: #f1f3f5;
    border-color: var(--color-primary);
}

.normalize-toggle input[type="checkbox"] {
    display: none;
}

.normalize-toggle-slider {
    position: relative;
    width: 2rem;
    height: 1.15rem;
    border-radius: 999px;
    background: #ccc;
    transition: background 0.2s;
    flex-shrink: 0;
}

.normalize-toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: calc(1.15rem - 4px);
    height: calc(1.15rem - 4px);
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.normalize-toggle input:checked + .normalize-toggle-slider {
    background: var(--color-primary);
}

.normalize-toggle input:checked + .normalize-toggle-slider::after {
    transform: translateX(calc(2rem - 1.15rem));
}

.normalize-toggle-label {
    color: var(--color-text);
    white-space: nowrap;
}

/* Normalized price labels in comparison */
.normalized-label {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.price-unit-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-muted);
    margin-left: 0.1rem;
}

/* Normalization hint banner */
.normalize-hint {
    font-size: 0.82rem;
    color: var(--color-muted);
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    padding: 0.5rem 0.85rem;
    margin-bottom: 1rem;
}

/* Responsive -------------------------------------------------------------- */
@media (max-width: 600px) {
    .comparison-content { border-radius: 8px; }
    .comparison-modal { padding: 1rem 0.5rem; }
    .comparison-stores { grid-template-columns: 1fr; }
    .comparison-header { padding: 1rem; flex-wrap: wrap; gap: 0.5rem; }
    .comparison-header h2 { font-size: 1.1rem; }
    .comparison-body { padding: 1rem; }
    .basket-fab { bottom: 1rem; right: 1rem; }
    .product-charts-grid { grid-template-columns: 1fr; }
    .main-chart-container { height: 250px; }
}
