@import url("https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700&display=swap");

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #3b82f6;
  --secondary: #64748b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --background: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Vazirmatn", sans-serif;
  background-color: var(--background);
  color: var(--text);
  direction: rtl;
  line-height: 1.6;
}

/* ناوبری */
.navbar {
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.navbar-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
}

.navbar-menu {
  display: flex;
  gap: 0.5rem;
  list-style: none;
}

.navbar-menu a {
  padding: 0.5rem 1rem;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius);
  transition: all 0.2s;
  font-size: 0.9rem;
}

.navbar-menu a:hover,
.navbar-menu a.active {
  background: var(--primary);
  color: white;
}

.navbar-menu .dropdown {
  position: relative;
}

.navbar-menu .dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.2s;
}

.navbar-menu .dropdown:hover .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-menu a {
  display: block;
  padding: 0.75rem 1rem;
  border-radius: 0;
}

.dropdown-menu a:first-child {
  border-radius: var(--radius) var(--radius) 0 0;
}

.dropdown-menu a:last-child {
  border-radius: 0 0 var(--radius) var(--radius);
}

/* کانتینر اصلی */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

/* کارت‌ها */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

/* دکمه‌ها */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--secondary);
  color: white;
}

.btn-secondary:hover {
  background: #475569;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #059669;
}

.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-warning:hover {
  background: #d97706;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
}

.btn-icon {
  padding: 0.5rem;
  border-radius: 50%;
}

/* فرم‌ها */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text);
}

.form-control {
  width: 100%;
  padding: 0.625rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

/* جدول */
.table-responsive {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: var(--background);
}

th,
td {
  padding: 0.875rem 1rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

tbody tr:hover {
  background: var(--background);
}

/* وضعیت‌ها */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 500;
}

.badge-success {
  background: #d1fae5;
  color: #065f46;
}

.badge-danger {
  background: #fee2e2;
  color: #991b1b;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-secondary {
  background: #e2e8f0;
  color: #475569;
}

.badge-info {
  background: #dbeafe;
  color: #1e40af;
}

/* مدال */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.9);
  transition: transform 0.3s;
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

/* پیام‌ها */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.alert-success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.alert-danger {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-warning {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

/* لودینگ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* حضور و غیاب */
.attendance-grid {
  display: grid;
  gap: 1rem;
}

.student-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--background);
  border-radius: var(--radius);
  transition: all 0.2s;
}

.student-row:hover {
  background: #e2e8f0;
}

/* استایل برای ردیف فوکوس شده در حضور و غیاب */
.student-row.focused {
  background: #dbeafe !important;
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.student-info {
  flex: 1;
  min-width: 150px;
}

.student-name {
  font-weight: 500;
  color: var(--text);
}

.student-code {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.attendance-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.status-toggle {
  display: flex;
  gap: 0.5rem;
}

.status-btn {
  padding: 0.5rem 1rem;
  border: 2px solid var(--border);
  background: white;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  font-size: 0.85rem;
}

.status-btn.present.active {
  border-color: var(--success);
  background: #d1fae5;
  color: #065f46;
}

.status-btn.absent.active {
  border-color: var(--danger);
  background: #fee2e2;
  color: #991b1b;
}

.delay-input {
  width: 80px;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  text-align: center;
}

/* گرید فیلترها */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--background);
  border-radius: var(--radius);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.filter-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* جدول گزارش */
.report-table {
  font-size: 0.85rem;
}

.report-table th,
.report-table td {
  padding: 0.625rem 0.75rem;
  text-align: center;
  min-width: 80px;
}

.report-table th:first-child,
.report-table td:first-child {
  text-align: right;
  position: sticky;
  right: 0;
  background: var(--surface);
  z-index: 1;
  min-width: 150px;
}

.report-table thead th:first-child {
  background: var(--background);
}

.cell-present {
  background: #d1fae5;
  color: #065f46;
}

.cell-absent {
  background: #fee2e2;
  color: #991b1b;
}

.cell-delay {
  background: #fef3c7;
  color: #92400e;
}

.cell-not-held {
  background: #e2e8f0;
  color: #64748b;
}

/* انتخابگر تاریخ */
.date-picker-container {
  position: relative;
}

.date-picker-input {
  width: 100%;
  padding: 0.625rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  background: white;
}

/* تب‌ها */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}

