/* ==========================================================
   0. TRAVA GERAL: sempre claro
   ========================================================== */

/* ignora preferência do SO */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: light;
  }
}

/* variáveis base que o Django usa */
:root {
  --body-bg: #ffffff !important;
  --header-bg: #78adc6 !important;
  --hairline-color: #e5e7eb !important;
  --body-fg: #0f172a !important;
  --link-fg: #0f172a !important;
  --link-hover-color: #2563eb !important;
  --selected-row: #edf2f7 !important;
}

/* todo mundo claro por padrão */
body {
  background: #ffffff !important;
  color: #111827 !important;
  color-scheme: light;
}

/* ==========================================================
   1. TUDO QUE É ADMIN (NÃO LOGIN)
   envelopado em body:not(.login)
   ========================================================== */

body:not(.login) #header {
  background: #78adc6 !important;
  border-bottom: 1px solid #e5e7eb !important;
  color: #111827 !important;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 16px !important;
}

body:not(.login) #branding {
  display: flex;
  align-items: center;
  gap: 10px;
}
body:not(.login) #branding img {
  height: 40px;
  max-width: 140px;
  object-fit: contain;
}

/* sidebar clara */
body:not(.login) #nav-sidebar,
body:not(.login) #nav-sidebar .app-list,
body:not(.login) button.toggle-nav-sidebar {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: #e5e7eb !important;
}

body:not(.login) #nav-sidebar h2,
body:not(.login) #nav-sidebar .section {
  color: #ffffff !important;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: .4px;
  padding: 6px 10px;
  border: none !important;
}

/* menu lateral links */
body:not(.login) #nav-sidebar .app-list a {
  background: #ffffff !important;
  color: #0f172a !important;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  text-decoration: none !important;
  transition: background .15s ease;
}
body:not(.login) #nav-sidebar .app-list a:hover {
  background: #edf2f7 !important;
}

/* campo de busca do menu lateral */
body:not(.login) #nav-filter {
  background: #ffffff !important;
  border: 1px solid #e5e7eb !important;
  color: #111827 !important;
}
body:not(.login) #nav-filter::placeholder {
  color: #070707 !important;
}

/* container e conteúdo */
body:not(.login) #container,
body:not(.login) .content,
body:not(.login) .module,
body:not(.login) .grp-module {
  background: #ffffff !important;
  color: #111827 !important;
  border-color: #e5e7eb !important;
}

/* changelist */
body:not(.login) .change-list,
body:not(.login) .change-list form,
body:not(.login) .change-list .module {
  background: #ffffff !important;
}

/* busca da changelist */
body:not(.login) #changelist-search,
body:not(.login) .change-list .search-form {
  background: #ffffff !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 8px;
  padding: 10px 14px !important;
  margin-bottom: 10px;
}
body:not(.login) #changelist-search input[type="text"],
body:not(.login) .change-list .search-form input[type="text"],
body:not(.login) .change-list .search-form input[type="search"] {
  background: #ffffff !important;
  border: 1px solid #d1d5db !important;
  color: #111827 !important;
}
body:not(.login) #changelist-search input[type="submit"],
body:not(.login) .change-list .search-form input[type="submit"] {
  background: #2563eb !important;
  color: #fff !important;
  border: 0 !important;
}

/* ações */
body:not(.login) .change-list .actions {
  background: #f9fafb !important;
  border-top: 1px solid #e5e7eb !important;
  border-bottom: 1px solid #e5e7eb !important;
  color: #111827 !important;
  padding: 8px 14px !important;
  margin-bottom: 10px !important;
}
body:not(.login) .change-list .actions select {
  background: #ffffff !important;
  border: 1px solid #d1d5db !important;
  color: #111827 !important;
}
body:not(.login) .change-list .actions .button,
body:not(.login) .change-list .actions input[type=submit],
body:not(.login) .change-list .actions button {
  background: #2563eb !important;
  color: #ffffff !important;
  border: 0 !important;
}

/* filtro lateral */
body:not(.login) #changelist-filter {
  background: #ffffff !important;
  border-left: 1px solid #e5e7eb !important;
  color: #111827 !important;
}
body:not(.login) #changelist-filter h2 {
  background: #ffffff !important;
  color: #111827 !important;
  border-bottom: 1px solid #e5e7eb !important;
}
body:not(.login) #changelist-filter a {
  color: #2563eb !important;
}
body:not(.login) #changelist-filter li.selected a {
  color: #1d4ed8 !important;
  font-weight: 600;
}

