/* =================================
   Root Variables & Base Styles
   ================================= */
:root {
  --bg: #f7f8fa;
  --panel: #fff;
  --text: #1f2430;
  --muted: #6b7280;
  --primary: #3b82f6;
  --primary-light: #f4f9ff;
  --border: #e5e7eb;
  --error: #ef4444;
  --alert: #f08a00;
  --shadow: 0 6px 20px rgba(0, 0, 0, .08);
  --radius: 14px;
  --radius-sm: 10px;
  --stripe-mix: 4%;
}

html[data-theme="dark"] {
  --bg: #0f1216;
  --panel: #161a21;
  --text: #e5e7eb;
  --muted: #9aa3b2;
  --primary: #60a5fa;
  --primary-light: #1e293b;
  --border: #242935;
  --error: #812b2b;
  --alert: #da8a4d;
  --shadow: 0 8px 24px rgba(0, 0, 0, .45);

  .card-desc::-webkit-scrollbar {
    width: 8px;
  }

  .card-desc::-webkit-scrollbar-track {
    background: var(--panel);
    border-radius: 4px;
  }

  .card-desc::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 4px;
    border: 2px solid var(--panel);
  }

  .card-desc::-webkit-scrollbar-thumb:hover {
    background-color: var(--muted);
  }

  .card-desc {
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--panel);
  }
}

* {
  box-sizing: border-box
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial, sans-serif
}

/* Utility class to prevent body scrolling when a dialog is open */
body.dialog-open {
  overflow: hidden;
}

/* =================================
   Header & Toolbar
   ================================= */
.app-header {
  position: sticky;
  /* position: relative; */
  top: 0;
  z-index: 5;
  backdrop-filter: saturate(1.2) blur(6px);
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  border-bottom: 1px solid var(--border);
  padding: 12px clamp(12px, 2vw, 20px);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap
}

.title {
  margin: 0;
  font-size: clamp(18px, 2.2vw, 22px);
  font-weight: 700;
  margin-right: 8px;
}

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1;
  flex-wrap: wrap
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: nowrap;
  flex: 1
}

.search {
  flex: 1 1 320px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  outline: none
}

.search:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent)
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap
}

.btn {
  padding: 10px 12px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  /* box-shadow: var(--shadow) */
}

.btn:hover, .btn.secondary:hover {
  transform: translateY(-1px);
  /* background: var(--primary-light); */
}

.btn:focus-visible {
  outline: 2px solid var(--primary)
}

.btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: transparent
}

.btn.error {
  color: var(--error);
  background-color: var(--error);
  color: white;
  border: none;
}

.btn.secondary {
  background: transparent
}

.file-btn {
  font-size: 0.89em;
  text-align: center;
}

#themeToggle,
#menuBtn {
  min-width: 40px;
}

/* --- Dropdown Menu Styles --- */
.dropdown-menu {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background-color: var(--panel);
  min-width: 180px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  z-index: 10;
  padding: 8px;
}

.dropdown-content.show {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dropdown-content .btn {
  width: 100%;
  text-align: left;
}


/* 1. Override default button appearance for menu items */
.dropdown-content .btn {
  background: transparent;
  border: none;
  border-radius: 6px;
  font-weight: 400;
  padding: 8px 12px;
}

/* 2. Add the hover effect */
.dropdown-content .btn:hover {
  background: var(--primary);
  color: var(--primary-light);
  transform: none;
  /* Remove the move-up effect */
}


/* =================================
   Tag Filters
   ================================= */
.tag-filters {
  order: 2;
  flex: 0 0 100%;
  width: 100%;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 16px 20px 0px 20px;
  margin-top: 4px
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px dashed var(--border);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  user-select: none
}

.tag-chip.active {
  border-style: solid;
  color: var(--text)
}

.tag-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%
}


/* =================================
   Board & Columns
   ================================= */
.board {
  position: relative;
  padding: 16px;
  padding-bottom: 24px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scroll-padding-left: 16px;
  min-height: calc(100vh - 150px);
  z-index: 1;
}

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

