/* ============================================================================
   BATALYOS — Kidney V2.5 Multiscale Anatomy & Physiology Academy Integration
   Matches the Liver & Heart Clinical Focus V5 ("Warm Beige Clinical Minimalism")
   benchmark 1:1. Zero dark background, zero scattered floating overlays.
   ============================================================================ */

/* Hide only the Three.js host canvas and host loading fallbacks when Kidney V2.5 is active;
   all shared Anatomy Explorer drawers, dock, and selection chip remain unified across Heart, Liver & Kidney */
.anatomy-workbench[data-kv25-active="true"] #anatomy-canvas,
.anatomy-workbench[data-kv25-active="true"] [data-anatomy-loading],
.anatomy-workbench[data-kv25-active="true"] [data-anatomy-load-error],
.anatomy-workbench[data-kv25-active="true"] [data-anatomy-webgl2-fallback] {
  display: none !important;
}

/* Transparent stage root inside .cf-viewport so the warm-beige .clinical-inspector-v3 studio stage and floor shadow shine through */
.kv25-stage-root {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  border-radius: inherit;
  overflow: hidden;
  background: transparent !important;
  color: var(--cf-text, #2b2118);
  --accent-cyan: #0f766e;
  --accent-emerald: #047857;
  --text-main: #2b2118;
  font-family: inherit;
  user-select: none;
}

.anatomy-workbench[data-kv25-active="true"] .kv25-stage-root {
  display: block;
}

/* Hide duplicate kidney-only UI drawers, toolbars, lesson bars, quiz tabs & telemetry in the student UI
   while preserving internal DOM nodes for future dedicated physiology/lesson/quiz sections */
.kv25-stage-root > :not(#s2e-canvas):not(#s2e-loader-overlay),
.kv25-legacy-bottom-row,
#btn-drawer-left,
#btn-drawer-right,
#kv25-dock-handle,
#panel-left,
#panel-right,
#kv25-adv-dock,
#kv25-selection-chip {
  display: none !important;
}

.kv25-cf-drawer {
  top: 10px;
  bottom: 16px;
}

.kv25-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: transparent !important;
  cursor: grab;
  touch-action: none;
}

.kv25-canvas:active {
  cursor: grabbing;
}

/* Ensure side organ-switcher arrows sit cleanly above the canvas and hide on the side of an open drawer, matching Liver */
.anatomy-workbench[data-kv25-active="true"] .cf-arrow {
  z-index: 4;
}

.anatomy-workbench.cf-left-open .cf-arrow-left,
.anatomy-workbench.cf-info-open .cf-arrow-right {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Loading Overlay (Warm Beige Clinical Style) */
.kv25-loader {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(243, 233, 220, 0.72);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 220ms cubic-bezier(0.22, 1, 0.36, 1), visibility 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.kv25-loader.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.kv25-loader-box {
  background: var(--cf-surface, #fcf8f1);
  border: 1px solid var(--cf-border-strong, #dcc9b1);
  border-radius: 16px;
  padding: 16px 24px;
  box-shadow: 0 12px 30px rgba(68, 48, 28, 0.14);
  text-align: center;
  color: var(--cf-text, #2b2118);
  font-size: 0.85rem;
  font-weight: 700;
}

/* Ensure Kidney V2.5 drawers & dock panel work with both .cf-*-open and .open classes */
.kv25-cf-drawer.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate3d(0, 0, 0);
  transition-delay: 0s;
}

.kv25-adv-dock.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate3d(-50%, 0, 0);
  transition-delay: 0s;
}

/* Right Drawer 4-Tab Sub-Navigation Bar */
.kv25-right-tabs {
  margin: 10px 14px 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.kv25-right-tabs .cf-tab {
  padding: 6px 4px;
  font-size: 11.5px;
  text-align: center;
  justify-content: center;
}

.kv25-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Dock Panel Internal Layout matching Liver Page */
.cf-dock-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--cf-border, rgba(166, 124, 53, 0.18));
}

.cf-dock-panel-head strong {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--cf-text, #2b2118);
}

.cf-dock-grid {
  display: grid;
  gap: 12px;
}

.cf-dock-block {
  display: grid;
  gap: 6px;
}

.cf-dock-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--cf-text-2, #6e5a44);
}

.cf-dock-divider {
  width: 1px;
  height: 24px;
  background: var(--cf-border-strong, rgba(166, 124, 53, 0.28));
}

.cf-dock-seg-icon,
.cf-trigger-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--cf-surface-2, #efe4d4);
  color: var(--cf-primary, #a67c35);
}

.cf-dock-seg-icon svg,
.cf-trigger-icon svg {
  width: 16px;
  height: 16px;
}

.cf-trigger-count {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--cf-soft, rgba(166, 124, 53, 0.14));
  color: var(--cf-primary-ink, #7c581e);
  font-size: 10.5px;
  font-weight: 800;
}

/* Section Cards inside Drawers */
.kv25-section {
  background: var(--cf-surface-2, #f3e9dc);
  border: 1px solid var(--cf-border, #e4d4be);
  border-radius: 14px;
  padding: 10px 12px;
}

.kv25-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--cf-primary-ink, #7c581e);
  margin-bottom: 8px;
}

.kv25-sub-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--cf-text-2, #52606d);
  margin: 6px 0 4px;
}

.kv25-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  background: #efe3d2;
  color: #7c581e;
  border: 1px solid #d5c0a3;
}

