/* Sections Grid */
.grid {
  margin-top: 32px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* Grid when used as table container */
.grid:has(.table-container) {
  display: block;
  grid-template-columns: none;
  gap: 0;
}

@media (max-width: 980px) {
  .grid {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }
}

.section {
  padding: 0;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  animation: fadeIn 0.3s ease-out forwards;
  position: relative;
  cursor: default;
  overflow: hidden;
}

.section[draggable="true"] {
  cursor: move;
}

.section.dragging {
  opacity: 0.5;
  transform: scale(0.98);
}

.section.drag-over {
  border: 2px dashed var(--primary);
  background-color: rgba(var(--primary-rgb), 0.05);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--background);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.section-head-left {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
  min-width: 0;
}

.section-head .drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--muted-foreground);
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
  font-size: 18px;
  border-radius: var(--radius-md);
  transition: background-color 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
  opacity: 1;
}

.section-head .drag-handle:hover {
  background: var(--secondary);
  color: var(--foreground);
}

.section-head .drag-handle:active {
  cursor: grabbing;
  background: var(--accent);
  color: var(--foreground);
}

.section-head-right {
  display: flex !important;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  visibility: visible !important;
  opacity: 1 !important;
}

.section-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.section-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--foreground);
}

.section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 4px 10px;
  background: var(--muted);
  color: var(--muted-foreground);
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.section-desc {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted-foreground);
  line-height: 1.4;
}

.section-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  min-width: 140px;
}

.section-add-btn {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--background);
  color: var(--muted-foreground);
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
  flex-shrink: 0;
  visibility: visible !important;
  opacity: 1 !important;
}

.section-add-btn:hover {
  background: var(--muted);
  border-color: var(--border);
  color: var(--foreground);
  transform: scale(1.05);
}

.section-add-btn:active {
  transform: scale(0.95);
}

.edit-section-btn {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  color: var(--muted-foreground);
  border: none;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  border-radius: var(--radius-md);
  visibility: visible !important;
  opacity: 1 !important;
}

.edit-section-btn:hover {
  background: var(--secondary);
  color: var(--foreground);
}

.edit-section-btn svg {
  width: 16px;
  height: 16px;
}

.section-content {
  padding: 2px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 50px;
}

/* Empty State Styles */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  text-align: center;
  background: var(--background);
  border-radius: var(--radius-md);
  border: 2px dashed var(--border);
  color: var(--muted-foreground);
  margin: 16px;
  font-size: 13px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.empty:hover {
  border-color: var(--primary);
  background: var(--muted);
}

.empty svg {
  margin-bottom: 12px;
  opacity: 0.5;
  color: #9ca3af !important;
}

.empty p {
  margin: 0 0 12px 0;
  font-weight: 500;
  line-height: 1.4;
}

/* Button inside empty state */
.empty button {
  background: var(--background);
  border: 1px solid var(--border);
  color: var(--foreground);
  font-size: 12px;
  padding: 6px 12px;
  height: auto;
  border-radius: var(--radius-md);
  margin-top: 4px;
}

.empty button:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #ffffff;
}

.section-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--background);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  margin-top: auto;
}

.progress-bar-bg {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary); /* Default Black */
  transition: width 0.5s ease-out;
}

/* Cor dinâmica baseada no progresso */
.progress-bar-fill[style*="width: 100%"] {
  background: var(--primary); /* Maintain neutrality */
}

.progress-bar-fill[style*="width: 0%"] {
  background: transparent;
}

.section-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 500;
  color: #6b7280;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-item svg {
  width: 12px;
  height: 12px;
  opacity: 0.7;
}

.stat-pill {
  background: var(--background);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Seção: Estado "Done" */
.section[data-done="true"] .section-head {
  background: var(--muted);
}

.section[data-done="true"] .section-title {
  color: var(--foreground);
}

.section[data-done="true"] .section-count {
  background: var(--muted);
  color: var(--foreground);
}

.section[data-done="true"] .progress-bar-fill {
  background: var(--primary);
}

/* Seção: Estado "Vazio" */
.section-empty {
  opacity: 0.8;
}

.section-empty .section-head {
  background: var(--background);
}