.column {
  min-width: min(340px, 92vw);
  max-width: 420px;
  scroll-snap-align: start;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  flex-shrink: 0;
}

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

.drag-handle {
  border: none;
  background: transparent;
  cursor: grab;
  padding: 4px;
  user-select: none;
  color: var(--muted);
  touch-action: none;
}

.drag-handle:active {
  cursor: grabbing
}

.column-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  outline: none
}

.column-actions {
  margin-left: auto;
  display: flex;
  gap: 6px
}

.cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 20px;
  flex-grow: 1;
}

.btn-add-card {
  align-self: stretch
}

.btn-del-card,
.btn-del-col,
.btn-rename {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 16px;
  line-height: 1;
  box-shadow: none;
  transition: color .2s ease
}

/* --- Archive Column Specific Styles --- */
.column--archive {
  background: repeating-linear-gradient(135deg, var(--panel), var(--panel) 10px, var(--bg) 10px, var(--bg) 20px);
  border-style: dashed;
  display: none;
  /* Hidden by default */
}

.board--archive-visible .column--archive {
  display: flex;
  /* Show when board has the class */
}

/* =================================
   Cards
   ================================= */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  outline: none;
  transition: transform .12s ease, box-shadow .2s ease;
  touch-action: none;
  cursor: pointer;
  word-wrap: break-word;
}

.card:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent)
}

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

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

.card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  flex: 1
}

.card-desc {
  margin: .35rem 0 .25rem;
  color: var(--muted);
  font-size: 13px;
  max-height: 200px;
  overflow: auto;
  scrollbar-width: thin;
}

.card-desc::-webkit-scrollbar {
  width: 8px;
}

.card-desc::-webkit-scrollbar-track {
  background: var(--panel);
  border-radius: 4px;
}

.card-desc::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 4px;
  border: 2px solid var(--panel);
}

.card-desc::-webkit-scrollbar-thumb:hover {
  background-color: var(--muted);
}


.card-meta {
  display: flex;
  gap: 8px;
  flex-direction: column;
}

.card-due {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--muted);
  align-self: flex-end;
  margin-top: 4px;

}

.tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel), var(--primary) 8%)
}

.tag .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%
}

.card-grip {
  width: 16px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: grab;
  touch-action: none;
  user-select: none;
  padding: 0px;
}

.card-grip:active {
  cursor: grabbing
}

/* =================================
   Drag & Drop States
   ================================= */
.card.dragging {
  display: none;
}

.card-ghost {
  position: fixed;
  pointer-events: none;
  opacity: .9;
  transform: rotate(2deg);
  box-shadow: var(--shadow);
  z-index: 9999;
}

.card.placeholder {
  border: 2px dashed var(--primary);
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: .7
}

body.dragging-ui,
body.dragging-ui * {
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none
}

.column-placeholder {
  background: repeating-linear-gradient(45deg,
      color-mix(in srgb, var(--panel), #000 var(--stripe-mix)),
      color-mix(in srgb, var(--panel), #000 var(--stripe-mix)) 6px,
      transparent 6px,
      transparent 12px);
  border: 2px dashed var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  opacity: 0.8;
}

/* =================================
   Dialogs
   ================================= */
dialog::backdrop {
  background: rgba(0, 0, 0, .35);
  backdrop-filter: blur(4px);
}

dialog {
  border: none;
  padding: 0;
  background: transparent
}

.editor-form {
  width: min(680px, 90vw);
  max-height: 90dvh;
  overflow: auto;
  background: var(--panel);
  /* Спрощуємо фон для коректної роботи градієнтів */
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  /* Прибираємо вертикальні відступи, щоб елементи прилипали до країв */
  padding: 0 clamp(16px, 5vw, 24px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.editor-form h3 {
  margin: 0px;
  font-size: 18px;
  font-weight: 800;
  text-align: center;
  position: sticky;
  padding: clamp(12px, 5vw, 8px) 0 12px;
  top: 0;
  background: var(--panel);
}

.editor-form h3::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 20px;
  background: linear-gradient(to bottom, var(--panel), transparent);
  pointer-events: none;
}

.editor-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  color: var(--muted)
}

.editor-form input,
.editor-form textarea {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
  width: 100%;
  font-weight: 400;
}

.editor-form textarea {
  resize: vertical;
  min-height: 96px
}

.editor-form input:focus,
.editor-form textarea:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent)
}

