/* ============================================================
   MORETECH ERP — CORE UI FRAMEWORK
   File: erp_core.css
   Version: v2026.7
   Scope: Global / Shared / Enterprise Core
   Architecture: Mobile-First, Design-Token Driven
============================================================ */

/* ------------------------------------------------------------
   ROOT VARIABLES (Design Tokens)
   Single source of truth for the entire design system.
   Override inside component scopes only when necessary.
------------------------------------------------------------ */
:root {
    /* ── Borders ── */
    --erp-border: #e2e2e2;
    --erp-border-light: #eaeef3;

    /* ── Typography ── */
    --erp-text-dark: #1a1d21;
    --erp-text-medium: #4b5563;
    --erp-text-light: #7b8794;
    --erp-text-muted: #9ca3af;

    /* ── Surfaces ── */
    --erp-bg-white: #ffffff;
    --erp-bg-app: #f4f6f8;
    --erp-bg-soft: #f8fafc;
    --erp-bg-hover: #f1f5f9;

    /* ── Radius ── */
    --erp-radius: 12px;
    --erp-radius-sm: 6px;
    --erp-radius-lg: 16px;
    --erp-radius-pill: 999px;

    /* ── Shadows ── */
    --erp-shadow-xs: 0 1px 3px rgba(0, 0, 0, 0.04);
    --erp-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    --erp-shadow-hover: 0 4px 14px rgba(0, 0, 0, 0.08);
    --erp-shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.07);

    /* ── Transitions ── */
    --erp-transition: 0.2s ease;

    /* ── Spacing Scale ── */
    --erp-space-xs: 4px;
    --erp-space-sm: 8px;
    --erp-space-md: 16px;
    --erp-space-lg: 24px;
    --erp-space-xl: 32px;
    --erp-space-2xl: 48px;

    /* ── Brand Colors ── */
    --erp-primary: #0d6efd;
    --erp-primary-soft: #eef4ff;
    --erp-primary-border: #cfe2ff;

    --erp-success: #16a34a;
    --erp-success-soft: #e8f7ef;

    --erp-warning: #d97706;
    --erp-warning-soft: #fff7ed;

    --erp-danger: #dc2626;
    --erp-danger-soft: #fef2f2;

    --erp-info: #0891b2;
    --erp-info-soft: #ecfeff;
}


/* ============================================================
   GLOBAL BASE STYLES & TYPOGRAPHY
============================================================ */

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    background: var(--erp-bg-app);
    color: var(--erp-text-dark);

    font-family:
        'Source Sans 3',
        system-ui,
        -apple-system,
        'Segoe UI',
        Roboto,
        Helvetica,
        Arial,
        sans-serif;

    font-weight: 400;
    font-size: 15px;
    line-height: 1.4;
    letter-spacing: 0;

    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* -- Weight Helpers -- */
.erp-page-title,
.chart-title,
.kpi-card h5 {
    font-weight: 600;
}


/* ============================================================
   GLOBAL LINK RESET
============================================================ */

a {
    color: var(--erp-primary);
    text-decoration: none;
    transition: color var(--erp-transition);
}

a:hover {
    text-decoration: none;
    color: #0b5ed7;
}


/* ============================================================
   ERP PAGE HEADER (Generic – Not Sticky)
============================================================ */

.erp-header {
    background: var(--erp-bg-white);
    padding: 12px var(--erp-space-lg);
    box-shadow: var(--erp-shadow-xs);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--erp-space-md);
    position: relative;
    z-index: 2;
}

.erp-header .logo-area {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.erp-header .logo-area h4 {
    margin: 0;
}

.erp-header .module-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--erp-text-dark);
}

.erp-header .action-buttons .btn {
    margin-left: var(--erp-space-xs);
}

@media (max-width: 576px) {
    .erp-header {
        padding: 10px var(--erp-space-md);
    }

    .erp-header .module-title {
        font-size: 1.1rem;
    }
}


/* ============================================================
   PAGE BODY WRAPPER
============================================================ */

.erp-body {
    padding: var(--erp-space-lg);
}

