/* ============================================================
   Employees Management System — Local app styles
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f9fafc;
  --border: #e4e8f0;
  --text: #1c2434;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #dbeafe;
  --accent: #0ea5e9;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --warning: #d97706;
  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #2563eb;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.18);
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans Arabic', 'Segoe UI', Tahoma, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

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

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 18px;
}
.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { color: #fff; font-size: 15px; }
.brand-text span { font-size: 12px; color: var(--sidebar-text); }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 500;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.nav-link::before {
  content: "";
  position: absolute;
  inset-inline-start: 6px;
  top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 3px;
  height: 60%;
  background: #fff;
  border-radius: 3px;
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  text-decoration: none;
}
.nav-link.active {
  background: linear-gradient(135deg, var(--sidebar-active) 0%, #1d4ed8 100%);
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(37, 99, 235, 0.6), inset 0 1px 0 rgba(255,255,255,0.12);
}
.nav-link.active::before {
  opacity: 1;
  transform: translateY(-50%) scaleY(1);
}
.nav-icon { width: 20px; height: 20px; flex-shrink: 0; opacity: 0.85; display: flex; align-items: center; justify-content: center; transition: opacity 0.18s ease, transform 0.18s ease; }
.nav-icon svg { width: 20px; height: 20px; display: block; }
.nav-link.active .nav-icon,
.nav-link:hover .nav-icon { opacity: 1; }
.nav-link.active .nav-icon { transform: scale(1.05); }

.nav-divider {
  height: 1px;
  margin: 12px 10px;
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.12), transparent);
}

.sidebar-footer {
  margin-top: auto;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.4);
  padding: 12px 8px 0;
}

.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; overflow: hidden; }

/* Dashboard recent payrolls — scrolls within the card */
.dash-recent-table {
  max-height: calc(100vh - 380px);
  overflow-y: auto;
}
.dash-recent-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h1 { margin: 0; font-size: 22px; font-weight: 600; }
.page-actions { display: flex; gap: 8px; align-items: center; }

.topbar-end {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Language toggle */
.lang-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  white-space: nowrap;
}
.lang-toggle.hidden { display: none; }
.lang-sep { color: var(--border); }
.lang-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  padding: 2px 5px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.lang-btn:hover { color: var(--text); background: var(--surface-2); }
.lang-btn.active { color: var(--primary); font-weight: 700; }

.view { padding: 28px 32px; flex: 1; min-height: 0; overflow-y: auto; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: background 0.15s, transform 0.05s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--primary-hover); }
.btn:active { transform: translateY(1px); }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-icon {
  padding: 5px 8px;
  font-size: 13px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.btn-icon.danger:hover { color: var(--danger); border-color: var(--danger); }

/* Icon-only action buttons (table rows) */
.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
  text-decoration: none;
}
.btn-action svg {
  width: 18px;
  height: 18px;
  display: block;
}
.btn-action:hover {
  background: var(--surface-2);
  color: var(--primary);
  border-color: var(--border);
}
.btn-action:active { transform: scale(0.94); }
.btn-action.danger:hover {
  color: var(--danger);
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.25);
}
.btn-action:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.icon-btn {
  background: transparent;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}
.icon-btn:hover { color: var(--text); }

/* ---------- Cards & Tables ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  margin-bottom: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-card-actions { justify-content: space-between; }
.quick-actions-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 10px; }
.stat-label { color: var(--text-muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 32px; font-weight: 700; color: var(--text); }

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.toolbar .grow { flex: 1; min-width: 200px; }

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  text-align: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
thead th {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  user-select: none;
  cursor: pointer;
  position: relative;
}
thead th .sort-ind { margin-inline-start: 4px; opacity: 0.5; font-size: 10px; }
thead th.sorted .sort-ind { opacity: 1; color: var(--primary); }
thead th.no-sort { cursor: default; }
tbody tr:nth-child(even) td { background: var(--surface-2); }
tbody tr:hover td { background: var(--primary-soft); }
tbody tr:last-child td { border-bottom: none; }

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: center;
}

/* Number/date inputs always LTR regardless of page direction */
.ltr-input {
  direction: ltr;
  text-align: start;
}
.empty {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
  font-size: 12px;
}

.muted { color: var(--text-muted); }

/* ---------- Forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.field label .req { color: var(--danger); margin-inline-start: 2px; }

/* ID image upload zone */
.id-image-drop-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  overflow: hidden;
  min-height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.id-image-drop-zone:hover,
