/* ============================================
   سامانه نظارت تردد رجبی - Main Stylesheet
   ============================================ */

@font-face {
  font-family: 'Vazirmatn';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/vazir/Vazirmatn-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Vazirmatn';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/vazir/Vazirmatn-Bold.woff2') format('woff2');
}

:root {
  --primary: #1a237e;
  --primary-light: #283593;
  --primary-dark: #0d1442;
  --secondary: #283593;
  --success: #2e7d32;
  --success-light: #4caf50;
  --warning: #f57f17;
  --warning-light: #fbc02d;
  --danger: #c62828;
  --danger-light: #e53935;
  --info: #0277bd;
  --info-light: #0288d1;

  --white: #ffffff;
  --gray-50: #fafafa;
  --gray-100: #f5f5f5;
  --gray-200: #eeeeee;
  --gray-300: #e0e0e0;
  --gray-400: #bdbdbd;
  --gray-500: #9e9e9e;
  --gray-600: #757575;
  --gray-700: #616161;
  --gray-800: #424242;
  --gray-900: #212121;

  --sidebar-width: 260px;
  --navbar-height: 60px;
  --border-radius: 8px;
  --border-radius-sm: 4px;
  --border-radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.15);
  --transition: all 0.25s ease;
  --font-family: 'Vazirmatn', 'Vazir', 'Tahoma', 'Arial', sans-serif;
}

/* ============================================
   CSS Reset / Normalize
   ============================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  direction: rtl;
  text-align: right;
  line-height: 1.6;
  color: var(--gray-800);
  background-color: var(--gray-100);
  overflow-x: hidden;
  min-height: 100vh;
}

a {
  text-decoration: none;
  color: inherit;
}

ul, ol {
  list-style: none;
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

table {
  border-collapse: collapse;
  width: 100%;
}

/* ============================================
   Typography
   ============================================ */

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--gray-900);
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

p {
  margin-bottom: 0.5rem;
}

/* ============================================
   App Container & Layout
   ============================================ */

.app-container {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-right: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content-wrapper {
  flex: 1;
  padding: 24px;
  padding-top: calc(var(--navbar-height) + 24px);
}

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--primary);
  color: var(--white);
  z-index: 1000;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--navbar-height);
}

.sidebar-header h2 {
  color: var(--white);
  font-size: 1.1rem;
  font-weight: 700;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.sidebar-group {
  margin-bottom: 2px;
}

.sidebar-group summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.9rem;
  transition: var(--transition);
  border-right: 3px solid transparent;
  user-select: none;
}

.sidebar-group summary::-webkit-details-marker {
  display: none;
}

.sidebar-group summary:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
}

.sidebar-group summary:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: -2px;
}

.sidebar-group-chevron {
  margin-inline-start: auto;
  transition: transform 0.2s ease;
  opacity: 0.6;
}

.sidebar-group[open] .sidebar-group-chevron {
  transform: rotate(180deg);
}

.sidebar-group[open] summary {
  color: var(--white);
  font-weight: 600;
  border-right-color: var(--white);
}

.sidebar-group .sidebar-link {
  padding-inline-start: 40px;
  font-size: 0.85rem;
}

.sidebar-section {
  margin-bottom: 8px;
}

.sidebar-header-label {
  padding: 8px 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.45);
}


.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.9rem;
  transition: var(--transition);
  border-right: 3px solid transparent;
}

.sidebar-link svg {
  flex-shrink: 0;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
}

.sidebar-link.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--white);
  border-right-color: var(--white);
  font-weight: 600;
}

.sidebar-link:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: -2px;
}

/* ============================================
   Navbar
   ============================================ */

.navbar {
  position: fixed;
  top: 0;
  right: var(--sidebar-width);
  left: 0;
  height: var(--navbar-height);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 900;
  transition: var(--transition);
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mobile-menu-btn,
.menu-toggle {
  display: none;
  font-size: 1.25rem;
  color: var(--gray-700);
  padding: 4px 8px;
  border-radius: var(--border-radius-sm);
}

.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}

.menu-toggle:focus-visible,
.notification-bell:focus-visible,
.user-dropdown:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.page-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gray-900);
}

.notification-bell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  color: var(--gray-600);
  border-radius: 50%;
  transition: var(--transition);
}

