/* ══════════════════════════════════════════════════════
   GOOGLE FONTS
   - Montserrat: main body font (clean & modern)
   - Chakra Petch: used for column headers (techy feel)
   - Fira Code: monospace font for task counts
══════════════════════════════════════════════════════ */
@import url("https://fonts.googleapis.com/css2?family=Chakra+Petch:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Fira+Code:wght@300..700&display=swap");

/* ══════════════════════════════════════════════════════
   CSS RESET
   Removes default browser padding/margin so we start fresh
══════════════════════════════════════════════════════ */
* {
  padding: 0;
  margin: 0;
  box-sizing: border-box; /* padding doesn't add to element size */
}

/* ══════════════════════════════════════════════════════
   CSS CUSTOM PROPERTIES (Variables)
   Define colors, spacing, and fonts once — reuse everywhere.
   Change a variable here and it updates throughout the whole app!
══════════════════════════════════════════════════════ */
:root {
  /* Background colors — dark theme layers */
  --bg: #080c14;
  --surface: #0d1420;
  --surface-2: #111827;

  /* Border colors */
  --border: rgba(255, 255, 255, 0.1);
  --border-hover: rgba(255, 255, 255, 0.22);
  --border-color: #20b2aa; /* used for search highlight */

  /* Text colors */
  --text: #ffffff;
  --text-muted: #8a95a8; /* dimmer text for descriptions */
  --text-dim: #4a5568;

  /* Accent colors for each column status */
  --accent-todo: #5b8fff; /* blue for To Do */
  --accent-progress: #ffb340; /* amber for In Progress */
  --accent-done: #3ddc84; /* green for Done */
  --danger: #ff5470; /* red for delete */

  /* Border radius (rounded corners) */
  --radius: 10px;
  --radius-lg: 16px;

  /* Font families */
  --font-family: "Montserrat", sans-serif;
  --font-mono: "Fira Code", monospace;
  --font-family2: "Chakra Petch", sans-serif;

  /* Spacing scale — using a consistent scale keeps the UI harmonious */
  --padding-basic: 2px;
  --padding-xs: 6px;
  --padding-s: 10px;
  --padding-m: 15px;
  --padding-l: 20px;
  --padding-xl: 25px;
  --padding-xxl: 30px;
  --padding-xxxl: 40px;
}

/* ══════════════════════════════════════════════════════
   BASE STYLES
   Set up the full-height layout for the page
══════════════════════════════════════════════════════ */
html,
body {
  height: 100%;
  width: 100%;
  background-color: var(--bg);
  color: var(--text);
}

body {
  font-family: var(--font-family);
  display: flex;
  flex-direction: column; /* header on top, main fills the rest */
  overflow-x: hidden;
}

/* ══════════════════════════════════════════════════════
   HEADER
   Fixed top bar with brand, search, and "New Task" button
══════════════════════════════════════════════════════ */
header {
  height: 70px;
  border-bottom: 1px solid rgb(39, 39, 39);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--padding-s) var(--padding-xxxl);
  gap: var(--padding-m);
  flex-shrink: 0; /* don't shrink the header */
  position: sticky; /* stays at top when scrolling */
  top: 0;
  z-index: 10;
  background-color: var(--bg);
}

/* Brand / Logo area */
.brand {
  display: flex;
  gap: var(--padding-xs);
  align-items: center;
  font-weight: 400;
  font-family: var(--font-family2);
  flex-shrink: 0; /* logo never shrinks */
}

.brand h1 {
  font-size: 15px;
  letter-spacing: 7px;
  font-weight: 800;
  white-space: nowrap;
}

.bracket {
  font-size: 20px;
  color: rgb(126, 167, 230);
}

