/* ============================================================================
   FACTORY JOB WORK ERP - PREMIUM THEME
   Glassmorphism + soft shadows + light/dark mode
   ============================================================================ */

:root {
    --erp-primary: #4f46e5;
    --erp-primary-dark: #4338ca;
    --erp-accent: #06b6d4;
    --erp-success: #10b981;
    --erp-warning: #f59e0b;
    --erp-danger: #ef4444;
    --erp-info: #3b82f6;

    --erp-bg: #f4f6fb;
    --erp-surface: #ffffff;
    --erp-surface-glass: rgba(255, 255, 255, 0.72);
    --erp-border: #e6e9f2;
    --erp-text: #1f2430;
    --erp-text-muted: #6b7280;
    --erp-sidebar-bg: #161a2b;
    --erp-sidebar-text: #b7bccb;
    --erp-sidebar-active: #4f46e5;
    --erp-shadow: 0 8px 30px rgba(31, 36, 48, 0.06);
    --erp-shadow-lg: 0 20px 50px rgba(31, 36, 48, 0.12);
    --erp-radius: 16px;
}

[data-theme="dark"] {
    --erp-bg: #0f1220;
    --erp-surface: #171b2e;
    --erp-surface-glass: rgba(23, 27, 46, 0.65);
    --erp-border: #262c46;
    --erp-text: #e7e9f4;
    --erp-text-muted: #97a0c3;
    --erp-sidebar-bg: #0b0e1a;
    --erp-sidebar-text: #8991b3;
    --erp-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
    --erp-shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

body {
    background: var(--erp-bg);
    color: var(--erp-text);
    font-family: 'Segoe UI', 'Inter', -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
    transition: background .25s ease, color .25s ease;
}

a { text-decoration: none; }

/* ---------------------------------------------------------------------------
   LAYOUT
   --------------------------------------------------------------------------- */
.erp-app {
    display: flex;
    min-height: 100vh;
}

.erp-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--erp-sidebar-bg);
    color: var(--erp-sidebar-text);
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 1030;
    transition: transform .25s ease, width .25s ease;
    display: flex;
    flex-direction: column;
    box-shadow: var(--erp-shadow-lg);
}
.erp-sidebar.collapsed { width: 80px; }
.erp-sidebar.collapsed .sidebar-label,
.erp-sidebar.collapsed .sidebar-section-title,
.erp-sidebar.collapsed .brand-text { display: none; }

.erp-sidebar .brand {
    display: flex; align-items: center; gap: .6rem;
    padding: 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.erp-sidebar .brand-icon {
    width: 38px; height: 38px; border-radius: 12px;
    background: linear-gradient(135deg, var(--erp-primary), var(--erp-accent));
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: #fff; flex-shrink: 0;
}
.erp-sidebar .brand-text { font-weight: 700; font-size: 1.05rem; color: #fff; white-space: nowrap; }

.erp-sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem .6rem; }
.erp-sidebar-nav::-webkit-scrollbar { width: 4px; }
.erp-sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.sidebar-section-title {
    font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
    color: #565d80; padding: .9rem .75rem .3rem;
}
.sidebar-link {
    display: flex; align-items: center; gap: .75rem;
    padding: .6rem .75rem; border-radius: 10px; margin-bottom: 2px;
    color: var(--erp-sidebar-text); font-size: .9rem; font-weight: 500;
    transition: all .15s ease;
}
.sidebar-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-link.active {
    background: linear-gradient(135deg, var(--erp-primary), var(--erp-primary-dark));
    color: #fff;
    box-shadow: 0 4px 14px rgba(79,70,229,.4);
}

.erp-main {
    margin-left: 260px;
    flex: 1;
    min-width: 0;
    transition: margin-left .25s ease;
    display: flex;
    flex-direction: column;
}
.erp-main.expanded { margin-left: 80px; }

/* Topbar */
.erp-topbar {
    position: sticky; top: 0; z-index: 1020;
    background: var(--erp-surface-glass);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--erp-border);
    padding: .7rem 1.25rem;
    display: flex; align-items: center; gap: 1rem;
}
.erp-topbar .search-box {
    flex: 1; max-width: 420px;
    position: relative;
}
.erp-topbar .search-box input {
    border-radius: 12px; border: 1px solid var(--erp-border);
    background: var(--erp-surface); padding: .5rem .9rem .5rem 2.3rem;
    width: 100%; color: var(--erp-text);
}
.erp-topbar .search-box i {
    position: absolute; left: .8rem; top: 50%; transform: translateY(-50%);
    color: var(--erp-text-muted);
}
.icon-btn {
    width: 40px; height: 40px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: var(--erp-surface); border: 1px solid var(--erp-border);
    color: var(--erp-text); position: relative; cursor: pointer;
}
.icon-btn:hover { background: var(--erp-bg); }
.icon-btn .dot {
    position: absolute; top: 6px; right: 6px;
    width: 8px; height: 8px; border-radius: 50%; background: var(--erp-danger);
}