.id-image-drop-zone.drag-over {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.04);
}
.id-image-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 16px;
  text-align: center;
  pointer-events: none;
}
.id-image-upload-icon {
  display: flex;
  color: var(--text-muted);
  opacity: 0.6;
}
.id-image-upload-icon svg { width: 40px; height: 40px; }
.id-image-hint {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 280px;
}
.id-image-preview {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  display: block;
  border-radius: calc(var(--radius) - 2px);
  padding: 6px;
}
.id-image-remove {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  transition: background 0.12s;
  z-index: 2;
}
.id-image-remove:hover { background: var(--danger); }
.id-image-remove svg { width: 14px; height: 14px; pointer-events: none; }

/* ID image indicator badge in table */
.id-image-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
}
.id-image-badge svg { width: 14px; height: 14px; display: block; }
.id-image-badge.attached {
  background: rgba(22, 163, 74, 0.12);
  color: #16a34a;
}
.id-image-badge.missing {
  background: rgba(0,0,0,0.05);
  color: var(--text-muted);
  opacity: 0.4;
}
.field input,
.field select,
.field textarea {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}
.field.invalid input,
.field.invalid select,
.field.invalid textarea {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}
.field .err {
  font-size: 12px;
  color: var(--danger);
  display: none;
}
.field.invalid .err { display: block; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* ---------- Modal ---------- */
.modal-root {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 100;
}
.modal-root.hidden { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
}
.modal {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: min(860px, calc(100% - 32px));
  max-height: calc(100vh - 64px);
  overflow: auto;
  animation: pop 0.15s ease;
}
.modal-sm { width: min(420px, calc(100% - 32px)); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; font-size: 17px; font-weight: 600; }
.modal-body { padding: 20px; }

@keyframes pop {
  from { transform: translateY(8px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

/* ---------- Toasts ---------- */
.toast-root {
  position: fixed;
  top: 22px;
  inset-inline-end: 22px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--surface);
  border-left: 4px solid var(--primary);
  box-shadow: var(--shadow);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  min-width: 240px;
  max-width: 360px;
  font-size: 13.5px;
  animation: slidein 0.18s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--accent); }
@keyframes slidein {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes slidein-rtl {
  from { transform: translateX(-20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
[dir="rtl"] .toast {
  animation: slidein-rtl 0.18s ease;
}

/* ---------- Detail page ---------- */
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.detail-header h2 { margin: 0 0 4px; font-size: 22px; }
.detail-meta {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 13px;
}
.detail-meta span strong { color: var(--text); }

/* Company info tiles */
.company-info-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
@media (max-width: 900px) { .company-info-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .company-info-grid { grid-template-columns: 1fr; } }
.info-tile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.info-tile-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  background: rgba(37, 99, 235, 0.08);
  border-radius: 10px;
  color: var(--primary);
}
.info-tile-icon svg { width: 20px; height: 20px; display: block; }
.info-tile-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.info-tile-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  white-space: nowrap;
}
.info-tile-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 24px 0 12px;
}
.section-title h3 { margin: 0; font-size: 16px; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-muted);
}
.back-link:hover { color: var(--primary); }

/* Overtime hours column alignment */
.ot-header { text-align: end !important; }
.ot-cell { text-align: end !important; }

.search-input,
.filter-select {
  padding: 0 11px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  outline: none;
  min-width: 200px;
  box-sizing: border-box;
}
.search-input:focus,
.filter-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}
.filter-select {
  -webkit-appearance: none;
  appearance: none;
  padding-inline-end: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: calc(100% - 10px) center;
  cursor: pointer;
}
[dir="rtl"] .filter-select {
  background-position: 10px center;
}

.link-cell {
  color: var(--primary);
  font-weight: 500;
  cursor: pointer;
}
.link-cell:hover { text-decoration: underline; }

.link-row { cursor: pointer; transition: background 0.12s; }
.link-row:hover { background: var(--surface-2); }

/* ---------- Payroll ---------- */
.payroll-card { margin-bottom: 18px; }
.payroll-card h3 { margin: 0 0 14px; font-size: 16px; }
.payroll-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px 16px;
}
.payroll-form-grid .full { grid-column: 1 / -1; }
.payroll-form-grid .field input,
.payroll-form-grid .field select,
.payroll-form-grid .field textarea {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.payroll-form-grid .field input:focus,
.payroll-form-grid .field select:focus,
.payroll-form-grid .field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}
.ot-input {
  width: 110px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  outline: none;
}
.ot-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}
.ot-input.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}
.payroll-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* Export dropdown */
.export-dropdown {
  position: relative;
  display: inline-block;
}
.export-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.export-toggle.is-disabled {
  opacity: 0.55;
  cursor: pointer;
}
.export-caret {
  font-size: 10px;
  line-height: 1;
  opacity: 0.7;
  transition: transform 0.15s ease;
}
.export-dropdown.open .export-caret { transform: rotate(180deg); }
.export-menu {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-start: 0;
  min-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 4px;
  z-index: 50;
  display: none;
  flex-direction: column;
  gap: 2px;
  white-space: nowrap;
}
.export-dropdown.open .export-menu { display: flex; }
.export-menu-item {
  background: transparent;
  border: 0;
  text-align: inherit;
  padding: 8px 14px;
  font: inherit;
  color: inherit;
  cursor: pointer;
  border-radius: 4px;
}
.export-menu-item:hover { background: var(--bg); }
[dir="rtl"] .export-menu { inset-inline-start: auto; inset-inline-end: 0; }

