/*
 * ══════════════════════════════════════════════════════════
 *   NUTRO ERP — Application Stylesheet
 *   Brand:   Nutro Life Science (nutrolifescience.com)
 *   Accent:  #c8102e (limited — alerts, active, critical)
 *   Primary: Black / White / Light Gray
 *   Font:    IBM Plex Sans
 * ══════════════════════════════════════════════════════════
 */

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
    --accent:          #c8102e;
    --accent-hover:    #a30d24;
    --accent-subtle:   rgba(200, 16, 46, 0.07);
    --accent-border:   rgba(200, 16, 46, 0.25);

    --sidebar-bg:      #dedede;
    --sidebar-width:   224px;
    --topbar-h:        90px;

    --bg:              #f4f4f4;
    --card-bg:         #ffffff;
    --border:          #e6e6e6;
    --border-strong:   #d0d0d0;

    --text-primary:    #111111;
    --text-secondary:  #6b6b6b;
    --text-muted:      #aaaaaa;

    --radius:          8px;
    --radius-lg:       12px;

    --font:            'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html { font-size: 14px; scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }
img { max-width: 100%; display: block; }


/* ══════════════════════════════════════════════════════════
   SHELL LAYOUT
══════════════════════════════════════════════════════════ */

.erp-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ══════════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════════ */

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.22s ease, min-width 0.22s ease;
    flex-shrink: 0;
    z-index: 200;
}

.sidebar.collapsed {
    width: 54px;
    min-width: 54px;
}

/* Hide labels when collapsed */
.sidebar.collapsed .nav-label,
.sidebar.collapsed .logo-text-wrap,
.sidebar.collapsed .nav-arrow,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .user-info,
.sidebar.collapsed .logout-btn,
.sidebar.collapsed .nav-section-header span:first-child { display: none; }

.sidebar.collapsed .sidebar-logo img  { display: none; }
.sidebar.collapsed .logo-mark { margin: 0 auto; }
.sidebar.collapsed .sidebar-logo { justify-content: center; padding: 0 12px; }
.sidebar.collapsed .nav-item-link { justify-content: center; padding: 0 12px; }
.sidebar.collapsed .sidebar-user { justify-content: center; }

/* ── Logo ─────────────────────────────────────────────────── */
.sidebar-logo {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    padding: 0 14px;
    border-bottom: 1px solid rgb(0 0 0 / 9%);
    flex-shrink: 0;
    overflow: hidden;
    gap: 10px;
}

.sidebar-logo-img {
    height: 80px;
    object-fit: contain;
    
    max-width: 140px;
}

.logo-fallback { display: flex; align-items: center; gap: 10px; }

.logo-mark {
    width: 28px;
    height: 28px;
    background: var(--accent);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}

.logo-text-wrap { white-space: nowrap; overflow: hidden; }
.logo-name { display: block; font-size: 13px; font-weight: 600; color: #fff; line-height: 1.3; }
.logo-sub  { display: block; font-size: 9px; color: rgba(255,255,255,0.3); text-transform: uppercase; letter-spacing: 0.1em; }

/* ── Nav Container ───────────────────────────────────────── */
.nav-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
}

.nav-container::-webkit-scrollbar { width: 3px; }
.nav-container::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.07); }

/* ── Nav Items ───────────────────────────────────────────── */
.nav-item-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 14px;
    height: 36px;
    color: #000000;
    font-size: 14.5px;
    transition: background 0.12s, color 0.12s;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item-link:hover {
    color: #c10000;
    background: rgba(255,255,255,0.04);
}

.nav-item-link.active {
    color: #fff;
    background: var(--accent-subtle);
}

.nav-item-link.active::before {
    content: '';
    position: absolute;
    left: 0; top: 8px; bottom: 8px;
    width: 2px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
}

.nav-item-link.sub { padding-left: 18px; font-size: 14px; height: 33px; }

.nav-icon {
    font-size: 16px;
    flex-shrink: 0;
    width: 18px;
    text-align: center;
}

.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }

.nav-badge {
    margin-left: auto;
    background: var(--accent);
    color: #fff;
    font-size: 9px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
    line-height: 14px;
    flex-shrink: 0;
}

/* ── Nav Sections ────────────────────────────────────────── */
.nav-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 14px 10px;
    font-size: 11.5px;
    font-weight: 900;
    color: #000000;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: color 0.12s;
	background-color: #d1d1d1;
}

