/* ═══════════════════════════════════════════════════════════════════════════
   Delivery Calendar — Ordinex
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Layout ──────────────────────────────────────────────────────────────── */
body { min-height: 100dvh; background: var(--bg-0); }

/* Embedded in the admin's iframe: the page header duplicates the admin
   header, so it's hidden and the month nav becomes the top row. */
.embedded .cal-header { display: none; }
.embedded .cal-month-nav { padding-top: 10px; }

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: var(--surface-flat);
  border-bottom: 1px solid var(--border-strong);
  position: sticky;
  top: 0;
  z-index: 100;
}

.cal-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cal-logo { height: 34px; width: auto; }

.cal-title {
  font-family: var(--display);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
}

.cal-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cal-nav-btn {
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.cal-nav-btn:hover { background: var(--border); color: var(--text); }

.cal-back-btn {
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.cal-back-btn:hover { background: var(--border); color: var(--text); }

/* ── Month nav ────────────────────────────────────────────────────────────── */
.cal-month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px 20px 8px;
}

.cal-month-label {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  min-width: 220px;
  text-align: center;
}

.cal-arrow {
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: 16px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast), color var(--t-fast);
}
.cal-arrow:hover { background: var(--border); color: var(--text); }

/* ── Legend ──────────────────────────────────────────────────────────────── */
.cal-legend {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: center;
  padding: 0 20px 14px;
  flex-wrap: wrap;
}
.cal-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.cal-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Grid ─────────────────────────────────────────────────────────────────── */
.cal-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px 60px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.cal-day-header {
  background: var(--surface-flat);
  padding: 8px 4px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cal-day {
  background: var(--bg-1);
  min-height: 90px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  cursor: default;
}
.cal-day.other-month { background: var(--bg-0); opacity: 0.5; }
.cal-day.weekend:not(.other-month) { background: var(--bg-0); }
.cal-day.today {
  background: var(--surface-flat-2);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.cal-day-num {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1;
  margin-bottom: 2px;
}
/* Today's number gets the filled accent circle — visible at a glance */
.cal-day.today .cal-day-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

/* ── Delivery chips inside day cells ─────────────────────────────────────── */
.cal-chip {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: opacity var(--t-fast);
  line-height: 1.4;
}
.cal-chip:hover { opacity: 0.8; }
/* The label is "CODE · Project name" (review P6): it truncates, never widens a day. */
.cal-day, .cal-chip { min-width: 0; }
.cal-chip-lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-chip[draggable="true"] { cursor: grab; }
.cal-chip[draggable="true"]:active { cursor: grabbing; }
.cal-day.drag-over {
  background: var(--focus-ring);
  outline: 2px dashed var(--focus);
  outline-offset: -2px;
}
/* Delivery-status legend — semantic data colors (tokenized where a token exists;
   on_hold purple has no brand token and stays as its own status color).
   These are the dark-tuned (v485) values, unchanged as the default/dark
   rendering — see the light-only override block below. */
.cal-chip.requested   { background: rgba(245,158,11,0.18); color: var(--warning); }
.cal-chip.on_schedule { background: rgba(90,169,240,0.18);  color: var(--info); }
.cal-chip.on_hold     { background: rgba(139,92,246,0.18);  color: #a78bfa; }
.cal-chip.delivered   { background: rgba(34,197,94,0.18);   color: var(--success); }

/* Light theme only: the fixed bright hues above read 1.8-2.1:1 as this
   chip's own text against its local translucent wash (computed WCAG,
   task-4-report.md) — an unreadable status label, not decoration. Swap to
   darker text-safe siblings; dark keeps the block above verbatim (v485).
   "delivered" needs a stronger green than the shared --success-ink
   (#15803d only clears 4.08:1 against THIS wash) — #166534 clears 5.80:1. */
[data-theme="light"] .cal-chip.requested   { color: var(--warning-ink); }
[data-theme="light"] .cal-chip.on_schedule { color: var(--info-ink); }
[data-theme="light"] .cal-chip.on_hold     { color: #6d28d9; }
[data-theme="light"] .cal-chip.delivered   { color: #166534; }

.cal-more {
  font-size: 10px;
  color: var(--text-muted);
  padding: 1px 4px;
}

/* ── Loading / empty ──────────────────────────────────────────────────────── */
.cal-loading {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 60px 20px;
}

/* ── Popover ──────────────────────────────────────────────────────────────── */
.cal-popover {
  position: fixed;
  background: var(--surface-flat);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 14px 16px;
  z-index: 500;
  min-width: 220px;
  max-width: 300px;
}
.cal-popover-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}
.cal-popover-project {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  padding-right: 20px;
}
.cal-popover-row {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.5;
}
.cal-popover-status {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  margin-top: 6px;
}

/* ── Mobile tweaks ────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .cal-day { min-height: 64px; padding: 4px; }
  .cal-chip { font-size: 10px; padding: 1px 4px; }
  .cal-month-label { font-size: 16px; min-width: 160px; }
}
