:root {
    --bg-color: #000000;
    --card-bg: #0a0a0a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #bb86fc;
    --accent-secondary: #03dac6;
    --border-color: #1e293b;
    --gold: #f59e0b;
    --danger: #ef4444;
    --font-stack: 'Inter', system-ui, -apple-system, sans-serif;
    
    /* Store Accents */
    --color-shwapno: #ff4081;
    --color-chaldal: #007aff;
    --color-meenabazar: #34c759;
    --color-dailyshopping: #ff9f0a;
}

* { box-sizing: border-box; }

body.pitch-black {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-stack);
    margin: 0;
    padding: 0;
}

.app-container { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 300px;
    background: #050505;
    border-right: 1px solid var(--border-color);
    display: flex; flex-direction: column; flex-shrink: 0; z-index: 100;
    position: sticky; top: 0; height: 100vh;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px 15px; border-bottom: 1px solid var(--border-color);
    background: rgba(187, 134, 252, 0.05);
}

.category-list { flex-grow: 1; overflow-y: auto; list-style: none; padding: 0; margin: 0; }

.category-group-header {
    padding: 12px 15px; background: #111; cursor: pointer;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid #222; font-weight: 700; color: var(--accent-secondary);
}

.category-sub-list { list-style: none; padding: 0; display: none; }
.category-sub-list.active { display: block; }

.category-item {
    padding: 8px 15px 8px 30px; cursor: pointer; font-size: 0.8rem;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid #0a0a0a; transition: 0.2s;
}
.category-item:hover { background: rgba(255, 255, 255, 0.05); }
.category-item.active { color: var(--accent-color); border-left: 2px solid var(--accent-color); }

