/*
 * NVXit component layer.
 * Hand-written CSS (no build step / no Tailwind @apply) so it works with the
 * Tailwind Play CDN as a plain stylesheet. Color values mirror the "envex"
 * and "accent" tokens in assets/js/tailwind-config.js — keep both in sync.
 */

:root {
  --envex-50: #F2F8F3;
  --envex-100: #E6F2E6;
  --envex-300: #6CBE5C;
  --envex-500: #16CC59;
  --envex-600: #119943;
  --envex-700: #0E8338;
  --envex-800: #0B662C;
  --envex-900: #0B3A1D;
  --envex-ink: #1E1E1E;
  --envex-ink-muted: #3F3F3F;
  --envex-ink-subtle: #808080;
  --envex-danger: #C00000;
  --envex-danger-dark: #960000;
  --envex-warning: #FF9900;
  --envex-warning-dark: #CC7A00;
  --accent-50: #EAF6F5;
  --accent-100: #D2ECEA;
  --accent-300: #7FC4C0;
  --accent-500: #2E9E93;
  --accent-600: #227F76;
  --accent-700: #1C6B63;
}

[x-cloak] {
  display: none !important;
}

/* ---------- Icons ----------
 * Default icon set for the whole project: Material Symbols (Outlined) from
 * Google Fonts (https://fonts.google.com/icons). Pick an icon name there and
 * render it as <span class="material-symbols-outlined">icon_name</span> —
 * don't add another icon library (inline SVG sets, Font Awesome, etc).
 * The webfont itself is loaded per-page via a <link> to fonts.googleapis.com
 * in <head> (see any .html file); this only sets the ligature/rendering rules.
 */
.material-symbols-outlined {
  font-family: "Material Symbols Outlined";
  font-weight: normal;
  font-style: normal;
  font-size: 1.25rem;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "liga";
  -webkit-font-feature-settings: "liga";
  vertical-align: middle;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 0.375rem;
  padding: 0.625rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.5rem;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1.125rem;
}

.btn-primary {
  background-color: var(--envex-700);
  color: #fff;
}
.btn-primary:hover {
  background-color: var(--envex-800);
}
.btn-primary:active {
  background-color: var(--envex-900);
}

.btn-secondary {
  background-color: var(--envex-50);
  color: var(--envex-800);
  border-color: rgb(11 102 44 / 0.2);
}
.btn-secondary:hover {
  background-color: var(--envex-100);
}

.btn-outline {
  background-color: transparent;
  color: var(--envex-ink-muted);
  border-color: rgb(128 128 128 / 0.3);
}
.btn-outline:hover {
  background-color: var(--envex-50);
  color: var(--envex-700);
}

.btn-danger {
  background-color: var(--envex-danger);
  color: #fff;
}
.btn-danger:hover {
  background-color: var(--envex-danger-dark);
}

.btn-ghost {
  background-color: transparent;
  color: var(--envex-ink-muted);
}
.btn-ghost:hover {
  background-color: rgb(128 128 128 / 0.1);
  color: var(--envex-ink);
}

/* Icon-only button — combine with .btn plus a color variant, e.g.
   <button class="btn btn-outline btn-icon" data-tooltip="Editar" aria-label="Editar">
     <span class="material-symbols-outlined">edit</span>
   </button>
   Always pair with data-tooltip (see Tooltip below) and aria-label, since the
   visible label goes away. */
.btn-icon {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  gap: 0;
}
.btn-icon .material-symbols-outlined {
  font-size: 1.125rem;
}

/* ---------- Tooltip ----------
 * Pure CSS, no JS: add data-tooltip="…" to any element (typically alongside
 * aria-label with the same text for screen readers). Shows above the element
 * on hover/keyboard focus. */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 0.375rem);
  left: 50%;
  transform: translateX(-50%) translateY(0.25rem);
  background-color: var(--envex-900);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
  z-index: 40;
}
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Elemento encostado na borda direita: tooltip alinhado à direita, para não
 * passar da tela (mesmo oculto, o ::after conta na largura rolável). */