.notification-bell:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}

.badge {
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: auto;
  padding: 2px 8px;
  border-radius: 9px;
  background: var(--danger);
  color: var(--white);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.6;
  white-space: nowrap;
}

.notification-bell .badge {
  position: absolute;
  top: 0;
  left: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: var(--white);
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.user-dropdown {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
}

.user-dropdown:hover {
  background: var(--gray-100);
}

.user-dropdown .user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

.user-dropdown .user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.user-dropdown .user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-800);
}

.user-dropdown .user-role {
  font-size: 0.7rem;
  color: var(--gray-500);
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 200px;
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--gray-200);
  padding: 6px 0;
  display: none;
  z-index: 1100;
}

.dropdown-menu.show,
.user-dropdown.open .dropdown-menu {
  display: block;
}

.dropdown-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  font-size: 0.875rem;
  color: var(--gray-700);
  transition: var(--transition);
}

.dropdown-menu a:hover {
  background: var(--gray-50);
  color: var(--primary);
}

.dropdown-menu .dropdown-divider {
  height: 1px;
  background: var(--gray-200);
  margin: 4px 0;
}

/* ============================================
   Notification bell popover
   ============================================ */

.notification-bell-wrap {
  position: relative;
}

.notification-popover {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: 340px;
  max-width: calc(100vw - 24px);
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-200);
  z-index: 1200;
  display: none;
  overflow: hidden;
}

.notification-bell-wrap.open .notification-popover {
  display: block;
  animation: popoverIn 0.2s ease;
}

@keyframes popoverIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.notification-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}

.notification-popover-header strong {
  font-size: 0.9rem;
  color: var(--gray-800);
}

.notification-popover-list {
  max-height: 340px;
  overflow-y: auto;
}

.notification-popover-item {
  display: block;
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: background 0.2s ease;
}

.notification-popover-item:hover {
  background: var(--gray-50);
}

.notification-popover-item.unread {
  background: #f3f6ff;
}

.notification-popover-item.unread:hover {
  background: #e8edfd;
}

.notification-popover-item .notification-popover-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--gray-800);
  margin-bottom: 2px;
}

.notification-popover-item:not(.unread) .notification-popover-title strong {
  font-weight: 500;
  color: var(--gray-600);
}

.notification-popover-item .notification-dot {
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  flex-shrink: 0;
}

.notification-popover-item p {
  margin: 0;
  color: var(--gray-600);
  font-size: 0.78rem;
}

.notification-popover-item small {
  color: var(--gray-400);
  font-size: 0.7rem;
}

.notification-popover-footer {
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
}

.notification-popover-footer a {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  transition: var(--transition);
}

.notification-popover-footer a:hover {
  background: var(--gray-100);
}

/* ============================================
   Forms
   ============================================ */

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-700);
}

.form-group label .required {
  color: var(--danger);
  margin-right: 2px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.9rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--border-radius);
  background: var(--white);
  color: var(--gray-800);
  transition: var(--transition);
  line-height: 1.5;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 35, 126, 0.1);
}

.form-control:disabled,
.form-control[readonly] {
  background: var(--gray-100);
  cursor: not-allowed;
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.form-inline .form-control {
  width: auto;
  flex: 0 1 auto;
}

.form-inline .btn {
  white-space: nowrap;
}

/* Filter bar (جستجو و فیلتر لیست‌ها) */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.filter-bar .form-control {
  width: auto;
  flex: 0 1 auto;
}

.filter-bar .btn {
  white-space: nowrap;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23757575' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 36px;
}

textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

.form-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.form-row > * {
  flex: 1;
  min-width: 200px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.form-error {
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--danger);
}

.form-control.is-invalid {
  border-color: var(--danger);
}

.form-control.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.1);
}

.form-control.is-valid {
  border-color: var(--success);
}

.form-text {
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--gray-500);
}

.form-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.form-actions.end {
  justify-content: flex-end;
}

.form-actions.center {
  justify-content: center;
}

.input-group {
  display: flex;
  align-items: stretch;
}

.input-group .form-control {
  border-radius: 0;
}

.input-group .form-control:first-child {
  border-radius: var(--border-radius) 0 0 var(--border-radius);
}

