/* ================================================
   PRICETRACKER // CORE_SYSTEM_v4.0
   Apple Glass Design // Glassmorphism
   ================================================ */

:root {
    --bg-light: #f5f5f7;
    --bg-dark: #121217;
    --glass-light: rgba(255, 255, 255, 0.7);
    --glass-dark: rgba(20, 20, 28, 0.75);
    --border-light: rgba(0, 0, 0, 0.08);
    --border-dark: rgba(255, 255, 255, 0.1);
    --accent: #007aff;
    --accent-glow: rgba(0, 122, 255, 0.4);
    --magenta: #ff2d55;
    --magenta-glow: rgba(255, 45, 85, 0.4);
    --lime: #34c759;
    --text-light: #1c1c1e;
    --text-dark: #f5f5f7;
    --text-muted-light: #8e8e93;
    --text-muted-dark: #aeaeb2;
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.12);
    --radius: 12px;
    --radius-lg: 24px;
    --font: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'Share Tech Mono', monospace;
}

.theme-dark {
    --bg: var(--bg-dark);
    --glass: var(--glass-dark);
    --border: var(--border-dark);
    --text: var(--text-dark);
    --text-muted: var(--text-muted-dark);
}

body {
    --bg: var(--bg-light);
    --glass: var(--glass-light);
    --border: var(--border-light);
    --text: var(--text-light);
    --text-muted: var(--text-muted-light);
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    height: 100vh; margin: 0;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Layout --- */
.app-container { display: flex; height: 100vh; width: 100vw; }

.sidebar {
    width: 290px; background: var(--glass);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column; z-index: 100;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    height: 100vh;
}

.sidebar-header { padding: 24px 20px; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1rem; color: var(--accent); letter-spacing: 1px; }

.sidebar-search { padding: 0 20px 20px; position: relative; flex-shrink: 0; }
.sidebar-search input {
    width: 100%; padding: 12px 12px 12px 38px;
    background: rgba(0, 0, 0, 0.05); border: 1px solid transparent;
    border-radius: 14px; color: var(--text); outline: none; transition: 0.2s;
}
.theme-dark .sidebar-search input { background: rgba(255, 255, 255, 0.05); }
.sidebar-search input:focus { border-color: var(--accent); background: transparent; }
.sidebar-search i { position: absolute; left: 34px; top: 14px; color: var(--text-muted); font-size: 0.9rem; }

/* Category Scrolling */
.category-container { flex: 1; overflow-y: auto; padding: 0 14px; }
.category-section { margin-bottom: 24px; }
.section-label { font-size: 0.65rem; font-weight: 800; color: var(--text-muted); padding: 0 10px 10px; letter-spacing: 1.5px; display: flex; align-items: center; gap: 8px; }
.select-all { display: flex; align-items: center; gap: 12px; padding: 10px; font-size: 0.8rem; font-weight: 700; cursor: pointer; border-radius: 10px; margin-bottom: 5px; }

.category-list { list-style: none; padding: 0; margin: 0; }
.category-item {
    display: flex; align-items: center; gap: 12px; padding: 10px;
    font-size: 0.82rem; font-weight: 500; border-radius: 12px;
    cursor: pointer; transition: 0.2s; position: relative;
}
.category-item:hover { background: rgba(0, 122, 255, 0.1); color: var(--accent); }
.category-item.active { background: rgba(0, 122, 255, 0.15); color: var(--accent); font-weight: 700; }

.bookmark-btn {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; padding: 5px; transition: 0.2s; margin-left: auto; font-size: 0.9rem;
}
.bookmark-btn.active { color: #ff9500; }

.sidebar-footer { padding: 20px; flex-shrink: 0; border-top: 1px solid var(--border); }

/* --- Main Content --- */
.main-content { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    min-width: 0; 
    background: var(--bg); 
    height: 100vh;
}

.top-nav {
    height: 72px; padding: 0 30px;
    background: var(--glass);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; 
    z-index: 50;
    flex-shrink: 0;
}

.view-title h1 { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.5px; margin: 0; }
.status-badge { font-size: 0.6rem; font-weight: 800; color: var(--lime); display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.pulse { width: 6px; height: 6px; background: var(--lime); border-radius: 50%; display: inline-block; animation: pulseFade 1.5s infinite; }
@keyframes pulseFade { 0% { opacity: 0.2; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.2); } 100% { opacity: 0.2; transform: scale(0.8); } }

.nav-right { display: flex; align-items: center; gap: 16px; }

.search-bar { position: relative; }
.search-bar input {
    padding: 10px 16px 10px 42px; border-radius: 14px;
    background: rgba(0, 0, 0, 0.05); border: none; color: var(--text);
    width: 220px; transition: 0.3s; outline: none; font-size: 0.85rem;
}
.theme-dark .search-bar input { background: rgba(255, 255, 255, 0.05); }
.search-bar input:focus { width: 320px; background: transparent; border: 1px solid var(--border); }
.search-bar i { position: absolute; left: 16px; top: 12px; color: var(--text-muted); font-size: 0.9rem; }

.controls { display: flex; align-items: center; gap: 10px; }
.glass-select {
    padding: 10px 14px; border-radius: 14px; border: 1px solid var(--border);
    background: var(--glass); color: var(--text); font-family: inherit;
    font-size: 0.75rem; font-weight: 700; outline: none; cursor: pointer;
}

/* Stats Bar */
.stats-grid { 
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    gap: 12px; 
    padding: 10px 30px; 
    flex-shrink: 0;
}
.stat-card {
    background: var(--glass); backdrop-filter: blur(20px); border: 1px solid var(--border);
    padding: 12px 16px; border-radius: var(--radius); display: flex; flex-direction: column; gap: 4px;
    box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat-card::after { content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%; background: var(--accent); }
.stat-card.highlight::after { background: var(--magenta); }

.stat-card .label { font-size: 0.6rem; color: var(--text-muted); font-weight: 800; text-transform: uppercase; letter-spacing: 1px; }
.stat-card .value { font-size: 1.2rem; font-weight: 800; font-family: var(--font-mono); }
.stat-card .value.highlight { color: var(--magenta); text-shadow: 0 0 10px var(--magenta-glow); }

/* Range Analysis Bar */
.filter-options { 
    padding: 0 30px 10px; 
    display: flex; 
    align-items: center; 
    flex-shrink: 0;
}
.glass-group {
    background: var(--glass); backdrop-filter: blur(20px); border: 1px solid var(--border);
    padding: 6px 14px; border-radius: 12px; display: flex; align-items: center; gap: 10px;
    font-size: 0.7rem; font-weight: 700; box-shadow: var(--shadow);
}
.range-text { color: var(--accent); font-family: var(--font-mono); background: rgba(0, 122, 255, 0.1); padding: 2px 8px; border-radius: 4px; }

/* Product Grid */
.content-area { 
    flex: 1; 
    overflow-y: auto; 
    padding-bottom: 20px; 
}

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; padding: 0 30px 20px; }

.product-card {
    background: var(--glass); backdrop-filter: blur(20px); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 10px; cursor: pointer; transition: 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    position: relative; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.product-card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2); }

.product-img {
    width: 100%; height: 80px; background: #fff; border-radius: 8px;
    margin-bottom: 8px; display: flex; align-items: center; justify-content: center;
    position: relative; transition: 0.3s;
}
.product-img img { max-width: 90%; max-height: 90%; object-fit: contain; }

.product-name { font-size: 0.75rem; font-weight: 700; line-height: 1.3; height: 2.6em; overflow: hidden; margin-bottom: 8px; }

.price-row { display: flex; align-items: baseline; gap: 4px; }
.price-val { font-size: 1.1rem; font-weight: 800; color: var(--accent); font-family: var(--font-mono); }
.price-val.price-up { color: var(--magenta); text-shadow: 0 0 8px var(--magenta-glow); }
.price-val.price-down { color: var(--lime); text-shadow: 0 0 8px rgba(52, 199, 89, 0.4); }
.price-unit { font-size: 0.65rem; color: var(--text-muted); font-weight: 600; }

/* Actual Price Hover View */
.hover-details {
    position: absolute; inset: 0; background: rgba(255, 255, 255, 0.95);
    border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center;
    opacity: 0; transition: 0.3s; z-index: 5; pointer-events: none;
}
.theme-dark .hover-details { background: rgba(28, 28, 30, 0.95); }
.product-img:hover .hover-details { opacity: 1; }

.hover-label { font-size: 0.5rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; }
.hover-price { font-size: 0.9rem; font-weight: 800; color: var(--magenta); }

/* Badges */
.badge { 
    position: absolute; top: 6px; right: 6px; 
    padding: 4px 8px; border-radius: 8px; 
    font-size: 0.65rem; font-weight: 900; 
    font-family: var(--font-mono); z-index: 10; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.badge.down { background: var(--lime); color: white; border: none; }
.badge.up { background: var(--magenta); color: white; border: none; }

/* --- Modals --- */
.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 2000; animation: modalIn 0.3s ease; }
.modal.hidden { display: none !important; }
@keyframes modalIn { from { opacity: 0; } to { opacity: 1; } }

.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(15px); }