[data-tooltip][data-tooltip-align="end"]::after {
  left: auto;
  right: 0;
  transform: translateY(0.25rem);
}
[data-tooltip][data-tooltip-align="end"]:hover::after,
[data-tooltip][data-tooltip-align="end"]:focus-visible::after {
  transform: translateY(0);
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 9999px;
  padding: 0.15rem 0.65rem;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.25rem;
  white-space: nowrap;
}

.badge-neutral {
  background-color: rgb(128 128 128 / 0.12);
  color: var(--envex-ink-muted);
}
.badge-success {
  background-color: var(--envex-100);
  color: var(--envex-800);
}
.badge-info {
  background-color: var(--accent-100);
  color: var(--accent-700);
}
.badge-warning {
  background-color: rgb(255 153 0 / 0.15);
  color: var(--envex-warning-dark);
}
.badge-danger {
  background-color: rgb(192 0 0 / 0.1);
  color: var(--envex-danger-dark);
}

/* ---------- Cards ---------- */

.card {
  background-color: #fff;
  border: 1px solid rgb(128 128 128 / 0.18);
  border-radius: 0.5rem;
  box-shadow: 0 1px 2px 0 rgb(30 30 30 / 0.06), 0 1px 3px 0 rgb(30 30 30 / 0.06);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgb(128 128 128 / 0.15);
}

.card-body {
  padding: 1.25rem;
}

.card-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgb(128 128 128 / 0.15);
}

/* ---------- Forms ---------- */

.field-label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--envex-ink);
}

.field-hint {
  margin-top: 0.375rem;
  font-size: 0.8125rem;
  color: var(--envex-ink-subtle);
}

.field-error {
  margin-top: 0.375rem;
  font-size: 0.8125rem;
  color: var(--envex-danger);
}

.input,
.select,
.textarea {
  display: block;
  width: 100%;
  border-radius: 0.375rem;
  border: 1px solid rgb(128 128 128 / 0.3);
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  color: var(--envex-ink);
  background-color: #fff;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--envex-ink-subtle);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--envex-700);
  box-shadow: 0 0 0 3px rgb(22 204 89 / 0.25);
}

.input.has-error,
.select.has-error,
.textarea.has-error {
  border-color: var(--envex-danger);
}
.input.has-error:focus,
.select.has-error:focus,
.textarea.has-error:focus {
  box-shadow: 0 0 0 3px rgb(192 0 0 / 0.2);
}

.textarea {
  resize: vertical;
  min-height: 6rem;
}

.checkbox,
.radio {
  width: 1rem;
  height: 1rem;
  border: 1px solid rgb(128 128 128 / 0.4);
  color: var(--envex-700);
  accent-color: var(--envex-700);
}
.radio {
  border-radius: 9999px;
}

/* ---------- Alerts ---------- */

.alert {
  display: flex;
  gap: 0.625rem;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  padding: 0.75rem 1rem;
  font-size: 1rem;
}

.alert-success {
  background-color: var(--envex-50);
  border-color: rgb(11 102 44 / 0.25);
  color: var(--envex-800);
}
.alert-info {
  background-color: var(--accent-50);
  border-color: rgb(46 158 147 / 0.3);
  color: var(--accent-700);
}
.alert-warning {
  background-color: rgb(255 153 0 / 0.1);
  border-color: rgb(255 153 0 / 0.35);
  color: var(--envex-warning-dark);
}
.alert-danger {
  background-color: rgb(192 0 0 / 0.08);
  border-color: rgb(192 0 0 / 0.3);
  color: var(--envex-danger-dark);
}

