/*
  Scoped stylesheet for the Students module.
  Every class and CSS custom property is prefixed with "student-" so this file is safe to
  include globally in Faradanesh without clashing with existing .btn/.card/.badge/--c-* etc.
  that other modules (like Books) may already define.
  Visually it reproduces the original students.html design (same colors/spacing/radius).
*/

.student-page {
  --student-bg: #f5f5f3;
  --student-surface: #ffffff;
  --student-surface-2: #fafaf8;
  --student-border: rgba(0,0,0,0.08);
  --student-border-strong: rgba(0,0,0,0.14);
  --student-text: #1a1a18;
  --student-text-2: #5a5a56;
  --student-text-3: #9a9994;
  --student-accent: #2563eb;
  --student-accent-bg: #eff6ff;
  --student-accent-text: #1d4ed8;
  --student-accent-border: #bfdbfe;
  --student-success: #16a34a;
  --student-success-bg: #f0fdf4;
  --student-success-text: #15803d;
  --student-success-border: #bbf7d0;
  --student-warning: #d97706;
  --student-warning-bg: #fffbeb;
  --student-warning-text: #b45309;
  --student-warning-border: #fde68a;
  --student-danger: #dc2626;
  --student-danger-bg: #fef2f2;
  --student-danger-text: #b91c1c;
  --student-danger-border: #fecaca;
  --student-purple: #7c3aed;
  --student-purple-bg: #f5f3ff;
  --student-radius-sm: 6px;
  --student-radius: 10px;
  --student-radius-lg: 14px;

  direction: rtl;
  font-family: 'Vazirmatn', system-ui, sans-serif;
  color: var(--student-text);
  font-size: 13px;
  line-height: 1.5;
}

/* dark theme: apply data-theme="dark" on any ancestor (e.g. <html> or .student-page itself) */
[data-theme="dark"] .student-page, .student-page[data-theme="dark"] {
  --student-bg: #15161a;
  --student-surface: #1c1d22;
  --student-surface-2: #202127;
  --student-border: rgba(255,255,255,0.08);
  --student-border-strong: rgba(255,255,255,0.14);
  --student-text: #f1f1ef;
  --student-text-2: #b3b3ad;
  --student-text-3: #76766f;
  --student-accent-bg: rgba(37,99,235,0.14);
  --student-success-bg: rgba(22,163,74,0.14);
  --student-warning-bg: rgba(217,119,6,0.14);
  --student-danger-bg: rgba(220,38,38,0.14);
}

.student-page * { box-sizing: border-box; }

