/* ShadowTime – shared styles (Tailwind via CDN for utilities, components here). */

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .3rem .6rem; border-radius: .375rem; font-size: .8rem;
  border: 1px solid #cbd5e1; background: #fff; color: #1e293b; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover:not(:disabled) { background: #f1f5f9; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-secondary { background: #f8fafc; }
.btn.active, .btn-primary { background: #1e293b; color: #fff; border-color: #1e293b; }
.btn.active:hover:not(:disabled), .btn-primary:hover:not(:disabled) { background: #334155; }
.btn-danger { color: #b91c1c; border-color: #fecaca; }
.btn-danger:hover:not(:disabled) { background: #fef2f2; }
.dot { width: .55rem; height: .55rem; border-radius: 999px; display: inline-block; flex-shrink: 0; }
.btn.done .dot { box-shadow: 0 0 0 2px #fff, 0 0 0 3px #16a34a; }

.input {
  width: 100%; padding: .35rem .5rem; border: 1px solid #cbd5e1; border-radius: .375rem;
  background: #fff; font-size: .85rem;
}
.input[readonly], .input:disabled { background: #f1f5f9; }
.input.invalid { border-color: #dc2626; }
.field { display: flex; flex-direction: column; gap: .2rem; font-size: .72rem; color: #475569; }
.seg { display: flex; align-items: center; gap: .3rem; padding: .35rem .6rem; font-size: .8rem; color: #1e293b; cursor: pointer; }
.seg + .seg { border-left: 1px solid #cbd5e1; }
.legend { display: inline-block; width: 14px; height: 3px; margin-right: 5px; vertical-align: middle; }
.badge { display: inline-block; font-size: .68rem; line-height: 1rem; padding: 0 .4rem; border-radius: 999px; font-weight: 500; }

/* ---------- header & account menu ---------- */
.topbar {
  height: 3rem; flex-shrink: 0; display: flex; align-items: center; gap: .75rem;
  padding: 0 max(1rem, env(safe-area-inset-right)) 0 max(1rem, env(safe-area-inset-left));
  background: #0f172a; color: #fff;
}
.account-btn {
  display: flex; align-items: center; gap: .4rem; padding: .25rem .5rem; border-radius: .5rem;
  font-size: .75rem; color: #e2e8f0; min-height: 2.25rem;
}
.account-btn:hover { background: #1e293b; }
.account-avatar {
  width: 1.6rem; height: 1.6rem; border-radius: 999px; background: #f59e0b; color: #0f172a;
  display: grid; place-items: center; font-weight: 700; font-size: .8rem;
}
.account-menu {
  position: absolute; right: 0; top: calc(100% + .35rem); z-index: 2000; min-width: 14rem;
  background: #fff; color: #1e293b; border-radius: .6rem; overflow: hidden;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .25); border: 1px solid #e2e8f0;
}
.menu-item { display: block; width: 100%; text-align: left; padding: .65rem .9rem; font-size: .85rem; }
.menu-item:hover, .menu-item:focus-visible { background: #f1f5f9; outline: none; }

.dialog { border-radius: .75rem; padding: 0; box-shadow: 0 20px 50px rgba(15, 23, 42, .35); }
.dialog::backdrop { background: rgba(15, 23, 42, .45); }

/* ---------- admin page ---------- */
.user-card { background: #fff; border: 1px solid #e2e8f0; border-radius: .75rem; padding: .85rem 1rem; }

/* ---------- photo canvas ---------- */
#photo { cursor: crosshair; touch-action: none; }
#photo.panning { cursor: grabbing; }
#photo.over-point { cursor: move; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .5rem; border-bottom: 1px solid #e2e8f0; }
.lbl-short { display: none; }
.hint-touch { display: none; }
@media (pointer: coarse) {
  .hint-touch { display: block; }
  .hint-mouse { display: none; }
}

.canvas-fab {
  position: absolute; right: .6rem; bottom: .6rem; z-index: 5; width: 2.5rem; height: 2.5rem;
  border-radius: 999px; background: rgba(15, 23, 42, .75); color: #fff; font-size: 1.2rem;
  display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
.canvas-fab.hidden { display: none; }
.canvas-fab:hover { background: rgba(15, 23, 42, .9); }

/* ---------- results ---------- */
.candidate { cursor: pointer; border: 1px solid #e2e8f0; background: #fff; border-radius: .5rem; padding: .6rem .75rem; }
.candidate:hover { border-color: #94a3b8; }
.candidate.selected { border-color: #16a34a; box-shadow: 0 0 0 2px #bbf7d0; }

/* ---------- map ---------- */
.map-pin { font-size: 22px; line-height: 22px; text-align: center; filter: drop-shadow(0 1px 1px rgba(0,0,0,.5)); }
.map-handle { width: 14px; height: 14px; border-radius: 999px; background: #dc2626; border: 2px solid #fff; box-shadow: 0 0 2px rgba(0,0,0,.6); }
.map-tools { position: absolute; bottom: 1.5rem; left: .5rem; z-index: 1000; display: flex; flex-direction: column; gap: .25rem; }
.map-legend {
  position: absolute; bottom: 1.5rem; right: .5rem; z-index: 1000; background: rgba(255,255,255,.92);
  border-radius: .375rem; box-shadow: 0 1px 3px rgba(0,0,0,.2); padding: .25rem .5rem; font-size: 11px; line-height: 1rem;
}
.map-legend summary { cursor: pointer; font-weight: 600; color: #334155; list-style: none; }
.map-legend summary::-webkit-details-marker { display: none; }
.map-legend summary::before { content: "▸ "; }
.map-legend[open] summary::before { content: "▾ "; }

/* ---------- app layout: desktop split screen ---------- */
html, body { height: 100%; }
body.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
#workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
#panel-photo { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
#panel-right { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
#panel-map { position: relative; height: 45%; min-height: 260px; flex-shrink: 0; }
#panel-calc { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
#tabbar { display: none; }

/* ---------- phone & tablet: one panel at a time + bottom tab bar ---------- */
@media (max-width: 1023.98px) {
  #workspace { display: block; position: relative; }
  #panel-photo, #panel-right { position: absolute; inset: 0; }
  body[data-tab="photo"] #panel-right,
  body:not([data-tab="photo"]) #panel-photo { display: none; }
  #panel-map { height: 100%; min-height: 0; }
  body[data-tab="map"] #panel-calc,
  body[data-tab="calc"] #panel-map { display: none; }
  #panel-calc { padding-bottom: 1.5rem; }

  #tabbar {
    display: flex; flex-shrink: 0; background: #fff; border-top: 1px solid #e2e8f0;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 8px rgba(15, 23, 42, .06);
  }
  .tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: .1rem;
    padding: .45rem 0 .4rem; font-size: .7rem; color: #64748b; position: relative;
    -webkit-tap-highlight-color: transparent;
  }
  .tab-icon { font-size: 1.15rem; line-height: 1.3rem; filter: grayscale(1); opacity: .7; }
  .tab.active { color: #0f172a; font-weight: 600; }
  .tab.active .tab-icon { filter: none; opacity: 1; }
  .tab.active::before {
    content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px;
    border-radius: 0 0 3px 3px; background: #f59e0b;
  }
  .tab-badge {
    position: absolute; top: .25rem; left: calc(50% + .6rem); min-width: 1rem; height: 1rem; padding: 0 .25rem;
    border-radius: 999px; font-size: .6rem; line-height: 1rem; font-weight: 700; color: #fff; background: #16a34a;
  }
  .tab-badge:empty { display: none; }

  /* compact, horizontally scrollable photo toolbar */
  .toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .toolbar::-webkit-scrollbar { display: none; }
  .toolbar .btn { flex-shrink: 0; }

  /* larger touch targets; 16px inputs stop iOS from zooming on focus */
  .btn { padding: .45rem .7rem; font-size: .85rem; min-height: 2.5rem; }
  .input { font-size: 16px; padding: .5rem .6rem; }
  .seg { padding: .5rem .7rem; }
  .map-tools { bottom: 1.75rem; }
  .map-tools .btn { min-height: 2.5rem; }
}
@media (max-width: 639.98px) {
  .lbl-long { display: none; }
  .lbl-short { display: inline; }
  .map-tools .btn span { display: none; }
  .map-tools .btn { font-size: 1.15rem; padding: .35rem .6rem; }
  .topbar { gap: .5rem; }
}
