@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           hsl(138,40%,95%);
  --fg:           hsl(220,25%,12%);
  --border:       hsl(138,18%,68%);
  --card:         #ffffff;
  --muted:        hsl(215,12%,48%);
  --primary:      hsl(25,95%,53%);   /* orange */
  --primary-fg:   #ffffff;
  --sidebar-bg:   hsl(127,52%,38%);  /* green */
  --sidebar-border: hsl(127,45%,32%);
  --radius:       0.5rem;
  --header-h:     3.75rem;
  --sidebar-w:    220px;
  --sidebar-collapsed-w: 60px;
  --panel-w:      220px;
}

html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--fg);
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ── Header ────────────────────────────────────────────────────────────── */
.header {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  height: var(--header-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 32px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0;
  text-decoration: none;
  color: var(--fg);
  flex-shrink: 0;
}
.header-brand img { width: 40px; height: 40px; object-fit: contain; }
.header-brand span { font-size: 15px; font-weight: 600; letter-spacing: -.025em; }

.header-divider { width: 1px; height: 20px; background: var(--border); flex-shrink: 0; }

.header-nav { display: flex; align-items: center; gap: 4px; }
.header-nav a {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.header-nav a:hover { background: hsl(138,20%,91%); color: var(--fg); }
.header-nav a.active { background: hsl(25,95%,53%,0.1); color: var(--primary); }
.header-nav a svg { width: 14px; height: 14px; }

/* ── Main area ─────────────────────────────────────────────────────────── */
.main { display: flex; flex: 1; min-height: 0; overflow: hidden; }

/* ── App Sidebar ────────────────────────────────────────────────────────── */
.app-sidebar {
  flex-shrink: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  transition: width .2s ease;
  overflow: hidden;
}
.app-sidebar.collapsed { width: var(--sidebar-collapsed-w); }

/* Sidebar logo area */
.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  min-height: 52px;
}
.sidebar-logo-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.app-sidebar.collapsed .sidebar-logo-inner { justify-content: center; width: 100%; }
.sidebar-logo-icon {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo-icon svg { width: 16px; height: 16px; color: #fff; }
.sidebar-logo-text {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
}
.app-sidebar.collapsed .sidebar-logo-text { display: none; }
.sidebar-collapse-btn {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,.5);
  transition: color .15s, background .15s;
  flex-shrink: 0;
}
.sidebar-collapse-btn:hover { color: #fff; background: rgba(255,255,255,.1); }
.sidebar-collapse-btn svg { width: 16px; height: 16px; }
.app-sidebar.collapsed .sidebar-collapse-btn { display: none; }

/* Expand button (collapsed state) */
.sidebar-expand-btn {
  display: none;
  width: 100%;
  padding: 8px 0;
  align-items: center;
  justify-content: center;
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,.5);
  border-bottom: 1px solid rgba(255,255,255,.12);
  transition: color .15s, background .15s;
}
.sidebar-expand-btn:hover { color: #fff; background: rgba(255,255,255,.1); }
.sidebar-expand-btn svg { width: 16px; height: 16px; }
.app-sidebar.collapsed .sidebar-expand-btn { display: flex; }

/* Sidebar nav */
.sidebar-nav { flex: 1; display: flex; flex-direction: column; padding: 4px 8px; gap: 0; }
.sidebar-nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: 6px;
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,.7);
  text-align: left;
  width: 100%;
  transition: background .15s, color .15s;
  position: relative;
}
.sidebar-nav-btn:hover { color: #fff; background: rgba(255,255,255,.1); }
.sidebar-nav-btn.active { background: var(--primary); color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.sidebar-nav-btn svg.nav-icon { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-nav-btn .nav-label { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; }
.sidebar-nav-btn .nav-chevron { width: 12px; height: 12px; margin-left: auto; flex-shrink: 0; opacity: .7; }
.app-sidebar.collapsed .nav-label,
.app-sidebar.collapsed .nav-chevron { display: none; }
.app-sidebar.collapsed .sidebar-nav-btn { justify-content: center; }

/* Sidebar bottom */
.sidebar-bottom {
  border-top: 1px solid rgba(255,255,255,.12);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-bottom-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 6px;
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: 12px; font-weight: 500;
  transition: background .15s, color .15s;
  width: 100%;
}
.sidebar-bottom-btn:hover { color: #fff; background: rgba(255,255,255,.1); }
.sidebar-bottom-btn.active { background: var(--primary); color: #fff; }
.sidebar-bottom-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-bottom-btn .nav-label { white-space: nowrap; overflow: hidden; }
.app-sidebar.collapsed .sidebar-bottom-btn { justify-content: center; gap: 0; }
.app-sidebar.collapsed .sidebar-bottom-btn .nav-label { display: none; }

/* ── Config Panel ───────────────────────────────────────────────────────── */
.config-panel {
  flex-shrink: 0;
  width: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width .2s ease;
}
.config-panel.open { width: var(--panel-w); }

.config-panel-inner {
  width: var(--panel-w);
  display: flex;
  flex-direction: column;
  height: 100%;
}
.config-panel-header {
  padding: 12px 12px 8px;
  border-bottom: 1px solid var(--border);
}
.config-panel-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--primary);
}
.config-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Section label inside panel */
.section-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--primary);
  margin-bottom: 4px;
}

/* Field row */
.field-row { display: flex; flex-direction: column; gap: 3px; }
.field-row label {
  font-size: 10px;
  font-weight: 500;
  color: rgba(26,26,26,.7);
  line-height: 1;
}
.field-row .field-input-wrap { position: relative; display: flex; align-items: center; }
.field-row .field-unit {
  position: absolute;
  right: 8px;
  font-size: 9px;
  font-weight: 500;
  color: rgba(100,100,100,.55);
  font-family: 'JetBrains Mono', monospace;
  pointer-events: none;
}

/* Inputs */
input[type="text"].field-input,
input[type="number"].field-input {
  height: 24px;
  width: 100%;
  padding: 0 24px 0 6px;
  font-size: 9px;
  font-family: 'JetBrains Mono', monospace;
  border: 1px solid rgba(0,0,0,.4);
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.1);
  outline: none;
  color: var(--fg);
}
input[type="text"].field-input { padding-right: 6px; }
input[type="text"].field-input:focus,
input[type="number"].field-input:focus { border-color: var(--primary); box-shadow: 0 0 0 1px hsla(25,95%,53%,.4); }

/* Color input */
input[type="color"].field-color {
  height: 28px;
  width: 100%;
  padding: 2px;
  border: 1px solid rgba(0,0,0,.4);
  border-radius: 4px;
  cursor: pointer;
  background: none;
}

/* Select */
select.field-select {
  height: 24px;
  width: 100%;
  padding: 0 4px;
  font-size: 9px;
  font-family: 'JetBrains Mono', monospace;
  border: 1px solid rgba(0,0,0,.4);
  border-radius: 4px;
  background: #fff;
  outline: none;
  cursor: pointer;
  color: var(--fg);
}
select.field-select:focus { border-color: var(--primary); }

/* Toggle row */
.toggle-row { display: flex; align-items: center; justify-content: space-between; }
.toggle-row label { font-size: 10px; font-weight: 500; color: rgba(26,26,26,.7); cursor: pointer; }
.toggle-row input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary); }