/* ── Page header ── */
.student-page-hdr { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.student-page-title { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.student-page-desc { font-size: 12px; color: var(--student-text-2); margin-top: 3px; }

/* ── Stats ── */
.student-stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.student-stat-card { background: var(--student-surface); border: 1px solid var(--student-border); border-radius: var(--student-radius); padding: 16px; transition: border-color .15s ease; }
.student-stat-card:hover { border-color: var(--student-border-strong); }
.student-stat-icon { width: 30px; height: 30px; border-radius: var(--student-radius-sm); display: flex; align-items: center; justify-content: center; margin-bottom: 10px; font-size: 15px; }
.student-stat-icon.green  { background: var(--student-success-bg); color: var(--student-success-text); }
.student-stat-icon.amber  { background: var(--student-warning-bg); color: var(--student-warning-text); }
.student-stat-icon.blue   { background: var(--student-accent-bg);  color: var(--student-accent-text); }
.student-stat-icon.purple { background: var(--student-purple-bg);  color: var(--student-purple); }
.student-stat-val { font-size: 20px; font-weight: 600; }
.student-stat-label { font-size: 11px; color: var(--student-text-2); margin-top: 2px; }

/* ── Card / table ── */
.student-card { background: var(--student-surface); border: 1px solid var(--student-border); border-radius: var(--student-radius); overflow: hidden; }
.student-tbl-wrap { overflow-x: auto; }
table.student-tbl { width: 100%; border-collapse: collapse; }
table.student-tbl th {
  text-align: right; font-size: 11px; font-weight: 600; color: var(--student-text-2);
  padding: 10px 14px; border-bottom: 1px solid var(--student-border); background: var(--student-surface-2); white-space: nowrap;
}
table.student-tbl td { padding: 10px 14px; border-bottom: 1px solid var(--student-border); font-size: 12.5px; vertical-align: middle; }
table.student-tbl tr:last-child td { border-bottom: none; }
table.student-tbl tr:hover td { background: var(--student-bg); }

.student-mini-avatar {
  width: 28px; height: 28px; border-radius: 50%; color: #fff; font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.student-row-actions { display: flex; gap: 4px; white-space: nowrap; }
.student-row-act-btn {
  width: 28px; height: 28px; border: 1px solid var(--student-border); border-radius: var(--student-radius-sm);
  background: transparent; color: var(--student-text-2); cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; transition: all .15s ease;
}
.student-row-act-btn i { font-size: 14px; }
.student-row-act-btn:hover { background: var(--student-accent-bg); border-color: var(--student-accent-border); color: var(--student-accent); }
.student-row-act-btn.danger:hover { background: var(--student-danger-bg); border-color: var(--student-danger-border); color: var(--student-danger); }

/* ── Badges ── */
.student-badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 500;
  padding: 3px 8px; border-radius: 20px; border: 1px solid transparent; white-space: nowrap;
}
.student-badge i { font-size: 11px; }
.student-badge.b-success { background: var(--student-success-bg); color: var(--student-success-text); border-color: var(--student-success-border); }
.student-badge.b-warning { background: var(--student-warning-bg); color: var(--student-warning-text); border-color: var(--student-warning-border); }
.student-badge.b-danger  { background: var(--student-danger-bg);  color: var(--student-danger-text);  border-color: var(--student-danger-border); }
.student-badge.b-gray    { background: #f4f4f2; color: #5a5a56; border-color: #e0e0dc; }

/* ── Buttons ── */
.student-btn {
  display: inline-flex; align-items: center; gap: 6px; font-family: inherit; font-size: 12.5px; font-weight: 500;
  padding: 0 13px; height: 34px; border-radius: var(--student-radius-sm); border: 1px solid var(--student-border-strong);
  background: var(--student-surface); color: var(--student-text); cursor: pointer; transition: all .15s ease;
}
.student-btn:hover { border-color: var(--student-text-3); }
.student-btn i { font-size: 14px; }
.student-btn-primary { background: var(--student-accent); border-color: var(--student-accent); color: #fff; }
.student-btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
.student-btn-danger { background: var(--student-danger); border-color: var(--student-danger); color: #fff; }
.student-btn-danger:hover { background: var(--student-danger-text); border-color: var(--student-danger-text); }

/* ── Forms ── */
.student-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.student-field { display: flex; flex-direction: column; gap: 5px; }
.student-field label { font-size: 11px; font-weight: 600; color: var(--student-text-2); letter-spacing: .02em; }
.student-field input, .student-field select, .student-field textarea,
.student-page > .student-card input[type="text"], .student-page select {
  height: 36px; border: 1px solid var(--student-border-strong); border-radius: var(--student-radius-sm);
  padding: 0 11px; font-size: 13px; background: var(--student-surface); color: var(--student-text);
  font-family: inherit; outline: none; transition: border-color .15s ease;
}
.student-field input:focus, .student-field select:focus, .student-field textarea:focus { border-color: var(--student-accent); }
.student-field input::placeholder { color: var(--student-text-3); }
.student-form-actions { display: flex; align-items: center; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--student-border); }

/* ── Modal ── */
.student-modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 10000;
  align-items: center; justify-content: center; padding: 20px;
}
.student-modal-backdrop.open { display: flex; }
.student-modal-box { background: var(--student-surface); border-radius: var(--student-radius-lg); width: 100%; max-height: 90vh; overflow-y: auto; }
.student-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--student-border); }
.student-modal-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.student-modal-close { width: 28px; height: 28px; border: none; background: var(--student-bg); border-radius: var(--student-radius-sm); cursor: pointer; color: var(--student-text-2); display: flex; align-items: center; justify-content: center; }
.student-modal-body { padding: 18px; }
.student-modal-actions { display: flex; gap: 8px; margin-top: 16px; }

/* اسپینر لودینگ برای StudentEditModal (پاپ‌آپ ویرایش سریع دانش‌آموز) */
@keyframes student-spin-anim { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.student-spin { display: inline-block; animation: student-spin-anim 0.8s linear infinite; }

.student-view-list { display: flex; flex-direction: column; }
.student-view-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--student-border); font-size: 12.5px; }
.student-view-row:last-child { border-bottom: none; }
.student-view-row .vk { color: var(--student-text-2); }
.student-view-row .vv { font-weight: 500; }

.student-confirm-icon { width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; }
.student-confirm-icon i { font-size: 26px; }
.student-confirm-icon.danger { background: var(--student-danger-bg); color: var(--student-danger); }
.student-confirm-icon.accent { background: var(--student-accent-bg); color: var(--student-accent); }
.student-confirm-text { font-size: 13px; color: var(--student-text-2); }

/* ── Toast ── */
.student-toast-wrap { position: fixed; bottom: 20px; left: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.student-toast {
  background: var(--student-text); color: var(--student-surface); font-size: 12.5px; padding: 10px 14px;
  border-radius: var(--student-radius-sm); display: flex; align-items: center; gap: 8px; cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,.18);
}
.student-toast i { font-size: 16px; }

/* ── Blazor validation ── */
.student-page .validation-message { color: var(--student-danger-text); font-size: 11px; margin-top: 2px; display: block; }
.student-page .validation-summary { background: var(--student-danger-bg); border: 1px solid var(--student-danger-border); color: var(--student-danger-text); border-radius: var(--student-radius-sm); padding: 10px 12px; font-size: 12px; margin-bottom: 14px; }
.student-page .validation-summary ul { margin: 0; padding-inline-start: 18px; }

/* ── Responsive ── */
@media (max-width: 720px) {
  .student-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .student-form-grid { grid-template-columns: 1fr; }

  .student-tbl-wrap.responsive table.student-tbl thead { display: none; }
  .student-tbl-wrap.responsive table.student-tbl,
  .student-tbl-wrap.responsive table.student-tbl tbody,
  .student-tbl-wrap.responsive table.student-tbl tr,
  .student-tbl-wrap.responsive table.student-tbl td { display: block; width: 100%; }
  .student-tbl-wrap.responsive table.student-tbl tr { border-bottom: 1px solid var(--student-border); padding: 10px 14px; }
  .student-tbl-wrap.responsive table.student-tbl td {
    display: flex; justify-content: space-between; align-items: center; border-bottom: none; padding: 6px 0;
  }
  .student-tbl-wrap.responsive table.student-tbl td::before { content: attr(data-label); font-size: 11px; color: var(--student-text-3); }
}

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