.tab {
  padding: 0.75rem 1.5rem;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
}

.tab.active {
  color: var(--primary);
}

.tab.active::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* خالی بودن */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

/* ریسپانسیو */
@media (max-width: 768px) {
  .navbar-container {
    flex-direction: column;
    gap: 1rem;
  }

  .navbar-menu {
    flex-wrap: wrap;
    justify-content: center;
  }

  .container {
    padding: 1rem;
  }

  .student-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .attendance-controls {
    width: 100%;
    justify-content: space-between;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}

/* انیمیشن‌ها */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease-out;
}

/* استایل اضافی برای ورودی تاریخ فارسی */
.persian-date-picker {
  direction: rtl;
}

/* آمار کلی */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* جمع کل در جدول */
.total-row {
  background: var(--background) !important;
  font-weight: 600;
}

.total-row td {
  border-top: 2px solid var(--border);
}

/* تقویم شمسی */
.datepicker-container {
  position: relative;
  display: inline-block;
}

.datepicker-input {
  width: 100%;
  padding: 0.625rem 1rem;
  padding-left: 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  background: white;
}

.datepicker-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.datepicker-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.datepicker-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 1rem;
  min-width: 280px;
  display: none;
}

.datepicker-dropdown.active {
  display: block;
}

.datepicker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.datepicker-title {
  font-weight: 600;
  font-size: 1rem;
}

.datepicker-nav {
  display: flex;
  gap: 0.5rem;
}

.datepicker-nav button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: white;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.datepicker-nav button:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.datepicker-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 0.5rem;
}

.datepicker-weekday {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.5rem 0;
}

.datepicker-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.datepicker-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.datepicker-day:hover {
  background: var(--background);
}

.datepicker-day.today {
  border: 2px solid var(--primary);
}

.datepicker-day.selected {
  background: var(--primary);
  color: white;
}

.datepicker-day.other-month {
  color: var(--text-muted);
  opacity: 0.5;
}

.datepicker-day.disabled {
  cursor: not-allowed;
  opacity: 0.3;
}

.datepicker-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* نمودار */
.chart-container {
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--background);
  border-radius: var(--radius);
}

.chart-title {
  font-weight: 600;
  margin-bottom: 1rem;
  text-align: center;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 200px;
  padding: 1rem;
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
}

.bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 50px;
  flex: 1;
}

.bar-wrapper {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 180px;
}

.bar {
  width: 20px;
  border-radius: 4px 4px 0 0;
  transition: all 0.3s;
  cursor: pointer;
  position: relative;
}

.bar:hover {
  opacity: 0.8;
}

.bar.delay-bar {
  background: linear-gradient(to top, #f59e0b, #fbbf24);
}

.bar.absence-bar {
  background: linear-gradient(to top, #ef4444, #f87171);
}

.bar-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.5rem;
  white-space: nowrap;
  transform: rotate(-45deg);
  transform-origin: right top;
}

.chart-legend {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 1rem;
  font-size: 0.85rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legend-color {
  width: 16px;
  height: 16px;
  border-radius: 4px;
}

.legend-color.delay {
  background: #f59e0b;
}

.legend-color.absence {
  background: #ef4444;
}

/* tooltip نمودار */
.bar-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
  z-index: 10;
}

.bar:hover .bar-tooltip {
  opacity: 1;
  visibility: visible;
}

/* دکمه اکسل */
.btn-excel {
  background: #217346;
  color: white;
}

.btn-excel:hover {
  background: #1a5c38;
}

/* کلید میانبر */
kbd {
  background: var(--background);
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.8rem;
  border: 1px solid var(--border);
}

/* موبایل منو */
.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text);
}

