/* ── Full-page container ── */
.planner-outer {
  position: fixed;
  top: 3.5rem;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  overflow: hidden;
  background: #fff;
  z-index: 1;
}

/* ── Sidebar ── */
.planner-sidebar {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 2px solid #dee2e6;
  overflow-y: auto;
  background: #f8f9fa;
}

.planner-sidebar-section {
  padding: 10px 12px;
}

.planner-sidebar-section h6 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #6c757d;
  margin-bottom: 6px;
  margin-top: 0;
}

.planner-sidebar-sights {
  flex: 1;
  overflow-y: auto;
}

.planner-sidebar-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
}

.planner-sidebar-toolbar-label {
  flex: 1;
  font-size: 11px;
  color: #495057;
}

.planner-add-day-row {
  display: flex;
  gap: 4px;
}

.planner-add-day-btn {
  flex: 1;
  font-size: 11px;
  padding: 4px 6px;
  border: 1px dashed #adb5bd;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  color: #6c757d;
  white-space: nowrap;
  text-align: center;
}

.planner-add-day-btn:hover {
  background: #e9ecef;
  color: #343a40;
}

.planner-corner-btn {
  font-size: 13px;
  font-weight: bold;
  border: 1px solid #dee2e6;
  border-radius: 3px;
  background: white;
  padding: 1px 6px;
  line-height: 18px;
  cursor: pointer;
  color: #495057;
  flex-shrink: 0;
}

.planner-corner-btn:hover {
  background: #e9ecef;
}

.planner-jump-btn {
  display: block;
  width: 100%;
  text-align: left;
  font-size: 11px;
  padding: 4px 6px;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  background: white;
  margin-bottom: 4px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.planner-jump-btn:hover {
  background: #e9ecef;
}

.planner-sidebar-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  background: white;
  margin-bottom: 6px;
  cursor: grab;
  user-select: none;
  touch-action: none;
  font-size: 12px;
}

.planner-sidebar-card:active {
  cursor: grabbing;
}

.planner-sidebar-card img {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 3px;
  flex-shrink: 0;
}

.planner-sidebar-card:hover {
  border-color: #adb5bd;
  background: #f1f3f5;
}

/* Mobile sidebar toggle + backdrop — hidden on desktop, where the sidebar is
   always visible inline. */
.planner-sidebar-toggle-btn {
  display: none;
}

.planner-sidebar-backdrop {
  display: none;
}

/* ── Main scroll area ── */
.planner-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  position: relative;
  background: #f0f0f0;
}

/* Global SVG overlay (connection arrows spanning all days) */
.planner-global-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 6;
}

.planner-arrow {
  pointer-events: all;
}

/* ── Day section ── */
.planner-day-section {
  background: #fff;
  border-bottom: 3px solid #adb5bd;
}

.planner-day-section--extra {
  opacity: .9;
}

/* Day header — sticky at top while scrolling through a tall day */
.planner-day-header {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 40px;
  display: flex;
  align-items: center;
  background: #343a40;
  color: #fff;
  border-bottom: 1px solid #495057;
  flex-shrink: 0;
}

.planner-day-header-gutter {
  width: 72px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-right: 1px solid #495057;
  height: 100%;
}

.planner-day-header-info {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 0 12px;
}

.planner-day-label {
  font-size: 13px;
  font-weight: 700;
}

.planner-day-date {
  font-size: 12px;
  opacity: .75;
}

.planner-collapse-day-btn,
.planner-delete-day-btn {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  color: #adb5bd;
  padding: 0 3px;
  line-height: 1.4;
  border-radius: 3px;
}

.planner-collapse-day-btn:hover {
  color: #fff;
  background: rgba(255,255,255,.15);
}

.planner-delete-day-btn {
  opacity: 0;
  transition: opacity .15s;
}

.planner-day-header:hover .planner-delete-day-btn {
  opacity: 1;
}

.planner-delete-day-btn:hover {
  color: #ff6b6b;
  background: rgba(255,255,255,.1);
}

/* Collapsed day indicator */
.planner-day-collapsed-bar {
  height: 24px;
  display: flex;
  align-items: center;
  padding: 0 12px 0 84px;
  font-size: 11px;
  color: #6c757d;
  background: repeating-linear-gradient(
    -45deg,
    #f8f9fa,
    #f8f9fa 4px,
    #e9ecef 4px,
    #e9ecef 8px
  );
}