.input-group .form-control:last-child {
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.input-group-text {
  display: flex;
  align-items: center;
  padding: 0 14px;
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  font-size: 0.9rem;
  color: var(--gray-600);
  white-space: nowrap;
}

/* ============================================
   Buttons
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--border-radius);
  border: 1px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
  line-height: 1.5;
  min-height: 40px;
}

.btn:hover {
  box-shadow: var(--shadow-sm);
}

.btn:active {
  opacity: 0.85;
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-light);
  border-color: var(--primary-light);
}

.btn-success {
  background: var(--success);
  color: var(--white);
  border-color: var(--success);
}

.btn-success:hover {
  background: var(--success-light);
  border-color: var(--success-light);
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
  border-color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-light);
  border-color: var(--danger-light);
}

.btn-warning {
  background: var(--warning);
  color: var(--white);
  border-color: var(--warning);
}

.btn-warning:hover {
  background: var(--warning-light);
  border-color: var(--warning-light);
}

.btn-info {
  background: var(--info);
  color: var(--white);
  border-color: var(--info);
}

.btn-info:hover {
  background: var(--info-light);
  border-color: var(--info-light);
}

.btn-outline {
  background: transparent;
  color: var(--gray-700);
  border-color: var(--gray-300);
}

.btn-outline:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
  min-height: 32px;
  border-radius: var(--border-radius-sm);
}

.btn-lg {
  padding: 12px 28px;
  font-size: 1rem;
  min-height: 48px;
}

.btn-icon {
  padding: 8px;
  min-width: 38px;
  min-height: 38px;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-group {
  display: inline-flex;
  gap: 0;
}

.btn-group .btn {
  border-radius: 0;
}

.btn-group .btn:first-child {
  border-radius: var(--border-radius) 0 0 var(--border-radius);
}

.btn-group .btn:last-child {
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.row-actions {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.btn-icon.btn-icon-leave,
.btn-icon.btn-icon-ot {
  position: relative;
  border-radius: 50%;
  border: 1px solid;
  background: var(--white);
  cursor: pointer;
  transition: var(--transition);
  min-width: 30px;
  min-height: 30px;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon.btn-icon-leave {
  color: var(--warning);
  border-color: var(--warning);
}

.btn-icon.btn-icon-leave:hover:not(:disabled) {
  background: var(--warning);
  color: var(--white);
}

.btn-icon.btn-icon-ot {
  color: var(--success);
  border-color: var(--success);
}

.btn-icon.btn-icon-ot:hover:not(:disabled) {
  background: var(--success);
  color: var(--white);
}

.btn-icon[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

[data-tooltip] {
  position: relative;
}

[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  right: 50%;
  transform: translateX(50%);
  background: #333;
  color: #fff;
  padding: 6px 10px;
  font-size: 0.75rem;
  border-radius: var(--border-radius-sm);
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
  box-shadow: var(--shadow-md);
}

[data-tooltip]:hover::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 3px);
  right: 50%;
  transform: translateX(50%);
  border: 5px solid transparent;
  border-top-color: #333;
  z-index: 100;
  pointer-events: none;
}

.page-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  background: var(--white);
  padding: 6px;
  border-radius: var(--border-radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}

.page-tab {
  padding: 7px 16px;
  border-radius: var(--border-radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
  border: 1px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
}

.page-tab:hover {
  background: var(--gray-100);
}

.page-tab.active {
  background: var(--primary);
  color: var(--white);
}

/* ============================================
   Cards
   ============================================ */

.card {
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.card-body {
  padding: 20px;
}

.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

/* ============================================
   Tables
   ============================================ */

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--border-radius);
  border: 1px solid var(--gray-200);
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table thead {
  background: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
}

.table thead th {
  padding: 12px 16px;
  font-weight: 700;
  color: var(--gray-700);
  text-align: right;
  white-space: nowrap;
  font-size: 0.8rem;
}

.table tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: var(--transition);
}

.table tbody tr:hover {
  background: var(--gray-50);
}

.table tbody td {
  padding: 10px 16px;
  color: var(--gray-700);
  vertical-align: middle;
}

.table-sm thead th,
.table-sm tbody td {
  padding: 8px 12px;
}

.table-striped tbody tr:nth-child(even) {
  background: var(--gray-50);
}

