/* iOS Cupertino dialog + picker, matching what the Flutter app uses:
   CupertinoAlertDialog (AppDialogs.showInfo/showConfirm) and the
   showCupertinoModalPopup + CupertinoPicker in DropDownWidget. */

:root {
  --cup-separator: rgba(60, 60, 67, 0.29);
  --cup-secondary-bg: #F2F2F7;
  --cup-secondary-label: rgba(60, 60, 67, 0.6);
  --cup-placeholder: #AEAEB2;
  --cup-destructive: #FF3B30;
  --cup-scrim: rgba(0, 0, 0, 0.2);
  --cup-fill: rgba(120, 120, 128, 0.12);
}

/* ---------- scrim shared by dialog + picker ---------- */

.cup-scrim {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--cup-scrim);
  display: flex;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.cup-scrim.is-open { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .cup-scrim, .cup-sheet { transition: none !important; }
}

/* ---------- alert dialog ---------- */

.cup-scrim--dialog { align-items: center; justify-content: center; padding: 16px; }

.cup-dialog {
  width: 270px;
  max-width: 100%;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  overflow: hidden;
  transform: scale(1.12);
  transition: transform 0.2s ease;
}

@supports (backdrop-filter: blur(20px)) {
  .cup-dialog { backdrop-filter: blur(20px); background: rgba(255, 255, 255, 0.82); }
}

.cup-scrim.is-open .cup-dialog { transform: scale(1); }

.cup-dialog-body {
  padding: 19px 16px 18px;
  text-align: center;
}

.cup-dialog-title {
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.3;
}

.cup-dialog-message {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-primary);
  margin: 6px 0 0;
  line-height: 1.4;
}

.cup-dialog-message a { color: var(--blue); font-weight: 600; }

/* Buttons: side by side when there are two, stacked otherwise — as iOS does. */
.cup-dialog-actions {
  display: flex;
  border-top: 0.5px solid var(--cup-separator);
}

.cup-dialog-actions.is-stacked { flex-direction: column; }

.cup-action {
  flex: 1;
  min-height: 44px;
  padding: 11px 8px;
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 400;
  color: var(--navy);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cup-action + .cup-action { border-left: 0.5px solid var(--cup-separator); }
.cup-dialog-actions.is-stacked .cup-action + .cup-action {
  border-left: none;
  border-top: 0.5px solid var(--cup-separator);
}

.cup-action:active { background: rgba(0, 0, 0, 0.08); }
.cup-action.is-default { font-weight: 600; }
.cup-action.is-destructive { color: var(--cup-destructive); }
.cup-action:disabled { color: var(--text-disabled); cursor: not-allowed; }

/* ---------- bottom-sheet picker ---------- */

.cup-scrim--sheet { align-items: flex-end; justify-content: center; }

.cup-sheet {
  width: 100%;
  max-width: 480px;
  background: #fff;
  transform: translateY(100%);
  transition: transform 0.25s ease;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.cup-scrim.is-open .cup-sheet { transform: translateY(0); }

.cup-sheet-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  background: var(--cup-secondary-bg);
  border-bottom: 0.5px solid var(--divider, #E5E7EB);
}

.cup-toolbar-btn {
  background: none;
  border: none;
  padding: 0 16px;
  height: 44px;
  font-family: var(--font-body);
  font-size: 15px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cup-toolbar-btn.is-cancel { color: var(--cup-destructive); }
.cup-toolbar-btn.is-done { color: var(--navy); font-weight: 600; }

/* Wheel — scroll-snap rather than a real 3D cylinder, which keeps native
   momentum scrolling on touch while reading as a picker. */
.cup-wheel {
  position: relative;
  height: 216px;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  overscroll-behavior: contain;
  /* Without a perspective the per-item rotateX just flattens them instead of
     reading as a cylinder. */
  perspective: 900px;
  transform-style: preserve-3d;
}

.cup-wheel::-webkit-scrollbar { display: none; }

/* The wheel is focused programmatically when the sheet opens, so only show
   a ring for actual keyboard navigation. */
.cup-wheel:focus { outline: none; }
.cup-wheel:focus-visible { outline: 2px solid var(--sky); outline-offset: -2px; }

.cup-wheel-item {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  scroll-snap-align: center;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text-primary);
  padding: 0 16px;
  text-align: center;
  transition: opacity 0.1s linear;
  will-change: transform, opacity;
}

.cup-wheel-spacer { height: 86px; }

/* Centre selection band */
.cup-wheel-band {
  position: absolute;
  left: 0;
  right: 0;
  top: 86px;
  height: 44px;
  pointer-events: none;
  background: var(--cup-fill);
  border-radius: 8px;
  margin: 0 8px;
}

.cup-sheet-body { position: relative; }

/* ---------- picker field (closed state) — mirrors DropDownWidget ---------- */

.cup-field {
  display: flex;
  align-items: center;
  width: 100%;
  background: #fff;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  padding: 14px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cup-field-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1;
}

.cup-field.is-placeholder .cup-field-value { color: var(--cup-placeholder); }

.cup-field-chevron {
  flex-shrink: 0;
  margin-left: 8px;
  color: var(--cup-secondary-label);
  font-size: 12px;
  line-height: 1;
}

.field.has-error .cup-field { border-color: var(--border-error); }
