/* =========================================================
   TOKENS GERAIS (independente de tema)
   ========================================================= */
:root {
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.28);
  --shadow-card: 0 18px 40px rgba(15, 23, 42, 0.4);

  --font-sans: "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;

  --transition-fast: 0.18s ease-out;
}

/* =========================================================
   TEMA ESCURO
   ========================================================= */
html[data-theme="dark"] {
  --bg: radial-gradient(circle at top left, #1f2937 0%, #020617 70%);
  --surface: #020617;
  --surface-soft: #050b18;
  --surface-elevated: #0b1020;
  --surface-alt: #111827;

  --border-subtle: rgba(148, 163, 184, 0.15);
  --border-strong: rgba(148, 163, 184, 0.32);

  --txt: #e5e7eb;
  --txt-muted: #9ca3af;
  --txt-soft: #6b7280;

  --accent: #6366f1;
  --accent-soft: rgba(99, 102, 241, 0.12);
  --accent-strong: #4f46e5;

  --danger: #f43f5e;
  --danger-soft: rgba(244, 63, 94, 0.12);

  --chip: rgba(15, 23, 42, 0.9);
}

/* =========================================================
   TEMA CLARO
   ========================================================= */
html[data-theme="light"] {
  --bg: radial-gradient(circle at top left, #ffffff 0%, #e5e7eb 80%);
  --surface: #f3f4f6;
  --surface-soft: #f9fafb;
  --surface-elevated: #ffffff;
  --surface-alt: #e5e7eb;

  --border-subtle: rgba(148, 163, 184, 0.5);
  --border-strong: rgba(31, 41, 55, 0.2);

  --txt: #111827;
  --txt-muted: #6b7280;
  --txt-soft: #9ca3af;

  --accent: #4f46e5;
  --accent-soft: rgba(79, 70, 229, 0.12);
  --accent-strong: #4338ca;

  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.12);

  --chip: #e5e7eb;
}

/* =========================================================
   BASE
   ========================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--txt);
  background: var(--bg);
}

.shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* =========================================================
   TOPO / HEADER
   ========================================================= */
.topbar {
  background: var(--surface-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  padding: 16px 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-dot {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: radial-gradient(circle, #22c55e 0%, #16a34a 60%, #14532d 100%);
  box-shadow: 0 0 18px rgba(34, 197, 94, 0.9);
}

.brand-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-title h1 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
}

.brand-title span {
  font-size: 0.8rem;
  color: var(--txt-muted);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  justify-content: flex-end;
}

.controls-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

/* MOBILE HEADER */
@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .controls {
    align-items: stretch;
  }

  .controls-row {
    justify-content: flex-start;
  }

  .controls-actions {
    justify-content: flex-start;
  }

  .field.small {
    width: 100%;
  }
}

/* =========================================================
   CAMPOS / INPUTS
   ========================================================= */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-size: 0.78rem;
  color: var(--txt-muted);
}

.field input,
.field select {
  font-size: 0.88rem;
  padding: 9px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--surface-soft);
  color: var(--txt);
  outline: none;
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    background var(--transition-fast),
    color var(--transition-fast);
}

.field input::placeholder {
  color: var(--txt-soft);
}

.field.small {
  width: 170px;
}

.field.full {
  width: 100%;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* =========================================================
   SELECT CUSTOM (somente o controle)
   ========================================================= */
.field select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 36px;
  position: relative;
  background-image: linear-gradient(135deg, rgba(148,163,184,0.06), rgba(148,163,184,0));
  background-repeat: no-repeat;
}

/* wrapper visual da seta */
.field.small {
  position: relative;
}

.field.small::after {
  content: "▾";
  position: absolute;
  right: 12px;
  bottom: 11px;
  font-size: 0.7rem;
  pointer-events: none;
  color: var(--txt-soft);
}

/* OBS: o dropdown aberto ainda é do SO/navegador. 
   Para custom completo seria preciso JS + componente próprio. */

/* =========================================================
   BOTÕES
   ========================================================= */
