/* ═══════════════════════════════════════════════
   AgileCrafts HR Admin — style.css
   ═══════════════════════════════════════════════ */

:root {
  --em50:  #ecfdf5; --em100: #d1fae5; --em200: #a7f3d0;
  --em500: #10b981; --em600: #059669; --em700: #047857; --em800: #065f46;
  --g50:  #f9fafb; --g100: #f3f4f6; --g200: #e5e7eb; --g300: #d1d5db;
  --g400: #9ca3af; --g500: #6b7280; --g600: #4b5563; --g700: #374151;
  --g800: #1f2937; --g900: #111827;
  --r100: #fee2e2; --r200: #fecaca; --r500: #ef4444; --r600: #dc2626;
  --b100: #dbeafe; --b600: #2563eb; --b700: #1d4ed8;
  --y100: #fef3c7; --y200: #fde68a; --y500: #f59e0b; --y600: #d97706;
  --o100: #ffedd5; --o500: #f97316; --o600: #ea580c;
  --sw: 248px;
  --topbar-h: 62px;
  --radius: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'Poppins', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--g100);
  color: var(--g800);
  display: flex;
  min-height: 100vh;
  line-height: 1.5;
}

/* ── REMOVE NUMBER SPINNERS ── */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

/* ══════════════════════════════
   SIDEBAR
══════════════════════════════ */
.sidebar {
  width: var(--sw);
  background: var(--g900);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width .2s;
}

.sidebar-logo {
  padding: 16px 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand-img {
  height: 30px;
  width: auto;
  display: block;
  filter: brightness(0) invert(1);
  opacity: .92;
}
.sidebar-module-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 1.8px;
  color: rgba(209,250,229,.65);
  margin-top: 5px;
  font-weight: 600;
}

.sidebar-nav { padding: 10px 0; flex: 1; overflow-y: auto; }

.nav-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--g500);
  padding: 14px 18px 5px;
  font-weight: 700;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 18px;
  cursor: pointer;
  color: var(--g400);
  font-size: 13.5px;
  font-weight: 500;
  transition: all .15s;
  border-left: 3px solid transparent;
  user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,.04); color: #fff; }
.nav-item.active {
  background: rgba(16,185,129,.12);
  color: var(--em500);
  border-left-color: var(--em500);
}
.nav-icon { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,.07);
  font-size: 11px;
  color: var(--g600);
}

/* ══════════════════════════════
   MAIN
══════════════════════════════ */
.main {
  margin-left: var(--sw);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--g200);
  padding: 0 28px;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-size: 18px; font-weight: 700; color: var(--g900); }
.topbar-sub { font-size: 12px; color: var(--g400); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.admin-chip {
  background: var(--em50);
  color: var(--em700);
  border: 1px solid var(--em200);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 11px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.content { padding: 26px 28px; flex: 1; }
.page { display: none; }
.page.active { display: block; }

/* ══════════════════════════════
   CARDS
══════════════════════════════ */
.card {
  background: #fff;
  border: 1px solid var(--g200);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.card-title { font-size: 15px; font-weight: 700; color: var(--g900); }
.card-title small { font-size: 12px; font-weight: 400; color: var(--g500); margin-left: 6px; }
.card-subtitle { font-size: 12px; color: var(--g500); margin-top: 2px; }

/* ══════════════════════════════
   STATS
══════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--g200);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.stat-card.c-em::before { background: var(--em500); }
.stat-card.c-bl::before { background: var(--b600); }
.stat-card.c-yl::before { background: var(--y500); }
.stat-card.c-rd::before { background: var(--r500); }
.stat-label { font-size: 11px; color: var(--g500); text-transform: uppercase; letter-spacing: .6px; font-weight: 700; margin-bottom: 8px; }
.stat-value { font-size: 24px; font-weight: 800; color: var(--g900); }
.stat-sub { font-size: 11px; color: var(--g400); margin-top: 4px; }
.stat-card.c-em .stat-value { color: var(--em600); }
.stat-card.c-bl .stat-value { color: var(--b600); }
.stat-card.c-yl .stat-value { color: var(--y600); }
.stat-card.c-rd .stat-value { color: var(--r600); }

/* ══════════════════════════════
   BUTTONS
══════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
  font-family: inherit;
}
.btn:disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--em500); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--em600); }
.btn-danger  { background: var(--r500); color: #fff; }
.btn-danger:hover:not(:disabled)  { background: var(--r600); }
.btn-outline {
  background: transparent;
  color: var(--em600);
  border: 1.5px solid var(--em400, var(--em500));
}
.btn-outline:hover:not(:disabled) { background: var(--em50); }
.btn-ghost {
  background: var(--g100);
  color: var(--g700);
  border: 1px solid var(--g300);
}
.btn-ghost:hover:not(:disabled) { background: var(--g200); }
.btn-revoke {
  background: var(--o100);
  color: var(--o600);
  border: 1px solid #fed7aa;
}
.btn-revoke:hover:not(:disabled) { background: #fde8d0; }
.btn-sm  { padding: 5px 10px; font-size: 12px; }
.btn-xs  { padding: 3px 8px;  font-size: 11px; }
.btn-icon { padding: 5px 7px; }

/* ══════════════════════════════
   TABLES
══════════════════════════════ */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--g200); }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--g50);
  color: var(--g500);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 9px 12px;
  text-align: left;
  border-bottom: 2px solid var(--g200);
  white-space: nowrap;
}
tbody td {
  padding: 10px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--g100);
  vertical-align: middle;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--g50); }
