/* DAO Derma HR - application shell and screens (builds on base.css tokens) */

/* ---------- Shell ---------- */
.hr-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--pine-deep);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 24px 0 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .brand { padding: 0 22px 6px; }
.sidebar .brand-name { color: #fff; }

.sidebar-role { padding: 0 22px 22px; font-size: 13px; color: rgba(255, 255, 255, 0.58); }

#sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 8px 12px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: var(--r-md);
  background: none;
  text-align: start;
  width: 100%;
  transition: background 120ms ease, color 120ms ease;
}
.sidebar-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.sidebar-link.active { background: rgba(255, 255, 255, 0.12); color: #fff; }
.sidebar-link.active .nav-icon { color: var(--mint); }
.sidebar-link:focus-visible, .sidebar-footer button:focus-visible { outline-color: var(--mint); }

.nav-icon { width: 20px; height: 20px; flex-shrink: 0; display: inline-flex; }
.nav-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.nav-badge {
  background: var(--mint);
  color: var(--pine-deep);
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  margin-inline-start: auto;
}

.sidebar-footer { margin-top: auto; padding: 16px 12px 0; display: flex; flex-direction: column; gap: 8px; }
.sidebar-footer button {
  width: 100%;
  min-height: 40px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  padding: 9px;
  font-size: 13px;
  font-weight: 500;
}
.sidebar-footer button:hover { background: rgba(255, 255, 255, 0.14); }

.hr-main { flex: 1; min-width: 0; padding: 40px 48px 80px; max-width: 1080px; }

/* ---------- Mobile: top bar + bottom tabs + More sheet ---------- */
.m-top, .m-tabs { display: none; }

@media (max-width: 820px) {
  .hr-shell { flex-direction: column; }
  .sidebar { display: none; }
  .hr-main { padding: 18px 16px 104px; max-width: 100%; }
  .page-title { font-size: 26px; }

  .m-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--paper);
    position: sticky;
    top: 0;
    z-index: 40;
    border-bottom: 1px solid var(--line);
  }
  .m-bell {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--pine);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .m-bell .nav-badge { position: absolute; top: -4px; inset-inline-end: -4px; margin: 0; }

  .m-tabs {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 6px 6px calc(8px + env(safe-area-inset-bottom));
  }
  .m-tab {
    border: none;
    background: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: var(--ink-soft);
    font-size: 11px;
    font-weight: 500;
    padding: 6px 2px;
    border-radius: var(--r-md);
    min-height: 52px;
  }
  .m-tab .nav-icon, .m-tab .nav-icon svg { width: 24px; height: 24px; }
  .m-tab.active { color: var(--pine); font-weight: 600; }
  .m-tab.active .nav-icon svg { stroke-width: 2.2; }

  .toast { bottom: 92px; }
}

.m-sheet-list { display: flex; flex-direction: column; gap: 2px; margin: 4px -8px 12px; }
.m-sheet-list .sidebar-link { color: var(--ink); background: none; min-height: 48px; font-size: 15px; }
.m-sheet-list .sidebar-link:hover { background: var(--mist-soft); }
.m-sheet-list .sidebar-link .nav-icon { color: var(--pine-soft); }
.m-sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Tabs (underline) ---------- */
.tab-row {
  display: flex;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-row::-webkit-scrollbar { display: none; }

.tab-btn {
  border: none;
  background: none;
  padding: 10px 0 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--pine); font-weight: 600; border-bottom-color: var(--pine); }

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

.hr-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }

.hr-table th {
  text-align: start;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  background: var(--mist-soft);
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.hr-table td { padding: 12px 16px; font-size: 14px; border-top: 1px solid var(--mist); vertical-align: middle; }
.hr-table tbody tr:first-child td { border-top: none; }
.hr-table tbody tr:hover td { background: var(--mist-soft); }

/* ---------- Key figures (replaces boxed stat cards) ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

.stat-card { display: flex; flex-direction: column-reverse; padding: 16px 20px; border-inline-start: 1px solid var(--line); }
.stat-card:first-child { border-inline-start: none; }
.stat-card .stat-label { font-size: 13px; color: var(--ink-soft); }
.stat-card .stat-value { font-size: 30px; font-weight: 300; letter-spacing: -0.02em; color: var(--ink); line-height: 1.2; font-variant-numeric: tabular-nums; }

/* ---------- Filters ---------- */
.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }

/* ---------- People ---------- */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--mist);
  color: var(--pine);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}
.person-cell { display: flex; align-items: center; gap: 12px; }

/* ---------- Policies ---------- */
.policy-doc {
  padding: 4px 0 0;
  font-size: 15px;
  line-height: 1.75;
  max-width: 68ch;
  color: var(--ink);
  white-space: pre-wrap;
}
.policy-doc mark, .card-title mark { background: #FFE9A8; color: inherit; border-radius: 3px; padding: 0 2px; }

/* ---------- Modal (bottom sheet on phones) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 40, 44, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  padding: 20px;
}

.modal-box {
  background: var(--surface);
  border-radius: 20px;
  padding: 26px;
  max-width: 460px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-pop);
  animation: sheet-in 200ms ease-out;
}
.modal-box > .card-title:first-child { font-size: 20px; font-weight: 600; letter-spacing: -0.015em; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 820px) {
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-box { max-width: none; border-radius: 22px 22px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); max-height: 92vh; }
}

/* ---------- Home: clock station (the one bold element) ---------- */
.station {
  background: radial-gradient(120% 150% at 88% -10%, #1B8E94 0%, var(--pine) 46%, var(--pine-deep) 100%);
  color: #fff;
  border-radius: var(--r-xl);
  padding: 32px 36px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 28px;
  align-items: center;
  margin-bottom: 28px;
}

.station-greeting { font-size: 15px; color: rgba(255, 255, 255, 0.7); margin-bottom: 14px; }
.station-time { font-size: 68px; font-weight: 300; letter-spacing: -0.035em; line-height: 1; font-variant-numeric: tabular-nums; }
.station-date { margin-top: 8px; font-size: 15px; color: rgba(255, 255, 255, 0.72); }

.station-facts { display: flex; flex-direction: column; gap: 6px; margin-top: 22px; font-size: 14px; color: rgba(255, 255, 255, 0.86); }
.station-fact { display: flex; align-items: center; gap: 10px; }
.station-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, 0.35); flex-shrink: 0; }
.station-dot.live { background: var(--mint); box-shadow: 0 0 0 4px rgba(135, 210, 206, 0.28); }

.station-note { margin-top: 14px; font-size: 13px; color: rgba(255, 255, 255, 0.6); max-width: 38ch; }

.ring-wrap { position: relative; width: 188px; height: 188px; flex-shrink: 0; }
.ring-wrap svg.ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: rgba(255, 255, 255, 0.14); stroke-width: 6; }
.ring-fill {
  fill: none;
  stroke: var(--mint);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 534;
  stroke-dashoffset: var(--ring-to, 534);
  animation: ring-draw 1100ms cubic-bezier(0.2, 0.7, 0.2, 1) 120ms backwards;
}
@keyframes ring-draw { from { stroke-dashoffset: 534; } }

