/* ═══════════════════════════════════════════
   StockSimple — Retail Inventory Tracker
   ═══════════════════════════════════════════ */

/* ---------- Reset & Variables ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:      #1e88e5;
    --primary-dark: #1565c0;
    --primary-bg:   #e3f2fd;
    --green:        #2e7d32;
    --green-bg:     #e8f5e9;
    --orange:       #ef6c00;
    --orange-bg:    #fff3e0;
    --red:          #c62828;
    --red-bg:       #ffebee;
    --purple:       #6a1b9a;
    --purple-bg:    #f3e5f5;
    --text:         #1a1a2e;
    --text-muted:   #64748b;
    --bg:           #f1f5f9;
    --card-bg:      #ffffff;
    --card-border:  #e2e8f0;
    --sidebar-bg:   #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-active: #ffffff;
    --shadow:       0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:    0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg:    0 10px 25px rgba(0,0,0,0.08);
    --radius:       10px;
    --radius-sm:    6px;
    --font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --transition:   0.2s ease;
    --sidebar-w:    240px;
    --sidebar-w-c:  64px;
    --topbar-h:     56px;
}

html { scroll-behavior: smooth; }
body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ---------- Utility ---------- */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green); }
.text-warning { color: var(--orange); }
.text-danger { color: var(--red); }
.fw-bold { font-weight: 700; }

/* ═══════════ APP LAYOUT ═══════════ */
.app-layout {
    display: flex;
    min-height: 100vh;
}
.main-area {
    flex: 1;
    margin-left: var(--sidebar-w);
    transition: margin-left var(--transition);
}
.sidebar.collapsed ~ .main-area {
    margin-left: var(--sidebar-w-c);
}
.main-content {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* ═══════════ SIDEBAR ═══════════ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width var(--transition);
    overflow: hidden;
}
.sidebar.collapsed {
    width: var(--sidebar-w-c);
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff !important;
    white-space: nowrap;
}
.sidebar-brand i { font-size: 1.3rem; color: var(--primary); }
.collapsed-brand { justify-content: center; }

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1.25rem;
    color: var(--sidebar-text) !important;
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: all var(--transition);
    border-left: 3px solid transparent;
}
.nav-item:hover {
    background: rgba(255,255,255,0.06);
    color: #fff !important;
}
.nav-item.active {
    background: rgba(255,255,255,0.1);
    color: #fff !important;
    border-left-color: var(--primary);
}
.nav-item i { width: 20px; text-align: center; font-size: 1rem; flex-shrink: 0; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 0.7rem; }

.sidebar-toggle {
    padding: 0.75rem;
    background: none;
    border: none;
    border-top: 1px solid rgba(255,255,255,0.08);
    color: var(--sidebar-text);
    cursor: pointer;
    transition: color var(--transition);
    font-size: 0.9rem;
}
.sidebar-toggle:hover { color: #fff; }

/* ═══════════ MOBILE TOPBAR ═══════════ */
.mobile-topbar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-h);
    background: var(--sidebar-bg);
    color: #fff;
    align-items: center;
    padding: 0 1rem;
    gap: 0.75rem;
    z-index: 999;
}
.mobile-menu-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.25rem;
}
.mobile-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff !important;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.mobile-brand i { color: var(--primary); }
.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 998;
}

/* ═══════════ PAGE HEADER ═══════════ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.page-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
}
.page-sub {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.15rem;
}

/* ═══════════ BUTTONS ═══════════ */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: background var(--transition), transform var(--transition);
    white-space: nowrap;
}
.btn-primary:hover { background: var(--primary-dark); color: #fff; transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--card-border);
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: all var(--transition);
}
.btn-outline:hover { border-color: var(--primary); background: var(--primary-bg); }

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--red);
    color: #fff;
    border: none;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: background var(--transition);
}
.btn-danger:hover { background: #b71c1c; color: #fff; }

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.75rem;
    transition: all var(--transition);
}
.btn-icon:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }

.action-btns { display: flex; gap: 0.25rem; justify-content: center; }

