/* DevaSys Training – brand layer on top of Bootstrap 5 (RTL).
   Colours come from the Avia DevaSys logo: navy, ocean blue, teal, leaf green. */
:root {
  --devasys-navy: #0a2233;
  --devasys-blue: #1763b0;
  --devasys-teal: #13858c;
  --devasys-leaf: #4f9a34;
  --devasys-bg: #f3f7f9;

  --bs-primary: var(--devasys-blue);
  --bs-primary-rgb: 23, 99, 176;
  --bs-body-bg: var(--devasys-bg);
  --bs-body-color: var(--devasys-navy);
  --bs-body-font-family: "Assistant", "Segoe UI", system-ui, sans-serif;
  --bs-link-color: var(--devasys-blue);
}

body { min-height: 100vh; }
/* elements with the hidden attribute stay hidden even when they also have a Bootstrap display
   class such as d-flex (otherwise d-flex wins and e.g. an empty banner shows up) */
[hidden] { display: none !important; }

.navbar-devasys { background: var(--devasys-navy); }
.navbar-devasys .navbar-brand { font-weight: 700; letter-spacing: 0.01em; }
/* menu: the current page is a filled bubble; in the phone menu every item is a big, clear row */
.navbar-devasys .nav-link { border-radius: 999px; padding: 0.4rem 0.9rem; color: rgba(255, 255, 255, 0.85); }
.navbar-devasys .nav-link:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.navbar-devasys .nav-link.active { color: #0a2233; background: #7cc4ec; font-weight: 700; }
@media (max-width: 767.98px) {
  .navbar-devasys .navbar-collapse { padding: 0.5rem 0 0.75rem; }
  .navbar-devasys .navbar-nav { gap: 0.35rem; }
  .navbar-devasys .nav-link { font-size: 1.1rem; padding: 0.65rem 1rem; border-radius: 12px; background: rgba(255, 255, 255, 0.06); }
  .navbar-devasys .nav-link.active { background: #7cc4ec; }
  .navbar-devasys #logout { margin-top: 0.75rem; }
}
.navbar-devasys .nav-link.disabled { color: rgba(255, 255, 255, 0.4); }

.btn-primary {
  --bs-btn-bg: var(--devasys-blue);
  --bs-btn-border-color: var(--devasys-blue);
  --bs-btn-hover-bg: #12528f;
  --bs-btn-hover-border-color: #12528f;
  --bs-btn-active-bg: #0f4478;
}

.page-title { font-weight: 700; }
.accent-rule { height: 3px; width: 72px; border-radius: 3px; background: linear-gradient(270deg, var(--devasys-blue), var(--devasys-teal), var(--devasys-leaf)); }

.card-surface { background: #fff; border-radius: 12px; box-shadow: 0 1px 3px rgba(10, 34, 51, 0.08); }

.table td, .table th { white-space: nowrap; vertical-align: middle; }
.table .num { font-variant-numeric: tabular-nums; }
tr.inactive td { color: #8a9aa6; }
.phone { direction: ltr; unicode-bidi: embed; }

.summary .stat { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.summary .label { color: #4a6274; font-size: 0.9rem; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); }

.stat-badge { min-height: 2.4rem; display: flex; align-items: center; }

/* ---- monthly calendar ---- */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-head div { text-align: center; font-weight: 600; color: #4a6274; font-size: 0.85rem; padding-bottom: 4px; }
.cal-cell {
  min-height: 92px; min-width: 0; padding: 4px 5px; border: 1px solid #dfe7ed; border-radius: 8px;
  background: #fff; text-align: start; display: flex; flex-direction: column; gap: 2px; font: inherit; color: inherit;
}
.cal-cell:hover:not(:disabled) { border-color: var(--devasys-blue); }
.cal-cell.empty { border: none; background: none; }
.cal-cell.past { background: #f8fafb; }
.cal-cell.today { border: 2px solid var(--devasys-teal); }
.cal-cell.selected { box-shadow: 0 0 0 3px rgba(23, 99, 176, 0.25); }
.cal-cell.sat { background: repeating-linear-gradient(-45deg, #f1f4f6, #f1f4f6 6px, #e9eef2 6px, #e9eef2 12px); color: #8a9aa6; cursor: default; }
.cal-num { font-weight: 700; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.cal-rest { font-size: 0.75rem; margin-top: auto; }
.cal-item {
  font-size: 0.72rem; line-height: 1.25; padding: 1px 4px; border-radius: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums;
}
.cal-item.scheduled { background: #e3eef7; color: #0f4478; }
.cal-item.open { background: var(--devasys-blue); color: #fff; }
.cal-item.done { background: #e6f2e1; color: #2c5e1d; }
.cal-item.self { background: #fff; border: 1px dashed #9fb3c1; color: #4a6274; }
.cal-more { font-size: 0.7rem; color: #4a6274; }
.cal-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: middle; }
.cal-dot.scheduled { background: #e3eef7; border: 1px solid #b9cfe3; }
.cal-dot.open { background: var(--devasys-blue); }
.cal-dot.done { background: #e6f2e1; border: 1px solid #bcd8b1; }
.cal-dot.self { border: 1px dashed #9fb3c1; }
@media (max-width: 576px) {
  .cal-cell { min-height: 64px; padding: 3px; }
  .cal-item { font-size: 0.62rem; padding: 0 2px; }
  .cal-item .t { display: none; } /* phones: first name only, the time is in the day list */
  .cal-item .pm { display: none; } /* phones: no emoji, it hid the name; unpaid gets a red stripe */
  /* red bar on the left edge, with room so it never touches the name */
  .cal-item.unpaid { border-left: 4px solid #dc3545; padding-left: 4px; border-radius: 4px 2px 2px 4px; }
}

/* workout page: an open session stands out */
.workout-state.is-open { border: 2px solid var(--devasys-blue); background: #eef5fc; }

/* ---- health declaration: signing page ---- */
.sign-questions > li, .sign-sub > li { margin-bottom: 0.6rem; }
.sign-q { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.sign-q > span { min-width: 0; }
.sign-yesno { flex-shrink: 0; }
.sign-yesno .btn { min-width: 3.2rem; }
.sign-pad-wrap { position: relative; }
.sign-pad {
  display: block; width: 100%; height: 170px; background: #fff; border: 1.5px dashed #9fb3c1; border-radius: 10px;
  touch-action: none; /* finger draws instead of scrolling */
}
.sign-clear { position: absolute; top: 6px; left: 6px; }

/* ---- health declaration: the document (screen and print) ---- */
.decl-doc { background: #fff; color: #000; padding: 28px 32px; border-radius: 12px; box-shadow: 0 1px 3px rgba(10, 34, 51, 0.08); line-height: 1.55; font-size: 0.95rem; }
.decl-doc h1 { font-size: 1.35rem; font-weight: 700; text-align: center; margin-bottom: 1rem; }
.decl-doc h2 { font-size: 1.1rem; font-weight: 700; margin-top: 1.2rem; }
.decl-doc h3 { font-size: 1rem; font-weight: 700; }
.decl-center { text-align: center; }
.decl-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.3rem 1.5rem; margin-bottom: 0.5rem; }
.decl-label { font-weight: 700; }
.decl-small { font-size: 0.85rem; }
.decl-q { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.decl-q-head { font-weight: 600; }
.decl-sub { list-style-type: hebrew; }
.decl-answer { flex-shrink: 0; min-width: 2.6rem; text-align: center; border: 1px solid #999; border-radius: 4px; padding: 0 0.4rem; font-weight: 700; }
.decl-answer.yes { border-color: #b02a37; color: #b02a37; }
.decl-sign-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 2rem; margin-top: 0.6rem; }
.decl-signature { height: 70px; max-width: 260px; border-bottom: 1px solid #000; }
.decl-line { display: inline-block; width: 200px; border-bottom: 1px solid #000; height: 1.4em; }
.decl-alert { border: 2px solid #b02a37; border-radius: 8px; padding: 0.7rem 1rem; margin-top: 1rem; font-weight: 600; }
.decl-footnotes { font-size: 0.82rem; margin-top: 1rem; }
.decl-footnotes p { margin-bottom: 0.4rem; }
.decl-minor { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid #ccc; }
.decl-audit { margin-top: 1.5rem; padding-top: 0.6rem; border-top: 1px solid #ccc; font-size: 0.75rem; color: #444; }
@media (max-width: 576px) {
  .decl-doc { padding: 18px 14px; }
  .decl-fields { grid-template-columns: minmax(0, 1fr); }
}

@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff !important; }
  .no-print, nav, .navbar { display: none !important; }
  main.container { max-width: none !important; padding: 0 !important; }
  .decl-doc { box-shadow: none; padding: 0; border-radius: 0; font-size: 10.5pt; }
  .decl-minor { break-before: page; border-top: none; }
  .decl-q, .decl-sign-row { break-inside: avoid; }
}

/* ---- phones: compact summary numbers and trainee cards ---- */
.kpi { padding: 1rem; }
.min-w-0 { min-width: 0; }
.trainee-card {
  display: block; padding: 0.7rem 0.4rem; border-bottom: 1px solid #dfe7ed; color: inherit; text-decoration: none;
}
.trainee-card:last-child { border-bottom: none; }
.trainee-card:active { background: #f3f7f9; }
.trainee-card.inactive { color: #8a9aa6; }
@media (max-width: 576px) {
  .summary .kpi { padding: 0.5rem 0.4rem; text-align: center; }
  .summary .stat { font-size: 1.25rem; line-height: 1.2; }
  .summary .label { font-size: 0.72rem; line-height: 1.2; }
  /* trainee file: the four summary cards a bit tighter too */
  .summary .card-surface.p-3 { padding: 0.75rem !important; }
  .summary .stat.fs-5 { font-size: 1rem !important; }
}
.cal-dot.unpaid-key { width: 14px; background: #e3eef7; border-left: 4px solid #dc3545; }

/* ---- weekly calendar ---- */
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.week-day { padding: 0.6rem; min-width: 0; display: flex; flex-direction: column; gap: 6px; min-height: 180px; }
.week-day.today { box-shadow: 0 0 0 2px var(--devasys-teal); }
.week-day.sat { background: repeating-linear-gradient(-45deg, #f1f4f6, #f1f4f6 6px, #e9eef2 6px, #e9eef2 12px); }
.week-day-head { font-size: 0.95rem; font-weight: 700; display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin: 0 0 2px; }
.week-item {
  display: flex; flex-direction: column; gap: 1px; padding: 6px 8px; border-radius: 8px;
  text-decoration: none; color: inherit; font-size: 0.85rem; line-height: 1.3;
}
.week-item .week-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.week-item .badge { align-self: flex-start; font-size: 0.68rem; }
.week-item.scheduled { background: #e3eef7; }
.week-item.open { background: var(--devasys-blue); color: #fff; }
.week-item.done { background: #e6f2e1; }
.week-item.self { background: #fff; border: 1px dashed #9fb3c1; }
.week-item:hover { filter: brightness(0.97); }
/* below 992px the 7 columns get too narrow: one day per row */
@media (max-width: 991px) {
  .week-grid { grid-template-columns: minmax(0, 1fr); }
  .week-day { min-height: 0; }
  .week-item { flex-direction: row; align-items: center; gap: 0.6rem; font-size: 0.95rem; }
  .week-item .badge { align-self: center; margin-inline-start: auto; }
}

/* ---- workout plan (free text) ---- */
.plan-text { font-size: 1rem; line-height: 1.6; min-height: 14rem; white-space: pre-wrap; overflow: hidden; resize: none; }
/* each line takes its own direction, as in WhatsApp: "×3" stays "×3" and not "3×" */
.plan-text, .plan-preview { unicode-bidi: plaintext; text-align: right; }
.plan-panel { border: 1px solid #dfe7ed; border-radius: 10px; padding: 0.75rem; background: #f8fafb; }
.plan-preview { white-space: pre-wrap; font-family: inherit; font-size: 0.85rem; max-height: 12rem; overflow: auto;
  background: #fff; border: 1px solid #dfe7ed; border-radius: 8px; padding: 0.5rem 0.75rem; margin-bottom: 0.5rem; }
.to-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0; border-bottom: 1px solid #e9eef2; }
.to-item:last-child { border-bottom: none; }
.recent-item { border-bottom: 1px solid #e9eef2; padding: 0.5rem 0; }
.recent-item:last-child { border-bottom: none; }
.recent-item > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; cursor: pointer; list-style-position: inside; }

/* ---- overview screens ---- */
.balance-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0; border-bottom: 1px solid #e9eef2; }
.balance-row:last-child { border-bottom: none; }
.alert-row { display: flex; align-items: baseline; gap: 0.5rem; padding: 0.35rem 0; color: inherit; text-decoration: none; border-bottom: 1px solid #f0f3f5; }
.alert-row:last-child { border-bottom: none; }
.alert-row:hover .fw-semibold { text-decoration: underline; }
.alert-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; transform: translateY(-1px); }
.alert-dot.danger { background: #dc3545; }
.alert-dot.warning { background: #f0ad00; }
.alert-dot.info { background: #9fb3c1; }

/* ---- trainee file ---- */
.trainee-tabs .btn { font-weight: 600; }
.health-note { white-space: pre-line; background: #fff8e1; border: 1px solid #f3e2a8; border-radius: 8px; padding: 0.6rem 0.8rem; }

/* ---- brand and back link ---- */
.brand-logo { height: 42px; width: auto; display: block; }
.login-logo { width: min(260px, 80%); height: auto; }
.back-link {
  display: inline-flex; align-items: center; gap: 0.45rem; margin-bottom: 0.4rem;
  padding: 0.3rem 0.85rem; border-radius: 999px; border: 1.5px solid #c9d6df; line-height: 1.3;
  background: #fff; color: var(--devasys-navy); font-weight: 600; text-decoration: none;
}
.back-link:hover { border-color: var(--devasys-blue); color: var(--devasys-blue); }
.back-arrow { width: 1.15rem; height: 1.15rem; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* grid items may shrink to the screen: wide content scrolls inside its own box instead of widening the page */
.d-grid > * { min-width: 0; }
.up-row { padding: 0.6rem 0; border-bottom: 1px solid #e9eef2; }
.up-row:last-child { border-bottom: none; }
.up-row .edit-slot:not(.d-none) { display: flex; gap: 0.5rem; }