/* New Task button in the header */
header nav button {
  padding: var(--padding-s) var(--padding-xl);
  border-radius: var(--padding-s);
  border: none;
  outline: none;
  background-color: var(--accent-todo);
  color: white;
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 13px;
  transition: 0.3s ease-in-out;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

header nav button:hover {
  transform: translateY(-2px);
  /* Glow effect on hover using box-shadow */
  box-shadow:
    0 0 10px #5b8fff,
    0 0 30px rgba(91, 143, 255, 0.3);
}

/* Search input wrapper */
.search-wrapper {
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  border-radius: var(--padding-s);
  padding: var(--padding-basic) var(--padding-m);
  flex: 0 1 450px; /* can shrink but max 450px */
  background-color: var(--surface-2);
  gap: var(--padding-xs);
  transition: border-color 0.3s;
}

.search-wrapper:focus-within {
  border-color: var(--accent-todo); /* highlight when user types inside */
}

.search-icon {
  font-size: 20px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.search-wrapper input {
  border: none;
  outline: none;
  background-color: transparent;
  padding: var(--padding-xs) var(--padding-s);
  width: 100%;
  color: white;
  font-family: var(--font-family);
  font-size: 14px;
}

/* ══════════════════════════════════════════════════════
   MAIN / BOARD LAYOUT
   The three-column Kanban board
══════════════════════════════════════════════════════ */
main {
  flex: 1; /* fills all remaining height after the header */
  width: 100%;
  overflow: hidden;
}

/* Board: horizontal flex container for the three columns */
.board {
  display: flex;
  height: 100%;
  padding: var(--padding-s) var(--padding-xl);
  gap: var(--padding-m);
  align-items: flex-start;
  overflow-y: auto; /* scroll if columns get tall */
}

/* ══════════════════════════════════════════════════════
   COLUMNS
   Each of the three Kanban columns (To Do, In Progress, Done)
══════════════════════════════════════════════════════ */
.column {
  border: 1px solid rgb(39, 39, 39);
  flex: 1 1 0; /* equal-width columns */
  min-width: 0; /* prevents overflow in flex context */
  margin-top: var(--padding-s);
  border-radius: var(--padding-l);
  background-color: var(--surface);
  min-height: 300px;
  display: flex;
  flex-direction: column;
  transition:
    border-color 0.5s ease-in-out,
    box-shadow 0.5s ease-in-out;
}

/* Column header (title + count badge) */
.info {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid rgb(39, 39, 39);
  padding: var(--padding-m) var(--padding-s);
  align-items: center;
  font-family: var(--font-family2);
}

/* Task count badge */
.info p.count {
  font-family: var(--font-mono);
  border: 1px solid rgb(56, 56, 56);
  padding: 2px var(--padding-s);
  border-radius: var(--padding-xxl);
  font-size: 13px;
  color: rgb(160, 149, 149);
}

.info h2 {
  line-height: 1.5;
  font-size: 14px;
  font-family: var(--font-family);
  color: rgb(196, 196, 196);
  margin-left: var(--padding-s);
  display: flex;
  align-items: center;
}

/* Colored dot next to column title */
.dot {
  height: 8px;
  width: 8px;
  border-radius: 50%;
  margin-right: var(--padding-s);
  flex-shrink: 0;
}

.dot1 {
  background-color: var(--accent-todo);
}
.dot2 {
  background-color: var(--accent-progress);
}
.dot3 {
  background-color: var(--accent-done);
}

/* Column body: where tasks live */
.column-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--padding-s);
  gap: var(--padding-m);
  align-content: flex-start;
  align-items: stretch;
  overflow-y: auto; /* scroll if too many tasks */
  min-height: 80px; /* minimum droppable area */
}

/* ══════════════════════════════════════════════════════
   TASK CARDS
   Individual task items inside a column
══════════════════════════════════════════════════════ */
.task {
  display: flex;
  flex-direction: column;
  border: 1px solid rgb(39, 39, 39);
  padding: var(--padding-m);
  border-radius: var(--padding-s);
  background-color: var(--surface-2);
  cursor: grab;
  gap: var(--padding-xs);
  transition:
    border-color 0.3s,
    box-shadow 0.3s,
    opacity 0.2s;
  animation: fadeIn 0.25s ease-out; /* smooth appear on create */
}

/* Fade-in animation when a task is first created */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.task:hover {
  border-color: rgb(78, 78, 78);
  box-shadow:
    0px 10px 13px -7px #000000,
    1px 5px 19px 3px rgba(0, 0, 0, 0.26);
}

/* Task being dragged */
.task.dragging {
  opacity: 0.4;
  cursor: grabbing;
}

.task h2 {
  font-size: 15px;
  font-weight: 600;
  word-break: break-word; /* wrap long titles */
}

.task p {
  font-size: 13px;
  color: var(--text-muted);
  word-break: break-word;
  line-height: 1.5;
}

/* Edit and Delete buttons row at the bottom of each task */
.task .task-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--padding-s);
  margin-top: var(--padding-xs);
  flex-wrap: wrap; /* wrap on very small screens */
}

