@tailwind base;
@tailwind components;
@tailwind utilities;

/* ==========================================================================
   Gedeelde UI-stijllaag (single source of truth)
   Zie docs/aanpak-ui-consistentie.md. Codificeert de dominante Flowbite-stijl
   zodat elke pagina dezelfde knoppen/kaarten/badges/velden gebruikt.
   ========================================================================== */
@layer components {
  /* --- Knoppen ----------------------------------------------------------- */
  .btn {
    @apply inline-flex items-center justify-center gap-2 font-medium rounded-lg text-sm px-4 py-2 focus:outline-none focus:ring-4 transition-colors;
  }
  .btn-primary {
    @apply text-white bg-primary-700 hover:bg-primary-800 focus:ring-primary-300 dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800;
  }
  .btn-secondary {
    @apply text-gray-900 bg-white border border-gray-300 hover:bg-gray-100 focus:ring-gray-200 dark:bg-gray-800 dark:text-white dark:border-gray-600 dark:hover:bg-gray-700 dark:focus:ring-gray-700;
  }
  .btn-danger {
    @apply text-white bg-red-600 hover:bg-red-700 focus:ring-red-300 dark:bg-red-700 dark:hover:bg-red-800 dark:focus:ring-red-900;
  }

  /* --- Kaart ------------------------------------------------------------- */
  .card {
    @apply bg-white border border-gray-200 rounded-lg shadow-sm dark:bg-gray-800 dark:border-gray-700;
  }

  /* --- Badges / pills ---------------------------------------------------- */
  .badge {
    @apply inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium whitespace-nowrap;
  }
  .badge-gray   { @apply bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300; }
  .badge-green  { @apply bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200; }
  .badge-blue   { @apply bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200; }
  .badge-red    { @apply bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200; }
  .badge-yellow { @apply bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200; }
  .badge-purple { @apply bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200; }

  /* --- Content-tags (lichte hoeken, voor labels met langere inhoud) ------- */
  .tag {
    @apply inline-flex items-center px-2.5 py-0.5 rounded text-xs font-medium;
  }
  .tag-blue { @apply bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300; }
  .tag-gray { @apply bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300; }

  /* --- Filter-chips (verwijderbaar, met X-icoon) ------------------------- */
  .chip {
    @apply inline-flex items-center gap-1.5 px-3 py-1 text-sm font-medium rounded-full transition-colors;
  }
  .chip-blue   { @apply bg-blue-100 text-blue-800 hover:bg-blue-200 dark:bg-blue-900 dark:text-blue-200 dark:hover:bg-blue-800; }
  .chip-green  { @apply bg-green-100 text-green-800 hover:bg-green-200 dark:bg-green-900 dark:text-green-200 dark:hover:bg-green-800; }
  .chip-purple { @apply bg-purple-100 text-purple-800 hover:bg-purple-200 dark:bg-purple-900 dark:text-purple-200 dark:hover:bg-purple-800; }
  .chip-yellow { @apply bg-yellow-100 text-yellow-800 hover:bg-yellow-200 dark:bg-yellow-900 dark:text-yellow-200 dark:hover:bg-yellow-800; }

  /* --- Formuliervelden --------------------------------------------------- */
  .form-input,
  .form-select,
  .form-textarea {
    @apply bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500;
  }
  .form-label {
    @apply block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1;
  }
  .form-checkbox {
    @apply w-4 h-4 text-primary-600 bg-gray-100 border-gray-300 rounded focus:ring-primary-500 dark:bg-gray-700 dark:border-gray-600 dark:focus:ring-primary-600;
  }
  .form-radio {
    @apply w-4 h-4 text-primary-600 bg-gray-100 border-gray-300 focus:ring-primary-500 dark:bg-gray-700 dark:border-gray-600 dark:focus:ring-primary-600;
  }
  .form-error {
    @apply rounded-lg border border-red-300 bg-red-50 p-4 text-sm text-red-800 dark:border-red-800 dark:bg-red-900/30 dark:text-red-300;
  }
}

.nav-link {
  transition: color 0.3s ease;
}

.nav-link.active {
  color: rgb(3 105 161/var(--tw-text-opacity, 1));
  /* Highlight kleur */
}

.table {
  display: grid;
  grid-template-columns: repeat(5, 2fr) 1fr;
  column-gap: 2rem;
  align-items: bottom;
  padding: 1rem;
  border-bottom: 1px solid #ccc;
}

.pagy-nav.pagination {
  @apply isolate inline-flex -space-x-px rounded-md shadow-sm;
}

