/* Loaded last so these beat main/components/pages.css */
.mobile-menu-btn {
  display: none !important;
}

@media (max-width: 1024px) {
  .mobile-menu-btn {
    display: flex !important;
  }
}

.search-box {
  width: min(420px, 100%);
}

.search-box .form-control {
  width: 100%;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-info p {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}

@media (max-width: 1100px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

.dashboard-grid {
  grid-template-columns: 1fr 1fr;
}

.page-header .page-title h2 {
  display: none;
}

/* ------------------------------------------------------------------
   Sidebar (explorer) — keep chrome inside 260px
   ------------------------------------------------------------------ */
.sidebar {
  overflow: hidden;
  min-width: 0;
}

.sidebar-header .logo-container {
  overflow: hidden;
}

.sidebar-header .logo-container img {
  max-height: 56px;
}

.sidebar-nav {
  min-height: 0;
}

.nav-item {
  min-width: 0;
}

.nav-item i {
  flex-shrink: 0;
}

.nav-item span {
  min-width: 0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-count {
  flex-shrink: 0;
}

.sidebar-footer {
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-3);
  padding: var(--space-3);
  overflow: hidden;
  min-width: 0;
}

[dir="rtl"] .sidebar-footer {
  flex-direction: column;
}

.user-snippet {
  min-width: 0;
  width: 100%;
}

.avatar-circle {
  flex-shrink: 0;
}

.user-info {
  min-width: 0;
  flex: 1;
}

.user-info h4,
.user-info p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  background: var(--bg-surface-hover);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.btn-logout i {
  font-size: 16px;
}

.btn-logout:hover {
  color: var(--status-danger);
  background: var(--status-danger-bg);
}

/* ------------------------------------------------------------------
   Tables — wrap, scroll, shrink actions, fit inputs
   ------------------------------------------------------------------ */
.main-wrapper,
.page-container,
.table-wrapper,
.widget-box {
  min-width: 0;
}

.page-container {
  overflow-x: hidden;
}

.table-wrapper {
  overflow: hidden;
  max-width: 100%;
}

.table-responsive {
  width: 100%;
  max-width: 100%;
  max-height: calc(100vh - var(--header-height) - 140px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 0;
  text-align: start;
}

.data-table th,
.data-table td {
  padding: 10px 14px;
  vertical-align: middle;
  text-align: start;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--bg-surface-hover);
  box-shadow: 0 1px 0 var(--border-strong);
  text-align: start;
}

.data-table tbody tr {
  transition: none;
}

.data-table tbody td {
  background: var(--bg-surface);
  transition: background-color 0.12s ease;
}

.data-table tbody tr:hover td {
  background: var(--bg-surface-hover);
}

.data-table tbody tr.ts-row-weekend td {
  background: var(--bg-app);
  color: var(--text-secondary);
}

.data-table tbody tr.ts-row-weekend:hover td {
  background: var(--bg-surface-hover);
}

.data-table td.cell-wrap,
.data-table .dept-cell {
  white-space: normal !important;
  max-width: 280px;
  line-height: 1.35;
  word-break: break-word;
}

.data-table .col-actions,
.data-table th.col-actions,
.data-table td:has(.row-actions) {
  width: 1%;
  white-space: nowrap;
  text-align: end;
}

.data-table .btn {
  transform: none;
  box-shadow: none;
}

.data-table .btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}

.data-table tbody tr:hover .btn-secondary,
.data-table tbody tr.ts-row-weekend .btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.data-table .btn-secondary:hover,
.data-table tbody tr:hover .btn-secondary:hover {
  background: var(--bg-app);
  border-color: var(--text-tertiary);
  color: var(--text-primary);
}

.data-table .btn-primary {
  background: var(--brand-accent);
  color: #fff;
  border: 1px solid var(--brand-accent);
}

.data-table tbody tr:hover .btn-primary {
  background: var(--brand-accent);
  color: #fff;
  border-color: var(--brand-accent);
}

.data-table .btn-primary:hover,
.data-table tbody tr:hover .btn-primary:hover {
  background: var(--brand-accent-hover);
  border-color: var(--brand-accent-hover);
  color: #fff;
  transform: none;
}

.data-table .form-control {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 36px;
}

.data-table td.col-status {
  min-width: 128px;
  width: 16%;
}

.data-table td.col-time {
  min-width: 118px;
  width: 14%;
}

.data-table td.col-hours {
  min-width: 88px;
  width: 10%;
  text-align: start;
}

.data-table.sticky-first thead th:first-child {
  z-index: 6;
  inset-inline-start: 0;
  background: var(--bg-surface-hover);
}

.data-table.sticky-first tbody td:first-child {
  position: sticky;
  z-index: 2;
  inset-inline-start: 0;
  background: var(--bg-surface);
}

.data-table.sticky-first tbody tr:hover td:first-child {
  background: var(--bg-surface-hover);
}

.data-table.sticky-first tbody tr.ts-row-weekend td:first-child {
  background: var(--bg-app);
}

.data-table.sticky-first tbody tr.ts-row-weekend:hover td:first-child {
  background: var(--bg-surface-hover);
}

.matrix-table .form-control {
  min-width: 0;
  max-width: none;
  width: 100%;
}

.calendar-day-cell {
  min-height: 72px;
}

@media (max-width: 640px) {
  .btn-logout span {
    display: inline;
  }
}

.app-dialog {
  z-index: 1100;
}

.modal-box.modal-box-sm {
  max-width: 420px;
}

.dialog-message {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.55;
}

.app-dialog .dialog-message + .form-group {
  margin-top: 12px;
}

.table-toolbar .form-group {
  margin-bottom: 0;
  min-width: 140px;
}

.table-toolbar .form-group .form-control {
  width: 100%;
  min-width: 140px;
}

.report-balances-hint {
  flex: 1 1 100%;
  margin: 0;
  padding-bottom: 0;
  max-width: none;
  line-height: 1.45;
}

/* RTL: toasts, notification items and badges, direction arrows (Phase 4, 1 Nov 2026) */
[dir="rtl"] #toast-container {
  right: auto;
  left: var(--space-5);
}
[dir="rtl"] .toast.success,
[dir="rtl"] .toast.error,
[dir="rtl"] .toast.info {
  border-left: none;
}
.toast.success { border-inline-start: 4px solid var(--status-success); }
.toast.error   { border-inline-start: 4px solid var(--status-danger); }
.toast.info    { border-inline-start: 4px solid var(--status-info); }
[dir="rtl"] .notif-item {
  text-align: right;
}
[dir="rtl"] .notif-badge,
[dir="rtl"] .notif-badge-count {
  right: auto;
  left: 4px;
}
[dir="rtl"] .icon-flip-rtl {
  display: inline-block;
  transform: scaleX(-1);
}
@media (max-width: 768px) {
  [dir="rtl"] #toast-container {
    left: var(--space-3);
    right: var(--space-3);
  }
}