.nav-section-header:hover { color: #c10000; }

.nav-arrow {
    font-size: 12px;
    transition: transform 0.2s ease;
}

.nav-sub {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.22s ease;
}

.nav-section.open > .nav-sub { max-height: 280px; padding-top: 12px; padding-bottom: 15px;}
.nav-section.open > .nav-section-header > .nav-arrow { transform: rotate(180deg); }

/* ── Sidebar User ────────────────────────────────────────── */
.sidebar-user {
    padding: 10px 14px;
    border-top: 1px solid rgba(255,255,255,0.07);
    display: flex;
    align-items: center;
    gap: 9px;
    flex-shrink: 0;
    overflow: hidden;
}

.user-avatar {
    width: 28px; height: 28px;
    background: rgba(200,16,46,0.75);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 600; color: #fff;
    flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; overflow: hidden; }
.user-name  { font-size: 12px; font-weight: 500; color: #000000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.4; }
.user-role  { font-size: 9.5px; color: #000000; text-transform: uppercase; letter-spacing: 0.05em; }

.logout-btn {
    color: #c10000;
    font-size: 16px;
    display: flex; align-items: center;
    transition: color 0.15s;
    flex-shrink: 0;
}
.logout-btn:hover { color: #000000; }


/* ══════════════════════════════════════════════════════════
   MAIN AREA
══════════════════════════════════════════════════════════ */

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ── Top Bar ─────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 10px;
    flex-shrink: 0;
    z-index: 100;
}

.topbar-toggle {
    color: var(--text-secondary);
    font-size: 18px;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: background 0.12s;
}
.topbar-toggle:hover { background: var(--bg); }

.topbar-title { flex: 1; }
.topbar-breadcrumb { font-weight: 900; font-size: 15px; color: #c10000; text-transform: uppercase; letter-spacing: 0.06em; line-height: 1; }
.topbar-page { font-size: 14.5px; font-weight: 500; color: var(--text-primary); line-height: 1.3; }

.topbar-actions { display: flex; align-items: center; gap: 6px; }

.icon-btn {
    width: 32px; height: 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary);
    font-size: 16px;
    position: relative;
    transition: border-color 0.12s, color 0.12s;
}
.icon-btn:hover { border-color: var(--border-strong); color: var(--text-primary); }

.notif-dot {
    position: absolute;
    top: 6px; right: 7px;
    width: 6px; height: 6px;
    background: var(--accent);
    border-radius: 50%;
    border: 1.5px solid #fff;
}

.topbar-user {
    display: flex; align-items: center; gap: 7px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.12s;
}
.topbar-user:hover { border-color: var(--border-strong); }

.user-avatar-sm {
    width: 22px; height: 22px;
    background: var(--accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 8px; font-weight: 600; color: #fff;
}

.topbar-user-name { font-size: 12px; font-weight: 500; color: var(--text-primary); }

/* ── Flash Message ───────────────────────────────────────── */
.flash-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 13px;
    border-bottom: 1px solid transparent;
    flex-shrink: 0;
}
.flash-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.flash-error   { background: #fff1f2; color: var(--accent); border-color: var(--accent-border); }
.flash-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.flash-close   { margin-left: auto; font-size: 18px; opacity: 0.5; line-height: 1; cursor: pointer; }
.flash-close:hover { opacity: 1; }

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

.content::-webkit-scrollbar { width: 6px; }
.content::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }

/* ── Page Header ─────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 18px;
}

.page-header-title { font-size: 17px; font-weight: 600; color: var(--text-primary); }
.page-header-sub   { font-size: 12.5px; color: var(--text-secondary); margin-top: 3px; }


/* ══════════════════════════════════════════════════════════
   CARDS
══════════════════════════════════════════════════════════ */

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.card-header {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fafafa;
}

.card-title { font-size: 12.5px; font-weight: 600; color: var(--text-primary); }

.card-link { font-size: 11px; color: var(--text-secondary); transition: color 0.12s; }
.card-link:hover { color: var(--text-primary); }
.card-link.danger { color: var(--accent); }
.card-link.danger:hover { color: var(--accent-hover); }

.card-body { padding: 16px; }

.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
}
.empty-state i { font-size: 28px; margin-bottom: 10px; display: block; }
.empty-state p { font-size: 13px; margin-bottom: 14px; }


/* ══════════════════════════════════════════════════════════
   KPI CARDS
══════════════════════════════════════════════════════════ */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.kpi-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.kpi-card.alert-card { border-left: 2px solid var(--accent); }

.kpi-icon-wrap {
    font-size: 20px;
    color: var(--text-muted);
    margin-bottom: 10px;
    line-height: 1;
}
.kpi-card.alert-card .kpi-icon-wrap { color: var(--accent); }

.kpi-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.kpi-value {
    font-size: 26px;
    font-weight: 600;
    color: #c10000;
    line-height: 1;
    margin-bottom: 5px;
}
.kpi-card.alert-card .kpi-value { color: var(--accent); }

.kpi-sub { font-size: 11px; color: var(--text-muted); }


/* ══════════════════════════════════════════════════════════
   TABLES
══════════════════════════════════════════════════════════ */

.table-wrap { overflow-x: auto; }

.erp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.erp-table thead th {
    padding: 9px 14px;
    text-align: left;
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    background: #fafafa;
    white-space: nowrap;
}

.erp-table tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid #f0f0f0;
    color: var(--text-primary);
    vertical-align: middle;
}

.erp-table tbody tr:last-child td { border-bottom: none; }
.erp-table tbody tr:hover td { background: #fafafa; }

.table-link { color: var(--text-primary); font-weight: 500; }
.table-link:hover { color: var(--accent); }


/* ══════════════════════════════════════════════════════════
   BADGES
══════════════════════════════════════════════════════════ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 9.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    line-height: 1.5;
}

.badge-success { background: #f0fdf4; color: #15803d; }
.badge-warning { background: #fffbeb; color: #b45309; }
.badge-danger  { background: #fff1f2; color: var(--accent); }
.badge-info    { background: #eff6ff; color: #1d4ed8; }
.badge-gray    { background: #f5f5f5; color: var(--text-secondary); }
.badge-dark    { background: #1a1a1a; color: #fff; }


/* ══════════════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s, border-color 0.15s;
    cursor: pointer;
    border: 1px solid transparent;
    line-height: 1;
    white-space: nowrap;
}

.btn-primary { background: #c10000; color: #fff; }
.btn-primary:hover { background: #333; }

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

.btn-outline { background: #fff; color: var(--text-primary); border-color: var(--border); }
.btn-outline:hover { border-color: var(--border-strong); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg); color: var(--text-primary); }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 14px; }

.btn-login {
    height: 40px;
    justify-content: center;
    margin-top: 4px;
    font-size: 14px;
}


/* ══════════════════════════════════════════════════════════
   FORMS
══════════════════════════════════════════════════════════ */

.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    letter-spacing: 0.03em;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-primary);
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: #666;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.06);
}

