/* Kanban Board Styles */

/* Board header */
.board-header {
  border-radius: 0.5rem;
  margin-bottom: 1.5rem;
}

/* Filter bar */
.board-filter-bar {
  background-color: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
}

.board-filter-bar .filter-group {
  min-width: 130px;
}

.board-filter-bar .form-select-sm,
.board-filter-bar .form-control-sm {
  font-size: 0.8rem;
}

.board-filter-bar .ts-wrapper {
  font-size: 0.8rem;
  min-width: 130px;
}

.board-filter-bar .ts-control {
  min-height: 0;
  padding: 0.25rem 0.5rem;
}

.board-filter-bar .ts-control input {
  font-size: 0.8rem;
}

.board-filter-bar .ts-dropdown {
  font-size: 0.8rem;
}

/* Horizontal scrolling container for columns */
.board-columns-container {
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1;
  padding-bottom: 1rem;
}

/* Inline-flex for horizontal layout */
.columns-wrapper {
  display: inline-flex;
  align-items: flex-start;
  min-height: 100%;
  padding: 0.5rem;
}

/* Fixed width columns */
.column-container {
  flex-shrink: 0;
  min-width: 300px;
  max-width: 300px;
}

/* Column header */
.column-header {
  cursor: grab;
}

.column-header:active {
  cursor: grabbing;
}

/* Scrollable cards within column */
.cards-container {
  min-height: 100px;
  max-height: calc(100vh - 250px);
  overflow-y: auto;
}

/* SortableJS drag states */
.sortable-ghost {
  opacity: 0.4;
}

.sortable-drag {
  cursor: grabbing !important;
  transform: rotate(3deg);
}

/* Board cards on index page */
.board-card {
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.board-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

/* New column form */
.new-column-form {
  min-width: 300px;
  max-width: 300px;
}

/* Smooth transitions */
.column-container,
.card {
  transition: all 0.2s ease;
}

/* Card styles */
.card.mb-2 {
  cursor: grab;
  position: relative;
}

.card.mb-2:active {
  cursor: grabbing;
}

.card.mb-2:hover {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

/* Label badges */
.label-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  color: white;
  font-size: 0.75rem;
  font-weight: 500;
  margin-right: 0.25rem;
  margin-bottom: 0.25rem;
}

/* Label picker in modal */
.label-picker .form-check {
  margin-bottom: 0.5rem;
}

.label-picker .label-badge {
  margin-left: 0.5rem;
}

/* Due date colors */
.card-due-date.overdue {
  color: #dc3545 !important;
  font-weight: bold;
}

.card-due-date.due-soon {
  color: #ffc107 !important;
  font-weight: bold;
}

/* Legacy custom modal overlay — the .modal itself acts as the backdrop
   because these modals don't use Bootstrap's data-bs-toggle/.modal-backdrop
   pattern. Scoped to data-controller="modal" so Bootstrap-toggled modals
   (which add their own .modal-backdrop) keep their default z-index of 1055. */
.modal[data-controller~="modal"] {
  z-index: 1050;
  background-color: rgba(0, 0, 0, 0.5);
}

/* Stretched link fix for card actions */
.stretched-link::after {
  z-index: 1;
}

.card-actions {
  position: relative;
  z-index: 10;
}

/* The filter reloads only this frame; it must not add a box of its own
   between the board and its scroll container. */
.board-columns-frame {
  display: contents;
}

turbo-frame.board-columns-frame[busy] .board-columns-container {
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

/* With a filter on, columns without a matching card are hidden. */
turbo-frame.column:has(> .column-filtered-empty) {
  display: none;
}

.column-reload-btn .bi {
  display: inline-block;
}

.column-reloading .column-reload-btn .bi {
  animation: column-reload-spin 0.8s linear infinite;
}

@keyframes column-reload-spin {
  to { transform: rotate(360deg); }
}

.cards-pager.loading {
  opacity: 0.5;
  pointer-events: none;
}

.board-filter-menu {
  min-width: 320px;
}

/* Column chips: only on phones (d-md-none in the view). */
.board-column-nav {
  display: flex;
  gap: 0.375rem;
  overflow-x: auto;
  padding: 0.25rem 0.75rem 0.5rem;
  scrollbar-width: none;
}

.board-column-nav::-webkit-scrollbar {
  display: none;
}

.board-column-nav-chip {
  flex-shrink: 0;
  border-radius: 999px;
  background-color: rgba(255, 255, 255, 0.85);
  color: #172b4d;
  white-space: nowrap;
}

.board-column-nav-chip.active {
  background-color: #fff;
  font-weight: 600;
  box-shadow: 0 0 0 2px rgba(23, 43, 77, 0.35);
}

/* Phones: one column per screen, swiped with snapping. */
@media (max-width: 767.98px) {
  .board-columns-container {
    scroll-snap-type: x mandatory;
    scroll-padding-left: 0.5rem;
    -webkit-overflow-scrolling: touch;
  }

  .columns-wrapper {
    padding: 0.25rem 0.5rem;
  }

  .column-container,
  .new-column-form {
    min-width: calc(100vw - 2rem);
    max-width: calc(100vw - 2rem);
    scroll-snap-align: start;
  }

  .column-container.me-3,
  .new-column-form.me-3 {
    margin-right: 0.5rem !important;
  }

  .cards-container {
    max-height: calc(100dvh - 330px);
  }

  /* Bigger tap targets in the column header. */
  .column-header .btn {
    min-width: 2.25rem;
    min-height: 2.25rem;
  }

  .board-filter-menu {
    min-width: 0;
    width: calc(100vw - 1.5rem);
    max-height: calc(100dvh - 140px);
    overflow-y: auto;
  }

  .board-header .board-actions .btn {
    min-width: 2.25rem;
    min-height: 2.25rem;
  }
}

/* No lift-on-hover on touch screens: it sticks after a tap. */
@media (hover: none) {
  .card.mb-2:hover {
    transform: none;
    box-shadow: none;
  }
}
