/* ============================================================
   TOKENS GLOBAIS
   ============================================================ */
:root {
  --font-ui: "Aptos", "Segoe UI Variable Text", "Segoe UI", sans-serif;
  --font-display: "Aptos Display", "Aptos", "Segoe UI Variable Display", "Segoe UI", sans-serif;

  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --radius-pill: 999px;

  --ease: 160ms ease;
  --ease-out: 200ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* ============================================================
   TEMA CLARO
   ============================================================ */
body[data-theme="light"] {
  --bg:             #e8edf1;
  --bg-accent:      rgba(160, 180, 196, 0.16);

  --surface:        rgba(255, 255, 255, 0.68);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --surface-muted:  rgba(244, 247, 249, 0.94);
  --surface-raised: rgba(255, 255, 255, 0.98);

  --text:           #111a22;
  --text-secondary: #3d5060;
  --muted:          #637880;

  --line:           rgba(17, 26, 34, 0.07);
  --line-strong:    rgba(17, 26, 34, 0.13);

  --primary:        #1460f5;
  --primary-hover:  #0f50d9;
  --primary-glow:   rgba(20, 96, 245, 0.22);
  --primary-contrast: #f4f8ff;

  --urgent:         #c93a48;
  --urgent-tint:    rgba(201, 58, 72, 0.04);
  --urgent-line:    rgba(201, 58, 72, 0.18);

  --medium:         #c97c20;
  --medium-tint:    rgba(201, 124, 32, 0.04);
  --medium-line:    rgba(201, 124, 32, 0.18);

  --low:            #2470cc;
  --low-tint:       rgba(36, 112, 204, 0.04);
  --low-line:       rgba(36, 112, 204, 0.18);

  --archived:       #7a8a94;
  --archived-tint:  transparent;
  --archived-line:  rgba(17, 26, 34, 0.08);

  --shadow-soft:    0 8px 32px rgba(15, 23, 42, 0.07), 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-card:    0 4px 16px rgba(15, 23, 42, 0.06), 0 1px 4px rgba(15, 23, 42, 0.04);
  --shadow-card-hover: 0 8px 24px rgba(15, 23, 42, 0.10), 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-topbar:  0 8px 40px rgba(15, 23, 42, 0.08);
}

/* ============================================================
   TEMA ESCURO
   ============================================================ */
body[data-theme="dark"] {
  --bg:             #0f1419;
  --bg-accent:      rgba(60, 80, 96, 0.20);

  --surface:        rgba(20, 28, 36, 0.90);
  --surface-strong: rgba(26, 35, 44, 0.97);
  --surface-muted:  rgba(18, 25, 32, 0.92);
  --surface-raised: rgba(30, 40, 50, 0.99);

  --text:           #e8f0f5;
  --text-secondary: #99b0be;
  --muted:          #6e8896;

  --line:           rgba(232, 240, 245, 0.07);
  --line-strong:    rgba(232, 240, 245, 0.13);

  --primary:        #4880ff;
  --primary-hover:  #5f90ff;
  --primary-glow:   rgba(72, 128, 255, 0.28);
  --primary-contrast: #eef4ff;

  --urgent:         #e8606e;
  --urgent-tint:    rgba(232, 96, 110, 0.05);
  --urgent-line:    rgba(232, 96, 110, 0.22);

  --medium:         #e89a40;
  --medium-tint:    rgba(232, 154, 64, 0.05);
  --medium-line:    rgba(232, 154, 64, 0.20);

  --low:            #5898f0;
  --low-tint:       rgba(88, 152, 240, 0.05);
  --low-line:       rgba(88, 152, 240, 0.20);

  --archived:       #7a8e9a;
  --archived-tint:  transparent;
  --archived-line:  rgba(232, 240, 245, 0.07);

  --shadow-soft:    0 8px 40px rgba(0, 0, 0, 0.30), 0 2px 8px rgba(0, 0, 0, 0.16);
  --shadow-card:    0 4px 18px rgba(0, 0, 0, 0.22), 0 1px 4px rgba(0, 0, 0, 0.14);
  --shadow-card-hover: 0 8px 28px rgba(0, 0, 0, 0.32), 0 2px 8px rgba(0, 0, 0, 0.18);
  --shadow-topbar:  0 8px 48px rgba(0, 0, 0, 0.36);
}

/* ============================================================
   RESET E BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  color-scheme: light dark;
}

h1, h2, h3, p {
  margin: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 60% 40% at 80% 0%, var(--bg-accent), transparent),
    radial-gradient(ellipse 40% 30% at 10% 10%, rgba(80, 110, 130, 0.06), transparent),
    linear-gradient(180deg, var(--bg) 0%, color-mix(in srgb, var(--bg) 94%, #000 6%) 100%);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

body.modal-open {
  overflow: hidden;
}

button, input, textarea, select {
  font: inherit;
}

button {
  cursor: pointer;
}

/* ============================================================
   SHELL
   ============================================================ */
.app-shell {
  width: min(1080px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 8px 0 72px;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 24px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--surface-strong);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-topbar);
  position: sticky;
  top: 8px;
  z-index: 20;
  will-change: transform;
  transition: transform var(--ease-out), padding var(--ease), border-radius var(--ease), box-shadow var(--ease);
}

