/* =========================================================
   Theme v2 — Navy + Âmbar, inspirado em dashboard SaaS moderno
   Carregar SEMPRE depois do bootstrap.min.css no <head>
   ========================================================= */

:root {
  /* Paleta */
  --brand-navy: #101a30;
  --brand-navy-light: #16223f;
  --brand-amber: #f59e0b;
  --brand-amber-dark: #d97f06;

  --bs-primary: #f59e0b;
  --bs-primary-rgb: 245, 158, 11;

  --bs-body-color: #1f2937;
  --bs-body-bg: #f5f6f8;
  --bs-border-color: #e5e7eb;

  --bs-border-radius: 0.75rem;
  --bs-border-radius-sm: 0.5rem;
  --bs-border-radius-lg: 1rem;

  --bs-box-shadow-sm: 0 1px 3px rgba(16, 26, 48, 0.06);
  --bs-box-shadow: 0 4px 16px rgba(16, 26, 48, 0.08);

  --bs-body-font-size: 0.9rem;
  --bs-body-line-height: 1.5;
}

html, body {
  height: 100%;
}

/* ---------- Navbar ---------- */
.navbar.bg-dark {
  background-color: var(--brand-navy) !important;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06), 0 2px 8px rgba(0, 0, 0, 0.15);
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
}

.navbar-brand img {
  height: 30px;
  width: 30px;
  object-fit: contain;
  background: white;
  border-radius: 0.5rem;
  padding: 3px;
}

.navbar .nav-link {
  color: rgba(255, 255, 255, 0.75) !important;
  border-radius: 999px;
  padding: 0.4rem 0.9rem !important;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.navbar .nav-link:hover {
  color: #ffffff !important;
  background-color: rgba(255, 255, 255, 0.08);
}

.navbar .nav-item.active > .nav-link,
.navbar .nav-link.active {
  background-color: var(--brand-amber);
  color: var(--brand-navy) !important;
  font-weight: 600;
}

.navbar .dropdown-menu {
  box-shadow: var(--bs-box-shadow);
  border: none;
  border-radius: var(--bs-border-radius);
  padding: 0.4rem;
  margin-top: 0.5rem;
}

.navbar .dropdown-item {
  border-radius: 0.5rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
}

.navbar .dropdown-item:hover {
  background-color: #fef3e2;
  color: var(--brand-amber-dark);
}

/* ---------- Hero / cabeçalho de página (substitui o jumbotron pesado) ---------- */
.jumbotron {
  background: transparent !important;
  padding: 2rem 0 1rem !important;
  margin-bottom: 0 !important;
}

.jumbotron .display-4 {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--bs-body-color);
}

.jumbotron .lead {
  font-size: 0.95rem;
  color: #6b7280;
  font-weight: 400;
}

/* ---------- Cards ---------- */
.card {
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  box-shadow: var(--bs-box-shadow-sm);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

/* ---------- Listagens (list-group usado como "cards" de item) ---------- */
.list-group-item {
  border: 1px solid var(--bs-border-color) !important;
  border-radius: var(--bs-border-radius) !important;
  margin-bottom: 0.75rem;
  padding: 1rem 1.25rem;
  box-shadow: var(--bs-box-shadow-sm);
  transition: box-shadow 0.15s ease, transform 0.1s ease;
}

.list-group-item-action:hover {
  box-shadow: var(--bs-box-shadow);
  transform: translateY(-1px);
  background-color: #ffffff;
}

/* ---------- Modais ---------- */
.modal-content {
  border: none;
  border-radius: var(--bs-border-radius-lg);
  box-shadow: 0 12px 32px rgba(16, 26, 48, 0.2);
  overflow: hidden;
}

.modal-header {
  border-bottom: 1px solid var(--bs-border-color);
  padding: 1rem 1.25rem;
}

.modal-title {
  font-weight: 700;
  font-size: 1.05rem;
}

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  border-top: 1px solid var(--bs-border-color);
  background-color: #fafbfc;
  padding: 0.85rem 1.25rem;
}

/* ---------- Botões ---------- */
.btn {
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.45rem 1.1rem;
}

.btn-primary {
  background-color: var(--brand-amber);
  border-color: var(--brand-amber);
  color: var(--brand-navy);
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: var(--brand-amber-dark);
  border-color: var(--brand-amber-dark);
  color: #ffffff;
}

.btn-secondary {
  background-color: transparent;
  border-color: var(--bs-border-color);
  color: #6b7280;
}

.btn-secondary:hover {
  background-color: #f3f4f6;
  color: #1f2937;
}

.btn-info {
  background-color: #eef2ff;
  border-color: #eef2ff;
  color: #3730a3;
}

.btn-danger {
  background-color: #fef2f2;
  border-color: #fef2f2;
  color: #b91c1c;
}

.btn-danger:hover {
  background-color: #fee2e2;
}

/* ---------- Formulários ---------- */
.form-label {
  margin-bottom: 0.3rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
}

.form-control,
.form-select {
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  border-color: var(--bs-border-color);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--brand-amber);
  box-shadow: 0 0 0 0.2rem rgba(245, 158, 11, 0.15);
}