/* ── Day body: flex row, children stretch to fill the explicit height ── */
.planner-day-body {
  display: flex;
  /* height set via inline style; default align-items:stretch makes children fill it */
}

/* Time gutter — left column; hour rows are absolutely positioned to follow collapsed ranges */
.planner-time-gutter {
  width: 72px;
  flex-shrink: 0;
  position: relative;
  background: #f8f9fa;
  border-right: 2px solid #dee2e6;
  overflow: hidden;
}

/* One row per non-collapsed hour — top/height set via inline style; click to collapse */
.planner-hour-row {
  position: absolute;
  left: 0;
  right: 0;
  box-sizing: border-box;
  border-top: 1px solid #dee2e6;
  padding: 2px 4px 0;
  font-size: 11px;
  font-weight: 600;
  color: #555;
  overflow: hidden;
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
}

.planner-hour-row:hover {
  background: rgba(0,0,0,.05);
}

/* ── Grid area — flex:1, stretches to body height ── */
.planner-grid-area {
  flex: 1;
  position: relative;   /* containing block for hour lines and cards */
  min-width: 0;
  /* Checkerboard: white/light-gray 10×10px squares (tile = 2× cell size) */
  background-image: repeating-conic-gradient(#fff 0% 25%, #e9e9e9 0% 50%);
  background-size: 20px 20px;
}

/* Dashed hour lines — one per hour, rendered as absolute divs */
.planner-hour-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 1px dashed #888;
  pointer-events: none;
  z-index: 2;
}

/* ── Collapse band (compressed time range strip) ── */
.planner-collapse-band {
  position: absolute;
  left: 0;
  right: 0;
  background: rgba(108,117,125,.1);
  border-top: 1px dashed #adb5bd;
  border-bottom: 1px dashed #adb5bd;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 10px;
  color: #6c757d;
  cursor: pointer;
  z-index: 2;
  white-space: nowrap;
  overflow: hidden;
}

.planner-collapse-band:hover {
  background: rgba(108,117,125,.2);
}

.planner-collapse-band--gutter {
  position: absolute;
  left: 0;
  right: 0;
  background: rgba(108,117,125,.08);
  border-top: 1px dashed #adb5bd;
  border-bottom: 1px dashed #adb5bd;
  display: flex;
  align-items: center;
  padding: 0 4px;
  font-size: 9px;
  color: #6c757d;
  writing-mode: horizontal-tb;
  overflow: hidden;
  white-space: nowrap;
  cursor: pointer;
}

.planner-collapse-band--gutter:hover {
  background: rgba(108,117,125,.18);
}

/* ── Placed sight cards ── */
.planner-sight-card {
  position: absolute;
  background: white;
  border: 1.5px solid #74b9ff;
  border-radius: 5px;
  overflow: hidden;
  cursor: grab;
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
  display: flex;
  flex-direction: column;
  z-index: 3;
  user-select: none;
  touch-action: none;
  transition: box-shadow .1s;
}

.planner-sight-card:active {
  cursor: grabbing;
}

.planner-sight-card:hover {
  box-shadow: 0 2px 10px rgba(0,0,0,.2);
  border-color: #0984e3;
  z-index: 10;
}

.planner-sight-card:hover .planner-card-actions {
  opacity: 1;
}

.planner-sight-card--connectable {
  border-color: #00b894;
  cursor: crosshair;
}

.planner-card-thumb {
  width: 100%;
  height: 32px;
  object-fit: cover;
  flex-shrink: 0;
  -webkit-user-drag: none;
}