/* Radio group */
.radio-group { display: flex; flex-direction: column; gap: 6px; }
.radio-option {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  font-size: 11px;
}
.radio-option:hover { border-color: var(--primary); background: hsla(25,95%,53%,.04); }
.radio-option.selected { border-color: var(--primary); background: hsla(25,95%,53%,.08); color: var(--primary); }
.radio-option input[type="radio"] { display: none; }
.radio-option svg { width: 13px; height: 13px; flex-shrink: 0; }
.radio-option .radio-label { font-weight: 500; }
.radio-option .radio-arrow { font-size: 13px; flex-shrink: 0; line-height: 1; }

/* Dot circular de sequência dentro do radio-option */
.seq-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(107,114,128,.4);
  flex-shrink: 0;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s;
}
.seq-dot:hover { border-color: var(--primary); }
.seq-dot.active { border-color: var(--primary); }
.seq-dot.active::after {
  content: '';
  display: block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--primary);
}

/* Sequence toggle */
.seq-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  transition: border-color .15s, background .15s;
  background: none;
  color: var(--fg);
  width: 100%;
}
.seq-toggle.active { border-color: var(--primary); background: hsla(25,95%,53%,.08); color: var(--primary); }
.seq-toggle svg { width: 13px; height: 13px; }
.seq-count-row { display: flex; gap: 4px; align-items: center; }
.seq-count-btn {
  width: 22px; height: 22px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: none;
  cursor: pointer;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  color: var(--fg);
  transition: background .1s;
}
.seq-count-btn:hover { background: hsl(138,20%,91%); }
.seq-count-display {
  flex: 1;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
}

