/* Planner – hand-written CSS. Only what Tailwind utilities cannot express.
   Everything else lives as Tailwind classes in the templates. */

/* ---- Global helpers -------------------------------------------------- */

[hidden] { display: none !important; }

/* Fallback focus ring (Tailwind `focus-visible:` classes are preferred, this covers
   elements that forgot them, e.g. server-rendered fragments). */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--color-brand-500, #e9b52f);
  outline-offset: 2px;
}

/* ---- Sprite icons ---------------------------------------------------- */

.icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.125em;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-spin { animation: icon-spin 1s linear infinite; }
@keyframes icon-spin { to { transform: rotate(360deg); } }

/* ---- Loading bar (top of viewport) ----------------------------------- */

.loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 80;
  pointer-events: none;
  opacity: 0;
  overflow: hidden;
  transition: opacity 0.2s ease;
}
.loading-bar::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 40%;
  background: var(--color-brand-500, #e9b52f);
  transform: translateX(-100%);
}
.loading-bar.is-active { opacity: 1; }
.loading-bar.is-active::before { animation: loading-bar-slide 1.2s ease-in-out infinite; }
@keyframes loading-bar-slide {
  0%   { transform: translateX(-100%); }
  60%  { transform: translateX(150%); }
  100% { transform: translateX(250%); }
}

/* ---- Running timer indicator ----------------------------------------- */

.pulse-dot {
  position: relative;
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  background: currentColor;
}
.pulse-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: inherit;
  animation: pulse-dot 1.4s ease-out infinite;
}
@keyframes pulse-dot {
  0%   { transform: scale(1);   opacity: 0.7; }
  100% { transform: scale(2.6); opacity: 0; }
}

/* ---- Overlay root: dropdowns, popovers, combobox lists (z 50) --------- */

#overlay-root { position: relative; z-index: 50; }

.popover {
  position: fixed;
  z-index: 50;
  min-width: 10rem;
  max-width: min(28rem, calc(100vw - 1rem));
  max-height: calc(100vh - 1rem);
  overflow: auto;
  border-radius: 0.5rem;
  border: 1px solid var(--color-slate-200, #e3e6ea);
  background: #fff;
  color: var(--color-slate-900, #1d1f21);
  box-shadow: 0 10px 25px -5px rgb(0 0 0 / 0.15), 0 4px 10px -6px rgb(0 0 0 / 0.1);
}
.dark .popover {
  border-color: var(--color-slate-700, #353536);
  background: var(--color-slate-800, #25282c);
  color: var(--color-slate-100, #f1f3f5);
}

/* ---- Drag & drop (planning grid) ------------------------------------- */

.drag-overlay {
  position: fixed;
  z-index: 55;
  pointer-events: none;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-slate-900, #1d1f21);
  background: var(--color-brand-400, #f6c343);
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.25);
  transform: translate(-50%, -120%);
  white-space: nowrap;
}
.is-dragging { cursor: grabbing !important; user-select: none; }
.is-dragging * { cursor: grabbing !important; }
[data-alloc].is-drag-source { opacity: 0.35; }
[data-grid-cell].is-drop-target { outline: 2px solid var(--color-brand-500, #e9b52f); outline-offset: -2px; }
[data-grid-cell].is-drop-invalid { outline: 2px solid rgb(239 68 68); outline-offset: -2px; }

/* ---- Range selection (drag across the cells of one row) --------------- */

.is-range-dragging { user-select: none; }
.is-range-dragging [data-grid-cell] { cursor: cell !important; }
[data-grid-cell].is-range-selected {
  outline: 2px solid var(--color-brand-500, #e9b52f);
  outline-offset: -2px;
  box-shadow: inset 0 0 0 999px rgb(233 181 47 / 0.16);
}

/* ---- Grid columns: width variable set by grid.js ---------------------- */

[data-grid] table { table-layout: fixed; }
[data-grid] col[data-day]     { width: var(--grid-col, 120px); }
[data-grid] col[data-day][data-weekend][data-empty] { width: var(--grid-col-weekend, 40px); }

/* ---- Grab-to-scroll containers --------------------------------------- */

[data-grab-scroll] { cursor: grab; }
[data-grab-scroll].is-grabbing { cursor: grabbing; user-select: none; }

/* ---- Sticky column shadow (z-index: heads 10, columns 20) ------------ */

.sticky-col {
  position: sticky;
  left: 0;
  z-index: 20;
  background: inherit;
}
.sticky-col::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  right: -6px;
  width: 6px;
  pointer-events: none;
  background: linear-gradient(to right, rgb(0 0 0 / 0.08), transparent);
}
.dark .sticky-col::after {
  background: linear-gradient(to right, rgb(0 0 0 / 0.4), transparent);
}

/* ---- Modal / scroll lock --------------------------------------------- */

body.modal-open { overflow: hidden; }

/* ---- Toasts -------------------------------------------------------- */

.toast-enter { animation: toast-in 0.18s ease-out; }
.toast-leave { animation: toast-out 0.15s ease-in forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(0.5rem); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(0.5rem); } }

@media (prefers-reduced-motion: reduce) {
  .toast-enter, .toast-leave, .loading-bar.is-active::before, .pulse-dot::after, .icon-spin { animation: none; }
}

/* ---- Print --------------------------------------------------------- */

@media print {
  aside, header, nav, #toast-container, #modal-container, #overlay-root, #loading-bar,
  [data-no-print], .no-print { display: none !important; }
  main { padding: 0 !important; }
  body { background: #fff !important; color: #000 !important; }
  a[href]::after { content: none !important; }
  table { break-inside: auto; }
  tr { break-inside: avoid; }
}

/* ---- Page-specific ---------------------------------------------------- */

/* Team calendar: weekend shading (CSS variable used by the grid). */
[data-team-calendar-page] { --tc-we: var(--color-slate-100); }
.dark [data-team-calendar-page] { --tc-we: var(--color-slate-800); }

/* Roles editor: flash rows whose permissions were set automatically (dependencies). */
[data-perm-row] { transition: background-color .6s; }
[data-perm-row].perm-auto { background-color: rgba(34, 135, 219, 0.12); transition: background-color .3s; }
.dark [data-perm-row].perm-auto { background-color: rgba(74, 160, 230, 0.2); }

/* ---- Tooltips (static/js/tooltip.js) ---------------------------------- */

/* Above modals (60) and toasts (70), below the loading bar (80). */
.tooltip {
  position: fixed;
  z-index: 75;
  max-width: 22rem;
  padding: 0.375rem 0.5rem;
  border-radius: 0.375rem;
  background: var(--color-slate-900);
  color: #fff;
  font-size: 0.75rem;
  line-height: 1.35;
  white-space: pre-line;
  overflow-wrap: anywhere;
  pointer-events: none;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.18);
}
.dark .tooltip {
  background: var(--color-slate-100);
  color: var(--color-slate-900);
}
