/* ═══════════════════════════════════════════════════════════════
   PROFESSIONAL POLISH — v3.1
   Skeleton loaders, badges, KPI cards, profile, refined states
   ═══════════════════════════════════════════════════════════════ */

/* ── Skeleton Loaders ──────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-2) 0%, #e8edf3 50%, var(--bg-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
}
.skeleton-line { height: 12px; width: 100%; border-radius: 4px; }
.skeleton-line.sm { height: 10px; width: 60%; }
.skeleton-line.lg { height: 18px; width: 80%; }
.skeleton-card {
  padding: 1.25rem;
  background: var(--card-bg);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 10px;
}

/* ── KPI / Stat Card v2 ────────────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.kpi {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.25rem 1.5rem;
  position: relative;
  overflow: hidden;
  transition: all 0.2s ease;
}
.kpi::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0; transition: opacity 0.2s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--sh-md); border-color: #cbd5e1; }
.kpi:hover::before { opacity: 1; }
.kpi-label {
  font-size: 0.7rem; font-weight: 800;
  color: var(--text-2); text-transform: uppercase;
  letter-spacing: 0.06em; margin-bottom: 0.5rem;
}
.kpi-value {
  font-size: 1.75rem; font-weight: 900;
  color: var(--primary); letter-spacing: -0.03em;
  line-height: 1.1;
}
.kpi-trend {
  font-size: 0.72rem; font-weight: 700;
  margin-top: 0.4rem; display: inline-flex; align-items: center; gap: 4px;
}
.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--danger); }
.kpi-trend.flat { color: var(--text-3); }

/* ── Search Result Counter ─────────────────────────────────── */
.search-counter {
  font-size: 0.75rem; font-weight: 700; color: var(--text-2);
  padding: 0 12px;
}
.search-counter strong { color: var(--primary); font-weight: 800; }

/* ── Better Empty State ────────────────────────────────────── */
.empty-rich {
  padding: 3rem 1.5rem; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 0.875rem;
}
.empty-rich-icon {
  width: 64px; height: 64px;
  border-radius: var(--r-xl);
  background: var(--bg-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.75rem;
  color: var(--text-3);
}
.empty-rich-title {
  font-size: 1rem; font-weight: 800; color: var(--primary);
  letter-spacing: -0.02em;
}
.empty-rich-desc {
  font-size: 0.85rem; color: var(--text-2);
  max-width: 360px; line-height: 1.5;
}
.empty-rich .btn { margin-top: 0.5rem; }

/* ── Badges & Counters ─────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px;
  padding: 0 6px;
  border-radius: var(--r-full);
  background: var(--accent);
  color: #0a0f1e;
  font-size: 0.65rem; font-weight: 800;
  letter-spacing: 0.02em;
}
.badge-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
}
.badge-dot.danger  { background: var(--danger); }
.badge-dot.warning { background: var(--warning); }
.badge-dot.info    { background: var(--info); }

/* ── Section Header (within panels) ────────────────────────── */
.section-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-2);
}
.section-header h2 {
  font-size: 1rem; font-weight: 800; color: var(--primary);
  letter-spacing: -0.02em;
}
.section-header .subtitle {
  font-size: 0.78rem; color: var(--text-2); font-weight: 600;
  margin-top: 2px;
}

/* ── Loading Bar (top progress) ────────────────────────────── */
.loading-bar {
  position: fixed; top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent));
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
  z-index: 5000;
  transition: opacity 0.2s;
}

/* ── Form: Required indicator + Help text ──────────────────── */
.field label .req { color: var(--danger); margin-left: 2px; }
.field-help {
  font-size: 0.72rem; color: var(--text-3);
  margin-top: 4px; line-height: 1.4;
}
.field-error {
  font-size: 0.72rem; color: var(--danger);
  margin-top: 4px; font-weight: 600;
  display: flex; align-items: center; gap: 4px;
}
.field input.has-error,
.field select.has-error,
.field textarea.has-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.08);
}

/* ── Profile Card ──────────────────────────────────────────── */
.profile-card {
  background: white;
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--sh-xs);
}
.profile-banner {
  height: 80px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}
