/* ─── Compliance Calendar Widget ─────────────────────────────────────────── */

/* Container query breakpoints (applied to the .ccw-root container):
   - Micro  (<= 260px wide OR <= 2 grid rows tall) → dot-only minimal view
   - Mini   (261–480px wide)                        → compact grid + dot legend
   - Full   (> 480px wide)                          → full calendar cells with event pills
*/

.ccw-root {
  container-type: size;
  container-name: ccw;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.ccw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px 6px;
  flex-shrink: 0;
  gap: 4px;
}

/* Compact header for micro mode — halve vertical padding */
.ccw-header-micro {
  padding-top: 4px;
  padding-bottom: 3px;
}

.ccw-month-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--foreground);
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex: 1;
  text-align: center;
}

/* \u2500\u2500 Jump picker wrapper \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.ccw-month-label-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.ccw-month-label-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  color: var(--foreground);
}

.ccw-month-label-btn:hover,
.ccw-month-label-btn--open {
  background: color-mix(in oklch, var(--primary) 10%, transparent);
  color: var(--primary);
}

.ccw-jump-chevron {
  opacity: 0.5;
  transition: transform 0.15s ease, opacity 0.15s ease;
  flex-shrink: 0;
}

.ccw-month-label-btn--open .ccw-jump-chevron {
  transform: rotate(180deg);
  opacity: 1;
}

/* \u2500\u2500 Dropdown panel \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
.ccw-jump-picker {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.14), 0 2px 6px rgba(0,0,0,0.08);
  padding: 8px;
  min-width: 160px;
  animation: ccw-picker-in 0.12s ease;
}

@keyframes ccw-picker-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-4px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Year row */
.ccw-jump-year-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.ccw-jump-yr-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  flex-shrink: 0;
  padding: 0;
}

.ccw-jump-yr-btn:hover {
  background: color-mix(in oklch, var(--primary) 10%, transparent);
  color: var(--primary);
}

.ccw-jump-yr-input {
  flex: 1;
  text-align: center;
  background: transparent;
  border: none;
  font-size: 12px;
  font-weight: 700;
  color: var(--foreground);
  outline: none;
  width: 0; /* let flex size it */
  min-width: 0;
  /* hide number spinners */
  -moz-appearance: textfield;
}
.ccw-jump-yr-input::-webkit-inner-spin-button,
.ccw-jump-yr-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* Month grid — 4 columns \u00d7 3 rows */
.ccw-jump-months {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
}

.ccw-jump-month-btn {
  font-size: 10px;
  font-weight: 600;
  padding: 5px 2px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: background 0.1s ease, color 0.1s ease;
  text-align: center;
}

.ccw-jump-month-btn:hover {
  background: color-mix(in oklch, var(--primary) 10%, transparent);
  color: var(--primary);
}

.ccw-jump-month-btn--active {
  background: var(--primary);
  color: var(--primary-foreground) !important;
}

.ccw-jump-month-btn--today:not(.ccw-jump-month-btn--active) {
  border: 1px solid color-mix(in oklch, var(--primary) 40%, transparent);
  color: var(--primary);
}

.ccw-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
  padding: 0;
}

.ccw-nav-btn:hover {
  background: color-mix(in oklch, var(--primary) 10%, transparent);
  color: var(--primary);
}

.ccw-today-btn {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid color-mix(in oklch, var(--primary) 30%, transparent);
  background: color-mix(in oklch, var(--primary) 8%, transparent);
  color: var(--primary);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
  line-height: 1.6;
}

.ccw-today-btn:hover {
  background: color-mix(in oklch, var(--primary) 16%, transparent);
}

/* ── Day-of-week header row ─────────────────────────────────────────────── */
.ccw-dow-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 0 6px;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.ccw-dow-cell {
  text-align: center;
  font-size: 9px;
  font-weight: 600;
  color: var(--muted-foreground);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 0;
}

/* ── Calendar grid ──────────────────────────────────────────────────────── */
.ccw-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  flex: 1;
  min-height: 0;
  padding: 0 6px 6px;
  gap: 2px;
}

/* ── Day cell — minimal (dot) mode ─────────────────────────────────────── */
.ccw-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  border-radius: 6px;
  padding: 3px 1px 2px;
  cursor: pointer;
  transition: background 0.12s ease;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

.ccw-day:hover {
  background: color-mix(in oklch, var(--primary) 6%, transparent);
}

.ccw-day.ccw-today .ccw-day-num {
  background: var(--primary);
  color: var(--primary-foreground);
}

.ccw-day.ccw-other-month .ccw-day-num {
  color: var(--muted-foreground);
  opacity: 0.4;
}

/* ── Micro mode: entire cell = one dot, no number ───────────────────────── */
.ccw-day.ccw-micro-mode {
  justify-content: center;
  align-items: center;
  padding: 2px;
}

/* Today ring in micro mode */
.ccw-day.ccw-micro-mode.ccw-today .ccw-micro-dot {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.ccw-micro-dot {
  /* Fills most of the cell — min 5px so it doesn't disappear entirely */
  width: clamp(5px, 60%, 14px);
  height: clamp(5px, 60%, 14px);
  border-radius: 50%;
  flex-shrink: 0;
  display: block;
  box-sizing: border-box;
}

.ccw-day-num {
  font-size: 10px;
  font-weight: 600;
  color: var(--foreground);
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  line-height: 1;
  transition: background 0.12s ease, color 0.12s ease;
}

/* Dot cluster below the day number */
.ccw-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  justify-content: center;
  margin-top: 2px;
  max-width: 100%;
}

.ccw-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Day cell — full (pill) mode ────────────────────────────────────────── */
.ccw-day.ccw-full-mode {
  align-items: stretch;
  padding: 3px 3px 2px;
  flex-direction: column;
  gap: 2px;
}

.ccw-day.ccw-full-mode .ccw-day-num {
  align-self: center;
  font-size: 11px;
  margin-bottom: 1px;
}

.ccw-pill {
  font-size: 9px;
  font-weight: 600;
  border-radius: 3px;
  padding: 1px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
  width: 100%;
}

/* overflow count */
.ccw-overflow {
  font-size: 8px;
  color: var(--muted-foreground);
  font-weight: 600;
  padding-left: 2px;
}

/* ── Legend strip (compact mode) ────────────────────────────────────────── */
.ccw-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 4px 8px 6px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}

.ccw-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  color: var(--muted-foreground);
  font-weight: 500;
}

.ccw-legend-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Loading shimmer ─────────────────────────────────────────────────────── */
.ccw-shimmer {
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--muted) 0%,
    color-mix(in oklch, var(--muted) 80%, var(--primary) 20%) 50%,
    var(--muted) 100%
  );
  background-size: 400px 100%;
  animation: ccw-shimmer 1.3s ease-in-out infinite;
}

@keyframes ccw-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}

/* ── Go to calendar link ─────────────────────────────────────────────────── */
.ccw-open-link {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--primary);
  padding: 4px 10px 6px;
  flex-shrink: 0;
  cursor: pointer;
  text-decoration: none;
  opacity: 0.8;
  transition: opacity 0.15s;
  justify-content: flex-end;
}

.ccw-open-link:hover {
  opacity: 1;
}