.table-striped tbody tr:nth-child(even):hover {
  background: var(--gray-100);
}

.table td .btn + .btn {
  margin-right: 4px;
}

/* Attendance history: empty + weekend rows */
.table tbody tr.att-empty td {
  color: var(--gray-500);
}

.table tbody tr.att-weekend,
.table-striped tbody tr.att-weekend:nth-child(even) {
  background: var(--gray-100);
}

.table tbody tr.att-weekend:hover {
  background: var(--gray-200);
}

/* ============================================
   History table (تاریخچه تردد) — clear borders & color
   ============================================ */

.history-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.history-nav .btn {
  min-width: 34px;
  min-height: 34px;
  padding: 4px 8px;
}

.table-history {
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  background: var(--white);
}

.table-history thead {
  background: linear-gradient(135deg, #e8eaf6 0%, #f2f4fd 100%);
  border-bottom: 2px solid var(--primary);
}

.table-history thead th {
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 13px 14px;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.table-history tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  vertical-align: middle;
}

.table-history tbody tr {
  background: var(--white);
  transition: background 0.15s ease;
}

.table-history tbody tr:last-child td {
  border-bottom: none;
}

.table-history tbody tr:nth-child(even) {
  background: #f6f8ff;
}

.table-history tbody tr:hover td {
  background: #e6e9fb;
}

.table-history tbody tr.att-weekend,
.table-history tbody tr.att-weekend:nth-child(even) {
  background: #fdf9f0;
}

.table-history tbody tr.att-weekend:hover td {
  background: #f8f0df;
}

.table-history tbody tr.att-empty td {
  color: var(--gray-400);
}

.table-history tbody td:first-child {
  font-weight: 600;
  color: var(--gray-800);
  white-space: nowrap;
}

.table-history tbody td:first-child small {
  display: block;
  font-weight: 400;
  font-size: 0.72rem;
  color: var(--gray-500);
  margin-top: 2px;
}

.table-history .badge {
  position: static;
  min-width: 0;
  height: auto;
  border-radius: 20px;
  padding: 4px 12px;
  font-weight: 600;
}

/* ============================================
   Badges
   ============================================ */

.badge-status {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 20px;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-success {
  background: #e8f5e9;
  color: var(--success);
}

.badge-danger {
  background: #ffebee;
  color: var(--danger);
}

.badge-warning {
  background: #fff8e1;
  color: var(--warning);
}

.badge-info {
  background: #e1f5fe;
  color: var(--info);
}

.badge-primary {
  background: #e8eaf6;
  color: var(--primary);
}

.badge-secondary {
  background: var(--gray-200);
  color: var(--gray-600);
}

/* ============================================
   Alerts
   ============================================ */

.alert {
  padding: 14px 18px;
  border-radius: var(--border-radius);
  font-size: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.alert-success {
  background: #e8f5e9;
  color: #1b5e20;
  border-color: #c8e6c9;
}

.alert-danger {
  background: #ffebee;
  color: #b71c1c;
  border-color: #ffcdd2;
}

.alert-warning {
  background: #fff8e1;
  color: #e65100;
  border-color: #ffecb3;
}

.alert-info {
  background: #e1f5fe;
  color: #01579b;
  border-color: #b3e5fc;
}

.alert .alert-close {
  margin-right: auto;
  cursor: pointer;
  font-size: 1.1rem;
  opacity: 0.6;
  transition: var(--transition);
}

.alert .alert-close:hover {
  opacity: 1;
}

/* Compact notification items */
.notification-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notification-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius-sm);
  background: var(--white);
  cursor: pointer;
  transition: background 0.3s ease;
}

.notification-item:hover {
  background: var(--gray-50);
}

.notification-item.unread {
  background: #e3f2fd;
  border-color: #bbdefb;
}

.notification-item:not(.unread) .notification-title strong {
  font-weight: 500;
  color: var(--gray-600);
}

.notification-item .notification-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.notification-item .notification-dot {
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  flex-shrink: 0;
}

.notification-unread-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  flex-shrink: 0;
}

.notification-search {
  position: relative;
  display: flex;
  align-items: center;
}

.notification-search svg {
  position: absolute;
  right: 10px;
  color: var(--gray-400);
}

.notification-search .form-control {
  padding-right: 36px;
}