@media (max-width: 576px) {
    .erp-body {
        padding: var(--erp-space-md) 14px;
    }
}


/* ============================================================
   KPI CARDS (Unified System-wide)
============================================================ */

.kpi-card {
    position: relative;
    background: var(--erp-bg-white);
    border-radius: var(--erp-radius);
    border: 1px solid var(--erp-border-light);
    min-height: 140px;
    padding: 18px 20px;
    overflow: hidden;
    transition: var(--erp-transition);
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--erp-shadow-hover);
}

.kpi-card h5 {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--erp-text-medium);
    margin-bottom: var(--erp-space-sm);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.kpi-card h3 {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--erp-text-dark);
    margin-bottom: var(--erp-space-sm);
    line-height: 1.1;
}

/* KPI icon watermark */
.kpi-icon {
    position: absolute;
    right: 14px;
    bottom: 10px;
    font-size: 36px;
    opacity: 0.05;
    color: #000;
    pointer-events: none;
}

/* Low stock / compact lists */
.low-stock-list {
    max-height: 80px;
    overflow: hidden;
}

.low-stock-list div {
    font-size: 0.76rem;
    padding: 1px 0;
}

.low-stock-list .badge {
    font-size: 0.68rem;
    padding: 2px 6px;
}

/* -- KPI Mobile -- */
@media (max-width: 576px) {
    .kpi-card {
        min-height: 120px;
        padding: 14px 16px;
    }

    .kpi-card h3 {
        font-size: 1.5rem;
    }
}


/* ============================================================
   FILTER BAR (ERP Standard)
============================================================ */

.filter-bar {
    background: var(--erp-bg-white);
    padding: var(--erp-space-md) 20px;
    border-radius: var(--erp-radius);
    border: 1px solid var(--erp-border-light);
    margin-bottom: var(--erp-space-lg);
}

.filter-bar label,
.filter-label {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--erp-text-medium);
    margin-bottom: var(--erp-space-xs);
}

.filter-btn {
    height: 40px;
    font-size: 0.88rem;
}

@media (max-width: 576px) {
    .filter-bar {
        padding: 12px 14px;
    }
}


/* ============================================================
   SELECT2 — ERP THEME (Scoped)
============================================================ */

.erp-body .select2-container--default .select2-selection--single {
    height: 40px !important;
    border-radius: var(--erp-radius-sm);
    border: 1px solid #d0d0d0;
    padding-top: 4px;
}

.erp-body
.select2-container--default
.select2-selection--single
.select2-selection__rendered {
    line-height: 36px !important;
}

.erp-body
.select2-container--default
.select2-selection--single
.select2-selection__arrow b {
    margin-top: 4px;
}


/* ============================================================
   ERP FOOTER
============================================================ */

.erp-footer {
    margin-top: var(--erp-space-xl);
    padding: 14px 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    font-size: 13px;
    color: #333;
}

.erp-footer a {
    color: var(--erp-primary);
    font-weight: 600;
    text-decoration: none;
}

.erp-footer a:hover {
    text-decoration: underline;
}

.erp-footer-brand {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.erp-footer-version {
    background: var(--erp-primary-soft);
    color: var(--erp-primary);
    padding: 2px 8px;
    border-radius: var(--erp-radius-sm);
    font-weight: 600;
    font-size: 12px;
}

.erp-footer-tagline {
    color: var(--erp-text-light);
    font-weight: 500;
}

/* ── Status Chips ── */

.erp-footer-status {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: var(--erp-space-sm);
}

.erp-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--erp-radius-pill);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.erp-chip-primary {
    background: rgba(13, 110, 253, 0.1);
    color: var(--erp-primary);
}

.erp-chip-info {
    background: rgba(13, 202, 240, 0.12);
    color: #055160;
}

.erp-chip-warning {
    background: rgba(255, 193, 7, 0.15);
    color: #664d03;
}

.erp-chip-danger {
    background: rgba(220, 53, 69, 0.12);
    color: #842029;
}

/* ── Footer Mobile ── */
@media (max-width: 768px) {
    .erp-footer-status,
    .erp-footer-brand {
        justify-content: center;
    }
}
