/* Base styles and orangey colour scheme */
body {
  margin: 0;
  font-family: Arial, sans-serif;
  background-color: #fff3e0;
  color: #4e342e;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Board header */
#board-header {
  display: flex;
  align-items: center;
  background: linear-gradient(135deg, #ff9800, #e65100);
  padding: 14px 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  color: #fff;
}

#board-title {
  margin: 0;
  font-size: 28px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

/* Nav up button */
.nav-button {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 18px;
  margin-right: 10px;
  color: #fff;
}
.nav-button:hover {
  background: rgba(255,255,255,0.3);
}
#nav-up-btn.hidden {
  display: none;
}

/* Kanban board container */
#kanban-board {
  display: flex;
  align-items: flex-start;
  overflow-x: auto;
  padding: 10px;
  flex: 1;
  min-height: 0;
}

/* List container */
.list {
  background-color: #ffe0b2;
  border: 1px solid #ff9800;
  border-radius: 4px;
  width: 300px;
  margin-right: 10px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

/* Glowing effect when selected */
.list.selected {
  box-shadow: 0 0 10px 2px rgba(255,152,0,0.8);
  animation: pulse 2s infinite;
}

/* Unsynced indicator */
.unsynced {
  border-left: 3px solid #ff5722;
}

/* List header */
.list-header {
  position: relative;
  padding: 8px;
  padding-right: 60px;
  background: linear-gradient(180deg, #ff9800, #f57c00);
  border-bottom: 2px solid #e65100;
}

/* List header title */
.list-header .list-title {
  display: block;
  width: 100%;
  box-sizing: border-box;
  outline: none;
  font-weight: bold;
}

/* Action buttons container for list header */
.list-header .action-buttons {
  position: absolute;
  right: 40px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out;
}

/* When the list header is selected and not editing, show the action buttons */
.list-header.selected:not(.editing) .action-buttons {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

/* Drill-down button */
.nav-down-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
}

.delete-all-btn {
  position: absolute;
  right: 36px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
}

/* Card container inside list */
.card-container {
  flex-grow: 1;
  padding: 8px;
  overflow-y: auto;
  min-height: 50px;
}

/* Zones for adding a new card above and below the card container */
.card-add-zone {
  height: 15px;
  line-height: 15px;
  text-align: center;
  font-weight: bold;
  color: rgba(0, 0, 0, 0.5);
  cursor: pointer;
  user-select: none;
  border: 1px dashed rgba(0, 0, 0, 0.2);
  margin: 2px 0;
}

/* Card styling */
.card {
  background-color: #ffcc80;
  border: 1px solid #ff9800;
  border-radius: 4px;
  padding: 8px;
  margin-bottom: 8px;
  cursor: grab;
  position: relative;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  transition: box-shadow 0.15s ease;
}
.card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Selected card: glowing border */
.card.selected {
  box-shadow: 0 0 10px 2px rgba(255,152,0,0.8);
  animation: pulse 2s infinite;
}

/* Dragging card: faster pulse, reduced opacity */
.card.dragging {
  opacity: 0.8;
  cursor: grabbing;
  animation: pulse 0.5s infinite;
}

/* Card title takes full width */
.card .card-title {
  width: 100%;
  outline: none;
  min-height: 16px;
}

/* Action buttons container for cards */
.card .action-buttons {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out;
}

/* Show card action buttons when card is selected and not editing */
.card.selected:not(.editing) .action-buttons {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

/* Pulse animation */
@keyframes pulse {
  0% { box-shadow: 0 0 5px 2px rgba(255,152,0,0.8); }
  50% { box-shadow: 0 0 15px 4px rgba(255,152,0,1); }
  100% { box-shadow: 0 0 5px 2px rgba(255,152,0,0.8); }
}

/* Styling for action buttons (both for lists and cards) */
.action-buttons button {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.action-buttons button:hover {
  background: #f0f0f0;
}

/* Card delete button styling */
.card-delete-btn {
  color: #d32f2f;
  border-color: #d32f2f;
}

/* Modal overlay to dim background */
#modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#modal-overlay.hidden {
  display: none;
}

/* Modal box */
#modal {
  width: 75vw;
  height: 75vh;
  background: #fff3e0;
  border: 2px solid #ff9800;
  border-radius: 8px;
  padding: 20px;
  box-sizing: border-box;
  overflow: auto;
  z-index: 1001;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}

/* Modal content */
#modal-content {
  width: 100%;
  height: 100%;
}
#modal-textarea {
  width: 100%;
  height: 100%;
  border: 1px solid #ff9800;
  border-radius: 4px;
  padding: 8px;
  resize: vertical;
  box-sizing: border-box;
}

/* Hide board title if necessary */
#board-title.hidden {
  display: none;
}

/* Custom dialog overlay */
#dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
#dialog-overlay.hidden {
  display: none;
}
#dialog-box {
  background: #fff3e0;
  border: 2px solid #ff9800;
  border-radius: 8px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  text-align: center;
}
#dialog-message {
  margin: 0 0 20px 0;
  font-size: 16px;
  color: #4e342e;
  line-height: 1.5;
}
#dialog-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}
#dialog-buttons button {
  padding: 8px 24px;
  border-radius: 4px;
  border: 1px solid #ff9800;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
}
#dialog-ok-btn {
  background: linear-gradient(180deg, #ff9800, #f57c00);
  color: #fff;
  border-color: #e65100;
}
#dialog-ok-btn:hover {
  background: linear-gradient(180deg, #ffa726, #ff9800);
}
#dialog-cancel-btn {
  background: #fff;
  color: #4e342e;
}
#dialog-cancel-btn:hover {
  background: #f5f5f5;
}

/* Dragging list: reduced opacity */
.list.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

/* Vertical drop indicator for list reordering */
.list-drop-indicator {
  width: 3px;
  background: #e65100;
  border-radius: 2px;
  margin: 0 4px;
  flex-shrink: 0;
  align-self: stretch;
  pointer-events: none;
}

/* Drop indicator line for drag & drop */
.drop-indicator {
  height: 3px;
  background: #e65100;
  border-radius: 2px;
  margin: 2px 0;
  pointer-events: none;
}

/* Collapsible help section */
#kanban-help {
  background: #ffe0b2;
  border-bottom: 1px solid #ffb74d;
  padding: 0 18px;
  font-size: 14px;
  color: #4e342e;
}
#kanban-help summary {
  cursor: pointer;
  padding: 8px 0;
  font-weight: bold;
  color: #e65100;
  outline: none;
  user-select: none;
}
#kanban-help summary:hover {
  color: #bf360c;
}
#kanban-help .help-content {
  padding: 4px 0 12px 0;
  line-height: 1.6;
}
#kanban-help .help-content dt {
  font-weight: bold;
  margin-top: 6px;
  color: #e65100;
}
#kanban-help .help-content dd {
  margin: 0 0 4px 16px;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  #kanban-board {
    flex-direction: column;
  }
  .list {
    width: 95%;
    margin: 10px auto;
  }
  .list-drop-indicator {
    width: auto;
    height: 3px;
    margin: 4px 0;
    align-self: auto;
  }
  #modal {
    width: 90vw;
    height: 60vh;
  }
}