.planner-card-content {
  padding: 2px 6px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.planner-card-content strong {
  display: block;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.planner-card-content small {
  font-size: 10px;
  color: #6c757d;
}

.planner-card-desc {
  margin: 2px 0;
  font-size: 10px;
  color: #495057;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.planner-card-actions {
  position: absolute;
  top: 2px;
  right: 2px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity .15s;
  z-index: 4;
}

.planner-card-action-btn {
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 3px;
  background: rgba(255,255,255,.9);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #495057;
  padding: 0;
}

.planner-card-action-btn:hover {
  background: #e9ecef;
}

.planner-card-action-btn--delete:hover {
  background: #ffe0e0;
  color: #dc3545;
}

/* Vertical resize handle — drag bottom edge to change duration */
.planner-resize-handle {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 6px;
  cursor: ns-resize;
  touch-action: none;
  background: linear-gradient(to bottom, transparent, rgba(0,120,212,.35));
  z-index: 4;
}

/* ── Connect mode toolbar ── */
.planner-connect-bar {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: #0984e3;
  color: white;
  border-radius: 24px;
  padding: 8px 20px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
}

.planner-connect-bar button {
  border: 1.5px solid white;
  border-radius: 12px;
  background: transparent;
  color: white;
  padding: 2px 10px;
  font-size: 12px;
  cursor: pointer;
}

/* ── Modals ── */
.planner-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.planner-modal {
  background: white;
  border-radius: 10px;
  padding: 24px;
  min-width: 320px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}

.planner-modal h3 {
  margin: 0 0 16px;
  font-size: 16px;
}

.planner-modal-field {
  margin-bottom: 12px;
}

.planner-modal-field label {
  display: block;
  font-size: 12px;
  color: #6c757d;
  margin-bottom: 4px;
}

.planner-modal-field input,
.planner-modal-field select {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  font-size: 13px;
}

.planner-modal-field-row {
  display: flex;
  gap: 8px;
}

.planner-modal-field-row .planner-modal-field {
  flex: 1;
}

.planner-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* ── Transport icon buttons ── */
.planner-transport-options {
  display: flex;
  gap: 6px;
}

.planner-transport-btn {
  flex: 1;
  padding: 6px 4px;
  border: 1.5px solid #dee2e6;
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-size: 18px;
  text-align: center;
  transition: border-color .15s, background .15s;
}

.planner-transport-btn.active {
  border-color: #0984e3;
  background: #e8f4fd;
}

/* ── Collapse ranges panel ── */
.planner-collapse-panel {
  position: fixed;
  top: 3.5rem;
  right: 0;
  bottom: 0;
  width: 300px;
  background: white;
  border-left: 2px solid #dee2e6;
  z-index: 50;
  overflow-y: auto;
  padding: 16px;
  box-shadow: -4px 0 16px rgba(0,0,0,.08);
}

.planner-collapse-panel h5 {
  margin: 0 0 12px;
  font-size: 14px;
}

.planner-range-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 13px;
}

.planner-range-row label {
  flex: 1;
  min-width: 0;
}

.planner-range-label {
  font-weight: 600;
  display: block;
}

.planner-range-times {
  font-size: 11px;
  color: #6c757d;
}

/* ── No-dates warning ── */
.planner-no-dates {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: #495057;
  text-align: center;
  padding: 2rem;
}

.planner-empty {
  padding: 40px;
  text-align: center;
  color: #6c757d;
  font-size: 13px;
}

/* ── Touch devices: enlarge small hit targets, keep card actions discoverable
   without relying on :hover (which touchscreens don't reliably emulate) ── */
@media (pointer: coarse) {
  .planner-resize-handle {
    height: 14px;
  }

  .planner-card-actions {
    opacity: 0.85;
  }

  .planner-card-action-btn {
    width: 22px;
    height: 22px;
    font-size: 12px;
  }
}

/* ── Phones: sidebar becomes an off-canvas drawer instead of a permanent
   220px column, so the timeline gets the full screen width ── */
@media (max-width: 640.98px) {
  .planner-sidebar-toggle-btn {
    display: inline-flex;
    align-items: center;
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 40;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: white;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #343a40;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,.15);
  }

  .planner-sidebar {
    position: fixed;
    top: 3.5rem;
    left: 0;
    bottom: 0;
    width: 80%;
    max-width: 280px;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 4px 0 16px rgba(0,0,0,.2);
  }

  .planner-sidebar--open {
    transform: translateX(0);
  }

  .planner-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 3.5rem 0 0 0;
    background: rgba(0,0,0,.35);
    z-index: 55;
  }

  .planner-modal {
    min-width: 0;
    width: 92%;
    padding: 18px;
  }

  .planner-collapse-panel {
    width: 85vw;
    max-width: 300px;
  }

  .planner-connect-bar {
    width: 92vw;
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
  }

  /* The "☰ Sights" toggle floats over the top-left of the sticky day header;
     push the day label right so it isn't hidden underneath. */
  .planner-day-header-info {
    padding-left: 24px;
  }
}
