/* ==========================================================================
   INSTITUTO ARBOR — Área Administrativa Interna
   Design System Corporativo: Verde Floresta (#1A5C2A) e Âmbar Dourado (#D4A017)
   ========================================================================== */

:root {
  --forest: #1A5C2A;
  --forest-dark: #0E3317;
  --forest-light: #2D7A3E;
  --amber: #D4A017;
  --amber-light: #E5B32B;
  --amber-dark: #B88910;
  --soil: #4A3525;

  /* Aliases corporativos */
  --navy: #1A5C2A;
  --navy-dark: #0E3317;
  --navy-light: #2D7A3E;
  --gold: #D4A017;
  --gold-light: #E5B32B;
  --gold-dark: #B88910;

  --bg: #F4F7F2;
  --bg-card: #ffffff;
  --border: #dce4d9;
  --text: #1b261e;
  --text-muted: #536357;
  --success: #1A5C2A;
  --warning: #ca8a04;
  --danger: #dc2626;
  --info: #0284c7;
  --radius: 12px;
  --shadow: 0 4px 20px -2px rgba(26, 92, 42, 0.08);
  --shadow-lg: 0 10px 25px -5px rgba(26, 92, 42, 0.12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .login-title, .page-title, .stat-value {
  font-family: 'Montserrat', sans-serif;
}

/* ---------- TELA DE LOGIN ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 100%);
  padding: 20px;
}

.login-card {
  background: #ffffff;
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  padding: 40px 32px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.login-logo {
  max-width: 220px;
  height: auto;
  margin-bottom: 24px;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.form-group {
  text-align: left;
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
  background-color: #fff;
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.2);
}

.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrapper .form-control {
  padding-right: 44px;
}

.btn-toggle-password {
  position: absolute;
  right: 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  transition: color 0.2s;
}

.btn-toggle-password:hover {
  color: var(--navy);
}

.btn-toggle-password svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.btn-primary {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  margin-top: 10px;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(197, 160, 89, 0.4);
}

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

.login-alert {
  padding: 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 18px;
  display: none;
}

.login-alert.show {
  display: block;
}

.login-alert.error {
  background-color: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

.login-backlink {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--navy);
  text-decoration: none;
  transition: all 0.2s ease;
  padding: 6px 10px;
  border-radius: 6px;
}

.login-backlink:hover {
  color: var(--gold-dark);
  background-color: rgba(197, 160, 89, 0.08);
}

/* ---------- ESTRUTURA DO PAINEL ---------- */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: var(--navy);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow: 2px 0 16px rgba(0, 0, 0, 0.08);
}

.sidebar-header {
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.sidebar-logo-card {
  background: #ffffff;
  border-radius: 10px;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
  flex-shrink: 0;
  width: 44px;
  height: 44px;
}

.sidebar-logo-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-brand-title {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: #ffffff;
  letter-spacing: 0.3px;
  line-height: 1.2;
}

.sidebar-brand-sub {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.65);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-top: 1px;
}

.sidebar-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 3px 10px;
  background: rgba(212, 160, 23, 0.18);
  color: var(--gold-light);
  border: 1px solid rgba(212, 160, 23, 0.35);
  border-radius: 20px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
}

.sidebar-nav {
  padding: 18px 12px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 8px;
  color: #d1d5db;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  transition: all 0.18s ease;
  cursor: pointer;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  transform: translateX(2px);
}

.nav-link.active {
  background: linear-gradient(90deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(212, 160, 23, 0.3);
}

.nav-link svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex-shrink: 0;
}

.nav-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 12px 6px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.12);
}

.sidebar-user-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.sidebar-user-meta {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.user-role {
  font-size: 11px;
  color: var(--gold-light);
  font-weight: 500;
}

.sidebar-user-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-sidebar-action {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.07);
  color: #e2e8f0;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-sidebar-action:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-sidebar-action.logout:hover {
  background: rgba(220, 38, 38, 0.2);
  color: #fca5a5;
  border-color: rgba(220, 38, 38, 0.4);
}

.btn-sidebar-action svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
  flex-shrink: 0;
}

/* Área de Conteúdo */
.content-area {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.topbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
}

.main-content {
  padding: 32px;
  flex-grow: 1;
}

/* Cards de Estatísticas */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-val {
  font-size: 28px;
  font-weight: 800;
  color: var(--navy);
  margin-top: 4px;
}

.stat-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 43, 54, 0.05);
  color: var(--navy);
}

.stat-icon.gold {
  background: rgba(197, 160, 89, 0.15);
  color: var(--gold-dark);
}

.stat-icon.green {
  background: rgba(22, 163, 74, 0.15);
  color: var(--success);
}

/* Barra de Filtros e Busca */
.filters-bar {
  background: #fff;
  padding: 16px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  width: 100%;
  max-width: 340px;
}

.search-box input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 13.5px;
  margin-left: 8px;
  font-family: inherit;
}

.filter-select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  outline: none;
}

/* Tabelas */
.table-card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13.5px;
}