.form-textarea { resize: vertical; min-height: 80px; line-height: 1.6; }

.input-with-action {
    position: relative;
}
.input-with-action .form-input { padding-right: 40px; }
.input-eye-btn {
    position: absolute;
    right: 10px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 16px;
    display: flex;
    align-items: center;
    transition: color 0.12s;
}
.input-eye-btn:hover { color: var(--text-primary); }

.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 11px; color: var(--accent); margin-top: 4px; }

.form-input.is-error { border-color: var(--accent); }


/* ══════════════════════════════════════════════════════════
   ALERTS
══════════════════════════════════════════════════════════ */

.alert {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.alert-error   { background: #fff1f2; color: var(--accent);   border-color: var(--accent-border); }
.alert-success { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.alert-warning { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.alert-info    { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }


/* ══════════════════════════════════════════════════════════
   MOVEMENT TYPES
══════════════════════════════════════════════════════════ */

.movement-type {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    font-weight: 500;
}

.movement-in         { color: #15803d; }
.movement-out        { color: var(--accent); }
.movement-adjustment { color: #b45309; }
.movement-transfer   { color: #1d4ed8; }


/* ══════════════════════════════════════════════════════════
   AUTH LAYOUT
══════════════════════════════════════════════════════════ */

.auth-body {
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px 40px;
    width: 400px;
    max-width: 100%;
}

.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo img { height: 38px; margin: 0 auto; }
.auth-logo-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}
.auth-logo-text span { color: var(--accent); }

.auth-title { font-size: 17px; font-weight: 600; color: var(--text-primary); text-align: center; margin-bottom: 5px; }
.auth-sub   { font-size: 13px; color: var(--text-secondary); text-align: center; margin-bottom: 22px; }

.auth-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-muted);
}


/* ══════════════════════════════════════════════════════════
   UTILITIES
══════════════════════════════════════════════════════════ */

.mb-4  { margin-bottom: 14px; }
.mb-5  { margin-bottom: 20px; }
.mb-6  { margin-bottom: 24px; }
.mt-4  { margin-top: 14px; }
.flex  { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.justify-between { justify-content: space-between; }
.text-sm  { font-size: 11.5px; }
.text-xs  { font-size: 10.5px; }
.text-muted   { color: var(--text-muted); }
.text-danger  { color: var(--accent); }
.text-success { color: #15803d; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.w-full  { width: 100%; }
.grid-2  { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3  { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
.grid-4  { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; }


/* ══════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-4   { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: calc(-1 * var(--sidebar-width));
        height: 100vh;
        transition: left 0.22s ease;
        z-index: 300;
    }
    .sidebar.mobile-open { left: 0; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-2   { grid-template-columns: 1fr; }
    .grid-3   { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
    .content { padding: 16px; }
}