.modal-content.expanded { width: 90vw; height: 90vh; max-width: 1600px; padding: 40px; border-radius: 40px; display: flex; flex-direction: column; }
.modal-content.compact { width: 450px; padding: 30px; border-radius: 30px; }

.modal-content.glass { background: var(--glass); backdrop-filter: blur(50px) saturate(180%); border: 1px solid var(--border); position: relative; box-shadow: 0 40px 100px rgba(0, 0, 0, 0.4); z-index: 10; }

.modal-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 30px; flex-shrink: 0; }
.header-main h2 { font-size: 1.8rem; font-weight: 800; letter-spacing: -1px; margin-bottom: 10px; }
.details-row { display: flex; gap: 20px; font-size: 0.9rem; font-weight: 600; color: var(--text-muted); }
.details-row strong { color: var(--accent); }

.modal-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chart-container { flex: 1; width: 100%; min-height: 0; }

/* Footer Compare Bar */
.compare-bar {
    position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(150%);
    padding: 16px 32px; border-radius: 24px; display: flex; align-items: center; gap: 40px;
    z-index: 1000; transition: 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); border: 1.5px solid var(--accent);
    background: var(--glass); backdrop-filter: blur(20px);
}
.compare-bar.visible { transform: translateX(-50%) translateY(0); }

/* Utility Buttons */
.icon-btn {
    width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--border);
    background: var(--glass); color: var(--text); cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: 0.2s;
}
.icon-btn:hover { background: var(--accent); color: white; border-color: var(--accent); box-shadow: 0 0 15px var(--accent-glow); }
.icon-btn.active { background: var(--magenta); color: white; border-color: var(--magenta); box-shadow: 0 0 15px var(--magenta-glow); }

.btn { padding: 14px 24px; border-radius: 16px; font-weight: 700; font-size: 0.9rem; cursor: pointer; transition: 0.2s; border: none; display: flex; align-items: center; gap: 10px; justify-content: center; }
.btn-primary { background: var(--accent); color: white; box-shadow: 0 10px 20px var(--accent-glow); }
.btn-secondary { background: rgba(0, 0, 0, 0.08); color: var(--text); }

.hide-desktop { display: none; }

@media (max-width: 1024px) {
    .hide-desktop { display: flex; }
    .sidebar { position: fixed; left: 0; top: 0; height: 100%; transform: translateX(-100%); }
    .sidebar.visible { transform: translateX(0); }
    .stats-grid { grid-template-columns: 1fr; }
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.15); border-radius: 10px; }
.theme-dark ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); }

@keyframes cardEntrance { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
