/* =====================================================================
   🛠 Admin theme — Ruichang Metals
   Distinct layout from the public theme: sidebar nav, lighter on dramatic
   styling, table-heavy. Still dark to match the brand.
   © Ihsan Land for programming | Eng. Iyad Abu Haibeh
   ===================================================================== */

:root {
    --bg: #0b0d10;
    --panel: #131820;
    --panel-2: #1a2029;
    --border: #1f2832;
    --fg: #e8edf3;
    --muted: #8a96a4;
    --accent: #df883c;      /* RM orange (logo) — AT used #00ff88 */
    --accent-2: #c7712a;
    --brand-blue: #325ba4;  /* RM blue (logo) */
    --brand-blue-2: #5b86d1;
    --danger: #ff4d4d;
    --warning: #ffb53b;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

/* ── Layout: sidebar + main ─────────────────────────────────────── */
.admin-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}
@media (max-width: 900px) {
    .admin-shell { grid-template-columns: 1fr; }
    .admin-sidebar { position: sticky; top: 0; z-index: 10; }
}

.admin-sidebar {
    background: #07090c;
    border-right: 1px solid var(--border);
    padding: 1.25rem 0.75rem;
    display: flex;
    flex-direction: column;
}
.admin-sidebar .brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}
.admin-sidebar .brand img { width: 44px; }
.admin-sidebar .brand-name { font-weight: 800; font-size: 1.05rem; }
.admin-sidebar nav { display: flex; flex-direction: column; gap: 0.1rem; }
.admin-sidebar nav a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.85rem;
    border-radius: 8px;
    color: var(--fg);
    font-weight: 500;
}
.admin-sidebar nav a:hover { background: var(--panel); text-decoration: none; }
.admin-sidebar nav a.active { background: var(--accent); color: #000; }
.admin-sidebar nav a .badge {
    margin-left: auto;
    font-size: 0.7rem;
    background: var(--danger);
    color: #fff;
    border-radius: 999px;
    padding: 0.05rem 0.45rem;
}
.admin-sidebar .who {
    margin-top: auto;
    padding: 1rem 0.85rem;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--muted);
}
.admin-sidebar .who a { color: var(--accent); }

.admin-main { padding: 1.5rem 2rem; }
.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.admin-topbar h1 { margin: 0; font-size: 1.5rem; }
.admin-topbar .actions { display: flex; gap: 0.5rem; align-items: center; }

/* ── Flash banners ─────────────────────────────────────────────── */
.flash {
    margin: 0 0 1rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-weight: 500;
}
.flash-success { background: rgba(223,136,60,0.12); color: var(--accent); border: 1px solid rgba(223,136,60,0.3); }
.flash-error   { background: rgba(255,77,77,0.12); color: var(--danger); border: 1px solid rgba(255,77,77,0.3); }
.flash-info    { background: rgba(255,255,255,0.06); color: #fff; border: 1px solid var(--border); }
.flash-warning { background: rgba(255,181,59,0.12); color: var(--warning); border: 1px solid rgba(255,181,59,0.3); }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--fg);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn-primary { background: var(--accent); color: #000; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-danger { background: rgba(255,77,77,0.12); color: var(--danger); border-color: rgba(255,77,77,0.3); }
.btn-danger:hover { background: rgba(255,77,77,0.18); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

/* ── Panel / card ─────────────────────────────────────────────── */
.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}
.panel h2 { margin: 0 0 0.85rem; font-size: 1.05rem; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.1rem;
}
.stat-card .label { font-size: 0.75rem; text-transform: uppercase; color: var(--muted); letter-spacing: 0.04em; }
.stat-card .value { font-size: 1.75rem; font-weight: 800; margin-top: 0.2rem; }

/* ── Tables ────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}
table.data th, table.data td { padding: 0.65rem 0.85rem; text-align: left; vertical-align: middle; }
table.data thead { background: var(--panel-2); }
table.data th { font-size: 0.75rem; text-transform: uppercase; color: var(--muted); letter-spacing: 0.05em; font-weight: 600; }
table.data tbody tr { border-top: 1px solid var(--border); }
table.data tbody tr:hover { background: rgba(255,255,255,0.02); }
table.data .thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; background: #fff; }
table.data .row-actions { display: flex; gap: 0.4rem; }

/* ── Forms ────────────────────────────────────────────────────── */
.form-grid { display: grid; gap: 1rem; }
.form-grid .row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid .row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
@media (max-width: 700px) {
    .form-grid .row-2, .form-grid .row-3 { grid-template-columns: 1fr; }
}
.form-grid label {
    display: block;
    font-size: 0.8rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.3rem;
    font-weight: 600;
}
.form-grid input[type="text"],
.form-grid input[type="number"],
.form-grid input[type="email"],
.form-grid input[type="url"],
.form-grid input[type="password"],
.form-grid select,
.form-grid textarea {
    width: 100%;
    background: var(--panel-2);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    font-size: 0.95rem;
    font-family: inherit;
}
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus { border-color: var(--accent); outline: none; }
.form-grid textarea { min-height: 110px; resize: vertical; }
.form-grid .help { font-size: 0.78rem; color: var(--muted); margin-top: 0.3rem; }
.form-grid .check {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    color: var(--fg);
    text-transform: none;
    letter-spacing: 0;
    margin: 0;
}
.form-grid .check input { width: 18px; height: 18px; }

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.image-strip {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.6rem;
    margin-top: 0.5rem;
}
.image-tile {
    position: relative;
    aspect-ratio: 1 / 1;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
}
.image-tile img { width: 100%; height: 100%; object-fit: cover; }
.image-tile .pin {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,0.65);
    color: #fff;
    padding: 0.15rem 0.4rem;
    border-radius: 999px;
    font-size: 0.7rem;
}
.image-tile .del {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0,0,0,0.65);
    color: #ff8a8a;
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    border: none;
}