.row-generated { background: #f0fdf4 !important; }
.row-generated:hover { background: #dcfce7 !important; }

/* ══════════════════════════════
   BADGES
══════════════════════════════ */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.6;
}
.b-active    { background: var(--em100); color: var(--em800); }
.b-inactive  { background: var(--g100);  color: var(--g600);  }
.b-sent      { background: var(--b100);  color: var(--b700);  }
.b-pending   { background: var(--y100);  color: var(--y600);  }
.b-draft     { background: var(--g100);  color: var(--g600);  }
.b-generated { background: var(--em100); color: var(--em700); }
.b-revoked   { background: var(--o100);  color: var(--o600);  }

/* ══════════════════════════════
   FORMS
══════════════════════════════ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }

label.field-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--g600);
  text-transform: uppercase;
  letter-spacing: .5px;
}
input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
select,
textarea {
  padding: 8px 11px;
  border: 1.5px solid var(--g300);
  border-radius: 6px;
  font-size: 13px;
  color: var(--g800);
  transition: border-color .15s, box-shadow .15s;
  background: #fff;
  width: 100%;
  font-family: inherit;
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--em500);
  box-shadow: 0 0 0 3px rgba(16,185,129,.1);
}
input.err { border-color: var(--r500) !important; }
.field-err { font-size: 11px; color: var(--r500); margin-top: 1px; min-height: 14px; }
.field-hint { font-size: 11px; color: var(--g400); margin-top: 1px; }

/* ── GRID INLINE INPUTS ── */
.gi {
  width: 88px;
  min-width: 88px;
  padding: 5px 8px;
  border: 1.5px solid var(--g300);
  border-radius: 5px;
  font-size: 12px;
  text-align: right;
  background: #fff;
  font-family: inherit;
  color: var(--g800);
  transition: border-color .15s;
  display: block;
}
.gi:focus { outline: none; border-color: var(--em500); box-shadow: 0 0 0 2px rgba(16,185,129,.1); }
.gi:disabled { background: var(--g50); color: var(--g400); cursor: not-allowed; }
.gi-sm { width: 72px; min-width: 72px; }
.gi-md { width: 100px; min-width: 100px; }

/* ══════════════════════════════
   TOGGLE SWITCH
══════════════════════════════ */
.tg { position: relative; display: inline-block; flex-shrink: 0; }
.tg input { opacity: 0; width: 0; height: 0; position: absolute; }
.tg-slider {
  display: block;
  background: var(--g300);
  border-radius: 24px;
  cursor: pointer;
  transition: background .2s;
  position: relative;
}
.tg-slider::before {
  content: '';
  position: absolute;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}
.tg input:checked + .tg-slider { background: var(--em500); }
.tg input:disabled + .tg-slider { opacity: .55; cursor: not-allowed; }

/* Standard size */
.tg { width: 42px; height: 23px; }
.tg-slider { width: 42px; height: 23px; }
.tg-slider::before { width: 17px; height: 17px; left: 3px; top: 3px; }
.tg input:checked + .tg-slider::before { transform: translateX(19px); }

/* Small (row toggle) */
.tg-sm { width: 34px; height: 19px; }
.tg-sm .tg-slider { width: 34px; height: 19px; }
.tg-sm .tg-slider::before { width: 13px; height: 13px; left: 3px; top: 3px; }
.tg-sm input:checked + .tg-slider::before { transform: translateX(15px); }

.tg-wrap { display: flex; align-items: center; gap: 8px; }
.tg-label { font-size: 13px; font-weight: 600; color: var(--g700); }

/* Row toggle cell */
.row-tg-cell { min-width: 96px; }
.row-tg-inner { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.row-tg-inner .tg-wrap { gap: 5px; }
.row-tg-amt { font-size: 11.5px; font-weight: 700; color: var(--em700); }
.row-tg-amt.off { color: var(--g400); }

/* ══════════════════════════════
   PAYROLL WORKSPACE
══════════════════════════════ */
.payroll-meta {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.payroll-meta .form-group {
  flex-direction: row;
  align-items: center;
  gap: 7px;
}
.payroll-meta .form-group label.field-label { margin: 0; white-space: nowrap; }
.payroll-meta input,
.payroll-meta select { width: auto; }

.pr-status {
  font-size: 12px;
  color: var(--g500);
  background: var(--g50);
  border: 1px solid var(--g200);
  padding: 5px 12px;
  border-radius: 6px;
}
.pr-status strong { color: var(--em700); }

/* Computed cell colors */
td.cp     { font-weight: 600; color: var(--g700); }
td.cp-inc { font-weight: 700; color: var(--b600); }
td.cp-ded { font-weight: 600; color: var(--r600); }
td.cp-net { font-weight: 800; color: var(--em700); font-size: 13.5px; }
td.cp-spd { font-weight: 600; color: var(--g600); }

.action-group { display: flex; gap: 4px; flex-wrap: nowrap; align-items: center; }

/* ══════════════════════════════
   MODAL
══════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.48);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 640px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,.22);
  animation: modalIn .18s ease;
}
.modal.lg  { max-width: 920px; }
.modal.xl  { max-width: 1080px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(-12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--g200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
  border-radius: 12px 12px 0 0;
}
.modal-title { font-size: 15px; font-weight: 700; color: var(--g900); }
.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--g400);
  padding: 3px 7px;
  border-radius: 4px;
  line-height: 1;
  transition: all .15s;
}
.modal-close:hover { background: var(--g100); color: var(--g700); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--g200);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ══════════════════════════════
   CONFIRM DIALOG
══════════════════════════════ */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
}
.confirm-overlay.open { display: flex; }
.confirm-box {
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  max-width: 400px;
  width: 100%;
  margin: 16px;
  text-align: center;
  box-shadow: 0 24px 48px rgba(0,0,0,.22);
  animation: modalIn .18s ease;
}
.confirm-icon  { font-size: 36px; margin-bottom: 10px; }
.confirm-title { font-size: 17px; font-weight: 700; margin-bottom: 8px; color: var(--g900); }
.confirm-msg   { font-size: 13px; color: var(--g600); margin-bottom: 22px; line-height: 1.55; }
.confirm-acts  { display: flex; gap: 10px; justify-content: center; }

/* ══════════════════════════════
   TOAST
══════════════════════════════ */
#toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.toast-item {
  background: var(--g900);
  color: #fff;
  padding: 10px 15px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  animation: toastIn .2s ease;
  box-shadow: var(--shadow-md);
  border-left: 4px solid var(--em500);
  max-width: 300px;
}
.toast-item.t-err  { border-left-color: var(--r500); }
.toast-item.t-warn { border-left-color: var(--y500); }
@keyframes toastIn { from { transform: translateX(60px); opacity: 0; } to { opacity: 1; transform: none; } }

/* ══════════════════════════════
   MISC
══════════════════════════════ */
.search-box {
  padding: 8px 10px 8px 33px;
  border: 1.5px solid var(--g300);
  border-radius: 6px;
  font-size: 13px;
  width: 220px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.099zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E") no-repeat 9px center;
  font-family: inherit;
  transition: border-color .15s;
}
.search-box:focus { outline: none; border-color: var(--em500); }

.empty-state { text-align: center; padding: 50px 20px; }
.empty-icon  { font-size: 40px; margin-bottom: 10px; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--g500); margin-bottom: 5px; }
.empty-sub   { font-size: 13px; color: var(--g400); }