/* ═══════════ STAT CARDS ═══════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
    position: relative;
    transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card.alert { border-left: 3px solid var(--orange); }
.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}
.stat-card-icon.blue   { background: var(--primary-bg); color: var(--primary); }
.stat-card-icon.green  { background: var(--green-bg); color: var(--green); }
.stat-card-icon.purple { background: var(--purple-bg); color: var(--purple); }
.stat-card-icon.orange { background: var(--orange-bg); color: var(--orange); }
.stat-card-body { flex: 1; }
.stat-card-num { font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.stat-card-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }
.stat-card-link {
    position: absolute;
    bottom: 0.5rem;
    right: 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
}

/* ═══════════ CARDS ═══════════ */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--card-border);
}
.card-header h2 {
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.card-header h2 i { color: var(--primary); font-size: 0.9rem; }
.card-header-link { font-size: 0.8rem; font-weight: 600; }
.card-body { padding: 1.25rem; }
.card-footer-link {
    display: block;
    text-align: center;
    padding-top: 0.75rem;
    margin-top: 0.75rem;
    border-top: 1px solid var(--card-border);
    font-size: 0.85rem;
    font-weight: 600;
}

/* ═══════════ DASHBOARD GRID ═══════════ */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

/* ═══════════ BADGES ═══════════ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}
.badge-warning { background: var(--orange-bg); color: var(--orange); }
.badge-danger  { background: var(--red-bg); color: var(--red); }
.stock-badge {
    display: inline-flex;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}

/* ═══════════ ALERT LIST ═══════════ */
.alert-list { display: flex; flex-direction: column; gap: 0.5rem; }
.alert-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    background: var(--bg);
    transition: background var(--transition);
}
.alert-item:hover { background: var(--orange-bg); }
.alert-item.out-of-stock { border-left: 3px solid var(--red); }
.alert-item-name { font-weight: 600; font-size: 0.9rem; display: block; }
.alert-item-sku { font-size: 0.75rem; color: var(--text-muted); }

/* ═══════════ TABLES ═══════════ */
.table-responsive { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--card-border);
    white-space: nowrap;
}
.table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--card-border);
    vertical-align: middle;
}
.table-hover tbody tr:hover { background: var(--bg); }
.row-warning { background: var(--orange-bg) !important; }
.row-danger  { background: var(--red-bg) !important; }
.product-link { font-weight: 600; }

.category-tag {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: var(--bg);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ═══════════ FILTER BAR ═══════════ */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.filter-search {
    position: relative;
    flex: 1;
    min-width: 200px;
}
.filter-search i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
}
.filter-search input {
    width: 100%;
    padding: 0.6rem 0.75rem 0.6rem 2.25rem;
    border: 1.5px solid var(--card-border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: var(--font);
    background: var(--card-bg);
    color: var(--text);
    transition: border-color var(--transition);
}
.filter-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30,136,229,0.1);
}
.filter-select {
    padding: 0.6rem 0.75rem;
    border: 1.5px solid var(--card-border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: var(--font);
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
    min-width: 160px;
}
.filter-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ═══════════ LOW STOCK PAGE ═══════════ */
.low-stock-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}
.low-stock-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    position: relative;
    border-left: 3px solid var(--orange);
}
.low-stock-card.out-of-stock { border-left-color: var(--red); }
.low-stock-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.low-stock-card h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.2rem; }
.low-stock-meta {
    display: flex;
    gap: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0.75rem 0;
}
.low-stock-actions { display: flex; gap: 0.5rem; }

/* ═══════════ FORMS ═══════════ */
.form-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 1.75rem;
    box-shadow: var(--shadow);
    max-width: 800px;
}
.form-section {
    margin-bottom: 1.75rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--card-border);
}
.form-section:last-of-type { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.form-section h3 {
    font-size: 0.95rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    color: var(--primary);
}
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}
.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.75rem;
}
.form-group label {
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text);
}
.form-input,
.form-group input,
.form-group textarea,
.form-group select {
    padding: 0.6rem 0.75rem;
    border: 1.5px solid var(--card-border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: var(--font);
    background: var(--card-bg);
    color: var(--text);
    transition: border-color var(--transition);
}
.form-input:focus,
.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30,136,229,0.1);
}
.form-input textarea { resize: vertical; }
.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.2rem; }
.form-static {
    padding: 0.6rem 0;
    font-size: 1.1rem;
    font-weight: 700;
}
.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding-top: 1.25rem;
    margin-top: 1.25rem;
    border-top: 1px solid var(--card-border);
}