.page.next a {
  @apply relative inline-flex items-center rounded-r-md border border-gray-300 bg-white px-2 py-2 text-sm font-medium text-gray-500 hover:bg-gray-50 focus:z-20;
}

.page.prev a {
  @apply relative inline-flex items-center rounded-l-md border border-gray-300 bg-white px-2 py-2 text-sm font-medium text-gray-500 hover:bg-gray-50 focus:z-20;
}

.page.next.disabled {
  @apply relative inline-flex items-center rounded-r-md border border-gray-300 bg-gray-100 px-2 py-2 text-sm font-medium text-gray-500 hover:bg-gray-50 focus:z-20;
}

.page.prev.disabled {
  @apply relative inline-flex items-center rounded-l-md border border-gray-300 bg-gray-100 px-2 py-2 text-sm font-medium text-gray-500 hover:bg-gray-50 focus:z-20;
}

.page a,
.page.gap {
  @apply bg-white border-gray-300 text-gray-500 hover:bg-gray-50 relative inline-flex items-center border px-4 py-2 text-sm font-medium focus:z-20;
}

.page.active {
  @apply z-10 border-indigo-500 bg-indigo-50 text-indigo-600 relative inline-flex items-center border px-4 py-2 text-sm font-medium focus:z-20;
}

/* ── Scheduler ────────────────────────────────────────────────────────────── */
/* Only rules that can't be expressed as inline Tailwind classes:             */
/* pseudo-elements, JS-toggled state classes, and complex gradients.          */

/* Task blocks – base + interactive states (JS sets .dragging / .highlighted) */
.gantt-task-block {
  @apply absolute top-2 h-[54px] rounded overflow-hidden cursor-pointer min-w-[4px] box-border px-[5px] py-[3px] transition-[box-shadow,transform] duration-150;
  border-left-width: 3px;
  border-left-style: solid;
}

.gantt-task-block.dragging {
  @apply opacity-[.35];
}

.gantt-task-block:hover {
  @apply -translate-y-px z-[5] shadow-[0_2px_8px_rgba(0,0,0,0.18)];
}

