/* ============================================================================
   Mobile ICD-11 Tree screen – dedicated full-screen takeover for phones.
   Pixel-match reskin to user reference (2026-05-17, light theme).
   Used by MobileICDTree component (js/mobile-icd-tree.js).
   Activates ONLY on phone viewports (max-width: 640px).
   ============================================================================ */

/* Hide overlay completely on desktop/tablet – phone-only feature. */
.mit-overlay { display: none; }

@media (max-width: 640px) {

.mit-overlay {
  position: fixed; inset: 0;
  z-index: 100000;
  background: #f8fafc;
  display: flex; flex-direction: column;
  font-family: 'Inter', system-ui, sans-serif;
  color: #0f172a;
  overflow: hidden;
  transform: translateY(100%);
  transition: transform .35s cubic-bezier(.2,.8,.2,1);
}
.mit-overlay.is-open { transform: translateY(0); }

/* ===== HEADER ===== */
.mit-header {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 12px;
  background: #ffffff;
  border-bottom: 1px solid #eef0f5;
  flex-shrink: 0;
}
.mit-close {
  width: 40px; height: 40px;
  background: transparent; border: 0;
  display: flex; align-items: center; justify-content: center;
  color: #0f172a;
  border-radius: 10px;
  cursor: pointer;
}
.mit-close:active { background: #f1f5f9; }
.mit-title-wrap {
  min-width: 0;
  text-align: center;
}
.mit-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mit-subtitle { display: none; }
.mit-bookmark {
  width: 40px; height: 40px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: #475569;
  cursor: pointer;
  justify-self: end;
}
.mit-bookmark:active { background: #f5f3ff; color: #7c3aed; border-color: #ddd6fe; }

/* ===== TABS (segmented pill control) – directly under header ===== */
.mit-tabs {
  display: flex;
  gap: 4px;
  margin: 12px 14px 0;
  padding: 4px;
  background: #eef0f5;
  border-radius: 999px;
  flex-shrink: 0;
}
.mit-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  border-radius: 999px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.mit-tab.is-active {
  background: #1e293b;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(15,23,42,0.20);
}
.mit-tab svg { flex-shrink: 0; }

/* ===== SEARCH ROW ===== */
.mit-search-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px 4px;
  flex-shrink: 0;
}
.mit-search {
  flex: 1; min-width: 0;
  position: relative;
  background: #eef0f5;
  border-radius: 999px;
  display: flex; align-items: center;
  padding: 0 16px;
  height: 44px;
}
.mit-search-icon {
  color: #94a3b8;
  margin-right: 10px;
  flex-shrink: 0;
}
.mit-search input {
  flex: 1; min-width: 0;
  background: transparent;
  border: 0; outline: 0;
  font-family: inherit;
  font-size: 14px;
  color: #0f172a;
}
.mit-search input::placeholder { color: #94a3b8; }
.mit-filter {
  width: 44px; height: 44px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: #475569;
  cursor: pointer;
  flex-shrink: 0;
}
.mit-filter:active { background: #ede9fe; color: #7c3aed; border-color: #ddd6fe; }

/* ===== TREE LIST (scrollable) ===== */
.mit-tree-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 14px 16px;
  -webkit-overflow-scrolling: touch;
}
.mit-tree {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

/* Row container – default white card */
.mit-row {
  position: relative;
  display: flex; align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #ffffff;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13.5px;
  color: #0f172a;
  cursor: pointer;
  user-select: none;
  min-height: 48px;
  transition: background .12s, border-color .12s;
}
.mit-row:active { background: #f8fafc; }

/* Skeleton loading state */
.mit-skel { pointer-events: none; cursor: default; }
.mit-skel-bar {
  display: inline-block;
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg, #eef0f6 0%, #f6f7fb 50%, #eef0f6 100%);
  background-size: 200% 100%;
  animation: mit-skel-shimmer 1.3s linear infinite;
}
.mit-skel-code { width: 48px; height: 22px; flex-shrink: 0; }
.mit-skel-name { flex: 1; max-width: 70%; }
@keyframes mit-skel-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .mit-skel-bar { animation: none; }
}

/* Depth-based indentation. 0=chapter, 1=block (6A), 2=category (6A2), 3=leaf (6A20). */
.mit-row[data-depth="0"] { margin-left: 0; }
.mit-row[data-depth="1"] { margin-left: 16px; }
.mit-row[data-depth="2"] { margin-left: 32px; }
.mit-row[data-depth="3"] { margin-left: 48px; }
.mit-row[data-depth="4"] { margin-left: 64px; }
.mit-row[data-depth="5"] { margin-left: 80px; }

/* Tree connector lines – vertical guide for OWN depth + L-shaped elbow.
   Plus ancestor-level pipes via background-image gradient stripes so the
   hierarchy line continues unbroken through deeper subtrees. */
.mit-row[data-depth="1"]::before,
.mit-row[data-depth="2"]::before,
.mit-row[data-depth="3"]::before,
.mit-row[data-depth="4"]::before,
.mit-row[data-depth="5"]::before {
  content: "";
  position: absolute;
  left: -10px;
  top: -4px;
  bottom: -4px;
  width: 1px;
  background: #e2e8f0;
}
.mit-row[data-depth="1"]::after,
.mit-row[data-depth="2"]::after,
.mit-row[data-depth="3"]::after,
.mit-row[data-depth="4"]::after,
.mit-row[data-depth="5"]::after {
  content: "";
  position: absolute;
  left: -10px;
  top: 50%;
  width: 10px;
  height: 1px;
  background: #e2e8f0;
}
/* For the LAST child at each depth, vertical guide stops at row mid-point
   → forms L-shape with horizontal elbow. !important defends against any
   data-depth ::before override conflict. */
.mit-row.is-last::before { bottom: 50% !important; }

/* Ancestor pipes: each row paints thin vertical stripes at every PARENT depth
   indent position, so depth-2 line stays visible while depth-3 children are
   expanded between depth-2 siblings. Single line at X = (ancestor_depth * 16) - 10. */
.mit-row[data-depth="2"] {
  background-image: linear-gradient(to right, transparent 6px, #e2e8f0 6px, #e2e8f0 7px, transparent 7px);
  background-repeat: no-repeat;
  background-size: 7px 100%;
  background-position: 0 0;
}
.mit-row[data-depth="3"] {
  background-image:
    linear-gradient(to right, transparent 6px, #e2e8f0 6px, #e2e8f0 7px, transparent 7px),
    linear-gradient(to right, transparent 22px, #e2e8f0 22px, #e2e8f0 23px, transparent 23px);
  background-repeat: no-repeat, no-repeat;
  background-size: 23px 100%, 23px 100%;
  background-position: 0 0, 0 0;
}
.mit-row[data-depth="4"] {
  background-image:
    linear-gradient(to right, transparent 6px, #e2e8f0 6px, #e2e8f0 7px, transparent 7px),
    linear-gradient(to right, transparent 22px, #e2e8f0 22px, #e2e8f0 23px, transparent 23px),
    linear-gradient(to right, transparent 38px, #e2e8f0 38px, #e2e8f0 39px, transparent 39px);
  background-repeat: no-repeat, no-repeat, no-repeat;
  background-size: 39px 100%, 39px 100%, 39px 100%;
  background-position: 0 0, 0 0, 0 0;
}
.mit-row[data-depth="5"] {
  background-image:
    linear-gradient(to right, transparent 6px, #e2e8f0 6px, #e2e8f0 7px, transparent 7px),
    linear-gradient(to right, transparent 22px, #e2e8f0 22px, #e2e8f0 23px, transparent 23px),
    linear-gradient(to right, transparent 38px, #e2e8f0 38px, #e2e8f0 39px, transparent 39px),
    linear-gradient(to right, transparent 54px, #e2e8f0 54px, #e2e8f0 55px, transparent 55px);
  background-repeat: no-repeat, no-repeat, no-repeat, no-repeat;
  background-size: 55px 100%, 55px 100%, 55px 100%, 55px 100%;
  background-position: 0 0, 0 0, 0 0, 0 0;
}

/* Expand toggle button hidden – chevron on the right handles toggle for non-leaf rows. */
.mit-expand { display: none !important; }
.mit-expand-spacer { display: none !important; }

/* Code badge – dark slate pill with white mono code (reference style) */
.mit-code {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 24px;
  padding: 0 8px;
  background: #1e293b;
  border: 1px solid #1e293b;
  border-radius: 6px;
  font-family: 'JetBrains Mono', 'SF Mono', ui-monospace, monospace;
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.02em;
}

/* Name (label) */
.mit-name {
  flex: 1; min-width: 0;
  font-size: 13.5px;
  font-weight: 500;
  color: #0f172a;
  line-height: 1.35;
  word-break: break-word;
}

/* Right chevron (collapsed=›, expanded=▾) */
.mit-chev {
  flex-shrink: 0;
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  color: #94a3b8;
  transition: transform .15s, color .15s;
}
.mit-chev[data-state="expanded"] { color: #475569; }

/* Favorite star button (leaf rows only, when NOT selected) */
.mit-fav {
  flex-shrink: 0;
  width: 28px; height: 28px;
  background: transparent;
  border: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #cbd5e1;
  cursor: pointer;
  border-radius: 8px;
  transition: color .15s, background .15s;
}
.mit-fav:active { background: #f1f5f9; }
.mit-fav.is-fav { color: #f59e0b; }
.mit-fav.is-fav svg { fill: currentColor; stroke: currentColor; }

/* Selected leaf checkmark badge (replaces star) – purple filled circle with white tick */
.mit-checkmark {
  flex-shrink: 0;
  width: 28px; height: 28px;
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(124,58,237,0.35);
}

/* SELECTED leaf state – purple gradient row */
.mit-row.is-active {
  background: linear-gradient(90deg, #ede9fe 0%, #ddd6fe 100%);
  border-color: #c4b5fd;
}
.mit-row.is-active .mit-code {
  background: #ffffff;
  border-color: #a78bfa;
  color: #6d28d9;
}
.mit-row.is-active .mit-name {
  color: #4c1d95;
  font-weight: 600;
}
.mit-row.is-active .mit-chev { color: #7c3aed; }

/* Focus rings */
.mit-row:focus-visible,
.mit-tab:focus-visible,
.mit-collapse-all:focus-visible,
.mit-accept-btn:focus-visible,
.mit-fav:focus-visible {
  outline: 2px solid #7c3aed;
  outline-offset: 2px;
}

/* Ancestor of active item – subtle purple hint on code */
.mit-row.is-active-parent .mit-code {
  background: #312e81;
  border-color: #312e81;
}

/* Chapter (depth 0) – emphasized */
.mit-row[data-depth="0"] {
  font-weight: 600;
}
.mit-row[data-depth="0"] .mit-name {
  font-weight: 700;
  color: #0f172a;
}

/* ===== BOTTOM BAR ===== */
.mit-footer {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: #ffffff;
  border-top: 1px solid #eef0f5;
  flex-shrink: 0;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}
.mit-collapse-all {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 6px;
  padding: 10px 14px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px; font-weight: 600;
  color: #475569;
  cursor: pointer;
}
.mit-collapse-all:active { background: #f5f3ff; color: #7c3aed; border-color: #ddd6fe; }
.mit-cta {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px;
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  border: 0; border-radius: 12px;
  font-family: inherit;
  font-size: 14px; font-weight: 700;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(124,58,237,0.30);
}
.mit-cta:active { transform: translateY(1px); }

/* ===== ACCEPT BAR (sliding bottom confirmation) ===== */
.mit-accept-bar {
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  background: rgba(255,255,255,0.96);
  border-top: 1px solid #eef0f5;
  box-shadow: 0 -8px 24px rgba(15,23,42,0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transform: translateY(110%);
  transition: transform .28s cubic-bezier(.2,.8,.2,1);
  z-index: 10;
}
.mit-accept-bar.is-visible { transform: translateY(0); }
.mit-accept-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff;
  border: 0; border-radius: 12px;
  font: 700 15px/1 'Inter', system-ui, sans-serif;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(124,58,237,0.40);
  transition: transform .12s;
}
.mit-accept-btn:active { transform: translateY(1px); }

/* ===== Favourites empty state ===== */
.mit-recent-empty,
.mit-fav-empty {
  padding: 32px 16px;
  text-align: center;
  color: #94a3b8;
  font-size: 13.5px;
  line-height: 1.55;
}

} /* end @media phone-only */