@media (max-width: 900px) {
  .mobile-menu-toggle {
    display: block;
  }

  .navbar-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    background: var(--surface);
    flex-direction: column;
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    border-top: 1px solid var(--border);
  }

  .navbar-menu.active {
    display: flex;
  }

  .navbar-menu .dropdown-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    padding-right: 1rem;
    background: var(--background);
    margin-top: 0.5rem;
  }

  .navbar-menu .dropdown:hover .dropdown-menu {
    display: block;
  }
}

/* ریسپانسیو بهتر */
@media (max-width: 1024px) {
  .container {
    padding: 1rem;
  }

  .card {
    padding: 1rem;
  }

  .filters {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    width: 100%;
  }

  .filter-group input,
  .filter-group select {
    width: 100% !important;
  }

  .bar-chart {
    height: 150px;
  }
}

@media (max-width: 768px) {
  .navbar-container {
    flex-direction: column;
    gap: 1rem;
  }

  .navbar-menu {
    flex-wrap: wrap;
    justify-content: center;
  }

  .navbar-menu a {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
  }

  .container {
    padding: 0.75rem;
  }

  .student-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .attendance-controls {
    width: 100%;
    flex-direction: column;
    gap: 0.75rem;
  }

  .status-toggle {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .status-btn {
    width: 100%;
    justify-content: center;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .card-header {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }

  .card-header .btn {
    width: 100%;
    justify-content: center;
  }

  table {
    font-size: 0.85rem;
  }

  th,
  td {
    padding: 0.5rem;
  }

  /* مدال حضور و غیاب - موبایل */
  .attendance-modal {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    margin: 0;
  }

  .attendance-modal .modal-body {
    padding: 0;
  }

  .attendance-list {
    max-height: calc(100vh - 140px);
    overflow-y: auto;
  }

  .attendance-row {
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
  }

  .attendance-row .student-info {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .attendance-row .attendance-controls {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .attendance-row .status-buttons {
    flex: 1;
    display: flex;
    gap: 0.5rem;
  }

  .attendance-row .status-btn {
    flex: 1;
    padding: 0.75rem 0.5rem;
    font-size: 0.9rem;
    text-align: center;
  }

  .attendance-row .delay-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    justify-content: flex-end;
  }

  .attendance-row .delay-input {
    width: 70px;
    padding: 0.5rem;
    font-size: 1rem;
  }

  /* اکشن باتن‌ها در جدول */
  .action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .action-buttons .btn {
    width: 100%;
    justify-content: center;
  }
}

/* مدال - تبلت */
@media (max-width: 1024px) and (min-width: 769px) {
  .attendance-modal {
    width: 95%;
    max-width: 700px;
  }
}

/* ===== استایل‌های صفحه ثبت حضور و غیاب ===== */

/* گرید برنامه‌های ثبت نشده */
.programs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.program-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.25rem 1rem;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.program-btn:hover {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.05);
}

.program-btn .program-icon {
  font-size: 1.5rem;
  color: var(--primary);
}

.program-btn .program-name {
  font-weight: 500;
  color: var(--text);
  text-align: center;
}

.program-btn.misc {
  border-color: var(--warning);
}

.program-btn.misc:hover {
  background: rgba(245, 158, 11, 0.05);
}

.misc-badge {
  font-size: 0.7rem;
  background: var(--warning);
  color: white;
  padding: 0.125rem 0.5rem;
  border-radius: 10px;
}

/* بخش‌های برنامه */
.programs-section {
  margin-bottom: 2rem;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}

/* کارت‌های برنامه ثبت شده */
.registered-programs {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.registered-program-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-right: 4px solid var(--success);
}

.registered-program-card.not-held {
  border-right-color: var(--text-muted);
  background: var(--background);
  opacity: 0.75;
}

.registered-program-card .program-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.registered-program-card .program-name {
  font-weight: 500;
  color: var(--text);
}

.registered-program-card .program-status {
  display: flex;
  align-items: center;
}

.registered-program-card .program-actions {
  display: flex;
  gap: 0.5rem;
}

/* تاگل وضعیت برگزاری */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.toggle-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.toggle-text {
  font-size: 0.85rem;
}

.toggle-text.held {
  color: var(--success);
}

.toggle-text.not-held {
  color: var(--text-muted);
}

/* لیست حضور و غیاب در مدال */
.attendance-list {
  max-height: 60vh;
  overflow-y: auto;
}

.attendance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.attendance-row:hover {
  background: var(--background);
}

.attendance-row.selected {
  background: rgba(37, 99, 235, 0.1);
  border-right: 3px solid var(--primary);
}

.attendance-row .student-info {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 150px;
}

.attendance-row .attendance-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.attendance-row .status-buttons {
  display: flex;
  gap: 0.5rem;
}

.attendance-row .delay-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.attendance-row .delay-input {
  width: 70px;
}

/* ریسپانسیو برنامه‌ها */
@media (max-width: 768px) {
  .programs-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
  
  .registered-program-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  
  .registered-program-card .program-actions {
    width: 100%;
  }
  
  .registered-program-card .program-actions .btn {
    flex: 1;
  }
}

/* ===== معیارها (Criteria) ===== */
.criteria-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
  padding: 1rem 0;
}

.criteria-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  background: var(--surface);
  transition: box-shadow 0.2s;
}

