/* Smart Groceries - Modern CSS */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #fafaf9;
    --surface: #ffffff;
    --text: #1c1917;
    --text-secondary: #57534e;
    --border: #e7e5e4;
    --coles: #d71920;
    --coles-light: #fef2f2;
    --woolworths: #00853E;
    --woolworths-light: #ecfdf5;
    --accent: #6366f1;
    --accent-light: #eef2ff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --radius: 12px;
    --radius-sm: 8px;
}

html { font-size: 16px; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* Header */
.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.app-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}
.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text);
    text-decoration: none;
}
.nav { display: flex; gap: 4px; }
.nav-btn {
    background: transparent;
    border: none;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}
.nav-btn:hover { background: var(--bg); color: var(--text); }
.nav-btn.active { background: var(--accent-light); color: var(--accent); }

/* Tab Content */
.tab-content { display: none; min-height: calc(100vh - 64px); }
.tab-content.active { display: block; }

/* Hero */
.hero {
    padding: 48px 0 32px;
    text-align: center;
}
.hero h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 12px;
}
.hero p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--color) 10%, transparent);
    color: var(--color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 700;
}
.stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-label { font-size: 0.85rem; color: var(--text-secondary); }

/* Section Card */
.section-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 24px;
}
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.section-header h2 { font-size: 1.2rem; font-weight: 600; }

/* Buttons */
.btn, .btn-primary, .btn-secondary, .btn-coles, .btn-woolworths, .btn-sm {
    border: none;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn:hover { background: #f5f5f5; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary { background: var(--bg); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-coles { background: var(--coles); color: white; width: 100%; justify-content: center; margin-top: 12px; }
.btn-coles:hover { opacity: 0.9; }
.btn-woolworths { background: var(--woolworths); color: white; width: 100%; justify-content: center; margin-top: 12px; }
.btn-woolworths:hover { opacity: 0.9; }

/* Search Bar */
.search-bar {
    display: flex;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.search-bar input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.15s;
}
.search-bar input:focus { border-color: var(--accent); }
.search-bar select {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    outline: none;
    background: white;
}

/* Categories Bar */
.categories-bar {
    display: flex;
    gap: 8px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}
.categories-bar::-webkit-scrollbar { display: none; }
.cat-chip {
    padding: 6px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.cat-chip:hover { background: #f0f0f0; }
.cat-chip.active { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }

/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    padding: 24px;
}
.product-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: all 0.15s ease;
    position: relative;
}
.product-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.product-image {
    width: 100%;
    height: 160px;
    background: #f8f8f8;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    overflow: hidden;
}
.product-image img { max-width: 100%; max-height: 100%; object-fit: contain; }
.product-brand { font-size: 0.78rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }
.product-name { font-weight: 600; font-size: 0.95rem; line-height: 1.3; margin-bottom: 8px; }
.product-add-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.15s;
}
.product-add-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }

/* Price Display */
.price-row { display: flex; align-items: baseline; gap: 8px; margin-top: 8px; }
.current-price { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.special .current-price { color: var(--coles); }
.was-price { font-size: 0.9rem; color: #999; text-decoration: line-through; }
.savings-badge {
    background: var(--coles-light);
    color: var(--coles);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 100px;
    margin-left: auto;
}
.store-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 100px;
}
.store-badge.coles { background: var(--coles-light); color: var(--coles); }
.store-badge.woolworths { background: var(--woolworths-light); color: var(--woolworths); }
.unit-price { font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; }
.price-updated { font-size: 0.72rem; color: var(--text-secondary); margin-top: 6px; opacity: 0.65; }

/* Lists */
.lists-container { display: grid; gap: 16px; padding: 24px; }
.list-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #fafafa;
    cursor: pointer;
}
.list-name { font-weight: 600; }
.list-meta { display: flex; gap: 16px; align-items: center; }
.list-total { color: var(--text-secondary); font-size: 0.9rem; }
.add-to-list-btn {
    padding: 6px 12px;
    background: var(--accent-light);
    color: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
}
.list-items { display: none; }
.list-card.open .list-items { display: block; }
.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}
.list-item-info { flex: 1; }
.list-item-name { font-weight: 500; font-size: 0.9rem; }
.list-item-qty { font-size: 0.8rem; color: var(--text-secondary); }
.list-item-actions { display: flex; gap: 8px; align-items: center; }

/* Import Cards */
.import-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    padding: 24px;
}
.import-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}
.store-info { display: flex; align-items: center; gap: 8px; margin: 16px 0; }

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 200;
}
.modal.show { display: flex; align-items: center; justify-content: center; }
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.3);
}
.modal-content {
    position: relative;
    background: white;
    border-radius: var(--radius);
    padding: 32px;
    width: 90%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
}
.modal-content h2 { margin-bottom: 24px; font-size: 1.3rem; }
.modal-content label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 6px; color: var(--text-secondary); }
.modal-content input { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 0.95rem; outline: none; }
.modal-content input:focus { border-color: var(--accent); }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 8px; }

/* Toast */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    background: #1c1917;
    color: white;
    font-size: 0.9rem;
    animation: slideIn 0.3s ease, fadeOut 0.5s ease 2.5s forwards;
    box-shadow: var(--shadow-lg);
}
.toast.success { background: #065f46; }
.toast.error { background: #991b1b; }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(10px); } }

/* Log area */
.log-area {
    padding: 24px;
    background: #1c1917;
    color: #e7e5e4;
    font-family: monospace;
    font-size: 0.8rem;
    line-height: 1.8;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 16px;
}

/* Pagination */
.pagination { display: flex; gap: 8px; padding: 16px 24px; justify-content: center; }
.page-btn {
    padding: 8px 14px;
    border: 1px solid var(--border);
    background: white;
    cursor: pointer;
    border-radius: var(--radius-sm);
}
.page-btn:hover { background: var(--bg); }

/* Responsive */
@media (max-width: 768px) {
    .app-header .container { flex-direction: column; height: auto; padding: 12px 24px; gap: 8px; }
    .nav { overflow-x: auto; width: 100%; justify-content: flex-start; }
    .hero h1 { font-size: 1.8rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .product-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; padding: 16px; }
}

