/* ================================================
   CRUD COMPONENT DESIGN SYSTEM v2.0
   HJ ERP — Modern, Responsive, Informative
   Loaded after application.css (c > a alphabetically)
   so these rules naturally override old crud-* styles.
   ================================================ */

/* ----------------------------------------
   CRUD Design Tokens
   ---------------------------------------- */
:root {
  --crud-surface:       #ffffff;
  --crud-surface-2:     #f8fafc;
  --crud-surface-3:     #f1f5f9;
  --crud-border:        #e2e8f0;
  --crud-border-light:  #f1f5f9;
  --crud-text:          #1e293b;
  --crud-text-muted:    #64748b;
  --crud-text-subtle:   #94a3b8;
  --crud-shadow-sm:     0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --crud-shadow-md:     0 4px 16px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --crud-shadow-lg:     0 8px 32px rgba(0,0,0,0.10), 0 4px 12px rgba(0,0,0,0.06);
  --crud-radius:        0.75rem;
  --crud-radius-sm:     0.5rem;
  --crud-radius-xs:     0.375rem;
  --crud-transition:    0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ----------------------------------------
   CRUD Page Header
   ---------------------------------------- */
.crud-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--crud-border);
  gap: 0.75rem;
  flex-wrap: wrap;
}

.crud-header h1 {
  font-weight: 700;
  color: var(--crud-text);
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: -0.3px;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.crud-header h1 i {
  color: var(--hj-primary);
  font-size: 1.2rem;
}

.crud-header .btn-primary {
  padding: 0.5rem 1.125rem;
  font-weight: 600;
  border-radius: var(--crud-radius-sm);
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  box-shadow: 0 2px 8px rgba(218, 165, 32, 0.30);
  transition: all var(--crud-transition);
  white-space: nowrap;
}

.crud-header .btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(218, 165, 32, 0.40);
}

.crud-header .btn-primary:active {
  transform: translateY(0);
}

/* ----------------------------------------
   Toolbar Stack — stacks search + filter
   ---------------------------------------- */
.crud-toolbar-stack {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.875rem;
}

/* ----------------------------------------
   Search Bar — flat pill-style input
   ---------------------------------------- */
.crud-search-bar {
  display: flex;
  align-items: center;
  background: var(--crud-surface);
  border: 1.5px solid var(--crud-border);
  border-radius: var(--crud-radius-sm);
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  height: 42px;
  overflow: hidden;
  transition: border-color var(--crud-transition), box-shadow var(--crud-transition);
}

.crud-search-bar:focus-within {
  border-color: var(--hj-primary);
  box-shadow: 0 0 0 3px rgba(218,165,32,0.12), 0 1px 6px rgba(0,0,0,0.06);
  overflow: visible;
}

.crud-search-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 100%;
  flex-shrink: 0;
  font-size: 0.88rem;
  color: var(--crud-text-subtle);
  background: var(--crud-surface-2);
  border-right: 1.5px solid var(--crud-border-light);
  transition: color var(--crud-transition), background var(--crud-transition), border-color var(--crud-transition);
}

.crud-search-bar:focus-within .crud-search-icon {
  color: var(--hj-primary);
  background: #fffdf5;
  border-right-color: rgba(218,165,32,0.25);
}

.crud-search-form {
  flex: 1;
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
  height: 100%;
}

.crud-search-fields {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.75rem;
  height: 100%;
  overflow: hidden;
}

.crud-search-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.875rem;
  color: var(--crud-text);
  padding: 0;
  height: 100%;
  box-shadow: none !important;
}

.crud-search-input::placeholder {
  color: var(--crud-text-subtle);
}

/* Remove browser native clear (X) on search inputs */
.crud-search-input[type="search"]::-webkit-search-cancel-button,
.crud-search-input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.crud-search-date-range {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex: 1;
}

.crud-search-sep {
  color: var(--crud-text-subtle);
  font-size: 0.7rem;
  flex-shrink: 0;
}

.crud-search-actions {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0 0.5rem;
  flex-shrink: 0;
  height: 100%;
}

.crud-search-spinner {
  display: flex;
  align-items: center;
  color: var(--hj-primary);
}

.crud-clear-btn {
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  color: var(--crud-text-subtle);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all var(--crud-transition);
  padding: 0;
  line-height: 1;
}

.crud-clear-btn:hover {
  background: var(--crud-surface-3);
  color: var(--hj-danger);
}