.input-group .btn {
  border-radius: 0.5rem;
}

/* ---------- Badges (pills de status) ---------- */
.badge {
  font-weight: 600;
  font-size: 0.7rem;
  padding: 0.4em 0.75em;
  border-radius: 999px;
  text-transform: none;
}

.badge.bg-primary,
.badge.text-bg-primary {
  background-color: #eef2ff !important;
  color: #3730a3 !important;
}

/* ---------- Tabelas ---------- */
.table {
  font-size: 0.85rem;
  --bs-table-striped-bg: rgba(16, 26, 48, 0.015);
}

.table > :not(caption) > * > * {
  padding: 0.6rem 0.9rem;
}

.table thead th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  font-weight: 700;
  border-bottom: 1px solid var(--bs-border-color);
  background-color: #fafbfc;
}

/* ---------- Alertas ---------- */
.alert {
  border: none;
  border-radius: var(--bs-border-radius);
  font-size: 0.875rem;
}

/* ---------- Footer ---------- */
.footer {
  background-color: var(--brand-navy) !important;
  color: rgba(255, 255, 255, 0.6);
  margin-top: auto !important;
  flex-shrink: 0;
  padding: 1.25rem 0 !important;
}

.footer small {
  font-size: 0.75rem;
  line-height: 1.5;
}

/* =========================================================
   Sidebar layout + Dark mode
   Adicionar ao FINAL do public/css/theme.css existente
   ========================================================= */

:root {
  --sidebar-width: 240px;
  --sidebar-width-collapsed: 64px;
  --topbar-height: 56px;
}

/* ---------- Shell geral ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background-color: var(--brand-navy);
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: width 0.2s ease;
  z-index: 1030;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  height: var(--topbar-height);
  padding: 0 1rem;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-brand img {
  height: 32px;
  width: 32px;
  object-fit: contain;
  background: #fff;
  border-radius: 0.5rem;
  padding: 3px;
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: 0.5rem;
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-link i:first-child {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-link:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-link.active {
  background-color: var(--brand-amber);
  color: var(--brand-navy);
  font-weight: 700;
}

.sidebar-chevron {
  margin-left: auto;
  font-size: 0.7rem;
  transition: transform 0.2s ease;
}

.sidebar-group-toggle[aria-expanded="true"] .sidebar-chevron,
.sidebar-group-toggle:not(.collapsed) .sidebar-chevron {
  transform: rotate(180deg);
}

.sidebar-submenu {
  display: flex;
  flex-direction: column;
  padding-left: 2.35rem;
  padding-top: 0.15rem;
  padding-bottom: 0.3rem;
}

.sidebar-submenu a {
  padding: 0.4rem 0.5rem;
  border-radius: 0.4rem;
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  font-size: 0.8rem;
}

.sidebar-submenu a:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-submenu-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 0.3rem 0.5rem;
}

.sidebar-user {
  padding: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* dropdown do usuário: garante contraste mesmo com o dropdown padrão do BS */
.dropdown-menu-dark-safe {
  --bs-dropdown-bg: #fff;
  --bs-dropdown-link-color: #1f2937;
  --bs-dropdown-link-hover-bg: #f3f4f6;
}

/* ---------- Sidebar colapsada (ícone-only, desktop) ---------- */
.sidebar-collapsed .sidebar {
  width: var(--sidebar-width-collapsed);
}

.sidebar-collapsed .sidebar-brand-text,
.sidebar-collapsed .sidebar-link span,
.sidebar-collapsed .sidebar-chevron,
.sidebar-collapsed .sidebar-submenu {
  display: none !important;
}

.sidebar-collapsed .sidebar-link {
  justify-content: center;
  padding: 0.6rem;
}

/* ---------- Área principal ---------- */
.app-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1rem;
  background-color: #ffffff;
  border-bottom: 1px solid var(--bs-border-color);
  position: sticky;
  top: 0;
  z-index: 1020;
}

.topbar-btn {
  background: transparent;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
}

.topbar-btn:hover {
  background-color: #f3f4f6;
  color: var(--brand-navy);
}

/* ---------- Mobile: sidebar vira off-canvas ---------- */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1025;
}

@media (max-width: 991.98px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: var(--sidebar-width) !important;
  }

  .sidebar-collapsed .sidebar-brand-text,
  .sidebar-collapsed .sidebar-link span,
  .sidebar-collapsed .sidebar-chevron,
  .sidebar-collapsed .sidebar-submenu {
    display: revert !important;
  }

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

  .sidebar-mobile-open .sidebar-backdrop {
    display: block;
  }

  .app-shell {
    display: block;
  }
}

/* ---------- Footer ajustado pro novo shell ---------- */
.footer {
  background-color: var(--brand-navy) !important;
  color: rgba(255, 255, 255, 0.6);
  flex-shrink: 0;
}

.footer img {
  background: #fff;
  border-radius: 0.35rem;
  padding: 2px;
}