.store-legend { padding: 15px; border-top: 1px solid #222; background: #050505; }
.legend-item { font-size: 0.75rem; color: var(--text-secondary); margin-bottom: 4px; }

/* Main Content */
.main-content { flex-grow: 1; display: flex; flex-direction: column; }

.dashboard-header {
    padding: 12px 20px; display: flex; justify-content: space-between; align-items: center;
    background: #0a0a0a; border-bottom: 1px solid var(--border-color); flex-wrap: wrap; gap: 15px;
}

.header-left { display: flex; align-items: center; gap: 15px; }
.search-wrapper { position: relative; }
.search-input {
    background: #111; border: 1px solid #333; color: #fff;
    padding: 10px 15px; border-radius: 8px; font-size: 0.85rem; width: 300px;
}

.suggestions-box {
    position: absolute; /* Relative to search-wrapper */
    top: 100%; left: 0; width: 400px;
    background: #111; border: 1px solid var(--accent-color);
    border-radius: 0 0 8px 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    z-index: 9999; display: none; max-height: 400px; overflow-y: auto;
}

.suggestion-item {
    padding: 10px 15px; cursor: pointer; border-bottom: 1px solid #222;
    display: flex; justify-content: space-between; align-items: center;
}
.suggestion-item:hover { background: #222; }

/* Intelligence Bar */
.intelligence-bar {
    padding: 10px 20px; background: #050505; border-bottom: 1px solid #111;
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.intel-btn {
    background: #111; border: 1px solid #333; color: #888;
    padding: 5px 12px; border-radius: 20px; cursor: pointer; font-size: 0.75rem; font-weight: 700;
}
.intel-btn:hover, .intel-btn.active { border-color: var(--accent-color); color: #fff; }

/* Grid */
.p-view-sh {
    flex-grow: 1; display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px; padding: 20px; background: #000;
}

.p-item-sh {
    background: var(--card-bg); border: 1px solid #222; border-radius: 10px;
    overflow: hidden; cursor: pointer; transition: 0.2s; position: relative;
}
.p-item-sh:hover { transform: scale(1.02); z-index: 5; }
.p-item-sh.selected { border: 2px solid var(--gold) !important; box-shadow: 0 0 15px var(--gold); }

.store-badge {
    position: absolute; top: 8px; left: 8px; padding: 2px 6px;
    border-radius: 4px; font-size: 0.55rem; font-weight: 900;
    text-transform: uppercase; background: var(--store-color); color: #000; z-index: 10;
}

.p-img-box { width: 100%; aspect-ratio: 1/1; background: #fff; padding: 15px; display: flex; align-items: center; justify-content: center; }
.product-image { max-width: 100%; max-height: 100%; object-fit: contain; }

.price-tag {
    position: absolute; bottom: 8px; right: 8px;
    background: rgba(0,0,0,0.85); color: #fff; padding: 3px 8px;
    border-radius: 4px; font-weight: 800; font-size: 1rem; border: 1px solid #333;
}

/* Mobile Sidebar Fixes */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        transform: translateX(-100%);
        box-shadow: 20px 0 50px rgba(0,0,0,0.8);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .sidebar.visible {
        transform: translateX(0);
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.7);
        backdrop-filter: blur(4px);
        z-index: 90;
    }
    .sidebar-overlay.active {
        display: block;
    }
}

/* Search Wrapper Fix */
.search-wrapper {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.search-input {
    width: 100%;
    padding-right: 35px; /* Room for clear icon */
}

/* Item Card Reconstruction - Zero Crowding */
.p-detail-sh {
    padding: 12px;
    display: flex;
    flex-direction: column;
    height: 125px; /* Taller card for clear rows */
    background: #080808;
    gap: 0;
}

.product-name {
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.3;
    height: 2.6em;
    overflow: hidden;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.product-meta {
    margin-top: auto;
    border-top: 1px solid #1a1a1a;
    padding-top: 8px;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.price-main {
    font-size: 1.1rem;
    font-weight: 900;
    color: var(--accent-color);
}

.unit-label {
    font-size: 0.6rem;
    opacity: 0.5;
    font-weight: normal;
}

.pack-info {
    font-size: 0.65rem;
    color: #888;
    background: #151515;
    padding: 2px 6px;
    border-radius: 4px;
}

.cat-tag {
    font-size: 0.6rem;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.avg-info {
    display: none;
}

.price-main::after {
    content: ''; /* Remove any potential generated content for symbols */
}

/* Multi-Check Category Styles */
.shop-cat-item {
    padding: 6px 15px 6px 35px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.cat-checkbox {
    width: 14px;
    height: 14px;
    accent-color: var(--accent-color);
}

/* Interactive Buttons */
.btn-icon, .intel-btn, .shop-header, .shop-cat-item {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.btn-icon:hover {
    background: rgba(255,255,255,0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.btn-icon:active {
    transform: translateY(0);
}

.btn-icon.active {
    background: var(--accent-color);
    color: #000;
    border-color: var(--accent-color);
}

.intel-btn:hover {
    border-color: var(--accent-color);
    background: rgba(187, 134, 252, 0.1);
}

.intel-btn.active {
    background: var(--accent-color);
    color: #000;
    font-weight: 900;
}

/* Custom Groups CRUD Styles */
.group-header {
    background: #111;
    color: var(--gold);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    font-size: 0.7rem;
    font-weight: 900;
    text-transform: uppercase;
    border-top: 1px solid #222;
    border-bottom: 1px solid #222;
}
.group-item {
    padding: 8px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-size: 0.8rem;
    border-bottom: 1px solid #0a0a0a;
}
.group-item:hover {
    background: rgba(245, 158, 11, 0.05);
}
.group-item.active {
    color: var(--gold);
    border-left: 3px solid var(--gold);
}

/* Shop Toggle Fix */
.shop-toggle-container {
    display: flex;
    align-items: center;
    gap: 8px;
}
.shop-checkbox {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: var(--accent-color);
}

/* Sticky Search Suggestions */
.search-wrapper {
    position: relative;
}
.suggestions-box {
    position: absolute;
    top: 100%;
    left: 0;
    width: 450px; /* Slightly wider than input */
    background: #080808;
    border: 1px solid var(--accent-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.9);
    z-index: 10000;
    display: none;
    max-height: 500px;
    overflow-y: auto;
}

/* Sidebar Shop Hierarchy */
.shop-group {
    border-bottom: 1px solid #111;
}
.shop-header {
    padding: 12px 15px;
    background: #0a0a0a;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 800;
    font-size: 0.75rem;
    color: var(--text-primary);
    transition: 0.2s;
}
.shop-header:hover {
    background: #111;
}
.shop-header i.toggle-icon {
    font-size: 0.6rem;
    transition: transform 0.3s;
}
.shop-header.active i.toggle-icon {
    transform: rotate(180deg);
}
.shop-categories {
    list-style: none;
    padding: 0;
    margin: 0;
    display: none;
    background: #020202;
}
.shop-categories.active {
    display: block;
}
.shop-cat-item {
    padding: 8px 15px 8px 35px;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #666;
    transition: 0.2s;
}
.shop-cat-item:hover {
    background: #0a0a0a;
    color: #fff;
}
.shop-cat-item.active {
    color: var(--accent-color);
    background: rgba(187, 134, 252, 0.05);
}

/* Modals - FULL SCREEN */
.modal {
    display: none; position: fixed; z-index: 10000; inset: 0;
    background: #000; align-items: center; justify-content: center;
}

.modal-content.full-screen-modal {
    width: 100vw; height: 100vh; border: none; border-radius: 0;
    display: flex; flex-direction: column; padding: 20px;
}

.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding-bottom: 15px; border-bottom: 1px solid #222; margin-bottom: 20px;
}

.modal-body-content { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }

/* Cart Tabs */
.cart-tabs { display: flex; gap: 5px; margin-bottom: 20px; border-bottom: 1px solid #222; }
.cart-tab-btn {
    background: transparent; border: none; color: #666; padding: 10px 20px;
    cursor: pointer; font-weight: 700; border-bottom: 2px solid transparent;
}
.cart-tab-btn.active { color: var(--accent-color); border-bottom-color: var(--accent-color); }

/* Stats Bar */
.stats-bar { display: flex; gap: 40px; padding: 15px 20px; background: #050505; border-bottom: 1px solid #111; }
.stat-item { display: flex; flex-direction: column; }
.stat-label { font-size: 0.6rem; color: #555; text-transform: uppercase; letter-spacing: 1.5px; }
.stat-value { font-size: 1.3rem; font-weight: 900; }

/* Filter Pills */
.multi-filter-group { display: flex; align-items: center; gap: 8px; background: #111; padding: 5px 10px; border-radius: 8px; border: 1px solid #222; }
.filter-label { font-size: 0.65rem; font-weight: 800; color: #555; }
.check-pill { font-size: 0.7rem; font-weight: 700; cursor: pointer; display: flex; align-items: center; gap: 4px; }

.btn-icon.danger { color: var(--danger); border-color: #422; }
.btn-icon.danger:hover { background: var(--danger); color: #fff; }

/* Chart Containers */
#compare-chart-container, .chart-container { flex: 1; min-height: 400px; background: #050505; border-radius: 12px; border: 1px solid #111; padding: 20px; }

@media (max-width: 1024px) {
    .search-input { width: 100%; }
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform 0.3s ease; }
    .sidebar.visible { transform: translateX(0); }
    .dashboard-header { flex-direction: column; align-items: stretch; }
    .header-right { flex-direction: column; }
    .stats-bar { overflow-x: auto; white-space: nowrap; }
}

/* Horizontal Stats in Modal */
.chart-analytics {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-evenly;
    gap: 15px;
    margin-bottom: 20px;
}
.stat-card {
    background: #111;
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid #222;
    text-align: center;
    flex: 1;
    min-width: 120px;
}

/* Favoriting */
.fav-btn {
    position: absolute; top: 8px; right: 8px;
    color: #fff; text-shadow: 0 0 5px #000; cursor: pointer; z-index: 15;
    transition: 0.2s;
    background: rgba(0,0,0,0.5);
    width: 25px; height: 25px; display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
}
.fav-btn.active { color: var(--gold); }
.fav-btn.active i { color: var(--gold); }

/* Cart Images */
.cart-content-area img {
    border: 1px solid #333;
}
.category-item label { width: 100%; display: flex; justify-content: space-between; align-items: center; cursor: pointer; }


/* Clear Search */
.clear-search {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    cursor: pointer; color: #555; display: none;
}
.clear-search.visible { display: block; }

/* Sidebar Toggle */
.sidebar-toggle-btn { display: none; }
@media (max-width: 1024px) {
    .sidebar-toggle-btn { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; background: #111; border: 1px solid #333; color: #fff; border-radius: 8px; cursor: pointer; }
}

.spinner-container { display: none; position: fixed; top: 0; left: 0; width: 100%; z-index: 99999; background: #000; text-align: center; padding: 10px; border-bottom: 1px solid var(--accent-color); }  
.spinner-container.active { display: block; }