.gantt-task-block.highlighted {
  @apply z-[6] shadow-[0_0_0_2px_#3b82f6,_0_2px_8px_rgba(0,0,0,0.15)];
}

.gantt-task-block.map-highlighted {
  @apply z-[6];
  box-shadow: 0 0 0 2px #f59e0b, 0 0 12px rgba(245,158,11,0.4);
  filter: brightness(1.08);
  transition: box-shadow 0.15s ease, filter 0.15s ease;
}

.gantt-task-block.selected {
  @apply z-[7];
  box-shadow: 0 0 0 2px #2563eb, 0 0 10px rgba(37,99,235,0.45);
}
.gantt-task-block.dimmed {
  @apply opacity-40;
  cursor: not-allowed;
}

/* Task block inner labels (also created dynamically in JS) */
.gantt-task-time {
  @apply text-[10px] font-semibold text-black/60 leading-tight whitespace-nowrap;
}

.gantt-task-name {
  @apply text-[11px] font-medium text-black/[.85] leading-snug overflow-hidden text-ellipsis whitespace-nowrap mt-px;
}

.gantt-task-type {
  @apply text-[10px] text-black/50 whitespace-nowrap overflow-hidden text-ellipsis;
}

.dark .gantt-task-name {
  @apply text-white/[.85];
}

.dark .gantt-task-time {
  @apply text-white/60;
}

/* Travel blocks – created dynamically in JS, complex gradient can't use @apply */
.gantt-travel-block {
  @apply absolute top-[22px] h-[26px] box-border rounded-[3px] flex items-center justify-center overflow-hidden border border-dashed border-emerald-400/40;
  background-image: repeating-linear-gradient(-45deg, rgba(16, 185, 129, 0.12) 0px, rgba(16, 185, 129, 0.12) 3px, transparent 3px, transparent 8px);
}

.gantt-travel-block.overlap {
  @apply border-red-400/60;
  background-image: repeating-linear-gradient(-45deg, rgba(239, 68, 68, 0.18) 0px, rgba(239, 68, 68, 0.18) 3px, transparent 3px, transparent 8px);
}

.gantt-travel-block.recalculating {
  animation: gantt-recalc-pulse 0.9s ease-in-out infinite;
  pointer-events: none;
}

@keyframes gantt-recalc-pulse {
  0%, 100% { opacity: 0.15; }
  50%       { opacity: 0.6;  }
}

.gantt-travel-label {
  @apply text-[9px] text-emerald-600 whitespace-nowrap select-none;
}

.gantt-travel-block.overlap .gantt-travel-label {
  @apply text-red-500;
}

.dark .gantt-travel-block {
  @apply border-emerald-500/30;
  background-image: repeating-linear-gradient(-45deg, rgba(16, 185, 129, 0.15) 0px, rgba(16, 185, 129, 0.15) 3px, transparent 3px, transparent 8px);
}

.dark .gantt-travel-block.overlap {
  @apply border-red-500/50;
  background-image: repeating-linear-gradient(-45deg, rgba(239, 68, 68, 0.22) 0px, rgba(239, 68, 68, 0.22) 3px, transparent 3px, transparent 8px);
}

.dark .gantt-travel-label {
  @apply text-gray-500;
}

/* Gantt task tooltip */
.gantt-tooltip {
  position: fixed; z-index: 9999; pointer-events: none;
  background: #1e2433;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 10px 28px rgba(0,0,0,0.35), 0 2px 8px rgba(0,0,0,0.2);
  border-radius: 10px;
  padding: 10px 13px;
  max-width: 320px;
  white-space: normal;
  overflow-wrap: break-word;
  opacity: 0;
  transform: translateY(5px) scale(0.96);
  transition: opacity 110ms ease, transform 110ms ease;
  transform-origin: bottom left;
}
.gantt-tooltip.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.gantt-tooltip-row {
  display: flex; gap: 8px; align-items: flex-start; line-height: 1.75;
}
.gantt-tooltip-row + .gantt-tooltip-row {
  border-top: 1px solid rgba(255,255,255,0.07);
  padding-top: 3px; margin-top: 3px;
}
.gantt-tooltip-icon {
  font-size: 11px; width: 14px; text-align: center;
  color: rgba(255,255,255,0.4); flex-shrink: 0;
}
.gantt-tooltip-text { color: #f1f5f9; font-size: 12px; font-weight: 500; }
.gantt-tooltip-sub  { color: rgba(255,255,255,0.4); font-weight: 400; }

/* Travel block tooltip – amber accent, compact */
.gantt-travel-tooltip {
  position: fixed; z-index: 9999; pointer-events: none;
  background: #451a03;
  border: 1px solid rgba(251,191,36,0.25);
  box-shadow: 0 6px 18px rgba(0,0,0,0.3);
  border-radius: 7px;
  padding: 5px 10px;
  font-size: 11px; font-weight: 500;
  color: #fcd34d;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 90ms ease, transform 90ms ease;
}
.gantt-travel-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Drag placeholder – created dynamically in JS */
.drag-placeholder {
  @apply absolute top-2 h-[54px] rounded pointer-events-none z-[15] box-border border-2 border-dashed border-blue-500 bg-blue-500/10;
}

/* Unscheduled panel – JS toggles .drop-target on the header */
.unscheduled-panel-header.drop-target {
  @apply bg-blue-50 border-b-blue-500;
}

/* Unscheduled table column resize handle */
.col-resize-handle {
  position: absolute;
  top: 10%;
  right: 0;
  width: 4px;
  height: 80%;
  cursor: col-resize;
  z-index: 10;
  border-radius: 2px;
  @apply bg-gray-300/60 dark:bg-gray-600/60;
}

.col-resize-handle:hover,
.col-resize-handle.dragging {
  @apply bg-blue-400;
}

.unscheduled-th.sorted-asc .sort-arrow::after {
  content: ' ▲';
}

.unscheduled-th.sorted-desc .sort-arrow::after {
  content: ' ▼';
}

.unscheduled-empty-row td {
  @apply text-center text-gray-400 py-4 italic cursor-default;
}

tr.dragging {
  @apply opacity-[.4];
}

/* Day-off overlay + outside-hours regions – same subtle diagonal stripe */
.gantt-outside-hours {
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(156, 163, 175, 0.10) 0px,
    rgba(156, 163, 175, 0.10) 4px,
    transparent 4px,
    transparent 12px
  );
}
.dark .gantt-outside-hours {
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(255, 255, 255, 0.04) 0px,
    rgba(255, 255, 255, 0.04) 4px,
    transparent 4px,
    transparent 12px
  );
}

/* Day-off overlay – subtle diagonal stripes when no business hours configured */
.gantt-day-off {
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(156, 163, 175, 0.10) 0px,
    rgba(156, 163, 175, 0.10) 4px,
    transparent 4px,
    transparent 12px
  );
}
.dark .gantt-day-off {
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(255, 255, 255, 0.04) 0px,
    rgba(255, 255, 255, 0.04) 4px,
    transparent 4px,
    transparent 12px
  );
}