.task .task-actions .btn {
  padding: var(--padding-xs) var(--padding-l);
  border: none;
  outline: none;
  font-size: 12px;
  font-family: var(--font-family);
  border-radius: 5px;
  font-weight: 500;
  transition: 0.2s ease-in-out;
  cursor: pointer;
}

/* Edit button styling */
.task .task-actions .edit-button {
  background-color: #191946;
  color: #7e7ee1;
  border: 1px solid #36365a;
}

.task .task-actions .edit-button:hover {
  border-color: #7e7ee1;
  transform: translateY(-2px);
}

/* Delete button styling */
.task .task-actions .delete-button {
  background-color: rgba(255, 69, 96, 0.08);
  border: 0.5px solid #4d3a3a;
  color: var(--danger);
}

.task .task-actions .delete-button:hover {
  border-color: var(--danger);
  transform: translateY(-2px);
}

/* ══════════════════════════════════════════════════════
   MODAL
   The popup dialog for creating and editing tasks.

   By default, the modal is HIDDEN (display: none).
   When the "open" class is added via JavaScript, it becomes visible.
══════════════════════════════════════════════════════ */
.modal {
  display: none; /* hidden by default */
  position: fixed; /* stays in place even when page scrolls */
  inset: 0; /* shorthand for top/right/bottom/left: 0 */
  justify-content: center;
  align-items: center;
  z-index: 100; /* appears above everything else */
}

/* Adding class "open" makes the modal visible */
.modal.open {
  display: flex;
}

/* Blurred backdrop behind modal */
.modal .bg {
  position: absolute;
  inset: 0;
  backdrop-filter: blur(5px);
  background-color: rgba(0, 0, 0, 0.4);
}

/* Modal card itself */
.modal .center {
  position: relative;
  z-index: 1; /* above the backdrop */
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--padding-s);
  padding: var(--padding-l);
  width: min(440px, 90vw); /* never wider than 90% of screen */
  gap: var(--padding-xxl);
  background-color: var(--surface-2);
  box-shadow: 1px 5px 25px 4px rgba(231, 231, 231, 0.1);
  animation: slideUp 0.2s ease-out;
}

/* Modal slide-up animation */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Modal header: title + close button */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--padding-s);
}

.modal-header h2 {
  font-size: 18px;
}

/* Close (X) button */
.close-modal {
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: var(--padding-xs);
  font-size: 14px;
  display: flex;
  align-items: center;
  color: rgb(153, 153, 153);
  background-color: var(--surface);
  cursor: pointer;
  transition: 0.1s ease-in;
  line-height: 1;
}

.close-modal:hover {
  background-color: rgba(155, 48, 48, 0.329);
  border-color: var(--danger);
  color: var(--danger);
}

/* Modal form fields */
.modal-body {
  display: flex;
  flex-direction: column;
  gap: var(--padding-xl);
}

.modal-body input,
.modal-body textarea {
  border: 1px solid var(--border);
  outline: none;
  background-color: var(--surface);
  width: 100%;
  padding: var(--padding-s) var(--padding-m);
  border-radius: 8px;
  color: white;
  font-family: var(--font-family);
  font-size: 14px;
  transition: border-color 0.3s;
}

.modal-body input:focus,
.modal-body textarea:focus {
  border-color: var(--accent-todo); /* highlight active field */
}

.modal-body textarea {
  resize: vertical; /* user can resize height only */
  min-height: 80px;
}

/* Add/Save button inside modal */
.modal-body .add-task {
  padding: var(--padding-m);
  border: none;
  outline: none;
  background-color: var(--accent-todo);
  color: white;
  font-family: var(--font-family);
  font-size: 15px;
  border-radius: var(--padding-s);
  font-weight: 600;
  width: 100%;
  cursor: pointer;
  transition: 0.3s ease-in-out;
}

.modal-body .add-task:hover {
  transform: translateY(-2px);
  box-shadow:
    0 0 10px #5b8fff,
    0 0 30px rgba(91, 143, 255, 0.3);
}

/* ══════════════════════════════════════════════════════
   DRAG & DROP VISUAL FEEDBACK
   When you drag a task and hover over a column, it glows
══════════════════════════════════════════════════════ */
.column.hover-over {
  border-color: var(--accent-todo);
  box-shadow: -1px 1px 35px -18px var(--accent-todo);
}