.criteria-card:hover {
  box-shadow: var(--shadow-lg);
}

.criteria-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.criteria-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.criteria-badge {
  display: inline-block;
  padding: 0.125rem 0.625rem;
  border-radius: 12px;
  font-size: 0.7rem;
  color: white;
  font-weight: 600;
}

.criteria-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.criteria-order {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--background);
  padding: 0.125rem 0.5rem;
  border-radius: 8px;
}

.criteria-config {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  min-height: 1.2em;
}

.criteria-card-actions {
  display: flex;
  gap: 0.5rem;
}

/* تنظیمات فرم معیار */
.config-section {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: var(--background);
}

/* ===== جدول عملکرد ===== */
.perf-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.perf-table th,
.perf-table td {
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--border);
  text-align: center;
  white-space: nowrap;
}

.perf-table th {
  background: var(--primary);
  color: white;
  font-weight: 500;
  font-size: 0.8rem;
  position: sticky;
  top: 0;
  z-index: 2;
}

.perf-table .sticky-col {
  position: sticky;
  right: 0;
  background: var(--surface);
  z-index: 3;
  text-align: right;
  min-width: 120px;
  font-weight: 500;
}

.perf-table th.sticky-col {
  background: var(--primary-dark);
  z-index: 4;
  color: white;
}

.perf-table tbody tr:nth-child(even) {
  background: #fafafa;
}

.perf-table tbody tr:hover {
  background: rgba(37, 99, 235, 0.04);
}

.type-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  vertical-align: middle;
}