/* paginator */
body:not(.login) .paginator {
  background: #ffffff !important;
  border-top: 1px solid #e5e7eb !important;
  color: #111827 !important;
}

/* tabelas SEM faixa escura */
body:not(.login) table,
body:not(.login) th,
body:not(.login) td {
  background: transparent !important;
  border-color: #e5e7eb !important;
  color: #111827 !important;
}
body:not(.login) table thead th {
  background: #f3f4f6 !important;
  color: #111827 !important;
  border-bottom: 2px solid #e5e7eb !important;
  text-transform: uppercase;
  letter-spacing: .02em;
}
body:not(.login) table tbody tr {
  background: #ffffff !important;
  border-bottom: 1px solid #e5e7eb !important;
  color: #111827 !important;
}
body:not(.login) table tbody tr:nth-child(even) {
  background: #f9fafb !important;
}
body:not(.login) table td a,
body:not(.login) table th a {
  color: #2563eb !important;
  text-decoration: none;
}
body:not(.login) table td a:hover,
body:not(.login) table th a:hover {
  text-decoration: underline;
}

/* tira o history duplicado */
body:not(.login) .content #content-main > ul.object-tools > li > a.historylink {
  display: none !important;
}
/* estiliza o que sobra */
body:not(.login) .object-tools a.historylink {
  background: #2563eb !important;
  color: #fff !important;
  border: none !important;
  border-radius: 999px !important;
  padding: 4px 12px !important;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  line-height: 1.4;
}
body:not(.login) .object-tools a.historylink:hover {
  background: #1d4ed8 !important;
}

/* ==========================================================
   2. SÓ A PÁGINA DE LOGIN
   ========================================================== */

body.login {
  background: #ffffff !important;
}

/* cabeçalho do login (a faixinha azul) */
body.login #header {
  background: #78adc6 !important;
  border-bottom: 1px solid #e5e7eb !important;
  min-height: 56px;
  display: flex;
  align-items: center;
  padding: 0 16px;
}

/* centraliza o conteúdo de login */
body.login #container,
body.login #content {
  min-height: calc(100vh - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff !important;
  padding: 30px 16px 40px;
}

/* caixinha do form */
body.login #content-main {
  width: 420px;
  max-width: 100%;
  background: #ffffff;
  border: 1px solid #edf2f7;
  border-radius: 10px;
  padding: 22px 22px 18px;
  box-shadow: 0 12px 35px rgba(15, 23, 42, 0.08);
}

body.login #content-main input[type="text"],
body.login #content-main input[type="password"] {
  width: 100%;
  background: #e2efff;
  border: 1px solid #bcd1e4;
  border-radius: 5px;
  height: 34px;
}

body.login #content-main input[type="submit"],
body.login #content-main .submit-row input {
  background: #78adc6 !important;
  border: none !important;
  color: #fff !important;
  border-radius: 6px !important;
  padding: 6px 18px !important;
  font-weight: 600;
  cursor: pointer;
}
body.login #content-main input[type="submit"]:hover {
  background: #5e95ae !important;
}

body.login #footer {
  display: none;
}

/* === LOGIN: esconder sidebar e deixar só o form === */
body.login #nav-sidebar,
body.login nav.breadcrumbs,
body.login .breadcrumbs,
body.login #toggle-nav-sidebar {
  display: none !important;
}

body.login #content,
body.login #container,
body.login .content {
  margin-left: 0 !important;
}


/* Força cor branca nos links tipo botão, mesmo com tema padrão Django */
#content a.it-btn--primary,
#content a.it-btn--primary:link,
#content a.it-btn--primary:visited {
  color: #fff !important;
  text-decoration: none !important;
}

#content a.it-btn--primary:hover {
  color: #fff !important;
  opacity: 0.9;
}

.it-btn--primary {
  background: #4a90e2;
  color: #fff !important;
  padding: 3px 8px;
  border-radius: 4px;
  text-decoration: none;
  font-size: 12px;
}
.it-btn--primary:hover {
  opacity: 0.9;
}

/* ===== Botão "Open" na tabela ===== */
#result_list a.open-link {
  display: inline-block;
  background: #4a90e2 !important;
  color: #fff !important;
  font-weight: 600;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 4px;
  text-decoration: none !important;
  line-height: 1.2;
}

#result_list a.open-link:hover {
  background: #357ABD !important; /* tom levemente mais escuro */
  color: #fff !important;
  text-decoration: none !important;
}
