/* =============== */
/* Base / Tokens   */
/* =============== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: Arial, Helvetica, sans-serif;
}

:root {
  color-scheme: light dark;
}

/* CORREÇÃO RECOMENDADA (global):
   O atributo hidden deve SEMPRE esconder o elemento,
   mesmo que exista uma regra a definir display:grid/flex/etc. */
[hidden] {
  display: none !important;
}

body {
  height: 100vh;
  overflow: hidden;

  --nav: #1e293b;
  --side: #334155;
  --bg: #f1f5f9;
  --fg: #0b1220;
  --card: #fff;

  --muted: #94a3b8;
  --shadow: rgba(0, 0, 0, 0.12);
  --border: rgba(148, 163, 184, 0.30);

  --primary: #38bdf8;
  --danger: #fb7185;

  background: var(--bg);
  color: var(--fg);
  transition: background 0.2s, color 0.2s;
}

body.dark {
  --nav: #020617;
  --side: #0b1220;
  --bg: #0f172a;
  --fg: #e5e7eb;
  --card: #0b1220;

  --muted: #94a3b8;
  --shadow: rgba(0, 0, 0, 0.35);
  --border: rgba(148, 163, 184, 0.22);

  --primary: #38bdf8;
  --danger: #fb7185;
}

a {
  color: inherit;
}

/* =============== */
/* Navbar          */
/* =============== */

.navbar {
  height: 60px;
  background: var(--nav);
  color: #fff;

  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 0 14px;
  gap: 12px;
}

.brand {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.brand-title {
  font-weight: 700;
}

.brand-subtitle {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.75);
}

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

.icon-btn {
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 10px;
}

.icon-btn.dark {
  color: var(--fg);
}

.pill {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 999px;
}

.pill:hover {
  background: rgba(255, 255, 255, 0.18);
}

.pill.ghost {
  color: var(--fg);
  background: transparent;
  border-color: var(--border);
}

.pill.primary {
  background: var(--primary);
  border-color: transparent;
  color: #001018;
}

.pill.danger {
  background: transparent;
  border-color: rgba(251, 113, 133, 0.55);
  color: var(--danger);
}

.badge {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

/* =============== */
/* Dropdown         */
/* =============== */

.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);

  min-width: 220px;
  background: var(--card);
  color: var(--fg);

  border-radius: 12px;
  box-shadow: 0 10px 28px var(--shadow);
  overflow: hidden;

  display: none;
  border: 1px solid var(--border);
}

.dropdown[data-open="true"] .dropdown-menu {
  display: block;
}

.dropdown-menu a {
  display: block;
  padding: 12px 14px;
  text-decoration: none;
}

.dropdown-menu a:hover {
  background: rgba(148, 163, 184, 0.18);
}

.hide {
  display: none !important;
}

/* =============== */
/* Layout / Sidebar */
/* =============== */

.layout {
  height: calc(100vh - 60px);
  display: grid;
  grid-template-columns: 240px 1fr;
  position: relative;
  transition: grid-template-columns 0.2s ease;
}

.layout.sidebar-closed {
  grid-template-columns: 0 1fr;
}

.sidebar {
  background: var(--side);
  color: #fff;
  padding: 16px;
  transition: transform 0.2s ease, width 0.2s ease, padding 0.2s ease;
  overflow: auto;
  width: 240px;
}

.sidebar.closed {
  width: 0;
  padding: 0;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.sidebar-title {
  font-weight: 700;
  opacity: 0.95;
}

.side-links a {
  display: block;
  padding: 12px 12px;
  border-radius: 12px;
  text-decoration: none;
  margin-bottom: 8px;
  white-space: nowrap;
}

.side-links a:hover {
  background: rgba(255, 255, 255, 0.10);
}

.side-links a.active {
  background: rgba(56, 189, 248, 0.20);
  border: 1px solid rgba(56, 189, 248, 0.25);
}

/* =============== */
/* Content / Cards  */
/* =============== */

.content {
  padding: 18px;
  overflow-y: auto;
  background: var(--bg);
}

.card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 6px 18px var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}

.muted {
  color: var(--muted);
}

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

.spread {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.label {
  font-size: 12px;
  color: var(--muted);
  margin: 10px 0 6px;
  display: inline-block;
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
}

.select {
  width: auto;
  min-width: 200px;
}

.textarea {
  min-height: 160px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
}

/* =============== */
/* Table            */
/* =============== */

.table {
  width: 100%;
  border-collapse: collapse;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.table th,
.table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.table th {
  font-size: 12px;
  color: var(--muted);
}

.table tr:last-child td {
  border-bottom: none;
}

/* =============== */
/* Snippets         */
/* =============== */

.snippet {
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: var(--card);
  box-shadow: 0 6px 18px var(--shadow);
  margin-bottom: 14px;
}

.snippet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}

.snippet-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.snippet pre {
  margin: 0;
  padding: 12px;
  overflow: auto;
}

.snippet code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre;
}

/* =============== */
/* Toast            */
/* =============== */

.toast {
  position: fixed;
  right: 14px;
  bottom: 14px;

  background: var(--card);
  color: var(--fg);

  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;

  box-shadow: 0 10px 28px var(--shadow);
  z-index: 9999;
  display: none;
}

.toast.show {
  display: block;
}

/* =============== */
/* Modal            */
/* =============== */

/* Modal visível só quando não está hidden (ou quando o JS quiser). */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);

  display: grid;
  place-items: center;

  z-index: 10000;
  padding: 14px;
}

/* (Mantido — mas o [hidden] global já resolve.) */
.modal[hidden] {
  display: none !important;
}

.modal-card {
  width: min(780px, 96vw);
  background: var(--card);
  color: var(--fg);

  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 28px var(--shadow);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-weight: 700;
}

.modal-body {
  padding: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}

/* =============== */
/* Backdrop         */
/* =============== */

.backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 20;
}

.backdrop[hidden] {
  display: none !important;
}

/* =============== */
/* Responsive       */
/* =============== */

.close-only-mobile {
  display: none;
}

@media (max-width: 820px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .layout.sidebar-closed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 260px;
    z-index: 30;
    transform: translateX(0);
  }

  .sidebar.closed {
    width: 260px;
    padding: 16px;
    overflow: auto;
    transform: translateX(-110%);
  }

  .close-only-mobile {
    display: inline-flex;
  }
}