/* ورودی‌های عملکرد */
.perf-check {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.perf-check input[type="checkbox"] {
  display: none;
}

.perf-check-mark {
  width: 24px;
  height: 24px;
  border: 2px solid #cbd5e1;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-size: 14px;
  color: transparent;
}

.perf-check input:checked + .perf-check-mark {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.perf-check input:checked + .perf-check-mark::after {
  content: "\2713";
}

.perf-select {
  width: 100%;
  min-width: 80px;
  padding: 0.25rem 0.375rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.8rem;
  background: white;
  cursor: pointer;
}

.perf-select:focus {
  border-color: var(--primary);
  outline: none;
}

.perf-time {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  justify-content: center;
}

.perf-num-input {
  width: 60px;
  padding: 0.25rem 0.375rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.85rem;
  text-align: center;
}

.perf-num-input:focus {
  border-color: var(--primary);
  outline: none;
}

.perf-unit {
  font-size: 0.7rem;
  color: var(--text-muted);
  min-width: fit-content;
}

/* نشانگرهای بله/خیر در گزارش */
.check-yes {
  color: var(--success);
  font-weight: 700;
  font-size: 1.1rem;
}

.check-no {
  color: #cbd5e1;
  font-size: 1rem;
}

.student-name-cell {
  font-weight: 500;
  min-width: 130px;
}

/* ریسپانسیو معیارها */
@media (max-width: 768px) {
  .criteria-cards {
    grid-template-columns: 1fr;
  }
  
  .perf-num-input {
    width: 50px;
  }
}

/* ===== صفحه ورود ===== */
.login-body {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-wrapper {
  width: 100%;
  max-width: 420px;
  padding: 1.5rem;
}

.login-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 2.5rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  background: var(--primary);
  border-radius: 16px;
  color: white;
  margin-bottom: 1.25rem;
}

.login-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.375rem;
}

.login-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.login-form .form-group {
  margin-bottom: 1.25rem;
}

.login-form .form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text);
}

.login-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.login-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.password-wrapper {
  position: relative;
}

.password-wrapper .login-input {
  padding-left: 2.75rem;
}

.password-toggle {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  display: flex;
}

.password-toggle:hover {
  color: var(--text);
}

.login-btn {
  width: 100%;
  padding: 0.875rem;
  font-size: 1rem;
  font-weight: 600;
  margin-top: 0.5rem;
}

.login-footer {
  text-align: center;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* اطلاعات کاربری در ناوبری */
.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
}

.user-details {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  line-height: 1.3;
}

.user-name {
  font-weight: 600;
  color: var(--text);
}

.user-role {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.btn-logout {
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
  background: none;
  border: 1px solid var(--border);
  color: var(--danger);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

/* ===== ریسپانسیو موبایل ===== */

/* منوی موبایل پیشرفته */
.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
}

.menu-toggle span {
  width: 25px;
  height: 3px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.3s;
}

.menu-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(10px, 10px);
}

.menu-toggle.active span:nth-child(2) {
  opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -7px);
}