.notification-item .notification-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* ============================================
   Compact inline stat chips (history/reports)
   ============================================ */

.stat-inline-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius-sm);
  font-size: 0.82rem;
  white-space: nowrap;
  line-height: 1.4;
}

.stat-chip .chip-value {
  font-weight: 700;
  color: var(--gray-800);
}

.stat-chip.success .chip-value { color: var(--success); }
.stat-chip.warning .chip-value { color: var(--warning); }
.stat-chip.danger .chip-value { color: var(--danger); }
.stat-chip.info .chip-value { color: var(--info); }
.stat-chip.primary .chip-value { color: var(--primary); }

/* ============================================
   Toggle switch
   ============================================ */

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--gray-300);
  border-radius: 24px;
  transition: var(--transition);
  cursor: pointer;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  right: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: var(--transition);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--success);
}

.toggle-switch input:checked + .toggle-slider::before {
  right: 23px;
}

/* Toggle group (settings) */
.toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.toggle-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 8px 14px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius-sm);
}

.toggle-item .toggle-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
  white-space: nowrap;
}

/* ============================================
   Jalali date picker
   ============================================ */

.jdp-wrapper {
  position: relative;
  display: block;
  max-width: 100%;
}

.jdp-wrapper .jdp-input {
  width: 100%;
  box-sizing: border-box;
}

.form-inline .jdp-wrapper {
  display: inline-block;
  width: auto;
}

.form-inline .jdp-wrapper .jdp-input {
  width: auto;
  min-width: 140px;
}

.jdp-input {
  cursor: pointer;
}

.jdp-popup {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 260px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  z-index: 1200;
  padding: 10px;
}

.jdp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.jdp-nav {
  background: var(--gray-100);
  border: none;
  border-radius: var(--border-radius-sm);
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 1rem;
  color: var(--gray-700);
  line-height: 1;
}

.jdp-nav:hover {
  background: var(--gray-200);
}

.jdp-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--gray-800);
}

.jdp-weekdays,
.jdp-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}

.jdp-weekdays span {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gray-500);
  padding: 4px 0;
}

.jdp-day {
  border: none;
  background: transparent;
  border-radius: var(--border-radius-sm);
  padding: 6px 0;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--gray-700);
}

.jdp-day:hover {
  background: var(--gray-100);
}

.jdp-selected {
  background: var(--primary);
  color: var(--white);
}

.jdp-selected:hover {
  background: var(--primary);
  color: var(--white);
}

.jdp-is-today::after {
  content: '';
  display: block;
  width: 4px;
  height: 4px;
  background: var(--primary);
  border-radius: 50%;
  margin: 2px auto 0;
}

.jdp-selected::after {
  background: var(--white);
}

.jdp-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--gray-100);
}

.jdp-today,
.jdp-clear {
  border: 1px solid var(--gray-200);
  background: var(--gray-50);
  border-radius: var(--border-radius-sm);
  padding: 4px 12px;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--gray-700);
}

.jdp-today {
  border-color: var(--primary);
  color: var(--primary);
}

.jdp-today:hover,
.jdp-clear:hover {
  background: var(--gray-100);
}

/* ============================================
   Modals
   ============================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background: var(--white);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.1rem;
}

.modal-close {
  font-size: 1.3rem;
  color: var(--gray-500);
  padding: 4px;
  border-radius: var(--border-radius-sm);
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}

/* ============================================
   Toasts
   ============================================ */

.toast-container {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  min-width: 300px;
  max-width: 420px;
  padding: 14px 18px;
  border-radius: var(--border-radius);
  background: var(--white);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  animation: toastIn 0.3s ease;
  border-right: 4px solid var(--gray-400);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast-success {
  border-right-color: var(--success);
}

.toast-error {
  border-right-color: var(--danger);
}

.toast-warning {
  border-right-color: var(--warning);
}

.toast-info {
  border-right-color: var(--info);
}

.toast-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--info); }

.toast-close {
  margin-right: auto;
  font-size: 1rem;
  color: var(--gray-500);
  cursor: pointer;
  transition: var(--transition);
}

.toast-close:hover {
  color: var(--gray-800);
}

/* ============================================
   Pagination
   ============================================ */

.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  padding: 0;
  flex-wrap: wrap;
}