/* ----------------------------------------
   Filter Bar — New Responsive Design
   ---------------------------------------- */
.crud-filter-bar {
  display: flex;
  align-items: flex-start; /* Align to top for consistent wrapping */
  background: var(--crud-surface);
  border: 1.5px solid var(--crud-border);
  border-radius: var(--crud-radius-sm);
  padding: 0.5rem;
  gap: 0.5rem;
  margin-bottom: 0.875rem;
  flex-wrap: wrap; /* Allow wrapping on all screen sizes */
}

.crud-filter-bar-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px; /* Match form input height */
  padding: 0 0.75rem;
  color: var(--crud-text-muted);
  font-weight: 600;
  font-size: 0.875rem;
  gap: 0.5rem;
  white-space: nowrap;
}

.crud-filter-form {
  flex: 1 1 auto; /* Allow form to grow and shrink */
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem; /* Consistent gap for wrapped items */
  align-items: flex-start; /* Align wrapped items to the top */
}

/* Individual filter items within the form */
.crud-filter-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1 1 180px; /* Grow and shrink, with a base size */
  min-width: 160px; /* Prevent becoming too small */
}

/* Specific sizing for date ranges */
.crud-filter-item.filter-item-date-range {
  flex-basis: 200px;
}

.crud-filter-item .form-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--crud-text-muted);
  margin-bottom: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crud-filter-item .form-control,
.crud-filter-item .form-select,
.crud-filter-item .ts-wrapper .ts-control {
  height: 38px;
  font-size: 0.875rem;
  border-radius: var(--crud-radius-xs);
}

.crud-filter-item .input-group .form-control {
  height: 38px;
}

.crud-filter-item .input-group-text {
  height: 38px;
  border-radius: var(--crud-radius-xs) 0 0 var(--crud-radius-xs);
  font-size: 0.875rem;
}

/* Tom-select specific adjustments */
.crud-filter-item .ts-wrapper.single .ts-control,
.crud-filter-item .ts-wrapper.single .ts-control input {
  height: 38px;
}

.crud-filter-item .ts-wrapper .ts-control {
  border-radius: var(--crud-radius-xs);
  border-color: var(--crud-border);
}

.crud-filter-item .ts-wrapper.focus .ts-control {
  border-color: var(--hj-primary);
  box-shadow: 0 0 0 0.25rem rgba(var(--hj-primary-rgb), 0.25);
}

.crud-filter-bar .btn-submit-filter {
  height: 38px;
  align-self: flex-end; /* Align button to the bottom of its flex line */
}

/* Active Filters Bar */
.crud-active-filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.5rem;
  background-color: var(--crud-surface-2);
  border-radius: var(--crud-radius-sm);
  border: 1px solid var(--crud-border-light);
}

.active-filter-pill {
  display: inline-flex;
  align-items: center;
  background-color: var(--crud-surface);
  border: 1px solid var(--crud-border);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--crud-text);
  white-space: nowrap;
}

.active-filter-pill .filter-label {
  color: var(--crud-text-muted);
  margin-right: 0.3rem;
}

.active-filter-pill .filter-value {
  font-weight: 600;
}

.crud-active-filters-bar .btn-outline-danger {
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
}

/* ----------------------------------------
   Mobile Filter Offcanvas
   ---------------------------------------- */
.crud-filter-offcanvas {
  max-height: 82vh;
  border-radius: 1.25rem 1.25rem 0 0;
  border: none;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.12);
}

.crud-filter-offcanvas .offcanvas-header {
  border-bottom: 1px solid var(--crud-border);
  padding: 1.125rem 1.25rem;
  background: var(--crud-surface-2);
  border-radius: 1.25rem 1.25rem 0 0;
}

.crud-filter-offcanvas .offcanvas-title {
  font-weight: 700;
  color: var(--crud-text);
  font-size: 1rem;
}

.crud-filter-offcanvas .offcanvas-body {
  padding: 1rem 1.25rem;
  overflow-y: auto;
}

.crud-filter-offcanvas .form-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--crud-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.35px;
}

.crud-filter-offcanvas .form-control,
.crud-filter-offcanvas .form-select {
  min-height: 44px;
  border: 1.5px solid var(--crud-border);
  border-radius: var(--crud-radius-xs);
}