.topbar.is-compact {
  transform: translateY(-8px);
  padding: 12px 18px;
  border-radius: 14px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  font-weight: 700;
}

#panel-title {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 2.6vw, 2.6rem);
  line-height: 1;
  letter-spacing: -0.04em;
  font-weight: 800;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ============================================================
   BOTÕES BASE
   ============================================================ */
.primary-button,
.secondary-button,
.theme-toggle,
.module-link,
.section-add-button,
.icon-button,
.chip-button {
  border: 0;
  transition:
    transform var(--ease),
    background-color var(--ease),
    color var(--ease),
    border-color var(--ease),
    box-shadow var(--ease),
    opacity var(--ease);
}

.primary-button,
.secondary-button,
.theme-toggle,
.module-link {
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.9rem;
}

.primary-button {
  background: var(--primary);
  color: var(--primary-contrast);
  box-shadow: 0 4px 20px var(--primary-glow);
  letter-spacing: -0.01em;
}

.primary-button:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 28px var(--primary-glow);
}

.secondary-button,
.theme-toggle,
.module-link,
.section-add-button,
.icon-button,
.chip-button {
  background: var(--surface-muted);
  color: var(--text-secondary);
  border: 1px solid var(--line-strong);
}

.secondary-button:hover,
.theme-toggle:hover,
.module-link:hover,
.section-add-button:hover,
.icon-button:hover,
.chip-button:hover {
  transform: translateY(-1px);
  color: var(--text);
  border-color: var(--line-strong);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 6px;
  min-height: auto;
  font-size: 1.2rem;
  opacity: 0.7;
}

.theme-toggle:hover {
  opacity: 1;
  transform: none;
}

.theme-toggle__icon {
  font-size: 1.14rem;
  line-height: 1;
  opacity: 0.88;
}

.module-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  letter-spacing: -0.01em;
  border-radius: 12px;
}

.topbar .module-link {
  min-height: auto;
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  border-radius: 6px;
}

/* ============================================================
   SEÇÕES (ZONAS DE PRIORIDADE)
   ============================================================ */
.sections-root {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.task-zone {
  position: relative;
  padding: 16px 16px 16px 22px;
  border: 1px solid var(--zone-line);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(135deg, var(--zone-tint) 0%, transparent 60%),
    var(--surface);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

/* Barra lateral colorida */
.task-zone::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--zone-color) 90%, white 10%) 0%,
    var(--zone-color) 50%,
    color-mix(in srgb, var(--zone-color) 80%, black 20%) 100%
  );
  opacity: 0.9;
}

