/* ==========================================================================
   Portal Opice Blum — identidade visual
   Cores/tipografia iniciais; ajuste os tokens abaixo conforme a marca oficial.
   ========================================================================== */

:root {
  /* Paleta — ajuste os hex com os valores oficiais da marca */
  --color-bg: #DDD;
  --color-surface: #f7f7f5;
  --color-surface-2: #a3a3a3;
  --color-text: #111418;
  --color-text-muted: #4a5159;
  --color-border: #e3e3dd;

  --color-primary: #b2dd2c;      /* navy institucional */
  --color-primary-600: #0a1f34;
  --color-primary-100: #e6edf4;
  --color-accent: #c7a45a;       /* dourado/âmbar */
  --color-accent-600: #a98736;

  --color-danger: #b3261e;
  --color-success: #1f6b3a;

  /* Tipografia */
  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-serif: "Source Serif 4", "Georgia", "Times New Roman", serif;

  /* Espaçamento / raio / sombra */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 42, 68, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 42, 68, 0.08);

  --container-max: 1600px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 { font-family: var(--font-serif); font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 2.25rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.5rem; margin: 0 0 0.5rem; }
p  { margin: 0 0 1rem; }

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.accent { color: var(--color-accent-600); }
.lead { color: var(--color-text-muted); font-size: 1.0625rem; }

