/* assets/css/admin.css - Asresoft admin: ERP-style shell (loaded after style.css) */

body.erp,
body.erp-auth {
    --erp-brand: #1f2470;
    --erp-brand-2: #2c3391;
    --erp-bg: #f3f4f7;
    --erp-surface: #ffffff;
    --erp-line: #e4e6ec;
    --erp-text: #1f2937;
    --erp-muted: #6b7280;
    --erp-accent: #3b5bdb;
    --bg-dark: var(--erp-bg);
    --bg-surface: #ffffff;
    --bg-card: #f6f7fa;
    --border-color: var(--erp-line);
    --text-white: #111827;
    --text-primary: #1f2937;
    --text-muted: #6b7280;
    --text-dim: #9ca3af;
    --gray-400: #6b7280;
    --primary-blue: var(--erp-accent);
    --shadow-card: 0 1px 2px rgba(16, 24, 40, .06);
    background: var(--erp-bg);
    color: var(--erp-text);
    font-size: 14px;
}

body.erp a { color: var(--erp-accent); }
body.erp h2 { font-size: 22px; color: var(--text-white); }
body.erp h3 { font-size: 16px; }

/* ---------- Top bar ---------- */
.erp-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 52px;
    padding: 0 14px;
    background: var(--erp-brand);
    color: #fff;
    box-shadow: 0 1px 0 rgba(0, 0, 0, .08);
}

body.erp .erp-topbar a { color: #fff; }

.erp-launcher {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    color: #fff !important;
}

.erp-launcher:hover,
.erp-appmenu a:hover,
.erp-appmenu a.active,
.erp-top-link:hover { background: rgba(255, 255, 255, .14); }

.erp-appname {
    font-weight: 800;
    font-size: 16px;
    padding: 0 14px 0 6px;
    white-space: nowrap;
}

.erp-appmenu { display: flex; align-items: center; gap: 2px; overflow-x: auto; }

.erp-appmenu a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    color: rgba(255, 255, 255, .86) !important;
}

.erp-appmenu a.active { color: #fff !important; }

.erp-badge {
    display: inline-block;
    min-width: 18px;
    padding: 0 6px;
    border-radius: 9px;
    background: #f03e3e;
    color: #fff;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
}

.erp-menu-toggle,
.erp-menu-btn { display: none; }

.erp-topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.erp-top-link { font-size: 13px; padding: 7px 10px; border-radius: 6px; opacity: .9; }

.erp-usermenu { position: relative; }
.erp-usermenu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.erp-usermenu summary::-webkit-details-marker { display: none; }
.erp-usermenu summary:hover { background: rgba(255, 255, 255, .14); }

.erp-avatar {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #fab005;
    color: #1f2470;
    font-weight: 800;
    font-size: 13px;
}

.erp-username { font-size: 13.5px; font-weight: 600; }

.erp-dropdown {
    position: absolute;
    right: 0;
    top: 44px;
    min-width: 240px;
    background: #fff;
    border: 1px solid var(--erp-line);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(16, 24, 40, .16);
    padding: 6px;
    color: var(--erp-text);
}

.erp-dropdown-head { padding: 10px 12px; border-bottom: 1px solid var(--erp-line); margin-bottom: 4px; }
.erp-dropdown-head small { display: block; color: var(--erp-muted); font-size: 12px; }
.erp-dropdown a,
.erp-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 9px 12px;
    border-radius: 6px;
    color: var(--erp-text) !important;
    background: none;
    border: 0;
    font: inherit;
    cursor: pointer;
}
.erp-dropdown a:hover,
.erp-dropdown button:hover { background: var(--bg-card); }

.erp-main { min-height: calc(100vh - 52px); }

