/* Drill illustration editor.
 *
 * Light theme aligned with the rest of the app (Bootstrap 5 defaults). The
 * pitch green is the one piece intentionally bright — that's the canvas.
 * Selection highlights stay sky-blue for contrast against grass.
 */

/* ---- the placeholder card on the drill form ------------------------- */
.illu-placeholder {
  border: 2px dashed #c4cbd2;
  border-radius: 0.5rem;
  padding: 1.6rem 1rem;
  text-align: center;
  background: #f8f9fa;
}
.illu-ph-icon {
  font-size: 2.1rem;
  color: #9aa3ad;
  line-height: 1;
}
.illu-preview-wrap {
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  overflow: hidden;
  background: #1c7a4d; /* pitch green so a transparent PNG still looks intentional */
  display: block;
}
.illu-preview-wrap img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 320px;
  object-fit: contain;
}
.illu-caption {
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.25rem 0.55rem;
  border-radius: 0.35rem;
}
.illu-caption.illu-cap-editor { background: #d1e7dd; color: #0a3622; }
.illu-caption.illu-cap-photo { background: #e9ecef; color: #495057; }

/* ---- the overlay scaffold ------------------------------------------- */
.illu-overlay {
  position: fixed;
  inset: 0;
  z-index: 1080;
  background: #ffffff;
  display: flex;
  color: #1f2937;
}
.illu-overlay.d-none { display: none !important; }

.illu-sidebar {
  width: 320px;
  flex: 0 0 320px;
  background: #f8f9fa;
  border-right: 1px solid #dee2e6;
  overflow-y: auto;
  padding: 1rem 1rem 1.25rem;
}
.illu-sidebar h2,
.illu-props-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: #495057;
}

/* ---- collapsible panel chrome (sidebar + properties) --------------- */
.illu-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}
.illu-collapse-btn,
.illu-expand-tab {
  border: 1px solid #ced4da;
  background: #ffffff;
  color: #495057;
  border-radius: var(--pc-radius-sm, 10px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.2rem 0.4rem;
  font-size: 0.85rem;
  line-height: 1;
  flex: 0 0 auto;
}
.illu-collapse-btn:hover,
.illu-expand-tab:hover { background: #f1f3f5; border-color: #adb5bd; }
/* The expand tab is only shown once a panel is collapsed. */
.illu-expand-tab { display: none; flex-direction: column; }

.illu-sidebar.illu-collapsed,
.illu-props.illu-collapsed {
  width: 44px;
  flex: 0 0 44px;
  padding: 0.5rem 0;
  overflow: hidden;
  align-items: center;
}
.illu-sidebar.illu-collapsed,
.illu-props.illu-collapsed { display: flex; flex-direction: column; }
.illu-sidebar.illu-collapsed .illu-panel-head,
.illu-sidebar.illu-collapsed [data-illu-sidebar-slot],
.illu-props.illu-collapsed .illu-panel-head,
.illu-props.illu-collapsed .illu-props-empty,
.illu-props.illu-collapsed [data-illu-props-content] { display: none; }
.illu-sidebar.illu-collapsed .illu-expand-tab,
.illu-props.illu-collapsed .illu-expand-tab { display: flex; }

.illu-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.illu-topbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.9rem;
  background: #ffffff;
  border-bottom: 1px solid #dee2e6;
  flex: 0 0 auto;
}
.illu-topbar .illu-title {
  font-weight: 600;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-right: 0.4rem;
}
.illu-topbar label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6c757d;
  margin: 0 0.1rem;
}
.illu-topbar .form-select-sm { width: auto; }
.illu-topbar .spacer { flex: 1; }
.illu-gscale {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: #f8f9fa;
  border: 1px solid #ced4da;
  border-radius: 0.375rem;
  padding: 0.15rem 0.5rem;
}
.illu-gscale input[type="range"] { width: 96px; }
.illu-gscale b {
  font-size: 0.78rem;
  color: #495057;
  min-width: 38px;
  text-align: right;
  font-weight: 500;
}