.kv25-badge.teal {
  background: #e0f2f1;
  color: #0f766e;
  border-color: #99f6e4;
}

/* Grids for 17 Lobes, Structures & Modules */
.kv25-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.kv25-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.kv25-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.kv25-btn {
  appearance: none;
  border: 1px solid #d5c0a3;
  background: #f9f3ea;
  color: #2b2118;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 6px 8px;
  border-radius: 9px;
  cursor: pointer;
  text-align: start;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.kv25-btn:hover {
  background: #eadbc7;
  border-color: #a67c35;
}

.kv25-btn.center {
  justify-content: center;
  text-align: center;
}

.kv25-btn.active {
  background: #a67c35;
  border-color: #8a6421;
  color: #ffffff;
}

.kv25-btn.teal.active {
  background: #0f766e;
  border-color: #115e59;
  color: #ffffff;
}

/* Key-Value & Note Cards */
.kv25-kv-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.kv25-kv-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.74rem;
  padding-bottom: 4px;
  border-bottom: 1px dashed #e4d4be;
}

.kv25-kv-key {
  color: #6e5a44;
  font-weight: 600;
  flex-shrink: 0;
}

.kv25-kv-val {
  color: #2b2118;
  font-weight: 700;
  text-align: end;
}

.kv25-note {
  background: #f9f3ea;
  border-inline-start: 3px solid #a67c35;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 0.74rem;
  line-height: 1.45;
  color: #2b2118;
}

.kv25-note.teal {
  border-inline-start-color: #0f766e;
}

/* Scale row inside collapsed scientific inspector */
.kv25-scale-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.kv25-scale-line {
  height: 6px;
  width: 88px;
  border: 2px solid #8a6421;
  border-top: none;
  transition: width 160ms ease;
}

.kv25-scale-label {
  font-size: 0.73rem;
  font-weight: 700;
  color: #2b2118;
}

.kv25-scale-meta {
  font-size: 0.68rem;
  color: #6e5a44;
}

/* Physiology Module & Lesson Cards */
.kv25-step-btn,
.s2e3-step-item {
  appearance: none;
  width: 100%;
  border: 1px solid #d5c0a3;
  background: #f9f3ea;
  color: #2b2118;
  font-family: inherit;
  padding: 8px 10px;
  border-radius: 9px;
  cursor: pointer;
  text-align: start;
  margin-bottom: 5px;
  transition: all 150ms ease;
}

.kv25-step-btn:hover,
.s2e3-step-item:hover {
  border-color: #a67c35;
  background: #efe3d2;
}

.kv25-step-btn.active,
.s2e3-step-item.active {
  border-color: #0f766e;
  background: #e6f4f1;
}

.kv25-step-title,
.s2e3-step-item strong {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: #0f766e;
  margin-bottom: 2px;
}

