/* ============================================
   سامانه نظارت تردد رجبی - 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: 70px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* ============================================
   Compact Sidebar (Mini)
   ============================================ */

.sidebar-mini {
  position: fixed;
  top: 0;
  right: 0;
  width: 70px;
  height: 100vh;
  background: var(--primary);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: width 0.25s ease;
  overflow: hidden;
}

.sidebar-mini:hover {
  width: 200px;
}

.sidebar-mini-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-mini-nav::-webkit-scrollbar {
  width: 0;
}

.sm-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  justify-content: center;
  color: rgba(255,255,255,0.7);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  transition: var(--transition);
  border-right: 3px solid transparent;
  text-decoration: none;
  min-height: 48px;
}

.sidebar-mini:hover .sm-link {
  justify-content: flex-start;
  padding-right: 16px;
}

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

.sm-link.active {
  background: rgba(255,255,255,0.18);
  color: var(--white);
  border-right-color: var(--white);
}

.sm-icon {
  font-size: 1.2rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.sm-label {
  opacity: 0;
  width: 0;
  overflow: hidden;
  transition: opacity 0.2s ease;
}

.sidebar-mini:hover .sm-label {
  opacity: 1;
  width: auto;
}

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

.navbar {
  position: fixed;
  top: 0;
  right: 70px;
  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 20px;
  z-index: 900;
  transition: var(--transition);
}

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

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--gray-700);
  padding: 4px 8px;
  cursor: pointer;
}

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

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

.notification-bell {
  position: relative;
  font-size: 1.1rem;
  color: var(--gray-600);
  padding: 6px;
  border-radius: var(--border-radius-sm);
  transition: var(--transition);
  text-decoration: none;
}

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

.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;
}

/* ============================================
   Table: sticky header
   ============================================ */
.table-responsive {
  overflow-x: auto;
  overflow-y: visible;
}
.table-responsive thead {
  position: sticky;
  top: 0;
  z-index: 3;
}
.table-responsive thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f8f9fa;
  box-shadow: 0 1px 0 #dee2e6;
}

.row-future td {
  opacity: 0.5;
}

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

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

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

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

.user-dropdown .dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 160px;
  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;
}

.user-dropdown:hover .dropdown-menu {
  display: block;
}

.user-dropdown .dropdown-menu a {
  display: block;
  padding: 8px 16px;
  font-size: 0.85rem;
  color: var(--gray-700);
  transition: var(--transition);
  text-decoration: none;
}

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

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

/* ============================================
   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;
}

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);
}

.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 {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: translateY(0);
}

.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);
}

.settings-tabs .btn {
  text-decoration: none;
}

.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;
}

/* ============================================
   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,
.table-responsive {
  overflow-x: auto;
  border-radius: var(--border-radius);
  border: 1px solid var(--gray-200);
}

.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;
  border: 1px solid var(--gray-300);
}

.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;
  border: 1px solid var(--gray-300);
}

.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;
}

/* ============================================
   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, .badge-danger, .badge-warning, .badge-info, .badge-primary, .badge-secondary {
  position: static;
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  min-width: auto;
  height: auto;
  line-height: 1.4;
}

.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: #f5f5f5;
  color: #616161;
}

/* ============================================
   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;
}

/* ============================================
   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;
  min-height: 0;
}

.modal form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

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

/* ============================================
   Upload progress (liquid bubble)
   ============================================ */