.erp-content { padding: 1.5rem; flex: 1; }

/* ---------------------------------------------------------------------------
   CARDS / GLASSMORPHISM
   --------------------------------------------------------------------------- */
.card-glass {
    background: var(--erp-surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-radius);
    box-shadow: var(--erp-shadow);
}

.erp-card {
    background: var(--erp-surface);
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-radius);
    box-shadow: var(--erp-shadow);
    padding: 1.25rem;
}

.stat-card {
    border-radius: var(--erp-radius);
    padding: 1.25rem 1.4rem;
    color: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: var(--erp-shadow);
    isolation: isolate;
}
.stat-card::after {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(circle at top right, rgba(255,255,255,.25), transparent 60%);
    z-index: -1;
}
.stat-card.bg-1 { background: linear-gradient(135deg,#4f46e5,#7c3aed); }
.stat-card.bg-2 { background: linear-gradient(135deg,#06b6d4,#3b82f6); }
.stat-card.bg-3 { background: linear-gradient(135deg,#10b981,#059669); }
.stat-card.bg-4 { background: linear-gradient(135deg,#f59e0b,#ef4444); }
.stat-card .stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    background: rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; margin-bottom: .75rem;
}
.stat-card .stat-value { font-size: 1.7rem; font-weight: 700; }
.stat-card .stat-label { opacity: .9; font-size: .85rem; }

/* ---------------------------------------------------------------------------
   TABLES
   --------------------------------------------------------------------------- */
.table-erp {
    background: var(--erp-surface);
    border-radius: var(--erp-radius);
    overflow: hidden;
    box-shadow: var(--erp-shadow);
}
.table-erp thead th {
    background: var(--erp-bg);
    border-bottom: 2px solid var(--erp-border);
    font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--erp-text-muted); font-weight: 600;
    padding: .85rem 1rem; white-space: nowrap;
}
.table-erp tbody td {
    padding: .8rem 1rem; vertical-align: middle;
    border-bottom: 1px solid var(--erp-border);
    color: var(--erp-text);
}
.table-erp tbody tr:hover { background: var(--erp-bg); }
.table-erp tbody tr:last-child td { border-bottom: none; }

.badge-status { font-weight: 500; padding: .4em .75em; border-radius: 20px; font-size: .72rem; }

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--erp-border) 25%, rgba(0,0,0,.03) 37%, var(--erp-border) 63%);
    background-size: 400% 100%;
    animation: skeleton-loading 1.4s ease infinite;
    border-radius: 8px;
}
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* Toasts */
.toast-container { z-index: 1080; }

/* Buttons */
.btn-erp-primary {
    background: linear-gradient(135deg, var(--erp-primary), var(--erp-primary-dark));
    border: none; color: #fff; border-radius: 10px; font-weight: 500;
}
.btn-erp-primary:hover { opacity: .92; color: #fff; }

/* Login page */
.login-wrapper {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 45%, #06b6d4 100%);
    padding: 1rem;
}
.login-card {
    width: 100%; max-width: 900px;
    background: rgba(255,255,255,.12);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0,0,0,.3);
    display: flex;
}
.login-side {
    flex: 1; padding: 3rem; color: #fff; display: flex; flex-direction: column; justify-content: center;
}
.login-form-side {
    flex: 1; background: var(--erp-surface); padding: 3rem; display: flex; flex-direction: column; justify-content: center;
}

/* Responsive */
@media (max-width: 992px) {
    .erp-sidebar { transform: translateX(-100%); }
    .erp-sidebar.mobile-open { transform: translateX(0); }
    .erp-main, .erp-main.expanded { margin-left: 0; }
    .login-card { flex-direction: column; }
}

.progress-thin { height: 6px; border-radius: 6px; }

/* Timeline */
.timeline { position: relative; padding-left: 1.75rem; }
.timeline::before {
    content: ''; position: absolute; left: 7px; top: 4px; bottom: 4px;
    width: 2px; background: var(--erp-border);
}
.timeline-item { position: relative; padding-bottom: 1.4rem; }
.timeline-item::before {
    content: ''; position: absolute; left: -1.75rem; top: 3px;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--erp-primary); border: 2px solid var(--erp-surface);
}