.crud-filter-offcanvas .btn-primary {
  min-height: 50px;
  font-weight: 700;
  font-size: 1rem;
  border-radius: var(--crud-radius-sm);
}

/* ----------------------------------------
   Nested Item Cards — Mobile Form
   ---------------------------------------- */
.nested-item-card {
  border: 1px solid var(--crud-border);
  border-radius: var(--crud-radius-sm);
  transition: all var(--crud-transition);
  background: var(--crud-surface);
}

.nested-item-card:hover {
  border-color: var(--hj-primary-light);
  box-shadow: 0 2px 8px rgba(218, 165, 32, 0.10);
}

.nested-item-card .form-label-sm {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--crud-text-muted);
}

/* ----------------------------------------
   Responsive Breakpoints
   ---------------------------------------- */

/* ── Mobile < 768px ── */
@media (max-width: 767.98px) {

  /* Header */
  .crud-header {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
  }

  .crud-header h1 {
    font-size: 1.2rem;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Show */
  .crud-show-row {
    flex-direction: column;
  }

  .crud-show-label {
    flex: none;
    border-right: none;
    border-bottom: 1px solid var(--crud-border-light);
    padding: 0.625rem 1rem 0.3rem;
    font-size: 0.68rem;
  }

  .crud-show-value {
    padding: 0.375rem 1rem 0.75rem;
    font-size: 0.9rem;
  }

  .crud-show-card .card-header {
    padding: 1rem;
  }

  .crud-show-card .card-header h5 {
    font-size: 0.95rem;
  }

  /* Pagination */
  .crud-pagination {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
  }

  .crud-pagination .page-link {
    width: 30px;
    height: 30px;
    font-size: 0.78rem;
  }

  /* Cards */
  .crud-search-card,
  .crud-filter-card {
    border-radius: var(--crud-radius-sm);
  }

  /* Form */
  .crud-form-card .card-body {
    padding: 1rem;
  }

  .crud-form-card .card-header {
    padding: 1rem 1.25rem;
  }

  /* Empty state */
  .crud-empty-state {
    padding: 2.5rem 1.25rem;
  }

  .crud-empty-state-icon {
    width: 68px;
    height: 68px;
  }

  .crud-empty-state-icon i {
    font-size: 1.6rem;
  }

  /* Tabs */
  .crud-tabs .nav-link {
    padding: 0.625rem 0.875rem;
    font-size: 0.82rem;
  }

  /* Content wrapper padding */
  .content-wrapper {
    padding: 0.75rem !important;
  }

  /* iOS-safe touch targets */
  .btn {
    min-height: 40px;
  }

  .form-control,
  .form-select {
    min-height: 44px;
    font-size: 16px; /* Prevents iOS zoom-on-focus */
  }

  .form-control-sm,
  .form-select-sm {
    min-height: 38px;
    font-size: 14px;
  }

  .crud-form-card .row > [class*="col-"] {
    margin-bottom: 0;
  }

  .nested-item-card .card-body {
    padding: 0.75rem;
  }
}

/* ── Tablet 768–991px ── */
@media (min-width: 768px) and (max-width: 991.98px) {

  .crud-show-label {
    flex: 0 0 175px;
    font-size: 0.75rem;
  }

  .crud-table thead th {
    font-size: 0.66rem;
    padding: 0.5rem 0.75rem;
  }

  .crud-table tbody td {
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
  }
}

/* ── Large ≥ 1200px ── */
@media (min-width: 1200px) {

  .crud-table thead th {
    padding: 0.75rem 1.125rem;
  }

  .crud-table tbody td {
    padding: 0.75rem 1.125rem;
  }

  .crud-show-label {
    flex: 0 0 230px;
  }
}

/* ----------------------------------------
   CRUD Table & Card View — New Styles
   ---------------------------------------- */

/* Wrapper for both table and cards */
.crud-table-wrapper {
  background-color: var(--crud-surface);
  border-radius: var(--crud-radius);
  border: 1px solid var(--crud-border);
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--crud-shadow-sm);
}

/* Desktop Table Styles (≥ 768px) */
.crud-table {
  width: 100%;
  border-collapse: collapse;
}

.crud-table th,
.crud-table td {
  padding: 0.875rem 1.25rem;
  text-align: left;
  vertical-align: middle;
  font-size: 0.875rem;
  color: var(--crud-text);
}