/* ==========================================================================
   Dashboard charts (1 Nov 2026). Palettes validated with the dataviz validator
   against the card surface: light #FFFFFF, dark #111827. Text never uses series colors.
   ========================================================================== */
.viz-root {
  --viz-surface: var(--bg-surface);
  --viz-present: #0ca30c;
  --viz-leave: #2a78d6;
  --viz-absent: #d03b3b;
  --viz-missing: #c98500;
  --viz-doc-iqama: #2a78d6;
  --viz-doc-passport: #eb6834;
  --viz-doc-contract: #1baf7a;
  --viz-bar: #2a78d6;
  --viz-expired-wash: rgba(208, 59, 59, 0.07);
  --viz-grid: #E2E8F0;
  --viz-axis: #CBD5E1;
  --viz-muted: #64748B;
}
[data-theme="dark"] .viz-root {
  --viz-leave: #3987e5;
  --viz-doc-iqama: #3987e5;
  --viz-doc-passport: #d95926;
  --viz-doc-contract: #199e70;
  --viz-bar: #3987e5;
  --viz-expired-wash: rgba(208, 59, 59, 0.12);
  --viz-grid: #1F2937;
  --viz-axis: #334155;
  --viz-muted: #94A3B8;
}

#app-shell .charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}
#app-shell .charts-row.charts-row-reverse {
  grid-template-columns: 1fr 2fr;
}
#app-shell .charts-row > .widget-box {
  margin-bottom: 0;
  min-width: 0;
}
@media (max-width: 1100px) {
  #app-shell .charts-row,
  #app-shell .charts-row.charts-row-reverse {
    grid-template-columns: 1fr;
  }
}

