/* ============================================================
   style.css — tokens de design + layout estrutural
   Paleta inspirada em painéis de campo/dispatch de um técnico de
   serviços elétricos: sidebar em grafite escuro fixo, área de
   trabalho clara ou escura, acento âmbar (luz de sinalização /
   indicador de multímetro) e números em fonte monoespaçada.
   ============================================================ */

:root {
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "Liberation Mono", monospace;

  --sidebar-bg: #171B24;
  --sidebar-bg-hover: #20252F;
  --sidebar-text: #AEB6C4;
  --sidebar-text-active: #F5F7FA;
  --sidebar-border: #262C38;

  --accent: #F2A93B;
  --accent-dark: #C9861F;
  --accent-soft: rgba(242, 169, 59, 0.16);

  --blue: #4C8DF2;
  --blue-soft: rgba(76, 141, 242, 0.14);
  --purple: #9B6BF2;
  --purple-soft: rgba(155, 107, 242, 0.14);
  --green: #2FA36B;
  --green-soft: rgba(47, 163, 107, 0.14);
  --red: #E5484D;
  --red-soft: rgba(229, 72, 77, 0.13);
  --amber-soft: rgba(242, 169, 59, 0.15);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(15, 18, 24, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 18, 24, 0.14);
  --shadow-lg: 0 16px 48px rgba(15, 18, 24, 0.28);
}

:root[data-theme="light"] {
  --bg: #F3F4F7;
  --surface: #FFFFFF;
  --surface-alt: #F7F8FA;
  --border: #E4E7ED;
  --text: #171B24;
  --text-muted: #6B7380;
  --text-faint: #9AA1AD;
}

:root[data-theme="dark"] {
  --bg: #0F1218;
  --surface: #171B24;
  --surface-alt: #1D222C;
  --border: #2A303C;
  --text: #ECEEF2;
  --text-muted: #99A1AF;
  --text-faint: #6D7480;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

#app-shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  height: 100vh;
}

/* ---------- Sidebar ---------- */

#sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 20px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  color: #1A1206;
  font-size: 14px;
}

.brand-name {
  color: var(--sidebar-text-active);
  font-weight: 600;
  font-size: 14.5px;
  line-height: 1.2;
}
.brand-sub {
  color: var(--sidebar-text);
  font-size: 11px;
}

#sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  color: var(--sidebar-text);
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-ui);
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--sidebar-bg-hover); color: var(--sidebar-text-active); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-icon { font-size: 15px; width: 18px; text-align: center; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--sidebar-border);
  color: var(--text-faint);
  font-size: 10.5px;
  padding-left: 10px;
}

/* ---------- Topbar + main ---------- */

#main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
}

#topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: relative;
  z-index: 5;
}


#mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 24px;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#mobile-menu-btn:hover {
  background: var(--surface-alt);
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 480px;
}

#global-search {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 13px;
}
#global-search:focus { outline: none; border-color: var(--accent); }

.search-wrap::before {
  content: "🔍";
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  opacity: .6;
}

#global-search-results {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-height: 380px;
  overflow-y: auto;
  padding: 6px;
}
#global-search-results.open { display: block; }
.search-group-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); padding: 8px 8px 2px; }
.search-result { padding: 8px 8px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; }
.search-result:hover { background: var(--surface-alt); }
.search-empty { padding: 14px 8px; color: var(--text-muted); font-size: 13px; }

.quick-add-wrap { position: relative; margin-left: auto; }

#quick-add-btn {
  background: var(--accent);
  color: #211705;
  border: none;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 13px;
}
#quick-add-btn:hover { background: var(--accent-dark); }

#quick-add-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  min-width: 190px;
  padding: 6px;
  flex-direction: column;
}
#quick-add-menu.open { display: flex; }
.quick-add-option {
  background: none; border: none; text-align: left; padding: 9px 10px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px; color: var(--text); font-family: var(--font-ui);
}
.quick-add-option:hover { background: var(--surface-alt); }

#view-root {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 60px;
}

/* ---------- typography helpers ---------- */

h1 { font-size: 22px; margin: 0 0 2px; }
h2 { font-size: 15px; margin: 0; }
h3 { font-size: 17px; margin: 0 0 4px; }
.page-subtitle { color: var(--text-muted); font-size: 13px; margin: 0; }
.muted { color: var(--text-muted); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-amber { color: var(--accent-dark); }
.clickable { cursor: pointer; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 768px) {

  /* Layout principal */
  #app-shell {
    display: block;
    height: 100vh;
  }

  #main-area {
    width: 100%;
    height: 100vh;
  }

  /* Botão do menu */
  #mobile-menu-btn {
    display: flex;
  }

  /* Barra lateral no celular */
  #sidebar {
    display: none;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    z-index: 100;
    padding: 20px 16px;
    overflow-y: auto;
  }

  /* Sidebar aberta */
  #sidebar.mobile-open {
    display: flex;
  }

  /* Marca da aplicação */
  .brand {
    padding: 8px 10px 24px;
  }

  .brand-name {
    font-size: 16px;
  }

  .brand-sub {
    font-size: 12px;
  }

  /* Opções do menu */
  .nav-item {
    width: 100%;
    padding: 14px 12px;
    font-size: 16px;
    gap: 12px;
  }

  .nav-icon {
    font-size: 18px;
    width: 24px;
  }

  /* Rodapé */
  .sidebar-footer {
    font-size: 11px;
    padding: 16px 10px;
  }

  /* Barra superior */
  #topbar {
    padding: 10px 12px;
    gap: 8px;
  }

  /* Busca */
  .search-wrap {
    min-width: 0;
  }

  #global-search {
    padding-left: 12px;
  }

  .search-wrap::before {
    display: none;
  }

  /* Botão Novo */
  #quick-add-btn {
    padding: 8px 12px;
    white-space: nowrap;
  }

  /* Conteúdo */
  #view-root {
    padding: 18px 14px 40px;
  }
}