/* Driver column – width controlled via CSS custom property set by JS */
.gantt-driver-col {
  width: var(--driver-col-width, 180px);
  min-width: 40px;
  flex-shrink: 0;
  position: relative;
}

/* ── Weekweergave ─────────────────────────────────────────────────────────── */
/* Eén scrollcontainer voor beide assen: dagkoppen sticky top, monteurkolom sticky left. */
.gantt-week-scroll {
  overflow: auto;
}
/* Wint van de `position: relative` op .gantt-driver-col hierboven, die anders
   de sticky-utility overschrijft (zelfde specificiteit, latere bronvolgorde). */
.gantt-week-scroll .gantt-driver-col {
  position: sticky;
  left: 0;
}
/* Vaste celbreedte zodat header en rijen uitlijnen; ~46px per uur bij 14 uur. */
.gantt-week-cell {
  width: 640px;
  min-width: 640px;
  box-sizing: border-box;
}

.driver-col-resize-handle {
  position: absolute;
  top: 10%;
  right: 0;
  width: 4px;
  height: 80%;
  cursor: col-resize;
  z-index: 10;
  border-radius: 2px;
  @apply bg-gray-300/60 dark:bg-gray-600/60;
}

.driver-col-resize-handle:hover,
.driver-col-resize-handle.dragging {
  @apply bg-blue-400;
}

/* Compact mode: only show avatar, hide name/stats */
.gantt-panel-compact .gantt-driver-info {
  display: none;
}

.gantt-panel-compact .gantt-driver-col {
  @apply px-1.5 justify-center gap-0;
}

/* Resizable dividers – pseudo-elements and JS-toggled .dragging */
.split-divider::after {
  content: '';
  @apply block w-0.5 h-10 rounded-sm bg-gray-300 transition-[background-color,height] duration-150;
}

.split-divider:hover::after,
.split-divider.dragging::after {
  @apply bg-blue-500 h-[60px];
}

.row-divider::after {
  content: '';
  @apply block h-0.5 w-10 rounded-sm bg-gray-300 transition-[background-color,width] duration-150;
}

.row-divider:hover::after,
.row-divider.dragging::after {
  @apply bg-blue-500 w-[60px];
}

/* ── Collapsible sidebar ──────────────────────────────────────── */
.sidebar-nav {
  width: 16rem;
  transition: width 300ms ease;
}

html.sidebar-collapsed .sidebar-nav {
  width: 4rem;
}

/* Smooth label fade + collapse */
.sidebar-label {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  max-width: 12rem;
  opacity: 1;
  transition: max-width 300ms ease, opacity 200ms ease, margin-left 300ms ease;
}

html.sidebar-collapsed .sidebar-label {
  max-width: 0;
  opacity: 0;
  margin-left: 0 !important;
}

/* Centre icons when collapsed */
.sidebar-link {
  transition: justify-content 0ms, padding 300ms ease;
}

html.sidebar-collapsed .sidebar-link {
  justify-content: center;
}

/* Rotate toggle chevron when collapsed */
html.sidebar-collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

/* Main content margin mirrors sidebar width */
@media (min-width: 640px) {
  .site-main {
    margin-left: 16rem;
    transition: margin-left 300ms ease;
  }

  html.sidebar-collapsed .site-main {
    margin-left: 4rem;
  }
}

/* Sidebar brand link (logo + naam) klapt in met de sidebar */
.sidebar-brand-link {
  overflow: hidden;
  max-width: 12rem;
  opacity: 1;
  transition: max-width 300ms ease, opacity 200ms ease;
}

html.sidebar-collapsed .sidebar-brand-link {
  max-width: 0;
  opacity: 0;
}

html.sidebar-collapsed .sidebar-brand-header {
  justify-content: center;
}
/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
 * vendor/assets/stylesheets directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any other CSS
 * files in this directory. Styles in this file should be added after the last require_* statement.
 * It is generally better to create a new file per style scope.
 *


 */

:root {
    --map-tiles-filter: brightness(0.6) invert(1) contrast(3) hue-rotate(200deg) saturate(0.3) brightness(0.7);
}

/* Dark mode styles that work with both system preference and class toggle */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .map-tiles {
        filter: var(--map-tiles-filter, none);
    }
}

/* For when dark mode is forced via class */
.dark .map-tiles {
    filter: var(--map-tiles-filter, none);
}