/* ══════════════════════════════════════════════════════
   SEARCH HIGHLIGHT
   Tasks that match the search query get a teal glow
══════════════════════════════════════════════════════ */
.task.highlight {
  border-color: var(--border-color);
  box-shadow: -1px 1px 35px -18px var(--border-color);
}

/* ══════════════════════════════════════════════════════
   DONE COLUMN GLOW
   When a task is dropped into Done, it briefly glows green
══════════════════════════════════════════════════════ */
.task.green {
  border-color: var(--accent-done);
  box-shadow: -1px 1px 35px -18px var(--accent-done);
  transition: 0.4s ease-in-out;
}

/* ══════════════════════════════════════════════════════
   MOVE TO BUTTON
   Only visible on mobile — lets users move tasks between
   columns without needing drag and drop
══════════════════════════════════════════════════════ */
.move-wrapper {
  position: relative;
}

.move-button {
  background-color: #0f2a1a;
  color: var(--accent-done);
  border: 1px solid #1a4a2a;
  display: none; /* hidden on desktop, shown on mobile */
}

.move-button:hover {
  border-color: var(--accent-done);
  transform: translateY(-2px);
}

.move-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  z-index: 50;
  min-width: 130px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.move-menu.open {
  display: flex;
  flex-direction: column;
}

.move-option {
  padding: var(--padding-s) var(--padding-m);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-family);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: 0.15s;
}

.move-option:hover {
  background-color: var(--surface-2);
  color: var(--text);
}

/* ══════════════════════════════════════════════════════
   MOBILE TABS
   On small screens (< 768px), show tab buttons to switch columns.
   Hidden by default on desktop.
══════════════════════════════════════════════════════ */
.mobile-tabs {
  display: none; /* hidden on desktop */
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS

   Breakpoints are screen-size thresholds where the layout changes.
   - max-width: 900px → tablet
   - max-width: 600px → mobile (single column)
══════════════════════════════════════════════════════ */

/* ── TABLET (900px and below) ── */
@media (max-width: 900px) {
  /* Reduce header padding on smaller screens */
  header {
    padding: var(--padding-s) var(--padding-l);
    height: auto;
    flex-wrap: wrap;
    gap: var(--padding-s);
    padding-top: 12px;
    padding-bottom: 12px;
  }

  /* Let search bar take full width when wrapped */
  .search-wrapper {
    flex: 1 1 100%;
    order: 3; /* moves search below logo + button */
  }

  .brand {
    order: 1;
  }
  header nav {
    order: 2;
  }

  /* Slightly reduce column gap */
  .board {
    padding: var(--padding-s) var(--padding-m);
    gap: var(--padding-s);
  }
}

/* ── MOBILE (600px and below) ── */
@media (max-width: 600px) {
  /* Stack header items */
  header {
    padding: var(--padding-s) var(--padding-m);
  }

  header nav button {
    padding: var(--padding-xs) var(--padding-m);
    font-size: 12px;
  }

  /* Show the mobile tab switcher */
  .mobile-tabs {
    display: flex;
    justify-content: center;
    gap: 0;
    padding: var(--padding-s) var(--padding-m);
    border-bottom: 1px solid rgb(39, 39, 39);
    background-color: var(--bg);
    position: sticky;
    top: 60px; /* below the header */
    z-index: 9;
  }

  /* Individual tab buttons */
  .tab-btn {
    flex: 1;
    padding: var(--padding-s);
    background: var(--surface);
    color: var(--text-muted);
    border: 1px solid rgb(39, 39, 39);
    font-family: var(--font-family);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
  }

  .tab-btn:first-child {
    border-radius: 8px 0 0 8px;
  }
  .tab-btn:last-child {
    border-radius: 0 8px 8px 0;
  }

  /* show the move button only on mobile */
  .move-button {
    display: inline-flex;
  }

  /* Active tab gets the blue accent color */
  .tab-btn.active {
    background-color: var(--accent-todo);
    color: white;
    border-color: var(--accent-todo);
  }

  /* On mobile: hide all columns, show only the active one */
  .board {
    display: block; /* switch from flex to block */
    padding: var(--padding-s);
    height: calc(100vh - 130px); /* fill the screen minus header + tabs */
    overflow-y: auto;
  }

  .column {
    display: none; /* hidden by default on mobile */
    width: 100%;
    margin: 0;
    border-radius: var(--radius);
  }

  /* JavaScript adds class "active-column" to show the selected column */
  .column.active-column {
    display: flex;
  }
}