.illu-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* ---- palette --------------------------------------------------------- */
.illu-palette {
  width: 212px;
  flex: 0 0 212px;
  background: #ffffff;
  border-right: 1px solid #dee2e6;
  overflow-y: auto;
  padding: 0.6rem;
}
.illu-pal-group {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #6c757d;
  margin: 0.7rem 0.2rem 0.35rem;
  font-weight: 600;
}
.illu-pal-group:first-child { margin-top: 0.2rem; }
.illu-tool-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-align: left;
  background: #ffffff;
  color: #212529;
  border: 1px solid #ced4da;
  border-radius: var(--pc-radius-sm, 10px);
  padding: 0.34rem 0.5rem;
  margin-bottom: 0.3rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s;
}
.illu-tool-btn:hover { background: #f1f3f5; border-color: #adb5bd; }
.illu-tool-btn.armed { background: rgba(240,101,74,0.10); border-color: #F0654A; color: #7A2215; }
.illu-tool-btn svg { flex: 0 0 26px; }

/* ---- canvas --------------------------------------------------------- */
.illu-canvas-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: radial-gradient(circle at 50% 35%, #f1f3f5, #dee2e6 80%);
  position: relative;
}
.illu-canvas-wrap > svg {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border-radius: 0.5rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  touch-action: none;
}
.illu-canvas-wrap > svg.illu-drawing { cursor: crosshair; }
.illu-obj { cursor: grab; }

.illu-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  background: rgba(33, 37, 41, 0.85);
  color: #f8f9fa;
  font-size: 0.76rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  pointer-events: none;
}
.illu-draw-banner {
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  background: var(--pc-accent, #F0654A);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(240,101,74,0.30);
}

/* ---- properties panel ---------------------------------------------- */
.illu-props {
  width: 262px;
  flex: 0 0 262px;
  background: #ffffff;
  border-left: 1px solid #dee2e6;
  overflow-y: auto;
  padding: 0.8rem 0.85rem;
}
.illu-props-empty {
  color: #6c757d;
  font-size: 0.85rem;
  text-align: center;
  padding-top: 2.5rem;
}
.illu-props-empty i {
  font-size: 1.8rem;
  display: block;
  margin-bottom: 0.5rem;
  color: #ced4da;
}
.illu-props-head {
  font-weight: 600;
  font-size: 1rem;
  border-bottom: 1px solid #dee2e6;
  padding-bottom: 0.45rem;
  margin-bottom: 0.7rem;
}
.illu-prop-row { margin-bottom: 0.85rem; }
.illu-prop-row > label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6c757d;
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 500;
}
.illu-prop-note {
  font-size: 0.76rem;
  color: #495057;
  background: #fff3cd;
  border-left: 3px solid #ffc107;
  padding: 0.4rem 0.55rem;
  border-radius: 0.25rem;
  margin-top: 0.2rem;
}
.illu-prop-actions {
  border-top: 1px solid #dee2e6;
  padding-top: 0.7rem;
}

.illu-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.32rem;
}
.illu-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #dee2e6;
  padding: 0;
}
.illu-swatch.active {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px #38bdf8;
}

.illu-seg .btn { font-size: 0.78rem; }
.illu-seg .btn-check:checked + .btn {
  background: var(--pc-accent, #F0654A);
  border-color: var(--pc-accent, #F0654A);
  color: #ffffff;
}

/* ---- compact form inputs in the sidebar ----------------------------- */
.illu-sidebar .mb-3 { margin-bottom: 0.75rem !important; }
.illu-sidebar .form-label { font-size: 0.85rem; margin-bottom: 0.25rem; }
.illu-sidebar textarea.form-control { min-height: 0; }

/* ---- responsive fallback ------------------------------------------- */
/* The editor is designed for desktop / tablet-landscape. Below 1100px the
   drill-details sidebar narrows; below 820px it hides entirely (the coach
   can still close the editor briefly to touch those fields). Below 680px
   the palette + properties stack vertically — usable but cramped.
   Coaches on phones are expected to use the upload-from-camera path. */
@media (max-width: 1280px) {
  .illu-sidebar { width: 260px; flex: 0 0 260px; padding: 0.75rem; }
  .illu-palette { width: 184px; flex: 0 0 184px; }
  .illu-props { width: 220px; flex: 0 0 220px; }
}
@media (max-width: 1080px) {
  .illu-sidebar { width: 220px; flex: 0 0 220px; }
  .illu-palette { width: 168px; flex: 0 0 168px; }
  .illu-props { width: 200px; flex: 0 0 200px; }
}
@media (max-width: 920px) {
  .illu-sidebar { display: none; }
}
@media (max-width: 680px) {
  .illu-body { flex-direction: column; }
  .illu-palette { width: 100%; flex: 0 0 auto; height: 200px; }
  .illu-props { width: 100%; flex: 0 0 auto; max-height: 240px; }
}

/* Phones: the editor is drag-heavy and needs room, so it stays a
   desktop / tablet-landscape tool. Keep the upload path (camera / gallery)
   as the mobile route by hiding the editor entry points; Replace / Remove
   stay available so a coach can still swap a photo on their phone. */
@media (max-width: 575.98px) {
  [data-illu-placeholder] [data-illu-action="open-editor"],
  [data-illu-placeholder] [data-illu-action="edit"] {
    display: none !important;
  }
}