@media (max-width: 800px) {
  .payroll-form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
  }
  .brand { border: none; padding: 0 8px; margin: 0; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .sidebar-footer { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .view { padding: 18px; }
  .topbar { padding: 14px 18px; }
  .topbar-end { gap: 8px; }
}

/* ============================================================
   RTL overrides
   ============================================================ */

/* Sidebar stays on the correct side — CSS grid handles direction automatically */
/* Form actions row reversed so primary button is on the left (visual end) in RTL */
[dir="rtl"] .form-actions { flex-direction: row-reverse; }

/* Modal header close button */
[dir="rtl"] .modal-header { flex-direction: row-reverse; }

/* Row actions align to the left in RTL (start of reading) */
[dir="rtl"] .row-actions { justify-content: center; }

/* Payroll actions */
[dir="rtl"] .payroll-actions { flex-direction: row-reverse; }

/* Badge stays numeric (LTR) */
.badge { direction: ltr; unicode-bidi: embed; }

/* Stat value always LTR numeric */
.stat-value { direction: ltr; unicode-bidi: embed; }

/* ---------- Import from Excel ---------- */
.btn-import {
  background: #16a34a;
  color: #fff;
  border-color: transparent;
}
.btn-import:hover { background: #15803d; }

/* Overtime Import button */
.btn-import-ot {
  background: #0369a1;
  color: #fff;
  border-color: transparent;
  font-size: 13px;
  padding: 7px 13px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.btn-import-ot:hover:not(:disabled) { background: #0284c7; }
.btn-import-ot:disabled { opacity: 0.5; cursor: not-allowed; }

.payroll-emp-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

/* Overtime Import preview modal */
.ot-import-table-wrap {
  max-height: 380px;
  overflow-y: auto;
  margin: 14px 0 0;
}
.ot-import-row-matched { background: rgba(22, 163, 74, 0.08); }
.ot-import-row-unmatched { background: rgba(234, 179, 8, 0.10); }
.ot-import-row-error { background: rgba(220, 38, 38, 0.08); }
.ot-import-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 13.5px;
  margin-bottom: 4px;
}
.ot-summary-matched { color: #16a34a; font-weight: 600; }
.ot-summary-unmatched { color: #b45309; font-weight: 600; }
.ot-summary-error { color: #dc2626; font-weight: 600; }
.ot-import-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
  justify-content: flex-end;
}
[dir="rtl"] .ot-import-actions { flex-direction: row-reverse; }

.ltr-cell { direction: ltr; unicode-bidi: embed; text-align: center; }

/* Flash animation for updated overtime inputs */
@keyframes ot-flash {
  0% { background: rgba(22, 163, 74, 0.4); }
  100% { background: transparent; }
}
.ot-import-flash {
  animation: ot-flash 1.2s ease forwards;
}

.import-modal-wrap { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.import-section { display: flex; flex-direction: column; gap: 8px; }
.import-label { font-weight: 600; font-size: 13px; color: var(--text); }

/* Drop Zone */
.import-drop-zone {
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  background: var(--primary-soft);
  transition: background 0.15s, border-color 0.15s;
  outline: none;
}
.import-drop-zone:hover,
.import-drop-zone:focus,
.import-drop-zone.drag-over {
  background: #bfdbfe;
  border-color: var(--primary-hover);
}
.import-drop-icon { font-size: 36px; margin-bottom: 8px; }
.import-drop-label { font-size: 14px; font-weight: 500; color: var(--text); }
.import-drop-hint { font-size: 12px; color: var(--text-muted); }

.import-file-name {
  font-size: 13px;
  color: var(--success);
  font-weight: 500;
  padding: 6px 10px;
  background: #f0fdf4;
  border-radius: var(--radius-sm);
  border: 1px solid #bbf7d0;
}

.import-parse-status {
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}
.import-parse-status.info { background: var(--primary-soft); color: var(--primary); }
.import-parse-status.error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

.import-template-link {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: underline;
  align-self: flex-start;
}
.import-template-link:hover { color: var(--primary); }

/* Company & Sheet selectors */
.import-company-sel,
.import-sheet-sel {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 14px;
  color: var(--text);
  width: 100%;
}

/* Header toggle */
.import-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}

/* Preview & Mapping table */
.import-preview-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 280px;
  overflow-y: auto;
}
.import-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 400px;
}
.import-preview-table th,
.import-preview-table td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: start;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.import-preview-table thead { background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
.preview-header { font-weight: 600; font-size: 12px; color: var(--text-muted); }
.mapping-row th { padding: 4px 6px; background: var(--surface); }

/* Mapping dropdown */
.import-map-sel {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  background: var(--surface);
  color: var(--text);
  min-width: 110px;
}

/* Count labels */
.import-count-label {
  font-size: 14px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}
.import-count-label.ready { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.import-count-label.skipped { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* Mapping error */
.import-mapping-error {
  color: var(--danger);
  font-size: 13px;
  padding: 6px 10px;
  background: #fef2f2;
  border-radius: var(--radius-sm);
  border: 1px solid #fecaca;
}

/* Action row */
.import-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}
[dir="rtl"] .import-actions { justify-content: flex-start; }

/* Loading spinner */
.import-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-muted);
  padding: 16px 0;
}
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Result section */
.import-result-success {
  font-size: 15px;
  font-weight: 600;
  color: var(--success);
  padding: 10px 14px;
  background: #f0fdf4;
  border-radius: var(--radius-sm);
  border: 1px solid #bbf7d0;
}
.import-result-skipped {
  font-size: 14px;
  color: #92400e;
  padding: 8px 12px;
  background: #fffbeb;
  border-radius: var(--radius-sm);
  border: 1px solid #fde68a;
}
.import-skip-reasons {
  font-size: 12px;
  color: var(--text-muted);
  padding-inline-start: 20px;
  margin: 4px 0 0 0;
}
.import-error {
  color: var(--danger);
  font-size: 14px;
  padding: 10px 14px;
}

/* Attendance-format import notice */
.import-attendance-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13.5px;
  padding: 10px 14px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  color: #1d4ed8;
  line-height: 1.5;
}

/* Widen modal for import */
#modal-root .modal:has(.import-modal-wrap) {
  max-width: min(860px, 96vw);
  width: 100%;
}
/* Fallback for browsers without :has() */
.modal-wide { max-width: min(860px, 96vw); width: 100%; }

/* ---------- Active / Inactive toggle switch ---------- */
.active-toggle-label,
.show-inactive-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}

/* Hide native checkbox */
.active-toggle-cb {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* Pill track */
.active-toggle-slider {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 0.22s ease;
}

/* Thumb */
.active-toggle-slider::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.22);
  transition: transform 0.22s ease;
}

.active-toggle-cb:checked + .active-toggle-slider {
  background: var(--primary);
}

.active-toggle-cb:checked + .active-toggle-slider::before {
  transform: translateX(18px);
}

.active-toggle-cb:focus-visible + .active-toggle-slider {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

/* Toggle label text */
.active-toggle-text {
  color: var(--text-muted);
  transition: color 0.15s;
}
.active-toggle-cb:checked ~ .active-toggle-text {
  color: var(--primary);
  font-weight: 600;
}

/* Inactive employee row in table */
.employee-inactive-row td {
  opacity: 0.55;
}

/* Inactive badge */
.inactive-badge {
  display: inline-block;
  margin-inline-start: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(220, 38, 38, 0.10);
  color: var(--danger);
  vertical-align: middle;
}
