/* Monday.com scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #c3c6d4;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #676879;
}

/* Context menu animation */
@keyframes contextMenuImproved {
  from { opacity: 0; transform: scale(0.95) translateY(-2px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.context-menu-enter {
  animation: contextMenuImproved 120ms ease-out;
}

/* Dropdown animation */
@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-enter {
  animation: dropdownIn 150ms ease-out;
}

/* Panel slide */
@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.panel-slide-in {
  animation: slideInRight 200ms ease-out;
}

/* Monday checkbox */
.monday-checkbox {
  width: 16px;
  height: 16px;
  border-radius: var(--apc-hub-radius-sm);
  border: 1.5px solid #C5C7D0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--apc-hub-transition);
  background: white;
  flex-shrink: 0;
}

.monday-checkbox:hover {
  border-color: var(--apc-hub-brand);
}

.monday-checkbox.checked {
  background: var(--apc-hub-brand);
  border-color: var(--apc-hub-brand);
}

/* Status cell full-fill */
.status-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--apc-hub-row-height);
  font-size: 13px;
  font-weight: 500;
  color: white;
  cursor: pointer;
  transition: background-color 200ms ease, opacity var(--apc-hub-transition);
  user-select: none;
}

.status-cell:hover {
  opacity: 0.85;
}

/* Group color bar */
.group-color-bar {
  width: 6px;
  flex-shrink: 0;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ===== Animation Infrastructure ===== */

/* Shimmer gradient sweep for skeleton loaders */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton-shimmer {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

/* Fade in */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.fade-in {
  animation: fadeIn 200ms ease-out both;
}

/* Fade in + slide up for stagger entries */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in-up {
  animation: fadeInUp 300ms ease-out both;
}

/* Scale in for modals */
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.scale-in {
  animation: scaleIn 200ms ease-out both;
}

/* Pulse ring for notification badge */
@keyframes pulseRing {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.8); opacity: 0; }
  100% { transform: scale(1.8); opacity: 0; }
}

.pulse-ring {
  position: relative;
}

.pulse-ring::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 9999px;
  background: #E2445C;
  animation: pulseRing 2s ease-out infinite;
  z-index: -1;
}

/* Spinner rotation */
@keyframes spinnerRotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spinner-rotate {
  animation: spinnerRotate 1s linear infinite;
}

/* Check draw animation for checkbox SVG */
@keyframes checkDraw {
  from { stroke-dashoffset: 20; }
  to { stroke-dashoffset: 0; }
}

.check-draw path {
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
  animation: checkDraw 250ms ease-out forwards;
}

/* Star pop bounce for rating/favorite */
@keyframes starPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.star-pop {
  animation: starPop 300ms ease-out;
}

/* Improved BatchActionsBar entrance with overshoot */
@keyframes slideInUp {
  0% { transform: translateX(-50%) translateY(100%); opacity: 0; }
  70% { transform: translateX(-50%) translateY(-6px); opacity: 1; }
  100% { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* Modal backdrop fade-in */
@keyframes modalBackdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-backdrop-enter {
  animation: modalBackdropIn 200ms ease-out both;
}

/* Slide in right with fade for panel */
@keyframes slideInRightFade {
  from { transform: translateX(100%); opacity: 0.5; }
  to { transform: translateX(0); opacity: 1; }
}

.panel-slide-fade-in {
  animation: slideInRightFade 250ms ease-out;
}

/* Shake animation for errors */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.error-shake {
  animation: shake 400ms ease-out, fadeIn 200ms ease-out;
}

/* Animated gradient background for auth pages */
@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.auth-gradient-bg {
  background: linear-gradient(135deg, #f0f2ff 0%, #e8f4fd 25%, #fef3f2 50%, #f0f2ff 75%, #e8f4fd 100%);
  background-size: 300% 300%;
  animation: gradientShift 8s ease infinite;
}

/* Logo breathe animation */
@keyframes logoBreathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.logo-breathe {
  animation: logoBreathe 3s ease-in-out infinite;
}

/* Float animation for empty state illustrations */
@keyframes gentleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.gentle-float {
  animation: gentleFloat 3s ease-in-out infinite;
}

/* SVG checkbox checked state */
.monday-checkbox.checked .check-draw path {
  stroke-dasharray: 20;
  stroke-dashoffset: 0;
  animation: checkDraw 250ms ease-out forwards;
}

/* Row entrance animation */
@keyframes rowFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.row-enter {
  animation: rowFadeIn 200ms ease-out both;
}

/* ===== Cell Focus Ring (Keyboard Navigation) ===== */
.cell-focused {
  outline: 2px solid var(--apc-hub-brand) !important;
  outline-offset: -2px;
  z-index: 5;
  position: relative;
}

/* ===== Progress Bar Animation ===== */
@keyframes progressFill {
  from { width: 0; }
}
.progress-animate {
  animation: progressFill 500ms ease-out;
}

/* ===== Status Pulse on Change ===== */
@keyframes statusPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}
.status-pulse {
  animation: statusPulse 300ms ease-out;
}

/* ===== Toast Animations ===== */
@keyframes toastIn {
  from { transform: translateY(100%) translateX(-50%); opacity: 0; }
  to { transform: translateY(0) translateX(-50%); opacity: 1; }
}
@keyframes toastOut {
  from { transform: translateY(0) translateX(-50%); opacity: 1; }
  to { transform: translateY(100%) translateX(-50%); opacity: 0; }
}
.toast-enter {
  animation: toastIn 300ms ease-out both;
}
.toast-exit {
  animation: toastOut 200ms ease-in both;
}

/* ===== Onboarding Highlight ===== */
@keyframes onboardingPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(97, 97, 255, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(97, 97, 255, 0); }
}
.onboarding-highlight {
  animation: onboardingPulse 2s ease-in-out infinite;
  border-radius: 8px;
}

/* ===== Column Width Resize Handle ===== */
.resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  cursor: col-resize;
  background: transparent;
  transition: background 150ms;
}
.resize-handle:hover,
.resize-handle.active {
  background: var(--apc-hub-brand);
}