.profile-body {
  padding: 0 1.5rem 1.5rem;
  margin-top: -36px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
}
.profile-avatar-lg {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: 4px solid white;
  display: flex; align-items: center; justify-content: center;
  color: #0a0f1e;
  font-weight: 900; font-size: 1.5rem;
  box-shadow: var(--sh-sm);
}
.profile-name { font-size: 1.15rem; font-weight: 800; color: var(--primary); letter-spacing: -0.02em; }
.profile-meta { font-size: 0.82rem; color: var(--text-2); font-weight: 500; }

/* ── Info / Hint banner ────────────────────────────────────── */
.banner {
  padding: 0.875rem 1.125rem;
  border-radius: var(--r-md);
  font-size: 0.82rem; line-height: 1.5;
  display: flex; align-items: flex-start; gap: 10px;
}
.banner-icon { font-size: 1rem; line-height: 1; flex-shrink: 0; margin-top: 2px; }
.banner-info    { background: var(--info-soft);    color: #1e3a8a; border: 1px solid #bfdbfe; }
.banner-warning { background: var(--warning-soft); color: #92400e; border: 1px solid #fde68a; }
.banner-success { background: var(--success-soft); color: #065f46; border: 1px solid #a7f3d0; }
.banner-danger  { background: var(--danger-soft);  color: #991b1b; border: 1px solid #fecaca; }

/* ── Improved focus ring (keyboard accessibility) ──────────── */
button:focus-visible,
.nav-link:focus-visible,
.tab-btn:focus-visible,
.btn-icon:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Table polish ──────────────────────────────────────────── */
.table-actions { display: flex; gap: 6px; }
.table-actions .btn-icon { width: 30px; height: 30px; font-size: 0.85rem; }

/* ── Dashboard layout helpers ──────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
@media (max-width: 1100px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ── Progress bar ──────────────────────────────────────────── */
.progress {
  height: 6px;
  background: var(--bg-2);
  border-radius: var(--r-full);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: var(--r-full);
  transition: width 0.5s ease;
}
.progress-bar.success { background: var(--success); }
.progress-bar.danger  { background: var(--danger); }
.progress-bar.warning { background: var(--warning); }

/* ── Util ──────────────────────────────────────────────────── */
.text-muted   { color: var(--text-3); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-info    { color: var(--info); }
.font-mono    { font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace; }
.text-xs   { font-size: 0.7rem; }
.text-sm   { font-size: 0.8rem; }
.text-base { font-size: 0.875rem; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-end { justify-content: flex-end; }
.w-100 { width: 100%; }

/* ── Avatar ────────────────────────────────────────────────── */
.avatar-sm { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 800; color: white; }
.avatar-md { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.82rem; font-weight: 800; color: white; }

/* ── Better toast stacking ─────────────────────────────────── */
.toast-container { pointer-events: none; }
.toast { pointer-events: auto; }

/* ── Smooth tab content transition ─────────────────────────── */
#schedule-body, #report-body, #admin-content {
  animation: fadeIn 0.22s ease-out;
}

/* ── Force LTR direction (override Arabic/RTL OS or browser locale) ── */
html, body {
  direction: ltr !important;
  text-align: left;
  unicode-bidi: isolate;
}
input, textarea, select, button {
  direction: ltr !important;
  text-align: left;
  unicode-bidi: plaintext;
}
input[type="number"],
input[type="date"],
input[type="time"],
input[type="email"],
input[type="tel"],
input[type="password"] {
  direction: ltr !important;
  text-align: left;
}
.search-box input {
  direction: ltr !important;
  text-align: left !important;
}

/* ── Compact icon button (in tables) ───────────────────────── */
.icon-btn-link {
  background: transparent; border: none;
  padding: 6px; border-radius: 6px;
  color: var(--text-2); cursor: pointer;
  transition: all 0.15s;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn-link:hover { background: var(--bg-2); color: var(--primary); }
.icon-btn-link.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ═════════════════════════════════════════════════════════════
   v4.5 — Wizard, Tabs, RBAC matrix, Lock states
   ═════════════════════════════════════════════════════════════ */

/* ── Step Wizard (Add Employee) ────────────────────────────── */
#emp-wizard {
  display: flex;
  flex-direction: column;
  min-height: 640px; /* Force consistent professional height across all steps */
}
#emp-wizard-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 2px;
  scrollbar-width: thin;
}
#emp-wizard-body::-webkit-scrollbar { width: 5px; }
#emp-wizard-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

.wizard-stepper {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 0.875rem 1rem;
  background: linear-gradient(180deg, #f8fafc, #ffffff);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: 1.25rem;
  flex-shrink: 0;
}
.wizard-step {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: white;
  color: var(--text-2);
  font-size: 0.78rem; font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.wizard-step:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--sh-xs);
}
.wizard-step .num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 0.72rem; font-weight: 800;
  flex-shrink: 0;
}
.wizard-step.done {
  border-color: var(--success);
  background: var(--success-soft);
  color: #065f46;
}
.wizard-step.done .num { background: var(--success); color: white; }
.wizard-step.active {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
  box-shadow: var(--sh-sm);
}
.wizard-step.active .num { background: var(--accent); color: #0a0f1e; }

.wizard-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: auto; padding-top: 1.25rem;
  border-top: 1px solid var(--border-2);
  flex-shrink: 0;
}

/* ── Choice cards (visa status, weekoff mode, branch mode) ── */
.choice-card {
  padding: 0.95rem 1.125rem;
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  background: white;
  cursor: pointer;
  transition: all 0.18s ease;
  display: block;
}
.choice-card:hover { border-color: var(--text-3); transform: translateY(-1px); }
.choice-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: var(--sh-xs);
}
.choice-card strong { font-size: 0.86rem; color: var(--primary); display: block; margin-bottom: 4px; }
.choice-card .desc { font-size: 0.74rem; color: var(--text-2); line-height: 1.45; }

/* ── Sub-page tabs (used in Employees, Disciplinary, Payroll) ── */
.tab-btn .pill {
  margin-left: 6px;
  padding: 1px 8px;
  font-size: 0.65rem;
}

/* ── Permission Matrix (Admin → User Form) ─────────────────── */
.perm-matrix {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.perm-matrix table { width: 100%; border-collapse: collapse; }
.perm-matrix thead th {
  background: var(--primary);
  color: white;
  padding: 10px 14px;
  font-size: 0.7rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.06em;
  text-align: left;
}
.perm-matrix thead th.center { text-align: center; width: 92px; }
.perm-matrix tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-2);
  font-size: 0.85rem;
}
.perm-matrix tbody tr:last-child td { border-bottom: none; }
.perm-matrix tbody tr:nth-child(even) td { background: #fafbfc; }
.perm-matrix .perm-cb {
  width: 18px; height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
}
.perm-matrix td.center { text-align: center; }
.perm-bulk { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

/* ── Locked state (attendance unlock) ─────────────────────── */
.lock-pill {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: var(--r-sm);
  padding: 4px 10px;
  font-size: 0.78rem; font-weight: 800;
  cursor: pointer;
  transition: all 0.15s;
}
.lock-pill:hover { background: #dc2626; transform: translateY(-1px); box-shadow: var(--sh-sm); }
.lock-pill.disabled { opacity: 0.7; cursor: not-allowed; }
.lock-pill.disabled:hover { transform: none; box-shadow: none; }

.btn-unlock-period {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--danger);
  color: white;
  border: none;
  padding: 0.625rem 1.125rem;
  border-radius: var(--r-md);
  font-size: 0.85rem; font-weight: 700;
  cursor: pointer;
  transition: all 0.18s;
  box-shadow: var(--sh-sm);
}
.btn-unlock-period:hover { background: #dc2626; transform: translateY(-1px); box-shadow: var(--sh-md); }

/* ── Process-wiring banners (cross-module hints) ───────────── */
.banner-process {
  background: linear-gradient(90deg, var(--accent-soft), transparent);
  border: 1px dashed var(--accent);
  color: var(--primary);
}

/* ── Field help tightening for wizard ──────────────────────── */
.field .field-help { margin-top: 4px; }

/* ── Disciplinary instalment row hover ─────────────────────── */
.balance-zero td { opacity: 0.55; }
.balance-zero td:hover { opacity: 1; }

/* ── Modal: keep footer visible for tall wizards ───────────── */
.modal-lg #modal-body { max-height: 70vh; }
