/* ============================================================
   INVENTORY OMS — Application Stylesheet
   Clean, professional business UI
   ============================================================ */

/* --- Variables --- */
:root {
    --sidebar-width: 240px;
    --topbar-height: 56px;
    --sidebar-bg: #0f1923;
    --sidebar-text: #a8b5c3;
    --sidebar-active-bg: #1e3a5f;
    --sidebar-active-text: #ffffff;
    --sidebar-hover-bg: rgba(255,255,255,0.06);
    --sidebar-section-color: #4a6080;
    --brand-color: #2563eb;
    --brand-light: #dbeafe;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --border: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --info: #0284c7;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow: 0 4px 12px rgba(0,0,0,.10);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--surface-alt);
    -webkit-font-smoothing: antialiased;
}

/* --- App Shell --- */
.app-wrapper {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.25s ease, transform 0.25s ease;
    z-index: 100;
    scrollbar-width: thin;
    scrollbar-color: #2a3f55 transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #2a3f55; border-radius: 4px; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}
.brand-icon {
    width: 36px; height: 36px;
    background: var(--brand-color);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: white;
    font-size: 18px;
    flex-shrink: 0;
}
.brand-name {
    font-weight: 700;
    color: white;
    font-size: 14px;
    display: block;
    line-height: 1.2;
}
.brand-version {
    font-size: 10px;
    color: var(--sidebar-section-color);
}

.sidebar-nav {
    padding: 12px 0 20px;
    flex: 1;
}

.nav-section {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--sidebar-section-color);
    padding: 16px 16px 4px;
    text-transform: uppercase;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 0;
    font-size: 13.5px;
    font-weight: 400;
    transition: background 0.15s, color 0.15s;
    margin: 1px 8px;
    border-radius: 6px;
}
.nav-item:hover {
    background: var(--sidebar-hover-bg);
    color: #e2e8f0;
}
.nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    font-weight: 500;
}
.nav-item i {
    font-size: 16px;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

/* --- App Body --- */
.app-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100vh;
    overflow: hidden;
}

/* --- Topbar --- */
.topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
    z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 22px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex; align-items: center;
    transition: color 0.15s;
}
.sidebar-toggle:hover { color: var(--text-primary); }

.page-heading {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-menu-btn {
    display: flex; align-items: center; gap: 8px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 12px 4px 4px;
    color: var(--text-primary);
    font-size: 13px;
}
.user-menu-btn:hover { background: var(--surface-alt); }

.user-avatar {
    width: 28px; height: 28px;
    background: var(--brand-color);
    color: white;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

/* --- Content Area --- */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.main-content { /* inner container, used by view() */ }

/* --- Cards --- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}
.card-body { padding: 20px; }

/* --- Stats / KPI Cards --- */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-sm);
}
.stat-icon {
    width: 46px; height: 46px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.stat-icon.blue   { background: #dbeafe; color: #1d4ed8; }
.stat-icon.green  { background: #dcfce7; color: #15803d; }
.stat-icon.orange { background: #ffedd5; color: #c2410c; }
.stat-icon.red    { background: #fee2e2; color: #b91c1c; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon.teal   { background: #ccfbf1; color: #0f766e; }

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}
.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* --- Tables --- */
.table {
    font-size: 13.5px;
}
.table thead th {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--border);
    padding: 10px 12px;
    background: var(--surface-alt);
    white-space: nowrap;
}
.table tbody td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text-primary);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--surface-alt); }
.table-responsive { border-radius: var(--radius); overflow: hidden; }

/* --- Badges --- */
.badge { font-weight: 500; font-size: 11.5px; padding: 4px 8px; }

/* --- Buttons --- */
.btn { font-size: 13.5px; font-weight: 500; border-radius: 6px; }
.btn-primary { background: var(--brand-color); border-color: var(--brand-color); }
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-xs { padding: 2px 8px; font-size: 12px; }

/* --- Forms --- */
.form-label { font-weight: 500; font-size: 13px; color: var(--text-primary); }
.form-control, .form-select {
    font-size: 13.5px;
    border-color: var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    color: var(--text-primary);
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand-color);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.form-text { font-size: 12px; }

/* --- Alerts --- */
.alert {
    border-radius: 6px;
    font-size: 13.5px;
    border: none;
    padding: 12px 16px;
}
.alert-success { background: #f0fdf4; color: #15803d; }
.alert-danger   { background: #fff1f2; color: #b91c1c; }
.alert-warning  { background: #fffbeb; color: #92400e; }
.alert-info     { background: #eff6ff; color: #1e40af; }

/* --- Page Header Row --- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

/* --- Search/Filter Bar --- */
.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 16px;
}
.filter-bar .form-control,
.filter-bar .form-select {
    max-width: 200px;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.empty-state i {
    font-size: 40px;
    margin-bottom: 12px;
    display: block;
    opacity: 0.4;
}
.empty-state p { font-size: 14px; margin-bottom: 0; }

/* --- Stock quantity colors --- */
.stock-low   { color: var(--danger); font-weight: 600; }
.stock-ok    { color: var(--success); font-weight: 600; }
.stock-zero  { color: var(--danger); font-weight: 700; }

/* --- Breadcrumb --- */
.breadcrumb { font-size: 13px; }
.breadcrumb-item.active { color: var(--text-secondary); }

/* --- Product image thumbnail --- */
.product-thumb {
    width: 40px; height: 40px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid var(--border);
}
.product-thumb-placeholder {
    width: 40px; height: 40px;
    border-radius: 6px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    font-size: 18px;
}

/* --- Modal --- */
.modal-header { border-bottom: 1px solid var(--border); }
.modal-footer { border-top: 1px solid var(--border); }
.modal-title { font-size: 15px; font-weight: 600; }

/* --- Login Page --- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f1923 0%, #1e3a5f 100%);
    padding: 20px;
}
.login-card {
    background: white;
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo {
    text-align: center;
    margin-bottom: 28px;
}
.login-logo .logo-icon {
    width: 56px; height: 56px;
    background: var(--brand-color);
    border-radius: 14px;
    display: inline-flex;
    align-items: center; justify-content: center;
    color: white;
    font-size: 28px;
    margin-bottom: 12px;
}
.login-logo h1 { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.login-logo p  { font-size: 13px; color: var(--text-secondary); }

/* --- Pagination --- */
.pagination .page-link { font-size: 13px; color: var(--brand-color); }
.pagination .page-item.active .page-link {
    background: var(--brand-color);
    border-color: var(--brand-color);
}

/* --- Dropdown menu --- */
.dropdown-item { font-size: 13.5px; }
.dropdown-header { font-size: 13px; padding: 8px 16px; }

/* --- Role permission grid --- */
.permission-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}
.permission-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-alt);
    cursor: pointer;
    transition: border-color 0.15s;
}
.permission-item:hover { border-color: var(--brand-color); }
.permission-item input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.permission-item label { font-size: 13px; cursor: pointer; margin: 0; }
.permission-item input:checked ~ label { color: var(--brand-color); font-weight: 500; }

/* --- Sidebar collapsed (mobile) --- */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        transform: translateX(-100%);
        z-index: 200;
    }
    .sidebar.open { transform: translateX(0); }
    .app-body { width: 100%; }
    .content-area { padding: 16px; }
    .page-header h2 { font-size: 17px; }
    .filter-bar .form-control,
    .filter-bar .form-select { max-width: 100%; }
    .page-heading { font-size: 14px; }
    .user-name { display: none !important; }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 199;
    }
    .sidebar-overlay.active { display: block; }
}