.upload-progress {
  position: fixed;
  inset: 0;
  z-index: 4000;
  background: rgba(8, 18, 38, 0.62);
  backdrop-filter: blur(4px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.bubble-progress {
  position: relative;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  overflow: hidden;
  background: #e7f2fc;
  box-shadow:
    0 0 0 9px rgba(255, 255, 255, 0.1),
    0 0 45px rgba(72, 166, 255, 0.45),
    inset 0 0 14px rgba(30, 100, 180, 0.18);
  animation: bubblePulse 2s ease-in-out infinite;
}

@keyframes bubblePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

.bubble-liquid {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--pct, 0%);
  background: linear-gradient(180deg, #56ccf2, #2f80ed);
  transition: height 0.2s ease-out;
}

.bubble-liquid::before,
.bubble-liquid::after {
  content: '';
  position: absolute;
  top: -46px;
  left: -25%;
  width: 150%;
  height: 92px;
  border-radius: 40%;
  background: inherit;
  animation: liquidWave 4.5s linear infinite;
}

.bubble-liquid::after {
  opacity: 0.45;
  animation-duration: 3s;
  animation-direction: reverse;
}

@keyframes liquidWave {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.bubble-percent {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: #0d47a1;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.65);
}

.upload-progress-label {
  color: #fff;
  font-size: 1rem;
  margin: 0;
  animation: labelFade 1.4s ease-in-out infinite;
}

@keyframes labelFade {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ============================================
   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-bar {
  display: flex;
  border-bottom: 2px solid var(--gray-200);
  gap: 0;
  overflow-x: auto;
  padding: 0 16px;
}

.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;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.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%; }
.w-40 { width: 40%; }
.w-10 { width: 10%; }

/* Avatar */
.profile-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--gray-200, #e9ecef);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
}

/* Document group rows */
.doc-group td {
    background: var(--gray-100, #f1f3f5);
    padding: 6px 12px;
}

/* 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;
}

/* ============================================
   Attendance Calendar
   ============================================ */

.attendance-calendar-page {
  max-width: 100%;
}

.calendar-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.current-month {
  font-size: 1.1rem;
  font-weight: 700;
  min-width: 160px;
  text-align: center;
}

.stats-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 24px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  flex: 1;
  min-width: 110px;
}

.stat-pill .stat-num {
  font-size: 1.3rem;
  font-weight: 800;
}

.stat-pill .stat-lbl {
  font-size: 0.75rem;
  color: var(--gray-500);
}

.stat-pill.success .stat-num { color: var(--success); }
.stat-pill.warning .stat-num { color: var(--warning); }
.stat-pill.danger .stat-num { color: var(--danger); }
.stat-pill.info .stat-num { color: var(--info); }
.stat-pill.purple .stat-num { color: #7b1fa2; }
.stat-pill.teal .stat-num { color: #00796b; }
.stat-pill.gray .stat-num { color: var(--gray-600); }

.stat-pill.success { border-color: #c8e6c9; background: #f1f8e9; }
.stat-pill.warning { border-color: #ffecb3; background: #fffde7; }
.stat-pill.danger { border-color: #ffcdd2; background: #fff5f5; }
.stat-pill.info { border-color: #b3e5fc; background: #e1f5fe; }
.stat-pill.purple { border-color: #e1bee7; background: #fce4ec; }
.stat-pill.teal { border-color: #b2dfdb; background: #e0f2f1; }
.stat-pill.gray { border-color: var(--gray-200); background: var(--gray-50); }

/* Calendar Grid */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding: 8px;
}

.cal-header {
  text-align: center;
  padding: 10px 4px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gray-500);
  border-bottom: 2px solid var(--gray-200);
}

.cal-cell {
  min-height: 90px;
  padding: 6px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.cal-cell:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.cal-cell.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
  background: #e8eaf6;
}

.cal-cell.empty {
  background: var(--gray-50);
  cursor: default;
}

.cal-cell.empty:hover {
  border-color: transparent;
  box-shadow: none;
}

.cal-row.selected {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  background: #e8eaf6 !important;
}

.cal-row {
  transition: background 0.15s;
}

.cal-row:hover {
  background: #f5f5f5;
}

.cal-cell.weekend {
  background: #fafafa;
}

.cal-cell.today {
  border-color: var(--primary);
  background: #e8eaf6;
}

.cal-day-num {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 4px;
}

.cal-cell.weekend .cal-day-num {
  color: var(--danger);
}

/* Status colors */
.cal-cell.status-present {
  background: #e8f5e9;
}

.cal-cell.status-present .cal-day-num {
  color: var(--success);
}

.cal-cell.status-late {
  background: #fff8e1;
}

.cal-cell.status-late .cal-day-num {
  color: var(--warning);
}

.cal-cell.status-absent {
  background: #ffebee;
}

.cal-cell.status-absent .cal-day-num {
  color: var(--danger);
}

.cal-cell.status-leave {
  background: #e1f5fe;
}

.cal-cell.status-leave .cal-day-num {
  color: var(--info);
}

.cal-cell.status-mission {
  background: #f3e5f5;
}

.cal-cell.status-mission .cal-day-num {
  color: #7b1fa2;
}

/* Time badges */
.cal-att-info,
.cal-leave-info,
.cal-mission-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cal-time {
  font-size: 0.7rem;
  font-weight: 600;
  direction: ltr;
  display: inline-block;
}

.cal-time.in { color: var(--success); }
.cal-time.out { color: var(--danger); }

.cal-badge {
  font-size: 0.6rem;
  padding: 1px 5px;
  border-radius: 8px;
  display: inline-block;
  white-space: nowrap;
}

.cal-badge.late { background: #fff3e0; color: #e65100; }
.cal-badge.ot { background: #e8f5e9; color: #2e7d32; }
.cal-badge.leave { background: #e1f5fe; color: #01579b; }
.cal-badge.mission { background: #f3e5f5; color: #7b1fa2; }

/* Day detail panel */
.detail-card {
  padding: 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
  margin-bottom: 8px;
}

.detail-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
}

.dl {
  font-size: 0.8rem;
  color: var(--gray-500);
  min-width: 80px;
}

.dv {
  font-size: 0.9rem;
  font-weight: 600;
}

.detail-section {
  font-size: 0.85rem;
  color: var(--gray-600);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--gray-100);
}

/* Context Menu */
.context-menu {
  position: fixed;
  z-index: 5000;
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-200);
  min-width: 200px;
  display: none;
  overflow: hidden;
}

.context-menu.show {
  display: block;
  animation: ctxIn 0.12s ease;
}

@keyframes ctxIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.ctx-header {
  padding: 10px 16px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gray-600);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 0.85rem;
  color: var(--gray-700);
  cursor: pointer;
  transition: background 0.1s;
}

.ctx-item:hover {
  background: #e8eaf6;
  color: var(--primary);
}

.ctx-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
}

.ctx-divider {
  height: 1px;
  background: var(--gray-100);
  margin: 2px 0;
}

/* درخواست سلولی (کلیک راست) */
td[data-req-status="pending"] {
  background-color: #fff3cd !important;
}

td[data-req-status="approved"] {
  background-color: #d4edda !important;
}

td[data-req-status="rejected"] {
  background-color: #f8d7da !important;
}

td[data-req-id] {
  cursor: help;
}

.req-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
}

.req-dot-pending {
  background: #f9a825;
}

.req-dot-approved {
  background: #2e7d32;
}

.req-dot-rejected {
  background: #c62828;
}

/* Report box */
.report-box .table td {
  padding: 8px 12px;
}

.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.report-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--gray-200);
}

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

@media (max-width: 768px) {
  .cal-cell {
    min-height: 60px;
    padding: 4px;
  }
  .cal-day-num {
    font-size: 0.75rem;
  }
  .cal-badge {
    font-size: 0.5rem;
    padding: 0 3px;
  }
  .cal-time {
    font-size: 0.6rem;
  }
  .stats-row {
    gap: 6px;
  }
  .stat-pill {
    min-width: 80px;
    padding: 8px 12px;
  }
  .stat-pill .stat-num {
    font-size: 1rem;
  }
  .stat-pill .stat-lbl {
    font-size: 0.65rem;
  }
}
}
