/* Dental Chart — page layout */

body {
  background: #f1f5f9;
}

.dental-page {
  width: 90%;
  margin: 0 auto;
  padding: 1rem 0 5rem;
}

.dental-header {
  margin-bottom: 1.5rem;
}

.dental-title {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  font-weight: 600;
  color: #1e293b;
}

.dental-subtitle {
  margin: 0;
  font-size: 0.875rem;
  color: #64748b;
}

/* Stage switcher */

.stage-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.stage-switcher__btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.125rem;
  padding: 0.625rem 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.stage-switcher__btn:hover {
  border-color: #93c5fd;
  background: #f8fafc;
}

.stage-switcher__btn--active {
  border-color: #3b82f6;
  background: #eff6ff;
  box-shadow: 0 0 0 1px #3b82f6;
}

.stage-switcher__name {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1e293b;
}

.stage-switcher__meta {
  font-size: 0.75rem;
  color: #64748b;
}

.stage-description {
  margin: 0 0 1rem;
  font-size: 0.8125rem;
  color: #94a3b8;
}

/* Workspace — chart + treatment sidebar */

.dental-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1.35rem;
  align-items: start;
  transition: grid-template-columns 0.25s ease, gap 0.25s ease;
}

.dental-workspace .dental-chart-wrapper {
  min-height: 0;
}

.dental-workspace .treatment-sidebar {
  min-height: 0;
  overflow: hidden;
}

.dental-workspace--sidebar-collapsed {
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 1rem;
}

@media (max-width: 1024px) {
  .dental-workspace,
  .dental-workspace--sidebar-collapsed {
    grid-template-columns: 1fr;
  }
}

/* Chart wrapper */

.dental-chart-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  width: 100%;
}

.dental-chart {
  flex: 1;
  position: relative;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 2rem 1.5rem 2.5rem;
  min-height: 480px;
  overflow-x: auto;
}

.dental-chart-wrapper.dental-chart--edit-mode .dental-chart {
  cursor: crosshair;
}

.dental-chart-wrapper.dental-chart--edit-mode .tooth {
  cursor: crosshair;
}

/* Arch rows */

.dental-arch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  position: relative;
  width: 100%;
}

.dental-arch--upper {
  padding-bottom: 1rem;
}

.dental-arch--lower {
  padding-top: 1rem;
}

.dental-arch__half {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.dental-arch--upper .dental-arch__half {
  align-items: flex-end;
}

.dental-arch--lower .dental-arch__half {
  align-items: flex-start;
}

.dental-arch__half--right {
  flex-direction: row;
  justify-content: flex-end;
}

.dental-arch__half--left {
  flex-direction: row;
  justify-content: flex-start;
}

/* Occlusal plane */

.occlusal-plane {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0.75rem 0;
  height: 36px;
}

.occlusal-plane::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: #e2e8f0;
}

.occlusal-plane__label {
  position: relative;
  z-index: 1;
  padding: 0.2rem 0.75rem;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #38bdf8;
  background: #fff;
  border: 1px solid #bae6fd;
  border-radius: 999px;
}

/* Quadrant labels */

.quadrant-label {
  position: absolute;
  font-size: 0.625rem;
  font-weight: 500;
  color: #94a3b8;
  letter-spacing: 0.02em;
  white-space: nowrap;
  pointer-events: none;
}

.quadrant-label--ur {
  top: 0.25rem;
  left: 0.5rem;
}

.quadrant-label--ul {
  top: 0.25rem;
  right: 0.5rem;
}

.quadrant-label--lr {
  bottom: 0.25rem;
  left: 0.5rem;
}

.quadrant-label--ll {
  bottom: 0.25rem;
  right: 0.5rem;
}

/* Individual tooth */