@media (max-width: 1024px) {
  .menu-toggle {
    display: flex;
  }
  
  .navbar-container {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .navbar-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0;
  }
  
  .navbar-menu.open {
    max-height: 500px;
    padding: 0.5rem 0;
  }
  
  .navbar-menu li {
    width: 100%;
  }
  
  .navbar-menu a {
    display: block;
    padding: 0.75rem 1.5rem !important;
    border-radius: 0 !important;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
  }
  
  .navbar-menu .dropdown-menu {
    position: static !important;
    box-shadow: none !important;
    background: var(--background) !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
  }
  
  .navbar-menu .dropdown.open .dropdown-menu {
    max-height: 300px;
  }
  
  .navbar-menu .dropdown-menu a {
    padding-right: 2.5rem !important;
    font-size: 0.85rem;
  }
  
  .user-info {
    width: 100%;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 768px) {
  .navbar {
    padding: 0.75rem 1rem;
  }
  
  .navbar-brand {
    font-size: 1.1rem;
  }
  
  .container {
    padding: 0.75rem;
    margin: 0;
  }
  
  .card {
    padding: 1rem;
    margin-bottom: 1rem;
  }
  
  .card-header {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }
  
  .card-header .btn {
    width: 100%;
    justify-content: center;
  }
  
  .card-title {
    font-size: 1.1rem;
  }
  
  /* فرم‌ها */
  .form-row {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  .form-group {
    margin-bottom: 0.75rem;
  }
  
  .form-control,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="date"],
  input[type="number"],
  select,
  textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    font-size: 16px; /* جلوگیری از zoom مرورگر */
  }
  
  .form-label {
    font-size: 0.85rem;
  }
  
  /* جداول */
  table {
    font-size: 0.8rem;
    overflow-x: auto;
    display: block;
  }
  
  table thead {
    display: none;
  }
  
  table tbody {
    display: block;
  }
  
  table tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    background: var(--surface);
  }
  
  table tbody td {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border: none;
    border-bottom: 1px solid var(--border);
  }
  
  table tbody td:last-child {
    border-bottom: none;
  }
  
  table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    width: 40%;
    color: var(--text-muted);
  }
  
  /* دکمه‌ها */
  .btn {
    padding: 0.625rem 1rem;
    font-size: 0.85rem;
    min-height: 44px; /* برای آسان‌تر شدن لمس */
  }
  
  .btn-group {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .btn-sm {
    padding: 0.5rem 0.75rem;
    min-height: 40px;
  }
  
  /* مدال‌ها */
  .modal {
    width: 95% !important;
    max-width: 100% !important;
    max-height: 90vh;
    margin: auto;
  }
  
  .modal-body {
    max-height: calc(90vh - 120px);
    overflow-y: auto;
  }
  
  /* گرید‌ها */
  .programs-grid {
    grid-template-columns: 1fr;
  }
  
  .student-row {
    flex-direction: column;
  }
  
  .attendance-controls {
    flex-direction: column;
    width: 100%;
  }
  
  .status-buttons {
    display: flex;
    gap: 0.25rem;
  }
  
  .status-btn {
    flex: 1;
    padding: 0.5rem;
    font-size: 0.75rem;
  }
  
  .delay-control {
    width: 100%;
    justify-content: flex-end;
    gap: 0.25rem;
  }
  
  .delay-input {
    width: 50px;
    padding: 0.5rem;
  }
  
  .perf-num-input {
    width: 50px;
  }
  
  /* کارت‌های معیار */
  .criteria-cards {
    grid-template-columns: 1fr;
  }
  
  /* کاربر منو */
  .user-info {
    flex-direction: row;
    width: 100%;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--border);
  }
  
  .user-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
  }
  
  .user-details {
    display: flex;
    flex-direction: column;
    flex: 1;
  }
  
  .user-name {
    font-size: 0.85rem;
  }
  
  .user-role {
    font-size: 0.7rem;
  }
  
  .btn-logout {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
  }
  
  /* صفحه ورود */
  .login-card {
    padding: 1.5rem 1rem;
  }
  
  .login-header {
    margin-bottom: 1.5rem;
  }
  
  .login-logo {
    width: 60px;
    height: 60px;
    margin-bottom: 1rem;
  }
  
  .login-title {
    font-size: 1.2rem;
  }
  
  /* آمار صفحه اول */
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .stat-card {
    padding: 1rem;
  }
  
  .stat-number {
    font-size: 1.5rem;
  }
}

/* حل برای موبایل های کوچک */
@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }
  
  .navbar {
    padding-top: max(0.75rem, env(safe-area-inset-top));
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
}

@media (max-width: 480px) {
  .navbar {
    padding: 0.5rem;
    padding-top: max(0.5rem, env(safe-area-inset-top));
  }
  
  .navbar-brand {
    font-size: 0.95rem;
  }
  
  .container {
    padding: 0.5rem;
  }
  
  .card {
    padding: 0.75rem;
  }
  
  .card-title {
    font-size: 1rem;
  }
  
  /* فرم‌های کوچک‌تر */
  .form-control,
  input,
  select,
  textarea {
    padding: 0.5rem;
    font-size: 16px;
  }
  
  .btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    min-height: 40px;
  }
  
  /* جداول جدید شکل */
  table tbody tr {
    margin-bottom: 0.75rem;
  }
  
  table tbody td {
    padding: 0.4rem 0.5rem;
    font-size: 0.75rem;
  }
  
  /* آیکون‌ها کوچک‌تر */
  .check-yes,
  .check-no {
    font-size: 1rem;
  }
  
  /* dropdown را فراخوانی با کلیک کن */
  .navbar-menu .dropdown:hover .dropdown-menu {
    display: none;
  }
}