/* ═══════════ EMPTY STATE ═══════════ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state.small { padding: 1.5rem 1rem; }
.empty-state i { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.4; }
.empty-state h3 { font-size: 1.1rem; color: var(--text); margin-bottom: 0.3rem; }
.empty-state p { font-size: 0.92rem; margin-bottom: 1rem; }

/* ═══════════ FOOTER ═══════════ */
.site-footer {
    text-align: center;
    padding: 1.5rem 1rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    border-top: 1px solid var(--card-border);
    margin-left: var(--sidebar-w);
    transition: margin-left var(--transition);
}
.sidebar.collapsed ~ .main-area ~ .site-footer,
.sidebar.collapsed + .mobile-topbar + .main-area ~ .site-footer { margin-left: var(--sidebar-w-c); }
.footer-credit { margin-top: 0.2rem; opacity: 0.7; }
.footer-credit a { color: var(--primary); }

/* ═══════════ LOADING ═══════════ */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    gap: 1rem;
    color: var(--primary);
}
.loading-icon { font-size: 2.5rem; animation: spin 2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#blazor-error-ui { display: none; }

/* ═══════════ RESPONSIVE ═══════════ */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .sidebar.mobile-open {
        display: flex;
        width: var(--sidebar-w);
        z-index: 1001;
    }
    .mobile-topbar { display: flex; }
    .mobile-overlay { display: block; }

    .main-area {
        margin-left: 0 !important;
        padding-top: var(--topbar-h);
    }
    .main-content { padding: 1.25rem; }
    .site-footer { margin-left: 0 !important; }

    .desktop-toggle { display: none; }

    .stats-grid { grid-template-columns: 1fr 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .low-stock-grid { grid-template-columns: 1fr; }

    .page-header { flex-direction: column; }
    .page-header h1 { font-size: 1.35rem; }

    .filter-bar { flex-direction: column; }
    .filter-select { min-width: 100%; }

    .form-row { grid-template-columns: 1fr; }
    .form-actions { flex-direction: column; }
    .form-actions .btn-primary { order: -1; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .stat-card-num { font-size: 1.25rem; }
    .table { font-size: 0.8rem; }
    .table th, .table td { padding: 0.4rem 0.5rem; }
}

/* ═══════════════════════════════════════════
   Barcode Scanner Modal
   ═══════════════════════════════════════════ */
.bs-container {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem;
    width: min(480px, 92vw);
    box-shadow: var(--shadow-lg);
}
.bs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.bs-header h3 { font-size: 1rem; font-weight: 600; }
.bs-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0 0.25rem;
}
.bs-close:hover { color: var(--text); }
.bs-viewport {
    position: relative;
    background: #000;
    border-radius: var(--radius-sm);
    overflow: hidden;
    aspect-ratio: 4/3;
}
#bs-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.bs-line {
    position: absolute;
    top: 50%;
    left: 10%;
    right: 10%;
    height: 2px;
    background: var(--primary);
    opacity: 0.8;
    box-shadow: 0 0 6px var(--primary);
    animation: bs-scan 2s ease-in-out infinite;
}
@keyframes bs-scan {
    0%, 100% { top: 35%; }
    50%       { top: 65%; }
}
.bs-status {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    text-align: center;
    color: var(--text-muted);
}

/* Input + inline scan button */
.input-with-btn {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.input-with-btn .form-input { flex: 1; }
.btn-scan {
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 1rem;
}
.btn-scan:hover {
    background: var(--primary-bg);
    color: var(--primary);
    border-color: var(--primary);
}
.btn-scan-find {
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