.crud-table thead th {
  background-color: var(--crud-surface-2);
  font-weight: 600;
  color: var(--crud-text-muted);
  border-bottom: 2px solid var(--crud-border);
  white-space: nowrap;
}

.crud-table thead th a {
  color: inherit;
  text-decoration: none;
}

.crud-table thead th a:hover {
  color: var(--hj-primary, var(--crud-text));
}

.crud-table thead th .sort-icon {
  margin-left: 0.3rem;
  opacity: 0.6;
}

.crud-table tbody tr {
  border-bottom: 1px solid var(--crud-border-light);
  transition: background-color var(--crud-transition);
}

.crud-table tbody tr:last-child {
  border-bottom: none;
}

.crud-table tbody tr:hover {
  background-color: var(--crud-surface-2);
}

.crud-table .actions-cell {
  text-align: right;
  white-space: nowrap;
}

.crud-table .actions-cell .btn {
  margin-left: 0.25rem;
}

/* Mobile Card View Styles (< 768px) */
.crud-card-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.75rem;
  background-color: var(--crud-surface-2);
}

.crud-card-item {
  background-color: var(--crud-surface);
  border-radius: var(--crud-radius-sm);
  border: 1px solid var(--crud-border);
  box-shadow: var(--crud-shadow-sm);
  overflow: hidden;
  transition: all var(--crud-transition);
}

.crud-card-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--crud-shadow-md);
}

.crud-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background-color: var(--crud-surface-2);
  border-bottom: 1px solid var(--crud-border-light);
}

.crud-card-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--crud-text);
  margin: 0;
}

.crud-card-body {
  padding: 0.5rem 0;
}

.crud-card-field {
  display: flex;
  justify-content: space-between;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--crud-border-light);
}
.crud-card-field:last-child {
  border-bottom: none;
}

.crud-card-label {
  font-weight: 500;
  color: var(--crud-text-muted);
  margin-right: 1rem;
}

.crud-card-value {
  font-weight: 500;
  text-align: right;
}

.crud-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background-color: var(--crud-surface-2);
  border-top: 1px solid var(--crud-border-light);
}

/* ----------------------------------------
   Menu Permissions Table
   ---------------------------------------- */
.menu-permissions-table-wrap {
  overflow-x: auto;
  background: var(--crud-surface);
  border-radius: var(--crud-radius);
  border: 1px solid var(--crud-border);
  box-shadow: var(--crud-shadow-sm);
}

.menu-permissions-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
  background: transparent;
}

.menu-permissions-table thead th {
  background: var(--crud-surface-2);
  color: var(--crud-text-muted);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--crud-border);
}

.menu-permissions-table thead th.menu-permissions-role {
  text-align: center;
}

.menu-permissions-table tbody td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--crud-border-light);
  background: var(--crud-surface);
  vertical-align: middle;
}

.menu-permissions-table tbody tr:last-child td {
  border-bottom: 0;
}

.menu-permissions-table tbody tr:hover td {
  background: #fffdf5;
}

.menu-permissions-name {
  min-width: 260px;
}

.menu-permissions-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding-left: calc(var(--menu-depth, 0) * 1.25rem);
}

.menu-permissions-row.is-parent .menu-permissions-label {
  font-weight: 600;
  color: var(--crud-text);
}

.menu-permissions-row.is-child .menu-permissions-label {
  color: var(--crud-text-muted);
}

.menu-permissions-cell {
  text-align: center;
}

.menu-permissions-cell.is-disabled {
  opacity: 0.45;
}

.menu-permissions-input {
  margin: 0;
  cursor: pointer;
}

.menu-permissions-level-title {
  font-weight: 600;
  color: var(--crud-text);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--crud-border);
}

/* ----------------------------------------
   ASSIGNMENT TIMELINE VIEW
   ---------------------------------------- */

.assignment-timeline {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Date group row */
.timeline-date-group {
  background: var(--crud-surface);
  border: 1px solid var(--crud-border);
  border-radius: var(--crud-radius);
  box-shadow: var(--crud-shadow-sm);
  overflow: hidden;
}

.timeline-date-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 1rem;
  background: var(--crud-surface-2);
  border-bottom: 1px solid var(--crud-border-light);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.timeline-date-info {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.timeline-date-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--crud-text);
}

.timeline-count-badge {
  background: var(--crud-surface-3);
  color: var(--crud-text-muted);
  border: 1px solid var(--crud-border);
  font-weight: 500;
  font-size: 0.75rem;
}

