html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

/* Enhanced focus indicators for WCAG compliance */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus, .form-select:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #0056b3;
  outline: 3px solid #0056b3;
  outline-offset: 2px;
}

/* Focus for links */
a:focus {
  outline: 3px solid #0056b3;
  outline-offset: 2px;
}

/* Skip link styling */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #000;
  color: #fff;
  padding: 8px;
  text-decoration: none;
  z-index: 100;
}

.skip-link:focus {
  top: 0;
  outline: 3px solid #fff;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* Priority Board Styles */
.priority-board {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  border: 1px solid #dee2e6;
  order: 1; /* Default order */
}

/* Mobile: Move priority board below the table */
@media (max-width: 767px) {
  .priority-board {
    order: 3;
    margin-top: 20px;
    margin-bottom: 0 !important;
    padding: 15px;
  }

  .tasks-table-container {
    order: 2;
  }

  .page-content-wrapper {
    display: flex;
    flex-direction: column;
  }

  /* Better touch targets on mobile */
  .task-card {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    padding: 12px;
  }

  .table tbody tr {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
  }

  .task-drag-handle {
    font-size: 20px;
    padding: 4px;
  }

  .priority-header h6 {
    font-size: 0.85rem;
  }

  .task-slot-empty {
    padding: 20px 10px;
    min-height: 60px;
  }
}

.priority-column {
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  height: 100%;
}

.priority-header {
  padding: 10px 12px;
  font-weight: 600;
}

.priority-header h6 {
  font-size: 0.9rem;
}

.priority-slots {
  padding: 10px;
  min-height: 180px;
}

@media (max-width: 991px) {
  .priority-slots {
    min-height: 150px;
  }
}

.task-card {
  background: white;
  border: 2px solid #dee2e6;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 8px;
  cursor: default;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

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

.task-card.dragging {
  opacity: 0.5;
  transform: rotate(2deg);
}

.task-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.task-drag-handle {
  color: #6c757d;
  font-size: 16px;
  cursor: grab;
  user-select: none;
}

.task-drag-handle:active {
  cursor: grabbing;
}

.task-card-title {
  font-weight: 500;
  color: #212529;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-card-meta {
  margin-top: 6px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.task-slot-empty {
  border: 2px dashed #ced4da;
  border-radius: 6px;
  padding: 15px 10px;
  margin-bottom: 8px;
  text-align: center;
  background: #f8f9fa;
  transition: all 0.2s ease;
}

.task-slot-empty.drag-over {
  background: #e7f3ff;
  border-color: #0d6efd;
  border-style: solid;
}

.slot-placeholder {
  color: #6c757d;
  font-size: 13px;
  font-style: italic;
}

.priority-slots.drag-over {
  background: #f0f8ff;
}

/* Make table rows draggable (only via drag handle) */
.table tbody tr {
  cursor: default;
}

.table tbody tr.dragging {
  opacity: 0.5;
}

.table tbody tr:hover {
  background-color: rgba(0, 123, 255, 0.05);
}

/* Table drag handle */
.table-drag-handle-cell {
  padding: 8px 4px !important;
  text-align: center;
  vertical-align: middle;
}

.table-drag-handle {
  color: #6c757d;
  font-size: 16px;
  cursor: grab;
  user-select: none;
  display: inline-block;
  padding: 4px;
}

.table-drag-handle:active {
  cursor: grabbing;
}

.table-drag-handle:focus {
  outline: 3px solid #0056b3;
  outline-offset: 2px;
  background-color: rgba(0, 86, 179, 0.1);
  border-radius: 3px;
}

/* Focus indicators for draggable elements */
.task-card:focus,
.task-slot-empty:focus {
  outline: 3px solid #0056b3;
  outline-offset: 2px;
  box-shadow: 0 0 8px rgba(0, 86, 179, 0.5);
}

.task-drag-handle:focus {
  outline: 3px solid #0056b3;
  outline-offset: 2px;
  background-color: rgba(0, 86, 179, 0.1);
}

/* Keyboard selection state */
.task-card.keyboard-selected {
  background-color: #cce5ff;
  border: 3px solid #0056b3;
  box-shadow: 0 0 12px rgba(0, 86, 179, 0.7);
  transform: scale(1.02);
}

/* Ensure adequate color contrast for warning badge (WCAG AA) */
.bg-warning {
  background-color: #ff8c00 !important; /* Dark orange for better contrast */
  color: #000 !important;
}

/* Improve text contrast on danger background */
.bg-danger {
  background-color: #c82333 !important;
  color: #fff !important;
}

/* Improve info badge contrast */
.bg-info {
  background-color: #0c5460 !important;
  color: #fff !important;
}

/* Toast notifications z-index */
.toast-container {
  z-index: 9999;
}

/* High contrast for overdue dates */
.text-danger {
  color: #cc0000 !important;
  font-weight: bold;
}

/* Ensure visually-hidden content is properly hidden */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.visually-hidden-focusable:not(:focus):not(:focus-within) {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Keyboard navigation for priority slots */
.priority-slots:focus-within {
  background: #f0f8ff;
  outline: 2px solid #0056b3;
  outline-offset: 2px;
}

/* Better contrast for completed tasks */
.table-secondary {
  background-color: #e9ecef !important;
}

.text-decoration-line-through {
  opacity: 0.7;
}

/* Improve checkbox visibility and focus */
.form-check-input {
  width: 1.25em;
  height: 1.25em;
  cursor: pointer;
}

.form-check-input:focus {
  border-color: #0056b3;
  box-shadow: 0 0 0 0.25rem rgba(0, 86, 179, 0.25);
}

/* Ensure button text has sufficient contrast */
.btn-outline-secondary:hover {
  color: #fff;
  background-color: #6c757d;
  border-color: #6c757d;
}

/* Condensed Priority Template Overlay (for mobile/tablet during drag) */
.condensed-priority-overlay {
  position: fixed;
  top: 0;
  right: 0;
  width: 200px;
  height: 100vh;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: -4px 0 12px rgba(0, 0, 0, 0.2);
  z-index: 1050;
  overflow-y: auto;
  transition: transform 0.2s ease;
}

.condensed-priority-overlay.active {
  transform: translateX(0);
}

.condensed-priority-header {
  background: #0d6efd;
  color: white;
  padding: 12px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 1;
}

.condensed-priority-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.condensed-priority-list {
  padding: 10px;
}

.condensed-priority-item {
  background: white;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  margin-bottom: 12px;
  padding: 12px 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.condensed-priority-item:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.condensed-priority-item.drag-over {
  background: #e7f3ff;
  border-color: #0d6efd;
  border-width: 3px;
  transform: scale(1.05);
}

.condensed-item-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
}

.priority-icon {
  font-size: 1.2rem;
}

.priority-name {
  font-weight: 600;
  flex: 1;
}

.priority-slots-count {
  font-size: 0.75rem;
  color: #6c757d;
}

/* Color variations for condensed items */
.condensed-priority-item.urgent-item {
  border-left: 5px solid #c82333;
}

.condensed-priority-item.high-item {
  border-left: 5px solid #ff8c00;
}

.condensed-priority-item.medium-item {
  border-left: 5px solid #0c5460;
}

.condensed-priority-item.low-item {
  border-left: 5px solid #6c757d;
}

/* Hide condensed overlay on larger screens */
@media (min-width: 992px) {
  .condensed-priority-overlay {
    display: none !important;
  }
}

/* Adjust width on very small screens */
@media (max-width: 480px) {
  .condensed-priority-overlay {
    width: 160px;
  }

  .condensed-item-header {
    font-size: 0.8rem;
  }

  .priority-icon {
    font-size: 1rem;
  }
}