/* 
 * Premium Glassmorphism Style Guide
 * Core Fonts: Inter, sans-serif
 */

:root {
    --bg-color: #0a0b14;
    --glass-bg: rgba(22, 26, 44, 0.5);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-hover: rgba(255, 255, 255, 0.15);
    
    --primary-glow: linear-gradient(135deg, #8b5cf6, #6d28d9);
    --secondary-glow: linear-gradient(135deg, #06b6d4, #0891b2);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-violet: #8b5cf6;
    --accent-cyan: #06b6d4;
    --accent-success: #10b981;
    --accent-discount: #14b8a6;
    --accent-danger: #ef4444;
    --accent-warning: #f59e0b;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Base resets & styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
    padding-bottom: 90px;
}

::-webkit-scrollbar {
    display: none;
}

h1, h2, h3, .stat-val, .premium-badge {
    font-weight: 600;
}

/* Ambient Background Glowing Orbs */
.glow-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    opacity: 0.2;
    pointer-events: none;
}

.orb-1 { width: 300px; height: 300px; background: #6d28d9; top: -50px; right: -50px; }
.orb-2 { width: 250px; height: 250px; background: #0891b2; bottom: 10%; left: -80px; }
.orb-3 { width: 350px; height: 350px; background: #db2777; top: 40%; right: -100px; opacity: 0.1; }

/* Main Layout Container */
.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--primary-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-info h2 {
    font-size: 18px;
    line-height: 1.2;
}

.premium-badge {
    font-size: 10px;
    color: var(--accent-cyan);
    display: flex;
    align-items: center;
    gap: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: var(--transition-smooth);
}

.icon-btn:active { transform: scale(0.9); }

/* Search Section */
.search-wrapper {
    position: relative;
    width: 100%;
}

.search-wrapper input {
    width: 100%;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 14px 40px;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    backdrop-filter: blur(10px);
    transition: var(--transition-smooth);
}

.search-wrapper input:focus {
    border-color: var(--accent-violet);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.clear-search-btn {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    display: none;
}

/* Tab Panels */
.tab-panel {
    display: none;
    animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-panel.active {
    display: block;
}

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

/* Glass Cards */
.glass-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(15px);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 16px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(15px);
    border-radius: 20px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
}

.stat-icon {
    font-size: 20px;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-details {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.stat-val {
    font-size: 18px;
    margin-top: 2px;
}

.savings-card {
    grid-column: span 2;
    background: linear-gradient(135deg, rgba(20, 184, 166, 0.1), rgba(13, 148, 136, 0.02));
    border-color: rgba(20, 184, 166, 0.2);
}

.savings-card .stat-icon {
    background: rgba(20, 184, 166, 0.15);
}

.savings-card .stat-val {
    font-size: 26px;
    color: var(--accent-discount);
}

.savings-glow {
    position: absolute;
    width: 100px;
    height: 100px;
    background: rgba(20, 184, 166, 0.2);
    filter: blur(40px);
    right: -20px;
    bottom: -20px;
}

/* Text helpers */
.text-success { color: var(--accent-success); }
.text-discount { color: var(--accent-discount); }
.text-danger { color: var(--accent-danger); }
.text-stable { color: var(--text-secondary); }

/* Dynamics */
.dynamics-card h3, .categories-dist-card h3, .create-cat-card h3 {
    font-size: 15px;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dynamics-bar {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    overflow: hidden;
    margin-bottom: 12px;
}

.dyn-seg { height: 100%; transition: width 0.5s ease; }
.dyn-discounted { background: var(--accent-discount); }
.dyn-stable { background: var(--text-muted); }
.dyn-increased { background: var(--accent-danger); }

.dynamics-legend { display: flex; justify-content: space-between; font-size: 12px; }
.legend-item { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.dot { width: 8px; height: 8px; border-radius: 50%; }

/* Categories Dist */
.dist-list { display: flex; flex-direction: column; gap: 14px; }
.dist-item { display: flex; flex-direction: column; gap: 6px; }
.dist-meta { display: flex; justify-content: space-between; font-size: 13px; }
.dist-progress-bg { width: 100%; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.05); }
.dist-progress-fill { height: 100%; background: var(--primary-glow); border-radius: 3px; }

/* Filters */
.filters-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}

select {
    width: 100%;
    padding: 12px 14px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-primary);
    outline: none;
    font-size: 13px;
    appearance: none;
}

/* Products List */
.products-grid { display: flex; flex-direction: column; gap: 12px; }

.product-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.product-header { display: flex; gap: 12px; }

.product-photo-wrapper {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.product-photo-wrapper img { width: 100%; height: 100%; object-fit: cover; }
.product-no-photo { font-size: 24px; opacity: 0.5; }

.product-info {
    flex-grow: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.product-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.product-meta-tags { display: flex; gap: 6px; flex-wrap: wrap; }

.cat-tag, .stock-tag {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.cat-tag { background: rgba(255, 255, 255, 0.08); }
.stock-tag { display: flex; align-items: center; gap: 4px; }
.stock-tag.in-stock { background: rgba(16, 185, 129, 0.1); color: var(--accent-success); }
.stock-tag.out-of-stock { background: rgba(239, 68, 68, 0.1); color: var(--accent-danger); }

.product-pricing {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding-top: 8px;
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
}

.price-box { display: flex; flex-direction: column; }
.price-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; }
.price-val { font-size: 18px; font-weight: 700; }

.pct-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 8px;
}
.pct-badge.discount { background: rgba(20, 184, 166, 0.15); color: var(--accent-discount); }
.pct-badge.increase { background: rgba(239, 68, 68, 0.15); color: var(--accent-danger); }
.pct-badge.stable { background: rgba(255, 255, 255, 0.08); color: var(--text-secondary); }

.product-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 4px;
}

.btn {
    padding: 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: var(--transition-smooth);
}

.btn:active { transform: scale(0.95); }

.btn-secondary { background: rgba(255, 255, 255, 0.05); color: var(--text-primary); }
.btn-danger-outline { background: rgba(239, 68, 68, 0.1); color: var(--accent-danger); }
.btn-link { background: rgba(6, 182, 212, 0.1); color: var(--accent-cyan); text-decoration: none; }
.btn-primary { background: var(--primary-glow); color: white; }

/* Category Management */
.input-group { display: flex; gap: 8px; }
.input-group input {
    flex-grow: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 10px 14px;
    color: white;
    outline: none;
}
select option {
    background: var(--bg-color);
    color: var(--text-primary);
}
.categories-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.cat-tile { 
    background: rgba(30, 34, 56, 0.6); 
    border: 1px solid var(--glass-border); 
    border-radius: 16px; 
    padding: 16px; 
    display: flex; 
    flex-direction: column; 
    justify-content: space-between;
    min-height: 90px;
    position: relative;
    overflow: hidden;
}
.cat-tile::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, var(--accent-violet), var(--accent-discount));
    opacity: 0.5;
}
.cat-tile-name { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; word-break: break-word; padding-right: 4px; }
.cat-tile-count { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.cat-tile-actions { display: flex; justify-content: flex-end; margin-top: auto; }
.btn-delete-cat { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.2); border-radius: 8px; color: var(--accent-danger); font-size: 12px; padding: 4px 8px; }
.cat-tile-new {
    background: rgba(139, 92, 246, 0.1);
    border: 1px dashed var(--accent-violet);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 90px;
    cursor: pointer;
}
.cat-tile-new span { color: var(--accent-violet); font-weight: 600; font-size: 14px; margin-top: 4px; }

/* Modal */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.3s;
}
.modal-backdrop.active { display: flex; opacity: 1; }
.glass-modal {
    width: 100%;
    max-width: 400px;
    background: rgba(15, 17, 30, 0.9);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    transform: scale(0.9);
    transition: transform 0.3s;
    overflow: hidden;
}
.modal-backdrop.active .glass-modal { transform: scale(1); }
.modal-header {
    display: flex;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.modal-body { padding: 20px; }
.close-modal-btn { background: none; border: none; color: var(--text-muted); font-size: 24px; }

.info-stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.info-stat-box { background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.05); border-radius: 12px; padding: 12px 8px; text-align: center; }
.is-label { display: block; font-size: 10px; color: var(--text-muted); text-transform: uppercase; margin-bottom: 4px; }
.is-val { display: block; font-size: 16px; font-weight: 700; }
.info-trend { display: flex; align-items: center; justify-content: center; gap: 8px; background: rgba(255,255,255,0.03); padding: 12px; border-radius: 12px; font-size: 14px; font-weight: 500; }
#info-trend-icon { font-size: 18px; }

.cat-select-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.cat-select-btn {
    padding: 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 13px;
}
.cat-select-btn.active { background: rgba(139, 92, 246, 0.2); border-color: var(--accent-violet); }

/* Bottom Nav */
.app-nav {
    position: fixed;
    bottom: 0; left: 50%; transform: translateX(-50%);
    width: 100%; max-width: 600px;
    background: rgba(10, 11, 20, 0.9);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    display: flex; justify-content: space-around;
    padding: 12px 10px 24px;
    z-index: 90;
}
.nav-item {
    background: none; border: none; color: var(--text-muted);
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    font-size: 11px; font-weight: 500;
}
.nav-item.active { color: var(--accent-violet); }
.nav-item.active svg { transform: translateY(-2px); }
.nav-item svg { transition: 0.3s; }

/* Toast */
.toast-container {
    position: fixed; bottom: 100px; left: 50%; transform: translate(-50%, 20px);
    background: rgba(30, 34, 56, 0.95);
    padding: 12px 24px; border-radius: 12px;
    font-size: 13px; z-index: 200; opacity: 0; pointer-events: none;
    transition: 0.3s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    border: 1px solid var(--glass-border);
}
.toast-container.show { transform: translate(-50%, 0); opacity: 1; }

/* Loading */
.loading-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: var(--bg-color); z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.5s;
}
.premium-spinner {
    width: 40px; height: 40px;
    border: 3px solid rgba(139, 92, 246, 0.2);
    border-top-color: var(--accent-violet);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

.empty-state {
    padding: 40px 20px; text-align: center; color: var(--text-muted);
    font-size: 14px; border: 1px dashed rgba(255,255,255,0.1); border-radius: 16px;
}
