/* Reset & base */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background-color 0.3s, color 0.3s;
}

/* background images */
[data-theme="viareggio"] {
  background: linear-gradient(to bottom, rgba(10, 46, 61, 0.72), rgba(10, 46, 61, 0.82)),
    url('/imgs/viareggio.webp') center top / cover no-repeat fixed;
}

[data-theme="light"] {
  background: linear-gradient(to bottom, rgba(85, 55, 61, 0.72), rgba(125, 85, 61, 0.82)),
    url('/imgs/neko.webp') center top / cover no-repeat fixed;
}

[data-theme="dark"] {
  background: linear-gradient(to bottom, rgba(10, 10, 10, 0.72), rgba(25, 25, 25, 0.82)),
    url('/imgs/neve.webp') center top / cover no-repeat fixed;
}



/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-title {
  font-family: var(--font-title);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.03em;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-compact {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-compact .filter-wrapper,
.header-compact .theme-wrapper {
  flex: 1;
}

.header-compact .btn {
  width: 100%;
}

/* Buttons */
.btn {
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
}

.btn:active {
  transform: scale(0.97);
}

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

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--btn-secondary-bg);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--btn-secondary-hover);
}

/* Theme dropdown wrapper */
.theme-wrapper {
  position: relative;
}

/* Board */
.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 20px 24px;
  min-height: calc(100vh - 57px);
  align-items: start;
}

/* Column */
.column {
  background: var(--bg-column);
  border-radius: 10px;
  padding: 14px;
  min-height: 200px;
}

.column-title {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--column-title-color);
  margin-bottom: 14px;
  padding: 0 4px;
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 60px;
}

/* Card */
.card {
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px var(--shadow);
  transition: box-shadow 0.2s;
}

.card:hover {
  box-shadow: 0 4px 16px var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: grab;
  user-select: none;
}

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

.card-title {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.card-label-badge {
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.9);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

.card-delete-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.2s;
}

.card-delete-btn:hover {
  color: #fff;
}

/* Card body */
.card-body {
  background: var(--bg-card-body);
  padding: 10px 12px 12px;
}

/* Common input style */
.input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 5px;
  padding: 6px 10px;
  font-size: 0.85rem;
  color: var(--text-primary);
  transition: border-color 0.2s, background-color 0.2s;
}

.input::placeholder {
  color: var(--text-muted);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-input-focus);
}

/* Add item input */
.card-add-item {
  margin-bottom: 8px;
}

.card-add-item input {
  font-size: 0.8rem;
}

/* Item list */
.item-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.item {
  border-radius: 4px;
  transition: background-color 0.15s;
}

.item:hover {
  background: var(--accent-subtle);
}

.item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  cursor: pointer;
}

.item-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid var(--text-muted);
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: border-color 0.2s, background-color 0.2s;
}

.item-row input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.item-row input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.item-text {
  font-size: 0.82rem;
  color: var(--text-primary);
  flex: 1;
  transition: color 0.2s;
  line-height: 1.4;
}

.item-text.checked {
  text-decoration: line-through;
  color: var(--checked-text);
}

.item-drag-handle {
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: grab;
  padding: 0 2px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
  user-select: none;
}

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

.item-row:hover .item-drag-handle {
  opacity: 1;
}

.item-delete-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
}

.item-row:hover .item-delete-btn {
  opacity: 1;
}

.item-delete-btn:hover {
  color: #e74c3c;
}

@media (pointer: coarse) {

  .item-drag-handle,
  .item-delete-btn {
    opacity: 0.5;
  }
}

.item-ghost {
  opacity: 0.4;
}

.item-expand-icon {
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.item-expand-icon.expanded {
  transform: rotate(90deg);
}

.item-description {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.25s ease, padding 0.25s ease;
  padding: 0 6px 0 30px;
}

.item-description.expanded {
  max-height: 200px;
  padding: 4px 6px 8px 30px;
}

.item-desc-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.5;
  resize: vertical;
  min-height: 2.4em;
}

.item-desc-input::placeholder {
  color: var(--text-muted);
}

.item-desc-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-input-focus);
  color: var(--text-primary);
}

/* Card move animation */
@keyframes card-fade-in {
  0% {
    opacity: 0;
    transform: translateY(-8px) scale(0.97);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.card-enter {
  animation: card-fade-in 0.4s ease-out;
}

/* Drag states */
.card-ghost {
  opacity: 0.4;
}

.card-drag {
  transform: rotate(1.5deg);
  box-shadow: 0 8px 24px var(--shadow-heavy);
}

/* Empty column state */
.card-list:empty::after {
  content: 'Smolla la lista qui';
  display: block;
  text-align: center;
  padding: 24px 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
}

/* Dialog */
.card-dialog {
  background: var(--dialog-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 24px;
  min-width: 320px;
  box-shadow: 0 16px 48px var(--shadow-heavy);
  margin: auto;
  overflow: visible;
}

.card-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.card-dialog h3 {
  margin-bottom: 16px;
  font-size: 1.1rem;
  color: var(--accent);
}

.card-dialog label {
  display: block;
  margin-bottom: 12px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.card-dialog input {
  display: block;
  margin-top: 4px;
  padding: 8px 10px;
}

.label-picker {
  position: relative;
}

.label-picker-btn {
  width: 100%;
  text-align: left;
  margin-top: 4px;
}

.label-picker-dropdown {
  top: calc(100% + 4px);
  left: 0;
  right: 0;
}

.label-picker-dropdown.open {
  display: block;
}

.new-label-row {
  margin-top: 6px;
}

.new-label-row input {
  margin-top: 0;
  padding: 8px 10px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* Filter dropdown */
.filter-wrapper {
  position: relative;
}

.filter-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--dialog-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 0;
  min-width: 180px;
  box-shadow: 0 8px 24px var(--shadow-heavy);
  z-index: 200;
}

.filter-dropdown.open {
  display: block;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-size: 0.82rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color 0.15s;
}

.filter-option:hover {
  background: var(--accent-subtle);
}

.filter-option input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
}

.filter-option .filter-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.filter-separator {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

.filter-option.active {
  color: var(--accent);
  font-weight: 600;
}

/* Responsive */
.mobile-break {
  display: none;
}

@media (max-width: 768px) {
  .mobile-break {
    display: inline;
  }

  .board {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .app-header {
    padding: 12px 16px;
  }

  .app-title {
    font-size: 1.1rem;
  }

  #new-card-btn {
    width: 5.5rem;
  }

  .header-compact {
    flex-direction: column;
    gap: 4px;
  }

  .header-compact .btn {
    width: 90px;
    font-size: 0.75rem;
    padding: 4px 8px;
  }
}