.editor-actions {
  position: sticky;
  bottom: 0;
  background-color: var(--panel);
  padding-top: 12px;
  padding-bottom: clamp(16px, 5vw, 24px);
  z-index: 10;
  /* Видаляємо попередні стилі, які тепер не потрібні */
  margin-top: 6px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Градієнт "згасання" НАД кнопками */
.editor-actions::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  height: 12px;
  background: linear-gradient(to top, var(--panel), transparent);
  pointer-events: none;
}

.editor-actions .btn {
  width: 100%
}

.editor-form-row {
  display: flex;
  flex-direction: row;
  gap: 6px;
}

/* =================================
   Due Date Badges
   ================================= */

/* Base style for any colored due date badge */
.due-badge {
  padding: 4px 10px;
  border-radius: 12px;
}

/* Style for badges indicating a task is due soon (e.g., < 48 hours) */
.due-badge--soon {
  border: 1px solid var(--alert);
  color: var(--alert);
  padding: 2px 8px;
  border-radius: 16px;
}

/* Style for badges indicating a task is overdue */
.due-badge--overdue {
  background-color: var(--error);
  font-weight: 600;
  color: white;
}

/* =================================
   Custom Checkbox / Toggle Switch
   ================================= */

.checkbox-wrapper {
  padding: 6px 0;
  display: flex;
  align-items: center;
}

.editor-form .toggle-switch {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  /* min-height: 35px; */
}

.label-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  user-select: none;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-switch .slider {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  background-color: var(--border);
  border-radius: 999px;
  transition: background-color 0.2s ease-in-out;
}

.toggle-switch .slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background-color: var(--panel);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease-in-out;
}

.toggle-switch input:checked+.slider {
  background-color: var(--primary);
}

.toggle-switch input:checked+.slider:before {
  transform: translateX(20px);
}

.hidden {
  display: none;
}

.content-editor {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
  width: 100%;
  min-height: 96px;
  max-height: 200px;
  resize: vertical;
  overflow: auto;
  font-weight: normal;
  cursor: text;
}

.content-editor:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent);
}

.card-desc a {
  color: var(--primary);
  text-decoration: none;
}

.card-desc a:hover {
  text-decoration: underline;
}

.hotkey-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11px;
  color: var(--muted);
}

.hotkey-hints kbd {
  font-family: monospace;
  background-color: var(--border);
  padding: 4px 6px;
  border-radius: 6px;
  line-height: 1;
  font-size: 10px;
  font-weight: 600;
}

.notification-warning {
  font-size: 12px;
  color: var(--alert);
  background-color: color-mix(in srgb, var(--alert) 10%, transparent);
  border: 1px solid var(--alert);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin: 4px 0 0;
  width: 100%;
}

.notification-warning.hidden {
  display: none;
}

/* =================================
   Responsive Media Queries
   ================================= */

@media (max-width:640px) {
  .hotkey-hints {
    display: none;
  }
}

@media (max-width:700px) {
  .search {
    flex: 1 1 100%
  }

  .actions {
    order: 2;
    flex: 1;
    flex-wrap: wrap
  }

  .actions .btn {
    flex: 1 1 calc(50% - 8px)
  }

  .tag-filters {
    order: 3
  }
}

/* @media (max-width:420px) {
  .editor-actions {
    grid-template-columns: 1fr !important
  }
} */

@media (min-width:900px) {
  .board {
    padding: 24px
  }
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px
}

.editor-form-row {
  flex-direction: column;
}
@media (min-width:640px) {
  .editor-form-row {
    flex-direction: row;
  }
}

.db-provider-choice {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  justify-content: center;
}

.db-provider-choice label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  cursor: pointer;
}

.db-provider-choice input[type="radio"] {
  width: auto;
  margin: 0;
}

.db-settings-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
}