.viz-subtitle {
  margin: calc(-1 * var(--space-3)) 0 var(--space-3);
  font-size: 13px;
  color: var(--text-secondary);
}
.viz-plot {
  position: relative;
  width: 100%;
}
.viz-plot svg {
  display: block;
  overflow: visible;
  /* Positions are mirrored in code for Arabic; keep text-anchor geometric (an inherited rtl flips start/end). */
  direction: ltr;
}
.viz-plot svg text {
  font-family: inherit;
  font-size: 11px;
  fill: var(--viz-muted);
}
.viz-plot .viz-hit {
  fill: transparent;
  cursor: default;
  outline: none;
}
.viz-plot .viz-hit:focus-visible {
  stroke: var(--brand-accent);
  stroke-width: 2px;
}
.viz-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin-bottom: var(--space-3);
  font-size: 12px;
  color: var(--text-secondary);
}
.viz-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.viz-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
.viz-swatch.dot {
  border-radius: 50%;
}
.viz-tooltip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  min-width: 160px;
  max-width: 260px;
  padding: 8px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 12px;
  color: var(--text-secondary);
  transform: translate(-50%, calc(-100% - 10px));
  white-space: nowrap;
}
.viz-tooltip-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: normal;
}
.viz-tooltip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.6;
}
.viz-tooltip-row strong {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
}
.viz-key {
  width: 12px;
  height: 3px;
  border-radius: 2px;
  flex-shrink: 0;
}
.viz-table-toggle {
  font-size: 12px;
}
.viz-table {
  font-variant-numeric: tabular-nums;
}
.viz-note {
  font-size: 13px;
  color: var(--text-secondary);
  padding: var(--space-4) 0;
}

/* Today donut */
.viz-donut-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  flex-wrap: wrap;
}
.viz-donut-hero {
  font-size: 28px;
  font-weight: 700;
  fill: var(--text-primary) !important;
}
.viz-donut-caption {
  font-size: 11px;
  fill: var(--text-secondary) !important;
}
.viz-donut-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  flex: 1;
  min-width: 150px;
}
.viz-donut-list li {
  display: flex;
  align-items: center;
  gap: 8px;
}
.viz-donut-list strong {
  margin-inline-start: auto;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* Leave by type: horizontal bars (logical properties so RTL grows from the right) */
.viz-hbars {
  display: grid;
  gap: var(--space-3);
}
.viz-hbar-row {
  display: grid;
  grid-template-columns: minmax(90px, 38%) 1fr;
  align-items: center;
  gap: var(--space-3);
  font-size: 13px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  outline: none;
}
.viz-hbar-row:focus-visible {
  box-shadow: 0 0 0 2px var(--brand-accent);
}
.viz-hbar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.viz-hbar-track {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.viz-hbar-area {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
}
.viz-hbar {
  display: block;
  height: 16px;
  background: var(--viz-bar);
  border-start-end-radius: 4px;
  border-end-end-radius: 4px;
  transition: opacity 0.15s ease;
}
.viz-hbar-row:hover .viz-hbar,
.viz-hbar-row:focus-visible .viz-hbar {
  opacity: 0.85;
}
.viz-hbar-value {
  color: var(--text-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.viz-hbar-value small {
  font-weight: 400;
  color: var(--text-secondary);
}
.viz-axis-line {
  stroke: var(--viz-axis);
  stroke-width: 1px;
}
.viz-grid-line {
  stroke: var(--viz-grid);
  stroke-width: 1px;
}