/* ---------- Header ---------- */
.site-header {
  background: var(--color-primary);
  color: #fff;
  border-bottom: 3px solid var(--color-accent);
}
.site-header .container { padding: 0 1.25rem; }
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: #fff;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  letter-spacing: 0.01em;
}
.brand:hover { text-decoration: none; }
.brand-name strong { font-weight: 700; }
.brand-mark {
  display: inline-block;
  width: 26px;
  height: 26px;
  border-radius: 3px;
  background:
    linear-gradient(135deg, var(--color-accent) 0 50%, #fff 50% 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}
.brand-mark-lg { width: 48px; height: 48px; border-radius: 6px; }

.nav { display: flex; align-items: center; gap: 0.75rem; }
.nav-user {
  color: rgba(0,0,0, 0.85);
  font-size: 0.95rem;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-logout { margin: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
  text-decoration: none;
}
.btn-primary {
  background: var(--color-accent);
  color: #1a1300;
  border-color: var(--color-accent-600);
}
.btn-primary:hover {
  background: var(--color-accent-600);
  color: #fff;
  text-decoration: none;
}
.btn-ghost {
  background: transparent;
  color: #000;
  border-color: rgba(255, 255, 255, 0.4);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.1); text-decoration: none; }
.btn-block { width: 100%; }

/* ---------- App shell (header + sidebar + main) ---------- */
.app-shell {
  display: flex;
  align-items: stretch;
  min-height: calc(100vh - 180px);
}
.app-main {
  flex: 1;
  min-width: 0;
}
.app-main .container {
  padding-top: 2.5rem;
  padding-bottom: 3rem;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: 1.5rem 0;
}
.sidebar-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sidebar-nav li { margin: 0; }
.sidebar-link {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.75rem 1.25rem;
  border-left: 3px solid transparent;
  color: var(--color-text);
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.sidebar-link:hover {
  background: var(--color-surface-2);
  text-decoration: none;
}
.sidebar-link.is-active {
  background: var(--color-primary-100);
  border-left-color: var(--color-accent);
  color: var(--color-primary);
}
.sidebar-link-label {
  font-weight: 600;
  font-size: 0.98rem;
}
.sidebar-link-desc {
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

/* ---------- Sidebar dropdown groups ---------- */
.sidebar-group { margin: 0; }
.sidebar-group > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.sidebar-group > summary::-webkit-details-marker { display: none; }
.sidebar-link-toggle .sidebar-link-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
}
.sidebar-caret {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  transition: transform 150ms ease;
}
.sidebar-group[open] > summary .sidebar-caret {
  transform: rotate(180deg);
}
.sidebar-group[open] > summary {
  background: var(--color-surface-2);
}

.sidebar-submenu {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0 0.5rem;
  background: var(--color-bg);
}
.sidebar-submenu li { margin: 0; }
.sidebar-sublink {
  display: block;
  padding: 0.5rem 1.25rem 0.5rem 2.25rem;
  color: var(--color-text);
  font-size: 0.92rem;
  border-left: 3px solid transparent;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.sidebar-sublink:hover {
  background: var(--color-surface-2);
  text-decoration: none;
}
.sidebar-sublink.is-active {
  background: var(--color-primary-100);
  border-left-color: var(--color-accent);
  color: var(--color-primary);
  font-weight: 600;
}

/* ---------- Hero / cards ---------- */
main.container { padding-top: 2.5rem; padding-bottom: 3rem; min-height: calc(100vh - 180px); }

.hero h1 { margin-bottom: 0.35rem; }
.hero .lead { margin-bottom: 2rem; max-width: 640px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-accent);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: var(--shadow-sm);
}
.card h2 { font-size: 1.15rem; margin: 0; }
.card p { color: var(--color-text-muted); flex: 1; }
.card .btn { align-self: flex-start; margin-top: 0.5rem; }

/* ---------- Auth ---------- */
.auth-panel {
  display: flex;
  justify-content: center;
  padding: 3rem 0 4rem;
}
.auth-card {
  max-width: 440px;
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2.25rem 2rem;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.auth-card h1 { font-size: 1.6rem; margin-top: 1rem; }
.auth-card .brand-mark-lg { margin: 0 auto; }
.auth-card .lead { margin-bottom: 1.75rem; }

.ms-logo {
  display: inline-grid;
  width: 16px;
  height: 16px;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 2px;
}
.ms-logo span:nth-child(1) { background: #f25022; }
.ms-logo span:nth-child(2) { background: #7fba00; }
.ms-logo span:nth-child(3) { background: #00a4ef; }
.ms-logo span:nth-child(4) { background: #ffb900; }

/* ---------- Error ---------- */
.error-panel { display: flex; justify-content: center; padding: 3rem 0; }
.error-card {
  max-width: 520px;
  text-align: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
}
.error-code {
  display: block;
  font-family: var(--font-serif);
  font-size: 4rem;
  color: var(--color-accent-600);
  line-height: 1;
  margin-bottom: 0.75rem;
}

/* ---------- Forms ---------- */
.form {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem 1.25rem;
}

.form-section {
  margin-bottom: 1.5rem;
  padding-bottom: 3.5rem;
  border-bottom: 1px solid var(--color-border);
}
.form-section-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: var(--color-accent-600);
  margin: 0 0 1rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}
.form-field--wide { grid-column: 1 / -1; }
.form-field label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-text);
}
.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  font: inherit;
  color: var(--color-text);
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(178, 221, 44, 0.25);
}
.form-field select[multiple] {
  min-height: 6rem;
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
}
.form-actions .btn-ghost {
  color: var(--color-text);
  border-color: var(--color-border);
}
.form-actions .btn-ghost:hover {
  background: var(--color-surface-2);
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  padding: 1.25rem 0;
  border-top: 1px solid var(--color-border);
}

@media (max-width: 768px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    padding: 0.5rem 0;
  }
  .sidebar-nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0 0.75rem;
  }
  .sidebar-link {
    padding: 0.5rem 0.75rem;
    border-left: none;
    border-bottom: 3px solid transparent;
    border-radius: var(--radius-sm);
  }
  .sidebar-link.is-active {
    border-left: none;
    border-bottom-color: var(--color-accent);
  }
  .sidebar-link-desc { display: none; }
}

@media (max-width: 640px) {
  h1 { font-size: 1.75rem; }
  .nav-user { display: none; }
  main.container { padding-top: 1.5rem; }
  .app-main .container { padding-top: 1.5rem; }
}

.required {
  border-color: #E00 !important;
  border: 1px solid;
}

/* ---------- Grid (listagem) ---------- */
.grid-wrapper {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  margin-bottom: 2rem;
}
.grid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.grid-table thead th {
  background: var(--color-primary-100);
  color: var(--color-primary-600);
  text-align: left;
  font-weight: 600;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.grid-table tbody td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}
.grid-table tbody tr:hover {
  background: rgba(178, 221, 44, 0.08);
}
.grid-table tbody tr:last-child td {
  border-bottom: none;
}
.grid-empty {
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 2rem;
  text-align: center;
  color: var(--color-text-muted);
  margin-bottom: 2rem;
}
.status-pill {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.status-pendente {
  background: #fff4d6;
  color: #8a6d00;
}
.status-sucesso {
  background: #dff5e3;
  color: var(--color-success);
}
.status-erro {
  background: #fbe2e0;
  color: var(--color-danger);
}

.disabled {
  background-color: #eaeaea !important;
}

/* ---------- Popup (toast) ---------- */
.popup {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  max-width: 380px;
  padding: 0.9rem 1.2rem;
  border-radius: var(--radius-md);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.4;
  box-shadow: var(--shadow-md);
  z-index: 9999;
  opacity: 0;
  transform: translateX(120%);
  transition: opacity 250ms ease, transform 250ms ease;
  pointer-events: none;
}
.popup.is-visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
.popup-success { background: var(--color-success); }
.popup-error   { background: var(--color-danger); }

@media (max-width: 640px) {
  .popup {
    left: 1rem;
    right: 1rem;
    top: 1rem;
    max-width: none;
  }
}