/* =========================================================
   DARK MODE — [data-bs-theme="dark"]
   ========================================================= */

[data-bs-theme="dark"] {
  --bs-body-bg: #0f1522;
  --bs-body-color: #e5e7eb;
  --bs-border-color: #253044;
}

[data-bs-theme="dark"] .app-topbar {
  background-color: #141b2b;
  border-bottom-color: #253044;
}

[data-bs-theme="dark"] .topbar-btn {
  color: #9ca3af;
}

[data-bs-theme="dark"] .topbar-btn:hover {
  background-color: #1e2740;
  color: #fff;
}

[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] .list-group-item {
  background-color: #141b2b;
  border-color: #253044 !important;
  color: #e5e7eb;
}

[data-bs-theme="dark"] .list-group-item-action:hover {
  background-color: #1a2338;
}

[data-bs-theme="dark"] .table {
  --bs-table-bg: transparent;
  --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
  color: #e5e7eb;
}

[data-bs-theme="dark"] .table thead th {
  background-color: #141b2b;
  color: #9ca3af;
  border-bottom-color: #253044;
}

[data-bs-theme="dark"] .modal-content {
  background-color: #141b2b;
  color: #e5e7eb;
}

[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-footer {
  border-color: #253044;
  background-color: #10182a;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background-color: #10182a;
  border-color: #253044;
  color: #e5e7eb;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
  background-color: #10182a;
  color: #fff;
}

[data-bs-theme="dark"] .form-label {
  color: #9ca3af;
}

[data-bs-theme="dark"] .jumbotron .display-4 {
  color: #e5e7eb;
}

[data-bs-theme="dark"] .jumbotron .lead {
  color: #9ca3af;
}

[data-bs-theme="dark"] .dropdown-menu-dark-safe {
  --bs-dropdown-bg: #141b2b;
  --bs-dropdown-link-color: #e5e7eb;
  --bs-dropdown-link-hover-bg: #1e2740;
  border-color: #253044;
}

[data-bs-theme="dark"] .alert {
  filter: brightness(0.9);
}

/* Respiro geral mais generoso */
.app-content {
  flex: 1 0 auto;
  padding-top: 1.5rem;
  padding-bottom: 2.5rem;
  padding-left: 1.75rem;
  padding-right: 1.75rem;
}

.jumbotron {
  padding: 2rem 1.75rem !important;
  border-radius: var(--bs-border-radius-lg);
}

.card-body {
  padding: 1.5rem;
}

.list-group-item {
  padding: 1.35rem 1.5rem;
  margin-bottom: 1rem;
}

.row {
  --bs-gutter-x: 1.5rem;
}

.sidebar-nav {
  padding: 1rem 0.75rem;
  gap: 0.25rem;
}

.sidebar-link {
  padding: 0.65rem 0.85rem;
}

/* =========================================================
   Layout de autenticação (login, registro, recuperar senha)
   ========================================================= */

.auth-body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--bs-body-bg);
}

.auth-navbar {
  background-color: var(--brand-navy) !important;
  padding: 1rem 0;
}

.auth-navbar .navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.1rem;
}

.auth-navbar .navbar-brand img {
  background: #fff;
  border-radius: 0.5rem;
  padding: 3px;
}

.auth-main {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1rem;
}

.auth-main .card {
  width: 100%;
  max-width: 420px;
  border: none;
  box-shadow: 0 8px 30px rgba(16, 26, 48, 0.1);
}

.auth-main .card-body {
  padding: 2.5rem 2.25rem;
}

.auth-main h1,
.auth-main h2,
.auth-main .card-header {
  font-size: 1.4rem;
  font-weight: 800;
  text-align: center;
  color: var(--brand-navy);
  border: none;
  background: transparent;
  padding: 0;
  margin-bottom: 1.75rem;
}

/* Espaçamento consistente entre campos, mesmo se a view usar form-group antigo */
.auth-main form > div,
.auth-main .form-group {
  margin-bottom: 1.1rem;
}

.auth-main .form-label {
  text-transform: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
  letter-spacing: normal;
}

.auth-main .form-control {
  padding: 0.6rem 0.85rem;
}

.auth-main .form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0 1.25rem;
}

.auth-main .form-check-input {
  margin: 0;
  cursor: pointer;
}

.auth-main .form-check-label {
  font-size: 0.85rem;
  color: #4b5563;
  cursor: pointer;
}

.auth-main .btn-primary {
  width: 100%;
  padding: 0.65rem;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.auth-main a {
  color: var(--brand-amber-dark);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}

.auth-main a:hover {
  text-decoration: underline;
}

.auth-main form {
  text-align: left;
}

.auth-main .card-body > a,
.auth-main form + a,
.auth-main form ~ a {
  display: block;
  text-align: center;
  margin-top: 0.25rem;
}

.auth-body .footer {
  background-color: var(--brand-navy) !important;
  color: rgba(255, 255, 255, 0.55);
  flex-shrink: 0;
}

.auth-body .footer small {
  font-size: 0.72rem;
  line-height: 1.5;
  max-width: 720px;
}