/* Tokens por prioridade */
.task-zone--urgent {
  --zone-color: var(--urgent);
  --zone-tint:  var(--urgent-tint);
  --zone-line:  var(--urgent-line);
}

.task-zone--medium {
  --zone-color: var(--medium);
  --zone-tint:  var(--medium-tint);
  --zone-line:  var(--medium-line);
}

.task-zone--low {
  --zone-color: var(--low);
  --zone-tint:  var(--low-tint);
  --zone-line:  var(--low-line);
}

/* Arquivados — tratamento secundário */
.task-zone--archived {
  --zone-color: var(--archived);
  --zone-tint:  var(--archived-tint);
  --zone-line:  var(--archived-line);
  opacity: 0.58;
  background: var(--surface-muted);
  box-shadow: none;
  transition:
    opacity 300ms ease,
    box-shadow 300ms ease,
    background-color 300ms ease;
}

.task-zone--archived:hover,
.task-zone--archived:focus-within {
  opacity: 1;
  box-shadow: var(--shadow-soft);
  background:
    linear-gradient(135deg, rgba(122, 138, 148, 0.04) 0%, transparent 60%),
    var(--surface);
}

/* Cabeçalho da seção */
.task-zone__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.task-zone__title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.task-zone__title {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}

/* Contador como badge pill */
.task-zone__count {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--surface-muted);
  border: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.section-add-button {
  width: 42px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: static;
  padding: 0;
  margin-right: 22px;
  border-radius: 9px;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}

/* ============================================================
   LISTA DE TAREFAS
   ============================================================ */
.task-list {
  display: grid;
  gap: 8px;
  min-height: 56px;
  border-radius: var(--radius-lg);
  transition: background-color var(--ease);
}

.task-list.is-over {
  background: color-mix(in srgb, var(--zone-color) 7%, transparent);
  border-radius: var(--radius-lg);
}

/* ============================================================
   ESTADO VAZIO
   ============================================================ */
.empty-state {
  padding: 16px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface-muted) 80%, transparent);
  color: var(--muted);
  display: grid;
  gap: 3px;
  font-size: 0.88rem;
}

.empty-state strong {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ============================================================
   CARDS DE TAREFA
   ============================================================ */
.task-card {
  position: relative;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-card);
  padding: 10px 46px 10px 16px;
  transition:
    transform var(--ease-out),
    box-shadow var(--ease-out),
    border-color var(--ease-out);
}

.task-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: color-mix(in srgb, var(--zone-color) 30%, var(--line-strong));
}

.task-card.is-dragging {
  opacity: 0.45;
  box-shadow: none;
  transform: none;
}

/* Borda lateral do card */
.task-card__line {
  position: absolute;
  inset: 10px auto 10px 0;
  width: 4px;
  border-radius: 0 2px 2px 0;
  background: var(--zone-color);
  opacity: 0.75;
  transition: opacity var(--ease);
}

.task-card:hover .task-card__line {
  opacity: 1;
}

/* Cabeçalho do card */
.task-card__head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.task-card__title {
  font-size: 0.97rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.015em;
  color: var(--text);
  flex: 1;
}

/* Botão expandir/recolher */
.icon-button {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border-radius: 9px;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  flex: 0 0 auto;
  color: var(--muted);
  transition:
    transform var(--ease),
    background-color var(--ease),
    color var(--ease),
    border-color var(--ease);
}

.card-toggle-button {
  position: absolute;
  right: -20px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-grid;
  place-items: center;
  text-align: center;
}

.icon-button:hover {
  color: var(--text);
  transform: none;
}

.card-toggle-button:hover {
  transform: translateY(-50%);
}

/* Corpo expandido */
.task-card__body {
  display: none;
  opacity: 0;
  transition: opacity 180ms ease, padding-top 180ms ease;
}