.tooth {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 40px;
  max-width: 72px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.tooth:hover {
  transform: scale(1.05);
}

.tooth--excluded {
  flex: 0 0 auto;
  opacity: 0.38;
  filter: grayscale(1);
  cursor: not-allowed;
  transition: opacity 0.2s, filter 0.2s, margin 0.2s ease;
}

/* Neighbor before excluded — partial pull (avoids overlap) */
.tooth--pull-next {
  margin-right: -22px;
  position: relative;
  z-index: 1;
}

/* Neighbor after excluded — partial pull */
.tooth--pull-prev {
  margin-left: -22px;
  position: relative;
  z-index: 1;
}

.tooth--pull-next:hover {
  transform: scale(1.05);
}

.tooth--pull-prev:hover {
  transform: scale(1.05);
}

/* Midline-side pull when inner neighbor is excluded */
.dental-arch__half--right .tooth--pull-midline {
  margin-right: -18px;
}

.dental-arch__half--left .tooth--pull-midline {
  margin-left: -18px;
}

.tooth--pull-midline:hover {
  transform: scale(1.05);
}

.tooth--excluded:hover {
  transform: none;
}

.tooth--excluded .tooth__number {
  text-decoration: line-through;
  color: #94a3b8;
}

.tooth--excluded .tooth__crown {
  fill: #f1f5f9;
}

.tooth--excluded .tooth__root {
  opacity: 0.35;
}

.dental-chart-wrapper.dental-chart--add-mode .tooth--excluded {
  cursor: pointer;
  opacity: 0.48;
}

.dental-chart-wrapper.dental-chart--add-mode .tooth--excluded:hover {
  opacity: 0.62;
  transform: scale(1.03);
}

.dental-chart-wrapper.dental-chart--remove-mode .tooth:not(.tooth--excluded) {
  cursor: crosshair;
}

.tooth--extra {
  position: relative;
}

.tooth--extra .tooth__number {
  color: #059669;
  font-weight: 700;
}

.tooth--extra .tooth__icon {
  outline: 2px dashed #6ee7b7;
  outline-offset: -9px;
  border-radius: 15px;
}

.dental-chart-wrapper.dental-chart--remove-extra-mode .tooth--extra {
  cursor: crosshair;
}

.dental-chart-wrapper.dental-chart--remove-extra-mode .tooth--extra:hover {
  transform: scale(1.06);
  outline: 2px solid #f59e0b;
  outline-offset: 2px;
  border-radius: 4px;
}

.stage-description--hint {
  color: #d97706;
  font-weight: 500;
}

.tooth--upper {
  flex-direction: column;
}

.tooth--lower {
  flex-direction: column;
}

.tooth__number {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #64748b;
  line-height: 1;
  margin: 4px 0;
  user-select: none;
}

.tooth__number--upper {
  order: 0;
}

.tooth__number--lower {
  order: 2;
}

.tooth__icon {
  order: 1;
  width: 100%;
  max-width: 56px;
  height: 72px;
}

.tooth__icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.dental-chart-wrapper.dental-chart--paint-mode .dental-chart {
  cursor: crosshair;
}

.dental-chart-wrapper.dental-chart--paint-mode .tooth {
  cursor: crosshair;
}

.dental-chart-wrapper.dental-chart--paint-mode .tooth-gap,
.dental-chart-wrapper.dental-chart--paint-mode .arch-midline-gap {
  cursor: crosshair;
}

.tooth--missing .tooth__number {
  color: #3b82f6;
  font-weight: 700;
}

.tooth--missing .tooth__crown {
  fill: #e2e8f0;
  opacity: 0.6;
}

.tooth__missing-x {
  stroke: #3b82f6;
  stroke-width: 2.5;
  stroke-linecap: round;
}

/* SVG tooth parts */

.tooth__crown {
  fill: #fff;
  stroke: #cbd5e1;
  stroke-width: 1;
}

.tooth__root {
  fill: #e8e0d4;
  opacity: 0.55;
  stroke: #d6cfc4;
  stroke-width: 0.5;
}

/* Midline gap between quadrants */

.arch-midline {
  width: 16px;
  flex-shrink: 0;
}