.btn {
  border: none;
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    box-shadow var(--transition-fast),
    transform var(--transition-fast),
    border-color var(--transition-fast),
    opacity var(--transition-fast);
}

/* principal */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #ffffff;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.4);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.55);
}

/* secundário */
.btn-secondary {
  background: var(--surface-soft);
  color: var(--accent-strong);
  border: 1px solid var(--accent-soft);
}

.btn-secondary:hover {
  background: var(--accent-soft);
}

/* ghost */
.btn-ghost {
  background: transparent;
  color: var(--txt-muted);
  border: 1px dashed var(--border-subtle);
}

.btn-ghost:hover {
  color: var(--txt);
  border-style: solid;
  background: rgba(148, 163, 184, 0.08);
}

/* danger */
.btn-danger {
  background: var(--danger-soft);
  border: 1px solid rgba(248, 113, 113, 0.5);
  color: #faa1a1;
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.22);
  color: #f5b2b2;
}

/* botão desativado */
.btn[disabled],
.btn.disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

/* =========================================================
   CARDS E LAYOUT PRINCIPAL
   ========================================================= */
.panel {
  display: grid;
  grid-template-columns: 1.05fr 1.05fr;
  gap: 18px;
  margin-top: 4px;
}

@media (max-width: 900px) {
  .panel {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--surface-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  padding: 18px;
}

.card h2.card-title {
  margin: 0 0 10px 0;
  font-size: 1.05rem;
}

/* form blocos */
.form-card .row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.form-card .row.end {
  justify-content: flex-end;
}

/* lista blocos */
.list-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.list-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.list-header .hint {
  font-size: 0.75rem;
  color: var(--txt-muted);
}

/* =========================================================
   BLOCOS / CARDS DE ETAPAS
   ========================================================= */
.lista-blocos {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty {
  padding: 12px;
  font-size: 0.82rem;
  border-radius: var(--radius);
  border: 1px dashed var(--border-subtle);
  color: var(--txt-muted);
  text-align: center;
  background: var(--surface-soft);
}

.bloco {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-alt);
  border: 1px solid var(--border-subtle);
  cursor: grab;
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
}

.bloco:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.45);
}

.bloco.drag-over {
  background: var(--accent-soft);
}

/* coluna de horário */
.bloco-time {
  min-width: 72px;
  padding-right: 10px;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.bloco-time strong {
  font-size: 0.9rem;
}

.bloco-time span {
  font-size: 0.72rem;
  color: var(--txt-muted);
}

/* conteúdo principal */
.bloco-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bloco-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.bloco-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--txt-muted);
}

.bloco-meta span {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--chip);
}

/* obs */
.bloco-obs {
  margin-top: 3px;
  font-size: 0.8rem;
  color: var(--txt-soft);
}

/* ações (editar/excluir) */
.bloco-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}

/* botões de ícone modernos */
.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--surface-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--txt-soft);
  font-size: 0.85rem;
  padding: 0;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    border-color var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
}

.icon-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.4);
}

.icon-btn.danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

/* em telas pequenas, bloco vira duas linhas */
@media (max-width: 640px) {
  .bloco {
    grid-template-columns: 1fr;
  }

  .bloco-time {
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 6px;
    margin-bottom: 4px;
    flex-direction: row;
    justify-content: flex-start;
    gap: 6px;
  }

  .bloco-actions {
    flex-direction: row;
  }
}

/* ======================= MODAL ======================= */
.modal {
  position: fixed;
  inset: 0;
  backdrop-filter: blur(4px);
  background: rgba(0,0,0,0.45);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 95%;
  max-width: 420px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: fadeScale .18s ease-out;
}

@keyframes fadeScale {
  from { transform: scale(.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-content h3 {
  margin-top: 0;
  margin-bottom: 18px;
  font-size: 1.2rem;
  font-weight: 600;
}

.modal-content label {
  font-size: .85rem;
  margin-bottom: 4px;
  color: var(--muted);
}

.modal-content input {
  margin-bottom: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 10px;
}