.page-item {
  display: inline-flex;
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--gray-300);
  border-radius: var(--border-radius);
  font-size: 0.85rem;
  color: var(--gray-700);
  background: var(--white);
  transition: var(--transition);
}

.page-link:hover {
  background: var(--gray-50);
  border-color: var(--primary);
  color: var(--primary);
}

.page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

.page-item.disabled .page-link {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ============================================
   Loading / Spinner
   ============================================ */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  z-index: 2500;
  display: none;
  align-items: center;
  justify-content: center;
}

.loading-overlay.show {
  display: flex;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.spinner-white {
  border-color: rgba(255, 255, 255, 0.3);
  border-top-color: var(--white);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   Tabs
   ============================================ */

.tabs {
  display: flex;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 20px;
  gap: 0;
  overflow-x: auto;
}

.tab-link {
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
  white-space: nowrap;
  cursor: pointer;
  background: none;
}

.tab-link:hover {
  color: var(--gray-700);
}

.tab-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ============================================
   Tree Structure
   ============================================ */

.tree {
  font-size: 0.9rem;
}

.tree-node {
  padding: 4px 0;
}

.tree-children {
  padding-right: 24px;
}

.tree-toggle {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: var(--border-radius-sm);
  transition: var(--transition);
}

.tree-toggle:hover {
  background: var(--gray-100);
}

.tree-toggle::before {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4px 0 4px 5px;
  border-color: transparent transparent transparent var(--gray-500);
  transition: transform 0.2s ease;
}

.tree-toggle.open::before {
  transform: rotate(90deg);
}

.tree-line {
  color: var(--gray-500);
  font-size: 0.85rem;
}

/* ============================================
   Utility Classes
   ============================================ */

/* Text Alignment */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

/* Text Colors */
.text-muted { color: var(--gray-500); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }
.text-primary { color: var(--primary); }

/* Margin Top */
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mt-5 { margin-top: 32px; }

/* Margin Bottom */
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.mb-5 { margin-bottom: 32px; }

/* Padding */
.p-1 { padding: 4px; }
.p-2 { padding: 8px; }
.p-3 { padding: 16px; }
.p-4 { padding: 24px; }
.p-5 { padding: 32px; }

/* Gap */
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.gap-4 { gap: 24px; }
.gap-5 { gap: 32px; }

/* Grid */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

/* Visibility */
.hidden { display: none !important; }
.visible { visibility: visible; }
.invisible { visibility: hidden; }

/* Flex */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }

/* Width */
.w-full { width: 100%; }

/* Rounded */
.rounded { border-radius: var(--border-radius); }
.rounded-full { border-radius: 50%; }

/* Overflow */
.overflow-auto { overflow: auto; }
.overflow-hidden { overflow: hidden; }

/* Font Weight */
.fw-bold { font-weight: 700; }
.fw-normal { font-weight: 400; }

/* Font Size */
.fs-sm { font-size: 0.8rem; }
.fs-md { font-size: 0.9rem; }
.fs-lg { font-size: 1.1rem; }

/* Divider */
.divider {
  height: 1px;
  background: var(--gray-200);
  margin: 16px 0;
  border: none;
}

/* ============================================
   Face verification (camera)
   ============================================ */

.face-camera-area {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  margin: 15px auto;
  width: 100%;
  max-width: 360px;
}

.face-camera-box {
  position: relative;
  width: 320px;
  max-width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: #f0f2f5;
  border: 2px dashed var(--gray-300);
}

.face-camera-box video,
.face-camera-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.face-camera-box video {
  transform: scaleX(-1);
}

.face-camera-box canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: none;
}

.face-camera-box .cam-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  color: var(--gray-500);
  font-size: 0.85rem;
  text-align: center;
  padding: 12px;
}

.face-camera-box.has-face .cam-placeholder,
.face-camera-box.has-face .face-overlay {
  display: flex;
}

.face-result-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.face-result-ok { background: #e8f5e9; color: var(--success); }
.face-result-wait { background: #fff8e1; color: var(--warning); }
.face-result-fail { background: #ffebee; color: var(--danger); }

.face-photo-list img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid var(--gray-200);
}

.face-confirm-photo {
  max-width: 240px;
  width: 100%;
  border-radius: 10px;
  border: 2px solid var(--primary);
}