.task-card__body.is-open {
  display: block;
  opacity: 1;
  padding-top: 10px;
}

.task-card__description {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

/* Ações do card */
.task-card__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 10px;
  flex-wrap: wrap;
  position: relative;
}

.chip-button {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-secondary);
}

.task-card__actions [data-action="edit"],
.task-card__actions [data-action="archive"],
.task-card__actions [data-action="delete-toggle"] {
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  line-height: 1;
}

.task-card__bottom-close {
  position: relative;
  min-height: 30px;
  margin-top: 8px;
}

.task-card__bottom-close .icon-button {
  position: absolute;
  right: -20px;
  top: 0;
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  line-height: 1;
}

.chip-button:hover {
  color: var(--text);
}

.chip-button--danger {
  color: color-mix(in srgb, var(--urgent) 70%, var(--text-secondary));
}

.chip-button--danger:hover {
  color: var(--urgent);
}

.delete-confirm {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid color-mix(in srgb, var(--urgent) 35%, var(--line-strong));
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-raised) 85%, var(--urgent) 15%);
}

.delete-confirm.is-open {
  display: inline-flex;
}

.delete-confirm__text {
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 2px;
}

.delete-confirm__cancel,
.delete-confirm__confirm {
  min-height: 26px;
  padding: 0 10px;
  font-size: 0.74rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
}

/* ============================================================
   ARQUIVADOS — CARDS
   ============================================================ */
.task-zone--archived .task-card {
  opacity: 0.5;
  box-shadow: none;
  transition:
    opacity 250ms ease,
    transform 250ms ease,
    box-shadow 250ms ease,
    border-color 250ms ease;
}

.task-zone--archived .task-card:hover,
.task-zone--archived .task-card:focus-within {
  opacity: 1;
  transform: translateY(-1px);
  box-shadow: var(--shadow-card);
}

/* ============================================================
   DROP PLACEHOLDER
   ============================================================ */
.drop-placeholder {
  border: 1px dashed color-mix(in srgb, var(--zone-color) 45%, var(--line-strong));
  background: color-mix(in srgb, var(--zone-color) 8%, transparent);
  border-radius: 8px;
  min-height: 52px;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 18, 0.50);
  backdrop-filter: blur(10px);
}

.modal-panel {
  position: relative;
  width: min(580px, calc(100vw - 32px));
  margin: 8vh auto 0;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-raised);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.28), 0 8px 24px rgba(0, 0, 0, 0.14);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.task-form {
  display: grid;
  gap: 14px;
  padding: 20px 24px 24px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
  font-size: 0.94rem;
  transition:
    border-color var(--ease),
    box-shadow var(--ease),
    background-color var(--ease);
}

.field textarea {
  resize: vertical;
  min-height: 100px;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: color-mix(in srgb, var(--primary) 55%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
  background: var(--surface-strong);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

.modal-actions .primary-button,
.modal-actions .secondary-button {
  min-height: 40px;
  padding: 0 14px;
  font-size: 0.86rem;
}

.modal-panel .icon-button {
  border-radius: 8px;
}

.modal-panel .primary-button,
.modal-panel .secondary-button {
  border-radius: 8px;
}

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (max-width: 760px) {
  .app-shell {
    width: calc(100vw - 20px);
    padding-top: 8px;
  }

  .topbar,
  .task-zone {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar {
    position: static;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .topbar-actions .primary-button {
    grid-column: 1 / -1;
  }

  .task-zone__head {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .section-add-button {
    align-self: flex-start;
  }

  .task-card__title {
    font-size: 0.93rem;
  }

  .modal-panel {
    margin-top: 16px;
  }

  .modal-head,
  .task-form {
    padding-left: 18px;
    padding-right: 18px;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions .primary-button,
  .modal-actions .secondary-button {
    width: 100%;
    justify-content: center;
  }
}

/* Esconde label do botao de tema — icone sozinho */
.theme-toggle__label { display: none; }