/* ===== Print Styles ===== */
@media print {
  aside, nav, .topbar, .sidebar,
  [data-sidebar], [data-topbar],
  .batch-actions-bar,
  button:not(.print-visible),
  .no-print { display: none !important; }

  body { background: white !important; color: black !important; }
  * { box-shadow: none !important; }

  .board-container { padding: 0 !important; margin: 0 !important; }

  table {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 11px !important;
  }

  td, th {
    border: 1px solid #ddd !important;
    padding: 4px 8px !important;
    background: white !important;
  }

  .status-cell {
    background: transparent !important;
    color: black !important;
    border: 1px solid currentColor !important;
  }

  .group-section { page-break-inside: avoid; }
  h1 { font-size: 16px !important; }
}

/* ===== Frozen Column Styles ===== */
.frozen-col {
  position: sticky !important;
  z-index: 10 !important;
  background: white !important;
}
.frozen-col-checkbox {
  left: 6px !important;
}
.frozen-col-name {
  left: 46px !important;
}

/* ===== Smooth transitions for interactive cells ===== */
.cell-interactive {
  transition: background-color 150ms ease, transform 100ms ease;
}
.cell-interactive:hover {
  background-color: rgba(0, 0, 0, 0.02);
}

/* ===== Drag ghost element ===== */
.drag-ghost {
  opacity: 0.8;
  transform: rotate(1deg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  background: white;
  border-radius: 8px;
}

/* ===== Board view tab indicator ===== */
.view-tab-active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--apc-hub-brand);
  border-radius: 2px 2px 0 0;
}

/* ===== Print: job briefing one-pager =====
   Strips chrome (sidebar, hero gradient, map iframe) so the printed
   page is a clean A4 briefing — used by site staff to take a hard
   copy to site. Triggered by the Print button on /items/[id].   */
@media print {
  /* Strip dashboard chrome */
  aside, nav, header[role="banner"], .topbar { display: none !important; }

  /* Flatten the dark hero gradient to a light header */
  .bg-gradient-to-br.from-slate-900,
  .bg-gradient-to-br.via-slate-800 {
    background: white !important;
    color: #0f172a !important;
  }
  .bg-gradient-to-br.from-slate-900 *,
  .bg-gradient-to-br.via-slate-800 * { color: #0f172a !important; }

  /* Force backgrounds to print */
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  /* Drop interactive overhead */
  iframe { display: none !important; }
  a[href]::after { content: "" !important; }

  /* Better page breaks */
  .rounded-xl { break-inside: avoid; page-break-inside: avoid; }
}

/* Monday update body — sanitised HTML rendered via UpdateBody.tsx */
.update-body p { margin: 0 0 0.5em; }
.update-body p:last-child { margin-bottom: 0; }
.update-body a { color: #0073EA; text-decoration: underline; }
.update-body a:hover { color: #005bbf; }
.update-body ul, .update-body ol { margin: 0.25em 0 0.5em 1.25em; }
.update-body li { margin: 0.125em 0; }
.update-body code { background: #f1f2f5; padding: 0 0.25em; border-radius: 3px; font-size: 0.92em; }
.update-body pre { background: #f1f2f5; padding: 0.5em 0.75em; border-radius: 4px; overflow-x: auto; }
.update-body blockquote { border-left: 3px solid #c3c6d4; padding-left: 0.75em; margin: 0.25em 0; color: #676879; }

/* @mention chips inside update bodies (rendered by UpdateBody.tsx) */
.update-body .mention-chip {
  display: inline-block;
  padding: 0 6px;
  margin: 0 1px;
  border-radius: 4px;
  background: #cce5ff;
  color: #0073EA;
  font-weight: 500;
  font-size: 0.92em;
  line-height: 1.5;
  white-space: nowrap;
}
.update-body .mention-chip[data-mention-type="Team"] {
  background: #ffe1e6;
  color: #d83a52;
}

/* MentionEditor composer (contentEditable) */
.mention-editor {
  min-height: 80px;
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.5;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
}
.mention-editor:empty::before {
  content: attr(data-placeholder);
  color: #9aa1ad;
  pointer-events: none;
}
.mention-editor .mention-chip {
  display: inline-block;
  padding: 0 6px;
  border-radius: 4px;
  background: #cce5ff;
  color: #0073EA;
  font-weight: 500;
  font-size: 0.95em;
  user-select: all;
  cursor: default;
}
.mention-editor .mention-chip[data-mention-type="Team"] {
  background: #ffe1e6;
  color: #d83a52;
}

/* Floating mention picker */
.mention-picker {
  position: fixed;
  z-index: 9999;
  background: white;
  border: 1px solid var(--apc-hub-border, #d0d4e4);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  width: 280px;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
}
.mention-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.mention-picker-item[data-active="true"],
.mention-picker-item:hover {
  background: #f0f3ff;
}
.mention-picker-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 10px;
  font-weight: 600;
  overflow: hidden;
}
.mention-picker-avatar img { width: 100%; height: 100%; object-fit: cover; }