.kv25-step-desc,
.s2e3-step-desc {
  font-size: 0.71rem;
  color: #4b3d2e;
  line-height: 1.38;
}

/* 6 Physiology Module Selector Buttons */
.s2e3-mod-btn {
  appearance: none;
  border: 1px solid #d5c0a3;
  background: #f9f3ea;
  color: #2b2118;
  font-family: inherit;
  padding: 7px 9px;
  border-radius: 9px;
  cursor: pointer;
  text-align: start;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: all 150ms ease;
}

.s2e3-mod-btn:hover {
  background: #efe3d2;
  border-color: #a67c35;
}

.s2e3-mod-btn.active {
  background: #0f766e;
  border-color: #115e59;
  color: #ffffff;
}

.s2e3-mod-num {
  font-size: 0.64rem;
  font-weight: 700;
  color: #7c581e;
}

.s2e3-mod-btn.active .s2e3-mod-num {
  color: #99f6e4;
}

.s2e3-mod-title {
  font-size: 0.73rem;
  font-weight: 700;
  line-height: 1.25;
}

/* Guided Lesson Cards & Linked Pills */
.s2e3-card {
  background: #f9f3ea;
  border: 1px solid #d5c0a3 !important;
  border-radius: 10px;
  padding: 9px 11px;
  color: #2b2118;
}

.s2e3-card-title {
  font-size: 0.77rem;
  font-weight: 700;
  color: #2b2118;
}

.s2e3-pill-btn,
.s2e3-link-pill {
  appearance: none;
  border: 1px solid #d5c0a3;
  background: #f3e9dc;
  color: #2b2118;
  font-family: inherit;
  font-size: 0.70rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 150ms ease;
}

.s2e3-pill-btn:hover,
.s2e3-link-pill:hover {
  background: #eadbc7;
  border-color: #a67c35;
}

.s2e3-pill-btn.active {
  background: #0f766e;
  border-color: #115e59;
  color: #ffffff;
}

#s2e3-lessons-container ul {
  color: #334e68 !important;
}

.s2e3-quiz-box {
  background: #f3e9dc;
  border: 1px solid #e4d4be;
  border-radius: 9px;
  padding: 8px 10px;
  margin-top: 6px;
}

/* Quiz Options */
.kv25-quiz-opt,
.s2e3-quiz-opt {
  appearance: none;
  width: 100%;
  border: 1px solid #d5c0a3;
  background: #f9f3ea;
  color: #2b2118;
  font-family: inherit;
  font-size: 0.73rem;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  text-align: start;
  margin-top: 4px;
}

.kv25-quiz-opt:hover,
.s2e3-quiz-opt:hover {
  background: #efe3d2;
  border-color: #a67c35;
}

.kv25-quiz-opt.correct,
.s2e3-quiz-opt.correct {
  background: #d1fae5;
  border-color: #059669;
  color: #065f46;
}

.kv25-quiz-opt.wrong,
.s2e3-quiz-opt.wrong {
  background: #fee2e2;
  border-color: #dc2626;
  color: #991b1b;
}

/* Checkboxes & Sliders */
.kv25-check-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
}

.kv25-check-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: #2b2118;
  background: #f9f3ea;
  padding: 5px 8px;
  border-radius: 7px;
  border: 1px solid #e4d4be;
  cursor: pointer;
}

.kv25-check-label input[type="checkbox"] {
  accent-color: #a67c35;
}

.kv25-slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.73rem;
  color: #2b2118;
  margin-top: 6px;
}

.kv25-slider-row input[type="range"] {
  flex: 1;
  accent-color: #a67c35;
}

/* Mobile Responsive Overrides matching Liver & Heart Mobile Layout */
@media (max-width: 768px) {
  .kv25-cf-drawer {
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 76% !important;
    border-radius: 22px 22px 0 0 !important;
  }

  .kv25-adv-dock {
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-height: 78% !important;
    border-radius: 22px 22px 0 0 !important;
    transform: translate3d(0, 14px, 0);
  }

  .kv25-adv-dock.open,
  .cf-dock-open .kv25-adv-dock {
    transform: translate3d(0, 0, 0);
  }
}