.erp-banner { padding: 10px 20px; font-size: 13.5px; }
.erp-banner-danger { background: #fff5f5; color: #c92a2a; border-bottom: 1px solid #ffc9c9; }

@media (max-width: 900px) {
    .erp-menu-btn { display: grid; place-items: center; width: 36px; height: 36px; cursor: pointer; font-size: 18px; border-radius: 6px; }
    .erp-appmenu {
        display: none;
        position: absolute;
        top: 52px;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        background: var(--erp-brand-2);
        padding: 8px;
    }
    .erp-menu-toggle:checked ~ .erp-appmenu { display: flex; }
    .erp-username,
    .erp-top-link { display: none; }
}

/* ---------- Existing admin components, light ---------- */
body.erp .container { max-width: 1280px; }

body.erp .admin-card,
body.erp .admin-stat-card {
    background: var(--erp-surface);
    border: 1px solid var(--erp-line);
    border-radius: 10px;
    box-shadow: var(--shadow-card);
}

body.erp .admin-card { padding: 22px 24px; margin-top: 20px; }
body.erp .admin-card-header { margin-bottom: 16px; padding-bottom: 12px; gap: 12px; flex-wrap: wrap; }
body.erp .admin-table th { background: #f8f9fb; color: #4b5563; font-size: 11.5px; letter-spacing: .02em; }
body.erp .admin-table th,
body.erp .admin-table td { padding: 11px 14px; }
body.erp .admin-table tbody tr:hover td { background: #fafbfd; }

body.erp .btn { padding: 9px 16px; border-radius: 8px; font-size: 13.5px; }
body.erp .btn:hover { transform: none; }
body.erp .btn-primary { background: var(--erp-brand); box-shadow: none; }
body.erp .btn-primary:hover { background: var(--erp-brand-2); }
body.erp .btn-outline-sm,
body.erp .btn-outline { background: #fff; border: 1px solid #d0d4dd; color: #374151; }
body.erp .btn-outline-sm:hover,
body.erp .btn-outline:hover { background: #f3f4f7; color: #111827; border-color: #c2c7d2; }
body.erp .btn-danger-sm { background: #fff5f5; border-color: #ffc9c9; color: #e03131; padding: 7px 12px; }
body.erp .btn-danger-sm:hover { background: #e03131; color: #fff; }

body.erp .field input,
body.erp .field select,
body.erp .field textarea,
body.erp-auth .field input {
    background: #fff;
    border: 1px solid #d0d4dd;
    color: #111827;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
}
body.erp .field select option { background: #fff; color: #111827; }
body.erp .field { margin-bottom: 16px; }
body.erp .field small,
.erp-hint { display: block; color: var(--erp-muted); font-size: 12.5px; margin-top: 5px; }

body.erp .alert-success,
body.erp-auth .alert-success { background: #ebfbee; border-color: #b2f2bb; color: #2b8a3e; }
body.erp .alert-danger,
body.erp-auth .alert-danger { background: #fff5f5; border-color: #ffc9c9; color: #c92a2a; }
body.erp .alert-info,
body.erp-auth .alert-info { background: #edf2ff; border-color: #bac8ff; color: #3b5bdb; }
body.erp .tag-sm { background: #edf2ff; color: #3b5bdb; }

/* ---------- Pages built for the ERP layout ---------- */
.erp-page { max-width: 1280px; margin: 0 auto; padding: 22px 24px 60px; }

.erp-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.erp-toolbar h2 { margin: 0; }
.erp-toolbar .erp-crumbs { color: var(--erp-muted); font-size: 13px; }
.erp-toolbar .erp-crumbs a { color: var(--erp-muted); }
.erp-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.erp-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.erp-filters input,
.erp-filters select {
    padding: 8px 10px;
    border: 1px solid #d0d4dd;
    border-radius: 8px;
    background: #fff;
    color: #111827;
    font: inherit;
    font-size: 13.5px;
}

.erp-sheet {
    background: #fff;
    border: 1px solid var(--erp-line);
    border-radius: 10px;
    padding: 24px;
    box-shadow: var(--shadow-card);
    margin-bottom: 20px;
}
.erp-sheet h3 { margin: 0 0 14px; font-size: 15px; color: #111827; }
.erp-sheet + .erp-sheet { margin-top: 0; }

.erp-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.erp-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 20px; }
.erp-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 20px; }
@media (max-width: 860px) {
    .erp-grid-2, .erp-grid-3, .erp-grid-4 { grid-template-columns: 1fr; }
}

.erp-table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--erp-line); border-radius: 10px; }
.erp-table-wrap .admin-table td,
.erp-table-wrap .admin-table th { white-space: nowrap; }
.erp-table-wrap .admin-table tr:last-child td { border-bottom: 0; }
.erp-table-wrap .admin-table td.wrap { white-space: normal; min-width: 200px; }
.admin-table .num-col { text-align: right; font-variant-numeric: tabular-nums; }

.pill {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: #f1f3f5;
    color: #495057;
    white-space: nowrap;
}
.pill-green { background: #ebfbee; color: #2b8a3e; }
.pill-red { background: #fff5f5; color: #e03131; }
.pill-amber { background: #fff9db; color: #e67700; }
.pill-blue { background: #edf2ff; color: #3b5bdb; }
.pill-grey { background: #f1f3f5; color: #868e96; }
.pill-violet { background: #f3f0ff; color: #7048e8; }

.erp-empty { text-align: center; padding: 60px 20px; color: var(--erp-muted); }
.erp-empty h2 { margin-bottom: 8px; }
.erp-empty p { margin-bottom: 12px; }

.erp-inline { display: inline; }
.link-btn { background: none; border: 0; padding: 0; color: var(--erp-accent); font: inherit; cursor: pointer; text-decoration: underline; }
.link-btn.danger { color: #e03131; }

.erp-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.erp-kpi { background: #fff; border: 1px solid var(--erp-line); border-radius: 10px; padding: 14px 16px; color: inherit !important; }
.erp-kpi b { display: block; font-size: 24px; color: #111827; line-height: 1.2; }
.erp-kpi span { color: var(--erp-muted); font-size: 12.5px; }
a.erp-kpi:hover { border-color: #bac8ff; }

.erp-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--erp-line); margin-bottom: 16px; flex-wrap: wrap; }
.erp-tabs a { padding: 9px 14px; color: var(--erp-muted) !important; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.erp-tabs a.active { color: var(--erp-brand) !important; border-bottom-color: var(--erp-brand); }

.check-line { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 6px 0; cursor: pointer; }
.check-line input { width: auto !important; }
.perm-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 4px 20px; }

/* Employee cards (kanban) */
.erp-kanban { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.erp-card {
    display: flex;
    gap: 12px;
    background: #fff;
    border: 1px solid var(--erp-line);
    border-radius: 10px;
    padding: 14px;
    color: inherit !important;
}
.erp-card:hover { border-color: #bac8ff; box-shadow: 0 4px 14px rgba(16, 24, 40, .07); }
.erp-card .erp-initials {
    flex: 0 0 52px;
    height: 52px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 18px;
    color: #fff;
}
.erp-card strong { display: block; color: #111827; }
.erp-card small { display: block; color: var(--erp-muted); font-size: 12.5px; line-height: 1.5; }

/* ---------- App launcher (home) ---------- */
.erp-home { max-width: 980px; margin: 0 auto; padding: 48px 24px 60px; }
.erp-home-hello { text-align: center; margin-bottom: 36px; }
.erp-home-hello h1 { font-size: 24px; color: #111827; }
.erp-home-hello p { color: var(--erp-muted); }

.erp-apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 26px 18px; margin-bottom: 44px; }
.erp-app { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; color: #1f2937 !important; }
.erp-app-icon {
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    border-radius: 18px;
    color: #fff;
    box-shadow: 0 6px 16px rgba(16, 24, 40, .14);
    transition: transform .15s ease, box-shadow .15s ease;
}
.erp-app:hover .erp-app-icon { transform: translateY(-3px); box-shadow: 0 10px 22px rgba(16, 24, 40, .2); }
.erp-app-name { font-weight: 700; font-size: 14px; }
.erp-app-desc { font-size: 12px; color: var(--erp-muted); margin-top: -6px; }

/* ---------- Sign-in ---------- */
body.erp-auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border: 1px solid var(--erp-line);
    border-radius: 14px;
    padding: 32px;
    box-shadow: 0 10px 40px rgba(16, 24, 40, .08);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.auth-brand strong { display: block; font-size: 18px; color: #111827; line-height: 1.1; }
.auth-brand small { color: var(--erp-muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.auth-card h1 { font-size: 21px; color: #111827; margin-bottom: 8px; }
.auth-lead { color: #4b5563; font-size: 14px; margin-bottom: 18px; }
.auth-help { color: var(--erp-muted); font-size: 13px; margin-top: 14px; text-align: center; }
.auth-submit { width: 100%; justify-content: center; background: var(--erp-brand) !important; box-shadow: none !important; padding: 11px 16px; }
.auth-inline { margin-top: 12px; text-align: center; font-size: 13px; }
.auth-cancel { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--erp-line); }
.auth-card .field label { color: #374151; }
.code-input { font-size: 22px !important; letter-spacing: 6px; text-align: center; font-variant-numeric: tabular-nums; }
.qr-box { display: grid; place-items: center; margin: 6px 0 12px; }
.qr-box svg { width: 200px; height: 200px; }
.auth-details { margin-bottom: 16px; font-size: 13px; color: #4b5563; }
.auth-details summary { cursor: pointer; color: var(--erp-accent); }
.secret-key { display: block; margin: 8px 0 4px; padding: 10px; background: #f6f7fa; border-radius: 8px; font-size: 15px; letter-spacing: 1px; word-break: break-all; }
.backup-codes { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0 0 12px; padding: 12px; background: #f6f7fa; border-radius: 10px; }
.backup-codes code { font-size: 15px; letter-spacing: 1px; }
.auth-actions { display: flex; gap: 8px; margin-bottom: 14px; }

/* Payslip print */
@media print {
    .erp-topbar, .erp-banner, .no-print, .auth-actions, .auth-cancel, form .auth-submit { display: none !important; }
    body.erp, body.erp-auth { background: #fff; }
    .erp-sheet { border: 0; box-shadow: none; }
}

/* Brand filter (top bar) and brand tags */
.brand-switch { position: relative; }
.brand-switch > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid #dee2e6; border-radius: 8px; font-size: 13px; font-weight: 600; color: #343a40; background: #fff; white-space: nowrap; }
.brand-switch > summary::-webkit-details-marker { display: none; }
.brand-switch-dot { width: 8px; height: 8px; border-radius: 50%; background: #1c7ed6; }
.brand-switch-menu { position: absolute; right: 0; top: 40px; z-index: 30; background: #fff; border: 1px solid #dee2e6; border-radius: 10px; padding: 12px; min-width: 220px; display: grid; gap: 8px; box-shadow: 0 10px 30px rgba(15, 23, 42, .14); color: #212529; }
.brand-switch-mode { display: flex; gap: 6px; background: #f1f3f5; border-radius: 8px; padding: 4px; }
.brand-switch-mode label { flex: 1; text-align: center; font-size: 12px; font-weight: 600; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.brand-switch-mode input { display: none; }
.brand-switch-mode label:has(input:checked) { background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.brand-switch-opt { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; cursor: pointer; }
.brand-switch-opt input { width: auto; margin: 0; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.brand-switch-apply { border: 0; border-radius: 8px; background: #1c7ed6; color: #fff; font-weight: 600; padding: 7px 10px; cursor: pointer; }
.brand-tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; color: var(--bc, #495057); background: color-mix(in srgb, var(--bc, #495057) 12%, transparent); border: 1px solid color-mix(in srgb, var(--bc, #495057) 30%, transparent); white-space: nowrap; }

/* Permissions grid (Roles and per-user permissions) */
.perm-help { color: var(--text-muted, #6c757d); font-size: 13px; margin: 4px 0 10px; }
.perm-matrix { display: grid; gap: 10px; }
.perm-module { border: 1px solid #dee2e6; border-radius: 10px; background: #fff; }
.perm-module > summary { cursor: pointer; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.perm-quick { display: inline-flex; gap: 6px; }
.perm-quick button { border: 1px solid #ced4da; background: #f8f9fa; border-radius: 6px; padding: 2px 8px; font-size: 12px; cursor: pointer; }
.perm-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.perm-table th, .perm-table td { padding: 8px 12px; border-top: 1px solid #f1f3f5; text-align: center; }
.perm-table th:first-child, .perm-table td:first-child { text-align: left; }
.perm-table td:first-child small { display: block; color: #868e96; font-size: 12px; }
.perm-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: #868e96; }
.perm-cell input[type=checkbox] { width: 18px; height: 18px; }
.perm-alt { display: block; font-size: 11px; color: #868e96; }
.perm-na { color: #ced4da; }
.perm-ovr { padding: 3px 4px; border-radius: 6px; font-size: 12px; border: 1px solid #ced4da; }
.perm-ovr.perm-grant { background: #ebfbee; border-color: #8ce99a; color: #2b8a3e; }
.perm-ovr.perm-deny { background: #fff5f5; border-color: #ffa8a8; color: #c92a2a; }
.perm-sum { font-size: 13px; margin: 2px 0; }
.erp-perm-overrides { margin: 16px 0; border-top: 1px solid #e9ecef; padding-top: 12px; }
.erp-perm-overrides > summary { cursor: pointer; margin-bottom: 10px; }
@media (max-width: 700px) { .perm-table th, .perm-table td { padding: 6px 4px; } }