/* ---------- Tables ---------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid rgb(31 41 33 / 0.16);
  border-radius: 0.5rem;
}

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
}

table.table th {
  text-align: left;
  font-weight: 700;
  color: var(--envex-ink);
  background-color: var(--envex-100);
  padding: 0.625rem 1rem;
  border-bottom: 2px solid rgb(31 41 33 / 0.22);
  white-space: nowrap;
}

table.table td {
  padding: 0.625rem 1rem;
  border-bottom: 1px solid rgb(31 41 33 / 0.14);
  color: var(--envex-ink);
}

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

table.table tbody tr:nth-child(even) td {
  background-color: rgb(31 41 33 / 0.03);
}

table.table tbody tr:hover td {
  background-color: rgb(22 204 89 / 0.12);
}

/* Mobile-responsive table: stack columns on small screens */
@media (max-width: 640px) {
  .table-wrap {
    border: none;
    overflow-x: visible;
  }

  table.table,
  table.table thead,
  table.table tbody,
  table.table tr,
  table.table th,
  table.table td {
    display: block;
    width: 100%;
  }

  table.table thead {
    display: none;
  }

  table.table tbody tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid rgb(31 41 33 / 0.16);
    border-radius: 0.5rem;
    overflow: hidden;
  }

  table.table td {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    border: none;
    border-bottom: 1px solid rgb(31 41 33 / 0.08);
  }

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

  table.table td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--envex-ink);
    margin-right: 1rem;
  }

  table.table tbody tr:nth-child(even) td {
    background-color: transparent;
  }

  table.table tbody tr:hover td {
    background-color: transparent;
  }
}

/* ---------- Misc ---------- */

.link {
  color: var(--envex-700);
  font-weight: 600;
  text-decoration: none;
}
.link:hover {
  color: var(--envex-800);
  text-decoration: underline;
}

.divider {
  border: none;
  border-top: 1px solid rgb(128 128 128 / 0.15);
}

/* ---------- App shell (sidebar nav) ---------- */

aside {
  transition: transform 200ms ease;
}

@media (max-width: 768px) {
  aside {
    position: fixed;
    left: 0;
    top: 57px;
    bottom: 0;
    z-index: 40;
    width: 15rem;
    box-shadow: 2px 0 8px rgba(30, 30, 30, 0.12);
    transform: translateX(-100%);
  }

  body.sidebar-open aside {
    transform: translateX(0);
  }

  body.sidebar-open::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(30, 30, 30, 0.3);
  }
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-left: 3px solid transparent;
  padding: 0.5rem 1rem;
  font-size: 0.9375rem;
  color: var(--envex-ink);
  text-decoration: none;
}
.sidebar-link:hover {
  background-color: var(--envex-50);
}
.sidebar-link-active {
  background-color: var(--envex-50);
  border-left-color: var(--envex-700);
  color: var(--envex-800);
  font-weight: 700;
}
.sidebar-group-label {
  padding: 0.75rem 1rem 0.25rem;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--envex-ink-subtle);
}

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgb(30 30 30 / 0.45);
  padding: 1rem;
}
.modal-box {
  width: 100%;
  max-width: 32rem;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: 0.5rem;
  background-color: #fff;
  padding: 1.5rem;
}

/* ---------- Mobile header menu button ---------- */

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: var(--envex-ink-muted);
  font-size: 1.5rem;
}

@media (max-width: 768px) {
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* ---------- Responsive utilities ---------- */

@media (max-width: 768px) {
  /* Hide sidebar by default on mobile, show with JavaScript when needed */
  body.sidebar-open aside:not(.mobile-hidden) {
    transform: translateX(0);
  }

  /* Ensure main content spans full width */
  .flex.min-h-screen > main {
    width: 100%;
  }

  /* Make button groups wrap on mobile */
  .flex.gap-2 {
    flex-wrap: wrap;
  }

  /* Improve form field spacing on mobile */
  .space-y-2 > * + * {
    margin-top: 0.75rem;
  }

  /* Better badge wrapping */
  .flex.flex-wrap.gap-1 {
    gap: 0.5rem;
  }

  /* Card body padding for mobile */
  .card-body {
    padding: 1rem;
  }

  .card-header {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
  }
}

/* Mobile-first typography */
@media (max-width: 640px) {
  body {
    font-size: 0.95rem;
  }

  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.25rem;
  }

  .text-sm {
    font-size: 0.875rem;
  }

  /* Better spacing for alerts and messages */
  .alert {
    padding: 0.75rem 0.875rem;
    font-size: 0.9rem;
    gap: 0.5rem;
  }
}
