/* Shared refinements: consistent spacing, calm surfaces, responsive layout on every screen size */
:root {
  --fb-ink: #0f1f3d;
  --fb-muted: #5b6b8a;
  --fb-line: #e4eaf5;
  --fb-surface: #ffffff;
  --fb-brand: #1d4ed8;
  --fb-navy: #0a2466;
  --fb-radius: 16px;
  --fb-shadow: 0 1px 2px rgba(15, 31, 61, .04), 0 10px 26px rgba(15, 31, 61, .05);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
img, svg, video { max-width: 100%; height: auto; }

.section-card, .card {
  background: var(--fb-surface);
  border: 1px solid var(--fb-line);
  border-radius: var(--fb-radius);
  box-shadow: var(--fb-shadow);
}
.page-title { color: var(--fb-navy); font-weight: 800; line-height: 1.5; }
.page-sub { color: var(--fb-muted); line-height: 1.9; }

.btn { border-radius: 12px; font-weight: 700; line-height: 1.5; transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid #93c5fd; outline-offset: 2px; }

table { border-collapse: separate; border-spacing: 0; width: 100%; }
th { font-size: 12.5px; font-weight: 700; color: var(--fb-muted); background: #f7f9fd; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--fb-line); text-align: start; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.table-wrap, [style*="overflow-x:auto"], [style*="overflow-x: auto"] { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---- instructor profile page ---- */
.page-profile .wrap { max-width: 1040px; margin: 0 auto; }
.page-profile .section-card { padding: 22px; }
.page-profile .form-group { margin-bottom: 14px; }
.page-profile .form-label { font-size: 13px; font-weight: 700; color: var(--fb-navy); margin-bottom: 6px; display: block; }
.page-profile .form-input, .page-profile .form-select, .page-profile textarea { border-radius: 12px; }
.page-profile .progress { height: 8px; border-radius: 99px; background: #e6edfb; overflow: hidden; }
.page-profile .progress > * { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #1d4ed8, #38bdf8); }
.page-profile .form-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }

/* ---- phones and small tablets ---- */
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 12px; }
  .topbar .btn { width: auto; }
  .page-profile .form-grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  body { font-size: 14px; }
  .section-card, .card { border-radius: 14px; }
  .page-profile .section-card { padding: 16px; }
  th, td { padding: 10px 10px; font-size: 13px; }
  .btn { padding: 10px 14px; }
  .page-title { font-size: 20px; }
}

/* dashboard breakdown line */
.stat-sub { font-size: 12px; color: var(--fb-muted); margin-top: 8px; line-height: 1.8; }

/* ---- instructors table: keep each row on one line at every zoom level ---- */
.page-instructors .table-wrap, .page-instructors [style*="overflow-x:auto"] { overflow-x: auto; }
.page-instructors table { min-width: 980px; table-layout: auto; }
.page-instructors th, .page-instructors td { white-space: nowrap; vertical-align: middle; }
.page-instructors td:first-child { white-space: normal; min-width: 180px; }
.page-instructors td .badge { white-space: nowrap; display: inline-block; line-height: 1.5; padding: 4px 10px; }
.page-instructors td .btn { white-space: nowrap; margin: 2px 4px 2px 0; }
.page-instructors td:last-child { min-width: 170px; }

/* ---- student ID card page: plain, solid, no decoration ---- */
body.page-card { background: #f3f5f9 !important; color: #0f1f3d; }
.page-card .no-print { background: #ffffff !important; color: #0f1f3d; border: 1px solid #dbe3f0 !important; box-shadow: none !important; backdrop-filter: none !important; -webkit-backdrop-filter: none !important; border-radius: 12px !important; }
.page-card .no-print * { color: inherit; }
.page-card .size-note { color: #5b6b8a !important; }
.page-card .guide-grid > div, .page-card .guide-grid > section { background: #ffffff !important; box-shadow: none !important; border: 1px solid #dbe3f0 !important; border-radius: 10px !important; }
.page-card .btn { color: #ffffff !important; }
.page-card .btn-outline { color: #0a2466 !important; }
.page-card .btn { background: #0a2466; color: #ffffff; border: 1px solid #0a2466; border-radius: 8px; box-shadow: none; font-weight: 600; transform: none !important; }
.page-card .btn:hover { background: #0c2d7a; }
.page-card .btn i { display: none; }
.page-card .btn-outline { background: #ffffff; color: #0a2466; border: 1px solid #c9d4ea; }
.page-card .btn-outline:hover { background: #f4f7fc; }
.page-card .title { font-size: 22px; font-weight: 800; color: #0a2466; }

/* ---- HR page ---- */
.hr-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.hr-summary .hr-card { background: #fff; border: 1px solid var(--fb-line); border-radius: 14px; padding: 14px 16px; }
.hr-summary .hr-num { font-size: 22px; font-weight: 800; color: var(--fb-navy); }
.hr-summary .hr-label { font-size: 12.5px; color: var(--fb-muted); }
.hr-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; align-items: end; margin-bottom: 14px; }
.hr-form .btn { justify-self: start; }
.hr-tag { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.hr-tag.ok { background: #e7f7ef; color: #0f7a4a; }
.hr-tag.expiring { background: #fff7e6; color: #8a5a00; }
.hr-tag.expired, .hr-tag.no-contract { background: #fdecec; color: #b42318; }


/* ---- birthdays and petals ---- */
.fb-petal-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 9999; }
.fb-petal { position: absolute; top: -24px; width: 12px; height: 16px; border-radius: 60% 0 60% 0; opacity: .92;
  animation-name: fbPetalFall; animation-timing-function: linear; animation-fill-mode: forwards; }
@keyframes fbPetalFall {
  0% { transform: translate3d(0, 0, 0) rotate(0deg); }
  50% { transform: translate3d(-30px, 50vh, 0) rotate(200deg); }
  100% { transform: translate3d(20px, 110vh, 0) rotate(540deg); }
}
.bd-card { background: #ffffff; border: 1px solid var(--fb-line); border-top: 4px solid #b8912f; border-radius: 18px;
  padding: 26px 22px; margin-bottom: 16px; text-align: center; box-shadow: var(--fb-shadow); }
.bd-kicker { color: #b8912f; font-size: 12px; letter-spacing: 3px; font-weight: 700; }
.bd-title { font-size: 28px; font-weight: 800; color: var(--fb-navy); margin: 8px 0 4px; line-height: 1.5; }
.bd-age { display: inline-flex; flex-direction: column; align-items: center; padding: 12px 32px; background: #f4f6fb; border-radius: 16px; margin: 10px 0; }
.bd-age-num { font-size: 46px; font-weight: 800; color: var(--fb-navy); line-height: 1.1; }
.bd-age-label { font-size: 14px; color: var(--fb-muted); }
.bd-text { max-width: 640px; margin: 10px auto 0; color: var(--fb-ink); line-height: 2.1; }
.bd-list .bd-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--fb-line); flex-wrap: wrap; }
.bd-list .bd-row:last-child { border-bottom: 0; }
.bd-name { font-weight: 800; color: var(--fb-navy); }
.bd-sub { font-size: 13px; color: var(--fb-muted); }
@media (prefers-reduced-motion: reduce) { .fb-petal { display: none; } }
@media (max-width: 640px) { .bd-title { font-size: 22px; } .bd-age-num { font-size: 36px; } }

/* ---- admin: the instructor's tazkira and signature (two boxes) ---- */
.id-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 16px 0; }
.id-box { background: #fff; border: 1px solid var(--fb-line); border-radius: 16px; padding: 18px; box-shadow: var(--fb-shadow); display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.id-box-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.id-box-title { font-weight: 800; color: var(--fb-navy); font-size: 15px; }
.id-box-state { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: #eef3fb; color: var(--fb-navy); white-space: nowrap; }
.id-box-state.is-empty { background: #fdecec; color: #b42318; }
.id-box-state.is-ok { background: #e7f7ef; color: #0f7a4a; }
.id-sign-frame { height: 130px; display: flex; align-items: center; justify-content: center; background: #fbfcfe; border: 1px dashed #c9d4ea; border-radius: 12px; overflow: hidden; }
.id-sign-frame img { max-height: 110px; max-width: 90%; object-fit: contain; }
.id-empty { color: var(--fb-muted); font-size: 13px; text-align: center; padding: 30px 0; }
.id-tazkira-body { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; min-height: 130px; background: #fbfcfe; border: 1px dashed #c9d4ea; border-radius: 12px; padding: 16px; }
.id-tazkira-body .id-tazkira-text { color: var(--fb-ink); font-size: 13px; line-height: 1.9; }
@media (max-width: 720px) { .id-pair { grid-template-columns: 1fr; } }

/* ---- admin: the student's tazkira box (same look as the instructor's boxes) ---- */
.st-upload { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.st-upload .st-file { flex: 1 1 220px; min-width: 0; font-size: 13px; color: var(--fb-ink); }
.st-upload .st-file::file-selector-button { font-family: inherit; font-weight: 700; color: var(--fb-navy); background: #eef3fb; border: 1px solid #c9d4ea; border-radius: 10px; padding: 8px 12px; margin-inline-end: 10px; cursor: pointer; }
.st-note { font-size: 13px; color: var(--fb-muted); min-height: 18px; }
#st-tazkira { margin: 16px 0; }
@media (max-width: 720px) { .st-upload .st-file { flex-basis: 100%; } }

/* ---- student conduct policy (shown after sign-in) ---- */
body.pg-locked { overflow: hidden; }
.pg-overlay { position: fixed; inset: 0; background: rgba(10, 20, 40, .62); z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 16px; }
.pg-card { background: #fff; border-radius: 18px; width: 100%; max-width: 760px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); overflow: hidden; }
.pg-head { padding: 20px 22px 12px; border-bottom: 1px solid #e4eaf5; }
.pg-title { font-weight: 800; font-size: 16px; color: var(--fb-navy); }
.pg-sub { font-size: 12px; color: var(--fb-muted); margin-top: 2px; }
.pg-intro { font-size: 12.5px; line-height: 1.9; margin-top: 10px; color: var(--fb-ink); }
.pg-hint { font-size: 12px; color: #b45309; margin-top: 10px; background: #fff7ed; border-radius: 10px; padding: 8px 10px; }
.pg-doc { padding: 14px 22px; overflow-y: auto; flex: 1 1 auto; min-height: 180px; max-height: 46vh; font-size: 12.5px; line-height: 1.9; color: var(--fb-ink); }
.pg-sec-title { font-weight: 800; color: var(--fb-navy); margin: 14px 0 4px; }
.pg-item { margin: 2px 0; }
.pg-decl { margin-top: 16px; padding-top: 12px; border-top: 1px dashed #c9d4ea; }
.pg-step { padding: 14px 22px; border-top: 1px solid #e4eaf5; background: #fbfcfe; }
.pg-hidden { display: none !important; }
.pg-check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.8; cursor: pointer; }
.pg-check input { margin-top: 5px; width: 18px; height: 18px; flex: 0 0 auto; }
.pg-sign-title { font-weight: 800; color: var(--fb-navy); margin-bottom: 8px; }
.pg-canvas { width: 100%; max-width: 520px; height: 160px; background: #fff; border: 1px dashed #b6c4dd; border-radius: 12px; touch-action: none; display: block; }
.pg-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.pg-note { font-size: 13px; color: #b42318; min-height: 18px; margin-top: 8px; }
@media (max-width: 720px) { .pg-overlay { padding: 0; } .pg-card { max-height: 100vh; height: 100vh; border-radius: 0; max-width: none; } .pg-doc { max-height: none; } }

/* ---- in-system help ---- */
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; margin-top: 14px; }
.help-card { background: #fff; border: 1px solid #e4eaf5; border-radius: 16px; padding: 16px 18px; box-shadow: 0 6px 22px rgba(11,42,91,.06); }
.help-card-title { font-weight: 800; color: #0b2a5b; margin-bottom: 8px; font-size: 15px; }
.help-list { margin: 0; padding-inline-start: 18px; line-height: 1.9; color: #1f2a44; font-size: 14px; }

/* ---- HR: photos, contract details and the instructor's contract panel ---- */
.hr-person{display:flex;align-items:center;gap:10px;}
.hr-avatar{width:36px;height:36px;border-radius:50%;object-fit:cover;flex:0 0 36px;border:1px solid #d7deea;background:#f1f4fa;}
.hr-avatar-blank{display:inline-flex;align-items:center;justify-content:center;color:#7a8594;}
.hr-details-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px;}
.hr-details-grid > div > .field-note{display:block;margin-bottom:4px;}
.hr-ins-box{margin-top:12px;}
.hr-print-row{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 0;border-bottom:1px solid #e7ecf4;flex-wrap:wrap;}
.notice{background:#fff8e6;border:1px solid #f2d68a;color:#6b4d00;border-radius:10px;padding:10px 12px;margin-top:10px;line-height:1.9;}

/* Text areas on every page: they can be made taller, never wider than their box, so they do not spill out of the layout */
textarea { resize: vertical; max-width: 100%; min-width: 0; box-sizing: border-box; }

/* Mixed Persian and English text: each paragraph, label, cell and text box takes the direction of its own text.
   English lines start at the left, Persian lines at the right; the layout around them does not change. */
p, li, summary, .field-note, .notice {
  unicode-bidi: plaintext;
}

/* Menu groups: a quiet heading above each group of links */
.sidebar .nav-group { margin: 16px 16px 4px; font-size: 12px; font-weight: 700; color: #9fb6e6; letter-spacing: 0; }
.sidebar .nav-group:first-of-type { margin-top: 4px; }

/* Staff directory */
.sd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.sd-card { background: #fff; border: 1px solid #e3e9f3; border-radius: 12px; padding: 14px; display: flex; gap: 12px; cursor: pointer; }
.sd-card:hover { border-color: #9db9e8; }
.sd-photo { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; flex: 0 0 56px; background: #eef2fa; display: flex; align-items: center; justify-content: center; color: #4a5a78; font-weight: 700; }
.sd-modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.sd-box { background: #fff; border-radius: 14px; max-width: 540px; width: calc(100% - 32px); padding: 20px; max-height: 90vh; overflow: auto; }

/* ===== phone layer (max 640px): every page stacks, nothing runs past the screen ===== */
img, video, canvas, svg { max-width: 100%; height: auto; }
input, select, textarea, button { max-width: 100%; box-sizing: border-box; }
/* table cells and labels wrap at spaces; a word is never split across lines */
.v-value, .field-value, .tag, .kv span { overflow-wrap: break-word; }
td, th { overflow-wrap: normal; word-break: normal; }
.table-wrap, .tbl-wrap, .responsive-table, .pol-tw { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 640px) {
  .fields-2, .profile, .kv, .grid, .stats, .hero, .docs, .id-pair,
  .form-grid-2, .form-row2, .form-grid, .detail-grid, .info-grid,
  #p-extra, .photo-row { grid-template-columns: 1fr !important; }
  .photo-box img, .photo-box { width: 120px !important; height: 120px !important; }
  .hero { overflow: hidden; padding: 16px !important; }
  .hero::after { display: none; }
  .section-card, .card, .panel, .box { min-width: 0; max-width: 100%; padding: 14px !important; }
  .kv { gap: 8px; }
  .kv > * { min-width: 0; }
  #classes-list table.t, table.t { min-width: 0 !important; }
  table { display: block; max-width: 100%; overflow-x: auto; }
  .tag { white-space: normal; }
  .btn-row, .actions, .toolbar { flex-wrap: wrap; }
  .btn-row > *, .actions > *, .toolbar > * { max-width: 100%; }
}
@media (max-width: 420px) {
  .section-card, .card, .panel { padding: 12px !important; }
}

/* ===== phone tables: each row becomes a card, with the column name beside each value ===== */
@media (max-width: 640px) {
  table { display: block !important; width: 100% !important; min-width: 0 !important; border: 0 !important; }
  table thead { display: none !important; }
  table tbody, table tr, table td { display: block !important; width: 100% !important; }
  table .mb-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-start; }
  table tbody tr { background: #fff; border: 1px solid #e1e5ec; border-radius: 12px; padding: 6px 12px; margin: 0 0 10px; }
  table td { display: flex !important; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 0; border: 0 !important; text-align: start; white-space: normal !important; overflow-wrap: anywhere; word-break: normal; }
  table td + td { border-top: 1px solid #f0f3f8 !important; }
  table td::before { content: attr(data-label); flex: 0 0 40%; font-size: 12px; font-weight: 600; color: #6b7a94; text-align: start; }
  table td:empty { display: none; }
  table td:first-child { font-weight: 700; }
}

/* ===== the student list of a class: readable on a laptop, an iPad and a phone ===== */
.student-table td, .student-table th { vertical-align: middle; }
.student-table td:nth-child(2) { min-width: 200px; }
.student-table td:nth-child(2) > * { overflow-wrap: break-word; }
.student-table .btn { white-space: nowrap; }

/* iPad and small laptops: the table keeps its width, scrolls sideways, and the name stays visible */
@media (min-width: 641px) and (max-width: 1100px) {
  .student-table { min-width: 880px; }
  .student-table th:nth-child(2), .student-table td:nth-child(2) {
    position: sticky; right: 0; background: #fff; z-index: 1; box-shadow: -6px 0 8px -8px rgba(11, 37, 69, 0.25);
  }
  .student-table td:last-child { min-width: 260px; }
  .student-table td:last-child > div, .student-table td:last-child { flex-wrap: wrap; }
}

/* phones: each student is a card; the name comes first */
@media (max-width: 640px) {
  .student-table tbody tr { padding: 10px 12px; }
  .student-table td:nth-child(2) { display: block !important; padding-bottom: 8px; }
  .student-table td:nth-child(2)::before { content: none; display: none; }
  .student-table td:nth-child(2) > * { display: inline-block; }
}

/* ----- the student list, final: the status on one line, the avatar sized, the actions wrap inside the card ----- */
.student-table td:nth-child(3) span, .student-table td:nth-child(3) .pill, .student-table td:nth-child(3) .tag { white-space: nowrap; }
@media (max-width: 640px) {
  .student-table td:nth-child(2) { display: flex !important; align-items: center; gap: 10px; flex-wrap: wrap; }
  .student-table td:nth-child(2) img, .student-table td:nth-child(2) [class*="avatar"] { flex: 0 0 44px; width: 44px !important; height: 44px !important; max-width: 44px; border-radius: 50%; object-fit: cover; }
  .student-table td:last-child { display: flex !important; flex-wrap: wrap; justify-content: flex-start; gap: 6px; }
  .student-table td:last-child .btn { white-space: normal; }
}

/* iPad: the table fits the screen; the action buttons wrap inside their column */
@media (min-width: 641px) and (max-width: 1100px) {
  .student-table { min-width: 860px !important; width: auto; }
  .student-table td:last-child { min-width: 170px !important; }
  .student-table td:last-child > * { margin: 2px; }
  .student-table td:last-child { white-space: normal; }
}

/* iPad: tighter cells and smaller buttons, so the whole row fits without sideways scrolling */
@media (min-width: 641px) and (max-width: 1100px) {
  .student-table th, .student-table td { padding: 8px 6px !important; font-size: 12px; }
  .student-table td:nth-child(2) { min-width: 150px !important; }
  .student-table .btn { padding: 5px 7px !important; font-size: 11px !important; }
}

/* every width: the actions of a student wrap onto a second line instead of running off the table */
.student-table td:last-child { white-space: normal !important; min-width: 0; }
.student-table td:last-child .btn { display: inline-flex; align-items: center; margin: 2px; }

/* ===== dashboard: quick-action cards, responsive on phone, tablet and laptop ===== */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin: 4px 0 16px; }
.quick-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: #fff; border: 1px solid #e3e9f2; border-radius: 14px;
  text-decoration: none; color: #0b2545; box-shadow: 0 1px 2px rgba(11,37,69,.04); transition: transform .15s, box-shadow .15s, border-color .15s; min-width: 0; }
.quick-card:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(11,37,69,.10); border-color: #b8c7da; }
.quick-icon { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: #eaf2fb; color: #1d4f8a; font-size: 17px; }
.quick-text { display: flex; flex-direction: column; min-width: 0; }
.quick-title { font-weight: 700; font-size: 14px; line-height: 1.4; overflow-wrap: break-word; }
.quick-count { font-size: 12px; color: #5b6b7f; margin-top: 2px; }
@media (max-width: 640px) {
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .quick-card { padding: 12px; flex-direction: column; align-items: flex-start; gap: 8px; }
  .quick-title { font-size: 13px; }
}