.data-table th {
  background: #f1f5f9;
  color: var(--navy);
  font-weight: 700;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.data-table tr:hover td {
  background-color: #f8fafc;
}

/* Badges de Status */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

.badge-pendente {
  background: #fef3c7;
  color: #92400e;
}

.badge-emanalise {
  background: #e0f2fe;
  color: #0369a1;
}

.badge-homologado {
  background: #dcfce7;
  color: #15803d;
}

.badge-reprovado {
  background: #fee2e2;
  color: #b91c1c;
}

/* Botões de Ação */
.btn-action {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--navy);
  transition: all 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-action:hover {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.btn-action.gold {
  background: var(--gold);
  color: #fff;
  border-color: var(--gold);
}

.btn-action.gold:hover {
  background: var(--gold-dark);
}

/* Modal de Detalhes */
.admin-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 43, 54, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.admin-modal.open {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 980px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  gap: 12px;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
}

/* Barra de Ações Rápidas da Ficha */
.modal-quick-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 24px;
  background: #f1f5f9;
  border-bottom: 1px solid var(--border);
}

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

.btn-quick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  text-decoration: none;
  transition: all 0.18s ease;
}

.btn-quick:hover {
  background: #e2e8f0;
  color: var(--navy);
}

.btn-quick.whatsapp {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.btn-quick.whatsapp:hover {
  background: #10b981;
  color: #fff;
  border-color: #10b981;
}

.btn-quick.print-action {
  background: #fff;
  color: var(--navy);
  border-color: #cbd5e1;
}

.btn-quick.print-action:hover {
  background: var(--navy);
  color: #fff;
}

.btn-quick.edit-toggle {
  background: #fefce8;
  color: #b45309;
  border-color: #fde68a;
}

.btn-quick.edit-toggle:hover {
  background: var(--gold);
  color: #fff;
  border-color: var(--gold);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex-grow: 1;
}

.detail-section {
  margin-bottom: 24px;
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--gold-dark);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.detail-item {
  display: flex;
  flex-direction: column;
}

.detail-item span.label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.detail-item span.value {
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
  margin-top: 2px;
  word-break: break-word;
}

.detail-item input.edit-input,
.detail-item select.edit-input,
.detail-item textarea.edit-input {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1.5px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--text);
  background-color: #fff;
  font-family: inherit;
  transition: border-color 0.2s;
}

.detail-item input.edit-input:focus,
.detail-item select.edit-input:focus,
.detail-item textarea.edit-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(212, 160, 23, 0.2);
}

.detail-item.span-full {
  grid-column: 1 / -1;
}

/* Cards de Anexos no Modal */
.anexos-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.anexo-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  gap: 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.anexo-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.anexo-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-grow: 1;
}

.anexo-tipo {
  font-size: 11px;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
}

.anexo-nome {
  font-size: 12.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
  margin-top: 2px;
}

.anexo-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.anexo-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.anexo-download-btn {
  padding: 6px 10px;
  background: var(--navy);
  color: #fff;
  border-radius: 6px;
  text-decoration: none;
  font-size: 11.5px;
  font-weight: 600;
  transition: background 0.2s;
}

.anexo-download-btn:hover {
  background: var(--gold-dark);
}

.anexo-delete-btn {
  padding: 6px 8px;
  background: #fff;
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
}

.anexo-delete-btn:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

/* Área de Upload de Novo Anexo */
.anexo-upload-card {
  margin-top: 14px;
  border: 1.5px dashed #cbd5e1;
  border-radius: 8px;
  padding: 16px;
  background: #fbfcfd;
}

.anexo-upload-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.anexo-upload-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* Folha timbrada para Impressão */
.print-header {
  display: none;
}

@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }

  .sidebar,
  .topbar,
  .filters-bar,
  .table-card,
  .modal-close,
  .modal-quick-bar,
  .anexo-actions,
  .anexo-upload-card,
  .modal-footer,
  .admin-toast,
  .btn-logout {
    display: none !important;
  }

  .admin-modal {
    position: static !important;
    background: none !important;
    backdrop-filter: none !important;
    padding: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: block !important;
  }

  .modal-content {
    max-width: 100% !important;
    max-height: none !important;
    box-shadow: none !important;
    border: none !important;
    overflow: visible !important;
  }

  .modal-header {
    border-bottom: 2px solid #1A5C2A !important;
    padding-bottom: 10px !important;
  }

  .print-header {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #1A5C2A;
  }

  .print-header-logo {
    max-height: 48px;
  }

  .print-header-meta {
    text-align: right;
    font-size: 11px;
    color: #444;
  }

  .detail-section {
    page-break-inside: avoid;
    margin-bottom: 18px !important;
  }

  .section-title {
    color: #1A5C2A !important;
    border-bottom: 1.5px solid #1A5C2A !important;
    font-size: 13px !important;
  }

  .detail-item span.label {
    color: #555 !important;
    font-size: 11px !important;
  }

  .detail-item span.value {
    color: #000 !important;
    font-size: 12.5px !important;
  }

  .print-signatures {
    display: flex !important;
    justify-content: space-around;
    margin-top: 50px;
    padding-top: 20px;
    page-break-inside: avoid;
  }

  .signature-box {
    text-align: center;
    width: 250px;
    border-top: 1px solid #333;
    padding-top: 6px;
    font-size: 12px;
  }
}

/* Toast de Alerta */
.admin-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 20px;
  border-radius: 8px;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  z-index: 10000;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
}

.admin-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.admin-toast.success {
  background-color: var(--success);
}

.admin-toast.error {
  background-color: var(--danger);
}
