/* ============================================================
   Material Design 3 Time Picker
   Self-contained component. All classes namespaced "m3tp-".
   Color roles exposed as CSS variables so the palette can be
   retargeted; --m3-primary defaults to the app accent (#3b7c86).
   ============================================================ */

.m3tp-root {
  /* M3 color roles (light) */
  --m3-primary: #3b7c86;
  --m3-on-primary: #ffffff;
  --m3-primary-container: #bce8ef;
  --m3-on-primary-container: #001f24;
  --m3-surface: #f7f4f6;
  --m3-surface-highest: #e7e1e4;
  --m3-on-surface: #1c1b1f;
  --m3-on-surface-variant: #49454f;
  --m3-outline: #79747e;
  --m3-scrim: rgba(0, 0, 0, 0.4);

  --m3-dial-size: 256px;
  --m3-tick-size: 44px;
  --m3-knob-size: 44px;
}

@media (prefers-color-scheme: dark) {
  .m3tp-root {
    --m3-primary: #82d3de;
    --m3-on-primary: #00363d;
    --m3-primary-container: #204e54;
    --m3-on-primary-container: #9eeffb;
    --m3-surface: #2b2930;
    --m3-surface-highest: #36343b;
    --m3-on-surface: #e6e1e5;
    --m3-on-surface-variant: #cac4d0;
    --m3-outline: #938f99;
    --m3-scrim: rgba(0, 0, 0, 0.6);
  }
}

/* ---- overlay / scrim ---- */
.m3tp-root {
  position: fixed;
  inset: 0;
  z-index: 2000;                 /* above the Bootstrap "Add Mileage" modal (~1055) */
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--m3-scrim);
  font-family: "Roboto", "Segoe UI", system-ui, sans-serif;
  opacity: 0;
  transition: opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.m3tp-root.m3tp-open { opacity: 1; }

/* ---- dialog card ---- */
.m3tp-card {
  background: var(--m3-surface);
  color: var(--m3-on-surface);
  border-radius: 28px;
  padding: 24px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  overflow: auto;
  transform: scale(0.92);
  transition: transform 0.15s ease;
}
.m3tp-root.m3tp-open .m3tp-card { transform: scale(1); }

.m3tp-title {
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: none;
  color: var(--m3-on-surface-variant);
  margin: 0 0 16px 0;
}

/* ---- time display (hour : minute + period) ---- */
.m3tp-display {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-bottom: 20px;
}
.m3tp-fields { display: flex; align-items: center; }

.m3tp-numbox {
  width: 96px;
  height: 80px;
  border: none;
  border-radius: 8px;
  background: var(--m3-surface-highest);
  color: var(--m3-on-surface);
  font-size: 48px;
  line-height: 80px;
  text-align: center;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  transition: background 0.1s ease, color 0.1s ease, box-shadow 0.1s ease;
}
.m3tp-numbox.m3tp-active {
  background: var(--m3-primary-container);
  color: var(--m3-on-primary-container);
}
/* input-variant text fields */
input.m3tp-numbox { outline: none; }
input.m3tp-numbox:focus {
  box-shadow: inset 0 0 0 2px var(--m3-primary);
  background: var(--m3-primary-container);
  color: var(--m3-on-primary-container);
}
.m3tp-colon {
  font-size: 48px;
  line-height: 80px;
  padding: 0 6px;
  color: var(--m3-on-surface);
}
.m3tp-fieldlabel {
  display: none;
  font-size: 12px;
  color: var(--m3-on-surface-variant);
  text-align: left;
  margin-top: 4px;
}
.m3tp-root.m3tp-mode-input .m3tp-fieldlabel { display: block; }

/* ---- AM / PM period toggle ---- */
.m3tp-period {
  display: flex;
  flex-direction: column;
  margin-left: 12px;
  border: 1px solid var(--m3-outline);
  border-radius: 8px;
  overflow: hidden;
  align-self: stretch;
}
.m3tp-period-btn {
  flex: 1;
  min-width: 52px;
  border: none;
  background: transparent;
  color: var(--m3-on-surface-variant);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.m3tp-period-btn + .m3tp-period-btn { border-top: 1px solid var(--m3-outline); }
.m3tp-period-btn.m3tp-active {
  background: var(--m3-primary-container);
  color: var(--m3-on-primary-container);
}

/* ---- clock dial ---- */
.m3tp-dialwrap {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}
.m3tp-dial {
  position: relative;
  width: var(--m3-dial-size);
  height: var(--m3-dial-size);
  border-radius: 50%;
  background: var(--m3-surface-highest);
  touch-action: none;
  user-select: none;
}
.m3tp-center {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--m3-primary);
  transform: translate(-50%, -50%);
  z-index: 3;
}
/* the clock hand: rooted at center, rotated by JS */
.m3tp-hand {
  position: absolute;
  top: 50%;
  left: 50%;
  height: 2px;
  background: var(--m3-primary);
  transform-origin: left center;
  z-index: 1;
}
.m3tp-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--m3-knob-size);
  height: var(--m3-knob-size);
  border-radius: 50%;
  background: var(--m3-primary);
  transform: translate(-50%, -50%);
  z-index: 2;
  pointer-events: none;
}
/* small hollow knob when the selected value has no number tick (odd minutes) */
.m3tp-knob.m3tp-knob-small::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--m3-on-primary);
  transform: translate(-50%, -50%);
}
.m3tp-tick {
  position: absolute;
  width: var(--m3-tick-size);
  height: var(--m3-tick-size);
  margin-left: calc(var(--m3-tick-size) / -2);
  margin-top: calc(var(--m3-tick-size) / -2);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 15px;
  color: var(--m3-on-surface);
  z-index: 2;
  cursor: pointer;
}
.m3tp-tick.m3tp-tick-selected { color: var(--m3-on-primary); }

/* ---- footer ---- */
.m3tp-footer {
  display: flex;
  align-items: center;
  margin-top: 12px;
}
.m3tp-toggle {
  background: transparent;
  border: none;
  color: var(--m3-on-surface-variant);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.m3tp-toggle:hover { background: rgba(127, 127, 127, 0.12); }
.m3tp-toggle .material-symbols-outlined { font-size: 24px; }
.m3tp-spacer { flex: 1; }
.m3tp-btn {
  background: transparent;
  border: none;
  color: var(--m3-primary);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  padding: 10px 12px;
  border-radius: 20px;
  font-family: inherit;
}
.m3tp-btn:hover { background: rgba(127, 127, 127, 0.12); }

/* hide the dial in input mode, show labels; hide labels area in dial mode */
.m3tp-root.m3tp-mode-input .m3tp-dialwrap { display: none; }