/* ── Filters bar ───────────────────────────────────────────────── */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: end;
    margin-bottom: 1rem;
}
.filters .field { display: flex; flex-direction: column; min-width: 160px; }
.filters label { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; margin-bottom: 0.2rem; font-weight: 600; }
.filters input, .filters select {
    background: var(--panel-2);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.45rem 0.6rem;
    font-size: 0.9rem;
}

.pager { display: flex; gap: 0.3rem; margin-top: 1rem; justify-content: center; }
.pager a, .pager span {
    padding: 0.35rem 0.7rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    color: var(--fg);
}
.pager .current { background: var(--accent); color: #000; border-color: var(--accent); }

/* ── HR module — tab bar + status pills + calendar ─────────────── */
.hr-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 1.25rem;
    padding: 0.35rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.hr-tabs a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.75rem;
    border-radius: 8px;
    color: var(--fg);
    font-weight: 500;
    font-size: 0.85rem;
    white-space: nowrap;
}
.hr-tabs a:hover { background: var(--panel-2); text-decoration: none; }
.hr-tabs a.active { background: var(--accent); color: #000; }
.hr-tabs .tab-badge {
    background: var(--danger); color: #fff;
    border-radius: 999px; padding: 0.05rem 0.45rem; font-size: 0.7rem; font-weight: 700;
}
.hr-tabs a.active .tab-badge { background: #000; color: var(--accent); }

.hr-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.5rem;
}
.hr-stat {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.1rem;
}
.hr-stat .label { font-size: 0.72rem; text-transform: uppercase; color: var(--muted); letter-spacing: 0.05em; }
.hr-stat .value { font-size: 2rem; font-weight: 800; margin-top: 0.15rem; }
.hr-stat.tone-active     .value { color: var(--accent); }
.hr-stat.tone-probation  .value { color: #ffb53b; }
.hr-stat.tone-on_leave   .value { color: #4d9dff; }
.hr-stat.tone-notice     .value { color: #ff8a3d; }
.hr-stat.tone-suspended  .value { color: var(--danger); }
.hr-stat.tone-terminated .value { color: var(--danger); }

.avatar-round {
    width: 44px; height: 44px; border-radius: 999px;
    background: linear-gradient(135deg, #1a2029, #131820);
    color: var(--fg); display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.95rem; overflow: hidden;
}
.avatar-round img { width: 100%; height: 100%; object-fit: cover; }
.avatar-round.avatar-lg { width: 72px; height: 72px; font-size: 1.4rem; }

.hr-cal { width: 100%; border-collapse: collapse; }
.hr-cal th { text-align: center; font-size: 0.75rem; color: var(--muted); padding: 0.35rem 0; text-transform: uppercase; letter-spacing: 0.05em; }
.hr-cal td {
    vertical-align: top;
    width: 14.285%;
    height: 90px;
    border: 1px solid var(--border);
    background: var(--panel);
    padding: 0.35rem;
    font-size: 0.78rem;
}
.hr-cal td.other-month { background: transparent; opacity: 0.4; }
.hr-cal td.today       { outline: 2px solid var(--accent); outline-offset: -2px; }
.hr-cal td.weekend     { background: rgba(255,255,255,0.02); }
.hr-cal .day-num { color: var(--muted); font-weight: 700; }
.hr-cal .leave-chip {
    display: block; margin-top: 0.2rem; padding: 0.1rem 0.35rem; border-radius: 4px;
    color: #000; font-weight: 600; font-size: 0.72rem; text-decoration: none;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Misc ──────────────────────────────────────────────────────── */
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.pill {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.pill-on  { background: rgba(223,136,60,0.15); color: var(--accent); }
.pill-off { background: rgba(255,255,255,0.06); color: var(--muted); }

/* ── Accounting ─────────────────────────────────────────────────── */
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tfoot td { border-top: 2px solid var(--border); font-weight: 700; background: var(--panel-2); }
table.data tr.group-head td { background: rgba(50, 91, 164, 0.18); color: var(--fg); font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
table.data tr.subtotal td { font-weight: 700; border-top: 1px solid var(--border); }
table.data tr.grand td { font-weight: 800; font-size: 1rem; border-top: 2px solid var(--accent); }
.neg { color: var(--danger); }
.je-lines input, .je-lines select {
    width: 100%; padding: 0.45rem 0.55rem; border-radius: 6px; border: 1px solid var(--border);
    background: var(--panel-2); color: var(--fg); font: inherit;
}
.je-lines td { padding: 0.35rem 0.4rem; }
.je-lines .amt { text-align: right; }
.balance-flag { font-weight: 700; }
.balance-flag.ok { color: var(--accent); }
.balance-flag.bad { color: var(--danger); }
.report-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.85rem; }
.report-links a { display: block; padding: 1rem; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--fg); }
.report-links a:hover { border-color: var(--accent); text-decoration: none; }
.report-links a strong { display: block; margin-bottom: 0.25rem; }
@media print {
    .admin-sidebar, .admin-topbar .actions, .hr-tabs, .filters { display: none !important; }
    .admin-shell { display: block; }
    body { background: #fff; color: #000; }
}