.clock-btn {
  position: absolute;
  inset: 20px;
  border-radius: 50%;
  border: none;
  background: var(--mint);
  color: var(--pine-deep);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 100ms ease, background 120ms ease;
}
.clock-btn:hover { background: #9EDCD8; }
.clock-btn:active { transform: scale(0.97); }
.clock-btn:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }
.clock-btn:disabled { opacity: 0.6; }
.clock-btn svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.station-alt { margin-top: 12px; text-align: center; }
.station-alt button {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 6px;
}
.station-alt button:hover { color: #fff; }
.station-alt button:focus-visible { outline-color: var(--mint); }

.station-error { grid-column: 1 / -1; background: rgba(250, 223, 216, 0.14); border: 1px solid rgba(250, 190, 175, 0.5); color: #FFE3DB; padding: 10px 14px; border-radius: var(--r-md); font-size: 14px; }

@media (max-width: 820px) {
  .station { grid-template-columns: 1fr; padding: 26px 22px 22px; border-radius: 24px; }
  .station-time { font-size: 56px; }
  .ring-wrap { justify-self: center; }
}

/* ---------- Home: attention list ---------- */
.section-title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 12px; }

.attn-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); margin-bottom: 28px; overflow: hidden; }
.attn-row {
  display: flex;
  align-items: center;
  gap: 18px;
  width: 100%;
  padding: 14px 20px;
  background: none;
  border: none;
  border-top: 1px solid var(--mist);
  text-align: start;
  color: var(--ink);
}
.attn-row:first-child { border-top: none; }
.attn-row:hover { background: var(--mist-soft); }
.attn-count { font-size: 28px; font-weight: 300; min-width: 38px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--pine); }
.attn-label { flex: 1; font-size: 15px; }
.attn-label small { display: block; font-size: 13px; color: var(--ink-soft); }
.attn-go { color: var(--ink-faint); width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[dir="rtl"] .attn-go { transform: scaleX(-1); }

.shortcut-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 28px; }
.shortcut-row button { width: auto; flex: 0 0 auto; }

/* ---------- Right-to-left (Arabic) ---------- */
[dir="rtl"] .card[style*="border-left"] { border-left: 1px solid var(--line) !important; border-right: 4px solid var(--mint-ink) !important; }

.station-time small { font-size: 20px; font-weight: 400; letter-spacing: 0; margin-inline-start: 8px; color: rgba(255, 255, 255, 0.7); }