.loan-bg   { background: var(--g200); border-radius: 4px; height: 5px; width: 72px; display: inline-block; vertical-align: middle; margin-left: 5px; }
.loan-fill { background: var(--em500); height: 100%; border-radius: 4px; }

.divider { border: none; border-top: 1px solid var(--g200); margin: 14px 0; }
.section-head { font-size: 12.5px; font-weight: 700; color: var(--g700); margin-bottom: 10px; padding-bottom: 7px; border-bottom: 2px solid var(--em100); }

/* Profile strip (employee history) */
.profile-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.ps-card { background: var(--g50); border: 1px solid var(--g200); border-radius: var(--radius); padding: 12px 14px; }
.ps-label { font-size: 10.5px; color: var(--g500); text-transform: uppercase; letter-spacing: .5px; font-weight: 700; margin-bottom: 4px; }
.ps-val   { font-size: 18px; font-weight: 800; color: var(--g900); }
.ps-card.em .ps-val { color: var(--em700); }

/* Dashboard grid */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* Alert */
.alert { padding: 10px 13px; border-radius: 6px; font-size: 13px; margin-bottom: 13px; display: flex; align-items: flex-start; gap: 8px; }
.alert-err { background: var(--r100); color: var(--r600); border: 1px solid var(--r200); }
.alert-ok  { background: var(--em50); color: var(--em700); border: 1px solid var(--em200); }
.alert-warn{ background: var(--y100); color: var(--y600); border: 1px solid var(--y200); }

/* Payslip preview scrollable */
#ps-preview { overflow-x: auto; }

/* Server status chip */
.srv-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 99px;
  letter-spacing: .3px;
  transition: all .3s;
}
.srv-online  { background: var(--em50);  color: var(--em700); border: 1px solid var(--em200); }
.srv-offline { background: var(--g100);  color: var(--g500);  border: 1px solid var(--g300); }

/* ══════════════════════════════
   RESPONSIVE
══════════════════════════════ */
@media (max-width: 1280px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 1024px) { .dash-grid  { grid-template-columns: 1fr; } }
@media (max-width: 900px)  { .form-grid  { grid-template-columns: 1fr; } }
@media (max-width: 768px)  {
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; }
}