/* Generate button area */
.config-panel-footer {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s;
  font-family: 'Inter', sans-serif;
  text-decoration: none;
}
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: hsl(25,95%,47%); }
.btn-outline { background: transparent; color: var(--fg); border: 1px solid var(--border); }
.btn-outline:hover { background: hsl(138,20%,91%); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--fg); background: hsl(138,20%,91%); }
.btn-danger { background: #fee2e2; color: #dc2626; border: none; padding: 4px 10px; border-radius: 4px; font-size: 12px; }
.btn-danger:hover { background: #fecaca; }
.btn svg { width: 14px; height: 14px; }
.btn-full { width: 100%; }

/* Generate button */
.btn-generate {
  height: 34px;
  font-size: 13px;
  font-weight: 600;
}

/* ── Map area ───────────────────────────────────────────────────────────── */
.map-area { flex: 1; position: relative; overflow: hidden; min-width: 0; }
#map { width: 100%; height: 100%; }

/* Search bar */
.search-bar {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  width: min(440px, calc(100% - 32px));
}
.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute; left: 10px;
  width: 16px; height: 16px;
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; z-index: 1;
}
.search-icon svg { width: 16px; height: 16px; }
.search-bar input {
  width: 100%;
  height: 40px;
  padding: 0 36px 0 34px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,.15);
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  outline: none;
  background: #fff;
  color: var(--fg);
}
.search-bar input:focus { border-color: var(--primary); box-shadow: 0 4px 12px rgba(0,0,0,.12), 0 0 0 2px hsla(25,95%,53%,.2); }
.search-spinner {
  position: absolute; right: 10px;
  width: 16px; height: 16px;
  color: var(--muted);
  align-items: center; justify-content: center;
  animation: spin .8s linear infinite;
}
.search-spinner svg { width: 16px; height: 16px; }
.search-clear {
  position: absolute; right: 10px;
  width: 16px; height: 16px;
  background: none; border: none; cursor: pointer;
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  transition: color .15s;
}
.search-clear:hover { color: var(--fg); }
.search-clear svg { width: 16px; height: 16px; }
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #fff;
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  overflow: hidden;
  max-height: 256px;
  overflow-y: auto;
}
.search-results button {
  display: block; width: 100%; text-align: left;
  padding: 10px 14px;
  font-size: 13px; font-family: 'Inter', sans-serif;
  border: none; background: none; cursor: pointer;
  border-bottom: 1px solid var(--border);
  color: var(--fg); line-height: 1.4;
  transition: background .1s;
}
.search-results button:hover { background: var(--bg); }
.search-results button:last-child { border-bottom: none; }

/* ── Dialog ─────────────────────────────────────────────────────────────── */
.dialog-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.dialog {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  width: 340px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.dialog-title { font-size: 16px; font-weight: 700; text-align: center; margin-bottom: 6px; }
.dialog-desc { font-size: 13px; color: var(--muted); text-align: center; margin-bottom: 14px; }
.dialog-name-input {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; text-align: center; outline: none;
  margin-bottom: 14px;
  font-family: 'Inter', sans-serif;
}
.dialog-name-input:focus { border-color: var(--primary); }
.dialog-actions { display: flex; flex-direction: column; gap: 8px; }
.dialog-secondary { display: flex; gap: 8px; }
.dialog-secondary .btn { flex: 1; }

/* ── Toast ─────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: hsl(220,25%,12%); color: #fff;
  padding: 10px 18px; border-radius: 8px;
  font-size: 14px; font-family: 'Inter', sans-serif;
  z-index: 9999; box-shadow: 0 4px 14px rgba(0,0,0,.25);
  transition: opacity .3s;
  max-width: 320px;
}
.toast.error { background: #dc2626; }
.toast.success { background: #16a34a; }

/* ── Pages ─────────────────────────────────────────────────────────────── */
.page-scroll { flex: 1; overflow-y: auto; background: var(--bg); }
.page-content { padding: 28px; max-width: 1000px; }
.page-header { margin-bottom: 20px; }
.page-header h2 { font-size: 22px; font-weight: 700; }
.page-header p { color: var(--muted); font-size: 14px; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
thead { background: hsl(127,52%,38%); color: #fff; }
th { padding: 11px 14px; font-size: 12px; font-weight: 600; text-align: left; text-transform: uppercase; letter-spacing: .05em; }
td { padding: 10px 14px; font-size: 13px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: hsl(138,40%,97%); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-completed { background: #dcfce7; color: #15803d; }
.badge-failed    { background: #fee2e2; color: #dc2626; }
.badge-pending   { background: #fef9c3; color: #a16207; }
.badge-processing{ background: #dbeafe; color: #1d4ed8; }

.stats-grid { display: flex; gap: 12px; flex-wrap: wrap; }
.stat-card { background: #fff; border-radius: 8px; padding: 10px 16px; min-width: 90px; text-align: center; border: 1px solid var(--border); }
.stat-card .stat-value { font-size: 22px; font-weight: 700; }
.stat-card .stat-label { font-size: 11px; color: var(--muted); margin-top: 2px; }
.stat-card.green .stat-value { color: #15803d; }
.stat-card.red   .stat-value { color: #dc2626; }

.hidden { display: none !important; }