@media (max-width: 820px) {
  .shortcut-row { display: grid; grid-template-columns: 1fr 1fr; }
  .shortcut-row button { width: 100%; padding-inline: 10px; font-size: 14px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-card:nth-child(odd) { border-inline-start: none; }
  .stat-card:nth-child(n+3) { border-top: 1px solid var(--line); }
}

.card .table-wrap { border: none; border-radius: 0; margin-inline: -18px; margin-bottom: -16px; }

/* ---------- Performance: score bars, rating chips, KPI rows ---------- */
.score-bar { height: 8px; background: var(--mist); border-radius: 100px; overflow: hidden; margin-top: 6px; }
.score-fill { height: 100%; background: var(--pine-soft); border-radius: 100px; }

.rate-row { display: flex; gap: 8px; flex-wrap: wrap; }
.rate-chip {
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
}
.rate-chip:hover { border-color: #B3CDCD; background: var(--mist-soft); }
.rate-chip.selected { background: var(--pine); border-color: var(--pine); color: #fff; font-weight: 600; }

.kpi-row {
  display: grid;
  grid-template-columns: 1.3fr 2fr 110px auto;
  gap: 10px;
  align-items: end;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-bottom: 8px;
}
@media (max-width: 820px) { .kpi-row { grid-template-columns: 1fr 1fr; } .kpi-row .field:nth-child(2) { grid-column: 1 / -1; } }

/* ---------- Profile photo and person chip ---------- */
img.avatar { object-fit: cover; display: inline-block; }
.avatar-lg { width: 96px; height: 96px; font-size: 30px; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  width: calc(100% - 24px);
  margin: 0 12px 18px;
  padding: 8px;
  border: none;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  text-align: start;
}
.sidebar-user:hover { background: rgba(255, 255, 255, 0.12); }
.sidebar-user .avatar { background: var(--mint); color: var(--pine-deep); width: 40px; height: 40px; }
.sidebar-user span { display: flex; flex-direction: column; min-width: 0; }
.sidebar-user strong { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user small { font-size: 12px; color: rgba(255, 255, 255, 0.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.m-avatar { border: none; background: none; padding: 0; border-radius: 50%; display: none; }
@media (max-width: 820px) { .m-avatar { display: flex; } .m-avatar .avatar { width: 42px; height: 42px; } }

.profile-head { display: flex; align-items: center; gap: 22px; margin-bottom: 22px; flex-wrap: wrap; }
.profile-head h2 { margin: 0 0 4px; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.profile-list { display: grid; grid-template-columns: minmax(130px, 200px) 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); margin-bottom: 20px; }
.profile-list dt, .profile-list dd { margin: 0; padding: 12px 18px; border-top: 1px solid var(--mist); }
.profile-list dt:first-of-type, .profile-list dd:first-of-type { border-top: none; }
.profile-list dt { color: var(--ink-soft); font-size: 13px; }

/* ---------- DAO Derma logo (PNG) ---------- */
.brand-chip { background: #fff; border-radius: 10px; padding: 7px 11px; display: inline-flex; align-items: center; }
.brand-chip img { height: 24px; width: auto; display: block; }
.m-top .brand img { height: 24px; width: auto; display: block; }
.sidebar .brand { align-items: center; gap: 10px; }
.sidebar .brand-name { color: rgba(255, 255, 255, 0.85); font-weight: 500; }

/* ---------- Charts ---------- */
.viz-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
@media (max-width: 1000px) { .viz-grid { grid-template-columns: 1fr; } }
.viz-loading { min-height: 120px; }

.viz { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px 18px 12px; margin: 0 0 18px; }
.viz-grid .viz { margin-bottom: 0; }
.viz-head { margin-bottom: 10px; }
.viz-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
.viz-sub { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }

.viz-legend { display: flex; gap: 18px; flex-wrap: wrap; margin: 0 0 8px; font-size: 13px; color: var(--ink-soft); }
.viz-legend-item { display: inline-flex; align-items: center; gap: 8px; }
.viz-key-box { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.viz-key-line { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }

.viz-plot { position: relative; width: 100%; }
.viz-plot svg { display: block; max-width: 100%; overflow: visible; }
.viz-plot svg:focus-visible { outline: 3px solid rgba(10, 127, 134, 0.45); outline-offset: 2px; border-radius: 6px; }
.viz-plot rect:focus-visible { outline: none; stroke: var(--pine-soft); stroke-width: 2; }
.viz-empty { padding: 36px 8px; text-align: center; color: var(--ink-soft); font-size: 14px; }

.viz-tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  box-shadow: 0 6px 18px rgba(0, 40, 44, 0.16);
  padding: 8px 10px;
  font-size: 12px;
  min-width: 110px;
}
.viz-tip-title { color: var(--ink-soft); margin-bottom: 4px; }
.viz-tip-row { display: flex; align-items: center; gap: 8px; line-height: 1.5; }
.viz-tip-row strong { font-size: 14px; color: var(--ink); }
.viz-tip-row span:last-child { color: var(--ink-soft); }

.viz-toggle { background: none; border: none; padding: 8px 0 4px; font-size: 12px; font-weight: 500; color: var(--pine-soft); text-decoration: underline; text-underline-offset: 3px; }
.viz-table { margin-top: 8px; max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); }
.viz-table .hr-table th, .viz-table .hr-table td { padding: 8px 12px; font-size: 13px; }

/* charts always draw left to right, even in the Arabic layout, so axis labels and bar values stay attached to their marks */
.viz-plot svg { direction: ltr; }

/* required fields */
.field label.req::after { content: " *"; color: var(--danger, #C0392B); }

/* organisation chart */
.org-tree, .org-tree ul { list-style: none; margin: 0; padding-inline-start: 24px; }
.org-tree { padding-inline-start: 0; }
.org-tree ul { border-inline-start: 2px solid var(--line); margin-inline-start: 18px; }
.org-tree li { margin: 8px 0; }
.org-tree summary { cursor: pointer; list-style: none; }
.org-tree summary::-webkit-details-marker { display: none; }
.org-card { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel, #fff); max-width: 520px; }
.org-name { font-weight: 500; }