/* Horizontal scrollable cards row */
.timeline-cards-row {
  display: flex;
  flex-direction: row;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--crud-border) transparent;
}

.timeline-cards-row::-webkit-scrollbar {
  height: 4px;
}

.timeline-cards-row::-webkit-scrollbar-track {
  background: transparent;
}

.timeline-cards-row::-webkit-scrollbar-thumb {
  background: var(--crud-border);
  border-radius: 2px;
}

/* Individual assignment card */
.assignment-card {
  min-width: 190px;
  max-width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--crud-radius-sm);
  border: 1px solid var(--crud-border);
  background: var(--crud-surface);
  box-shadow: var(--crud-shadow-sm);
  transition: box-shadow var(--crud-transition), transform var(--crud-transition);
  border-left-width: 4px;
  overflow: hidden;
}

.assignment-card:hover {
  box-shadow: var(--crud-shadow-md);
  transform: translateY(-1px);
}

/* Left-border color by status */
.assignment-card--pending       { border-left-color: #6c757d; }
.assignment-card--in_progress   { border-left-color: #0d6efd; }
.assignment-card--completed     { border-left-color: #198754; }
.assignment-card--cancelled     { border-left-color: #dc3545; }
.assignment-card--expired       { border-left-color: #fd7e14; }

.assignment-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.625rem 0.375rem;
  border-bottom: 1px solid var(--crud-border-light);
}

.assignment-card__order {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--crud-text-subtle);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Status badge colors per status */
.assignment-status--pending     { background-color: #6c757d; color: #fff; }
.assignment-status--in_progress { background-color: #0d6efd; color: #fff; }
.assignment-status--completed   { background-color: #198754; color: #fff; }
.assignment-status--cancelled   { background-color: #dc3545; color: #fff; }
.assignment-status--expired     { background-color: #fd7e14; color: #fff; }

.assignment-card__status-badge {
  font-size: 0.65rem;
  padding: 0.2em 0.5em;
  border-radius: 0.25rem;
}

.assignment-card__body {
  padding: 0.5rem 0.625rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.assignment-card__outlet {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--crud-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.assignment-card__outlet-link {
  color: var(--crud-text);
  text-decoration: none;
}

.assignment-card__outlet-link:hover {
  text-decoration: underline;
  color: #0d6efd;
}

.assignment-card__area {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.assignment-card__footer {
  padding: 0.5rem 0.625rem;
  border-top: 1px solid var(--crud-border-light);
}

.assignment-card__detail-btn {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
}

/* Mobile: stack cards vertically on very small screens */
@media (max-width: 480px) {
  .timeline-cards-row {
    flex-direction: column;
    overflow-x: unset;
  }

  .assignment-card {
    min-width: unset;
    max-width: unset;
  }
}

/* ── Past / expired date groups ─────────────────────────────────────── */

.timeline-date-group--past {
  border-color: #f8d7da;
  background: #fff8f8;
}

.timeline-date-group--past .timeline-date-header {
  background: #fdf2f2;
  border-bottom-color: #f8d7da;
}

.timeline-date-group--past .timeline-date-label {
  color: #842029;
}

.timeline-date-group--today {
  border-color: #b6d4fe;
}

.timeline-date-group--today .timeline-date-header {
  background: #f0f6ff;
  border-bottom-color: #b6d4fe;
}

.timeline-expired-badge {
  font-size: 0.7rem;
}

/* Cards on past dates that are still pending/in-progress get a visual warning */
.assignment-card--past {
  opacity: 0.85;
}

.assignment-card--past .assignment-card__header {
  background: #fff3cd22;
}

/* ── Drag-and-drop ──────────────────────────────────────────────────── */

.assignment-card__drag-handle {
  color: var(--crud-text-subtle);
  cursor: grab;
  font-size: 0.75rem;
  padding: 0 2px;
  line-height: 1;
}

.assignment-card__drag-handle:active {
  cursor: grabbing;
}

.assignment-card[draggable="true"] {
  cursor: grab;
}

.assignment-card[draggable="true"]:active {
  cursor: grabbing;
}

/* Card being dragged */
.assignment-card.is-dragging {
  opacity: 0.4;
  transform: scale(0.97);
}

/* Drop zone highlight */
.timeline-date-group.drop-highlight {
  border-color: #0d6efd;
  box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25);
  background: #f0f6ff;
}

.timeline-date-group.drop-highlight .timeline-cards-row {
  background: rgba(13, 110, 253, 0.04);
  border-radius: 0 0 var(--crud-radius) var(--crud-radius);
  min-height: 80px;
}

/* Empty zone placeholder */
.timeline-empty-drop-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 140px;
  min-height: 60px;
  border: 2px dashed var(--crud-border);
  border-radius: var(--crud-radius-sm);
  color: var(--crud-text-subtle);
  font-size: 0.8rem;
  padding: 0.5rem 1rem;
}

/* Drag legend hint */
.timeline-drag-hint {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.78rem;
}

/* ── Vertical Kanban Styles ──────────────────────────────────────────── */

/* Kanban container */
.assignment-kanban {
  padding: 0.5rem 0;
}

/* Kanban filters - COMPACT */
.kanban-filters {
  background: #f8f9fa;
  border-radius: var(--crud-radius);
  padding: 0.5rem;
  border: 1px solid var(--crud-border);
}

.kanban-filters .form-select,
.kanban-filters .form-control {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
}

.kanban-filters .input-group-text {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}

.kanban-filters .btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}

/* Drag hint */
.kanban-drag-hint {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
}

/* Kanban columns container - 4 column grid */
.kanban-columns {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

@media (max-width: 1200px) {
  .kanban-columns {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .kanban-columns {
    grid-template-columns: 1fr;
  }
}

/* Individual column */
.kanban-column {
  display: flex;
  flex-direction: column;
  background: var(--crud-surface);
  border: 2px solid var(--crud-border);
  border-radius: var(--crud-radius);
  min-height: 200px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.kanban-column--empty {
  border-style: dashed;
  background: #f8f9fa;
}

/* Column-specific colors */
.kanban-column--expired {
  border-color: #f5c2c7;
}

.kanban-column--today {
  border-color: #9ec5fe;
}

.kanban-column--besok {
  border-color: #9eeaf9;
}

.kanban-column--mendatang {
  border-color: #a6e9d5;
}

/* Column header - COMPACT */
.kanban-header {
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--crud-radius) - 2px) calc(var(--crud-radius) - 2px) 0 0;
  font-weight: 600;
}

.kanban-header--danger {
  background: #f8d7da;
  color: #842029;
}

.kanban-header--primary {
  background: #cfe2ff;
  color: #084298;
}

.kanban-header--success {
  background: #d1e7dd;
  color: #0f5132;
}

.kanban-header--info {
  background: #cff4fc;
  color: #055160;
}

.kanban-header__label {
  font-size: 0.8rem;
}

.kanban-header .badge {
  font-size: 0.7rem;
  padding: 0.25em 0.5em;
}

/* Cards container */
.kanban-cards {
  flex: 1;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 80px;
}

/* Individual kanban card - COMPACT */
.kanban-card {
  display: flex;
  flex-direction: column;
  background: var(--crud-surface);
  border: 1px solid var(--crud-border);
  border-radius: var(--crud-radius-sm);
  box-shadow: var(--crud-shadow-sm);
  transition: box-shadow 0.1s ease, transform 0.1s ease;
  border-left-width: 3px;
  cursor: grab;
  font-size: 0.8rem;
}

.kanban-card:hover {
  box-shadow: var(--crud-shadow-md);
  transform: translateY(-1px);
}

.kanban-card:active {
  cursor: grabbing;
}

/* Status-based left border colors */
.kanban-card--pending       { border-left-color: #6c757d; }
.kanban-card--in_progress   { border-left-color: #0d6efd; }
.kanban-card--completed     { border-left-color: #198754; }
.kanban-card--cancelled     { border-left-color: #dc3545; }
.kanban-card--expired       { border-left-color: #fd7e14; }

/* Expired warning style */
.kanban-card--expired {
  opacity: 0.9;
}

.kanban-card--expired .kanban-card__header {
  background: #fff3cd22;
}

/* Drag handle */
.kanban-card__drag-handle {
  color: var(--crud-text-subtle);
  cursor: grab;
  font-size: 0.7rem;
  padding: 0.15rem;
  line-height: 1;
}

.kanban-card__drag-handle:active {
  cursor: grabbing;
}

/* Card header - COMPACT */
.kanban-card__header {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--crud-border-light);
  min-height: 28px;
}

.kanban-card__order {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--crud-text-subtle);
  flex: 1;
  line-height: 1;
}

.kanban-card__badge {
  font-size: 0.6rem;
  padding: 0.15em 0.4em;
  line-height: 1;
}

/* User color indicator - small colored circle */
.kanban-card__user-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* Sales name styling */
.kanban-card__sales {
  font-size: 0.7rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.kanban-card__sales i {
  font-size: 0.65rem;
}

/* Card body - COMPACT */
.kanban-card__body {
  padding: 0.4rem 0.5rem;
  flex: 1;
  min-height: 0;
}

.kanban-card__outlet {
  font-weight: 600;
  font-size: 0.78rem;
  margin-bottom: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.kanban-card__link {
  color: var(--crud-text);
  text-decoration: none;
}

.kanban-card__link:hover {
  color: #0d6efd;
  text-decoration: underline;
}

.kanban-card__meta {
  font-size: 0.7rem;
  color: var(--crud-text-subtle);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.kanban-card__meta i {
  font-size: 0.65rem;
}

/* Card footer - COMPACT */
.kanban-card__footer {
  display: block;
  padding: 0.3rem 0.5rem;
  border-top: 1px solid var(--crud-border-light);
  font-size: 0.7rem;
  color: var(--crud-text-subtle);
  text-decoration: none;
  text-align: center;
  line-height: 1;
}

.kanban-card__footer:hover {
  background: var(--crud-bg-light);
  color: var(--crud-text);
}

.kanban-card__footer i {
  font-size: 0.65rem;
}

/* Card being dragged */
.kanban-card.is-dragging {
  opacity: 0.5;
  transform: scale(0.98) rotate(2deg);
  box-shadow: 0 8px 16px rgba(0,0,0,0.15);
}

/* Drop zone highlight */
.kanban-column.drop-highlight {
  border-color: #0d6efd;
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.2);
  background: #f0f6ff;
}

/* Empty placeholder - COMPACT */
.kanban-empty-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  border: 1px dashed var(--crud-border);
  border-radius: var(--crud-radius-sm);
  color: var(--crud-text-subtle);
  font-size: 0.75rem;
  background: #f8f9fa;
}

/* Area section header - COMPACT */
.kanban-area-header {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.5rem;
  margin-top: 0.3rem;
  margin-bottom: 0.2rem;
  background: #e9ecef;
  border-radius: var(--crud-radius-sm);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--crud-text);
  border-left: 2px solid #6c757d;
}

.kanban-area-header:first-child {
  margin-top: 0;
}

.kanban-area-header__icon {
  color: #6c757d;
  font-size: 0.65rem;
}

.kanban-area-header__name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kanban-area-header__count {
  background: #fff;
  color: #6c757d;
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  border-radius: 10px;
  font-weight: 700;
}

/* Load more button container */
.kanban-column .p-2.border-top {
  padding: 0.35rem !important;
}

.kanban-column .btn-outline-secondary {
  padding: 0.3rem 0.5rem;
  font-size: 0.75rem;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .kanban-columns {
    gap: 0.75rem;
  }

  .kanban-column {
    min-height: 150px;
  }

  .kanban-card {
    font-size: 0.9rem;
  }
}

/* ============================================================
   PRODUCT PURCHASE ORDER KANBAN
   ============================================================ */

.ppo-kanban .kanban-columns {
  grid-template-columns: repeat(6, minmax(200px, 1fr));
}

@media (max-width: 1400px) {
  .ppo-kanban .kanban-columns {
    grid-template-columns: repeat(3, minmax(250px, 1fr));
  }
}

@media (max-width: 768px) {
  .ppo-kanban .kanban-columns {
    grid-template-columns: repeat(2, minmax(250px, 1fr));
  }
}

.ppo-kanban .kanban-card {
  font-size: 0.8rem;
  transition: all 0.2s ease;
}

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

.ppo-kanban .card-header {
  font-size: 0.75rem;
}

.ppo-kanban .kanban-column__body {
  scrollbar-width: thin;
  scrollbar-color: #ced4da #f8f9fa;
}

.ppo-kanban .kanban-column__body::-webkit-scrollbar {
  width: 6px;
}

.ppo-kanban .kanban-column__body::-webkit-scrollbar-track {
  background: #f8f9fa;
  border-radius: 3px;
}

.ppo-kanban .kanban-column__body::-webkit-scrollbar-thumb {
  background: #ced4da;
  border-radius: 3px;
}
