/* AT Institucional - Estilos Customizados */
:root {
  --primary: #1e3a5f;
  --primary-light: #2563eb;
  --primary-dark: #0f1f3a;
  --accent: #f59e0b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --gray-50: #f8fafc;
  --sidebar-w: 256px;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  min-height: 100vh;
}

/* ============ LAYOUT ============ */
#app { display: flex; min-height: 100vh; width: 100%; }

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--primary-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
}

.sidebar-logo .logo-text {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #fff;
}

.sidebar-logo .logo-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  margin-top: 2px;
  letter-spacing: 0.5px;
}

.sidebar nav { flex: 1; padding: 12px 0; }

.nav-section {
  padding: 8px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.35);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 14px;
  font-weight: 500;
  border-left: 3px solid transparent;
  text-decoration: none;
}

.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(37,99,235,0.3); color: #fff; border-left-color: #2563eb; }
.nav-item i { width: 18px; text-align: center; font-size: 15px; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 13px;
}

.user-avatar {
  width: 32px; height: 32px;
  background: var(--primary-light);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
}

/* Main Content */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title { font-size: 18px; font-weight: 700; color: var(--primary); flex: 1; }
.topbar-sub { font-size: 13px; color: #64748b; }

.search-box {
  display: flex;
  align-items: center;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px 12px;
  gap: 8px;
  min-width: 240px;
}

.search-box input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  width: 100%;
  color: #1e293b;
}

.page-content { padding: 24px; flex: 1; }

/* ============ CARDS / KPI ============ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  border-left: 4px solid var(--primary-light);
  transition: transform 0.15s, box-shadow 0.15s;
}

.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.kpi-card.success { border-left-color: var(--success); }
.kpi-card.warning { border-left-color: var(--warning); }
.kpi-card.danger { border-left-color: var(--danger); }
.kpi-card.info { border-left-color: var(--info); }

.kpi-value { font-size: 32px; font-weight: 800; color: var(--primary); line-height: 1; }
.kpi-label { font-size: 13px; color: #64748b; margin-top: 6px; font-weight: 500; }
.kpi-icon { float: right; font-size: 28px; opacity: 0.15; color: #1e3a5f; }

/* ============ CARDS ============ */
.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title { font-size: 15px; font-weight: 700; color: #1e293b; }
.card-body { padding: 20px; }

/* ============ TABELA ============ */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  background: #f8fafc;
  padding: 11px 14px;
  text-align: left;
  font-weight: 700;
  color: #475569;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: middle;
}
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

/* ============ BADGES / STATUS ============ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-nao_iniciado { background: #f1f5f9; color: #64748b; }
.badge-em_andamento { background: #dbeafe; color: #1d4ed8; }
.badge-concluido { background: #dcfce7; color: #15803d; }
.badge-cancelado { background: #fee2e2; color: #dc2626; }

.badge-baixa { background: #f0fdf4; color: #15803d; }
.badge-media { background: #fef9c3; color: #854d0e; }
.badge-alta { background: #fff7ed; color: #c2410c; }
.badge-urgente { background: #fee2e2; color: #dc2626; }

.badge-municipal { background: #e0f2fe; color: #0369a1; }
.badge-estadual { background: #fae8ff; color: #7e22ce; }
.badge-federal { background: #fff7ed; color: #c2410c; }

.badge-oficio { background: #e0f2fe; color: #0369a1; }
.badge-requerimento { background: #fae8ff; color: #7e22ce; }
.badge-outro { background: #f1f5f9; color: #475569; }

/* ============ BOTÕES ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--primary-light); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #f1f5f9; color: #334155; border: 1px solid #e2e8f0; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px; border-radius: 8px; }

/* ============ FORMULÁRIOS ============ */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 5px; }
.form-label .required { color: var(--danger); }

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  color: #1e293b;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}

.form-control:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.form-control:disabled { background: #f8fafc; color: #94a3b8; }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-section { margin-bottom: 24px; }
.form-section-title {
  font-size: 14px; font-weight: 700; color: var(--primary);
  padding-bottom: 8px; border-bottom: 2px solid #e2e8f0; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}

/* Radio/Checkbox groups */
.radio-group, .check-group {
  display: flex; flex-wrap: wrap; gap: 8px;
}

.radio-option, .check-option {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px; border: 1.5px solid #e2e8f0; border-radius: 8px;
  cursor: pointer; font-size: 13.5px; font-weight: 500; transition: all 0.15s;
}

.radio-option:hover, .check-option:hover { border-color: var(--primary-light); background: #f0f7ff; }
.radio-option input, .check-option input { margin: 0; accent-color: var(--primary-light); }

/* ============ FILTROS ============ */
.filters-bar {
  background: #fff;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.filter-group { display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.filter-label { font-size: 11px; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: 0.5px; }
.filter-control {
  padding: 7px 10px; border: 1.5px solid #e2e8f0; border-radius: 7px;
  font-size: 13px; color: #334155; background: #fff; outline: none; cursor: pointer;
}
.filter-control:focus { border-color: var(--primary-light); }

/* ============ TIMELINE ============ */
.timeline { position: relative; padding-left: 24px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 10px; top: 0; bottom: 0;
  width: 2px; background: #e2e8f0;
}

.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-dot {
  position: absolute;
  left: -20px; top: 4px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--primary-light);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--primary-light);
}

.timeline-dot.cadastro { background: #6366f1; box-shadow: 0 0 0 2px #6366f1; }
.timeline-dot.encaminhamento { background: #f59e0b; box-shadow: 0 0 0 2px #f59e0b; }
.timeline-dot.conclusao { background: #10b981; box-shadow: 0 0 0 2px #10b981; }
.timeline-dot.cancelamento { background: #ef4444; box-shadow: 0 0 0 2px #ef4444; }
.timeline-dot.comentario { background: #64748b; box-shadow: 0 0 0 2px #64748b; }

.timeline-content {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 16px;
}

.timeline-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.timeline-user { font-size: 13px; font-weight: 700; color: #334155; }
.timeline-date { font-size: 11.5px; color: #94a3b8; }
.timeline-text { font-size: 13.5px; color: #475569; }

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.5);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 760px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  margin: auto;
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 18px; font-weight: 700; color: var(--primary); }
.modal-body { padding: 24px; max-height: 75vh; overflow-y: auto; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #f1f5f9; display: flex; gap: 10px; justify-content: flex-end; }

/* ============ NOTIFICAÇÕES ============ */
.toast-container {
  position: fixed;
  top: 16px; right: 16px;
  z-index: 999;
  display: flex; flex-direction: column; gap: 8px;
}

.toast {
  background: #fff;
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  display: flex; align-items: center; gap: 12px;
  min-width: 280px;
  animation: slideIn 0.2s ease;
  border-left: 4px solid var(--success);
}

.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

/* ============ LOGIN ============ */
.login-page {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: stretch;
  background: linear-gradient(135deg, #0f2556 0%, #1a3a8f 40%, #1e40af 100%);
}

/* Painel esquerdo — formulário */
.login-left {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  flex: 0 0 460px;
  max-width: 460px;
  background: rgba(0,0,0,0.15);
  backdrop-filter: blur(4px);
  border-right: 1px solid rgba(255,255,255,0.08);
  z-index: 2;
}

/* Painel direito — mapa MG decorativo */
.login-right {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: transparent;
}

.login-right-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.login-right-bg img {
  width: 85%;
  max-width: 560px;
  height: auto;
  opacity: 0.25;
  filter: brightness(2.5) saturate(0) invert(1);
  pointer-events: none;
  user-select: none;
  animation: mapFloat 9s ease-in-out infinite;
}

@keyframes mapFloat {
  0%, 100% { transform: translateY(0px) scale(1); }
  50%       { transform: translateY(-18px) scale(1.03); }
}

.login-right-label {
  position: absolute;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  color: rgba(255,255,255,0.6);
  font-size: 15px;
  letter-spacing: 3px;
  text-transform: uppercase;
  font-weight: 700;
  white-space: nowrap;
}

.login-right-label span {
  display: block;
  font-size: 11px;
  margin-top: 6px;
  letter-spacing: 1.5px;
  opacity: 0.65;
  font-weight: 400;
  text-transform: uppercase;
}

/* Card do formulário */
.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.4);
}

.login-logo { text-align: center; margin-bottom: 28px; display:flex; align-items:center; justify-content:center; }

/* Mobile: oculta painel direito em telas pequenas */
@media (max-width: 768px) {
  .login-page {
    align-items: center;
    justify-content: center;
    padding: 20px;
  }
  .login-left {
    flex: 1;
    max-width: 100%;
    width: 100%;
    padding: 20px;
    border-right: none;
    background: transparent;
  }
  .login-right { display: none; }
}

/* ============ AGENDA / CALENDÁRIO ============ */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-header {
  text-align: center;
  padding: 8px 4px;
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
}

.cal-day {
  min-height: 90px;
  padding: 6px;
  border: 1px solid #f1f5f9;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
  background: #fff;
}

.cal-day:hover { background: #f0f7ff; }
.cal-day.other-month { background: #f8fafc; opacity: 0.5; }
.cal-day.today { border-color: var(--primary-light); background: #eff6ff; }

.cal-day-num {
  font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 4px;
}

.cal-day.today .cal-day-num { color: var(--primary-light); }

.cal-event {
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.cal-event.reuniao { background: #dbeafe; color: #1d4ed8; }
.cal-event.audiencia { background: #fae8ff; color: #7e22ce; }
.cal-event.entrega_documentos { background: #dcfce7; color: #15803d; }
.cal-event.retorno { background: #fff7ed; color: #c2410c; }
.cal-event.ligacao { background: #f1f5f9; color: #475569; }
.cal-event.compromisso { background: #fef9c3; color: #854d0e; }

/* ============ GRÁFICOS ============ */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card { background: #fff; border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.07); }
.chart-title { font-size: 14px; font-weight: 700; color: #1e293b; margin-bottom: 16px; }

/* ============ PROTOCOLO BADGE ============ */
.protocolo-badge {
  font-family: 'Courier New', monospace;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--primary);
  background: #eff6ff;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

/* ============ EMPTY STATE ============ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #94a3b8;
}

.empty-state i { font-size: 48px; margin-bottom: 16px; display: block; }
.empty-state h3 { font-size: 18px; font-weight: 700; color: #64748b; margin-bottom: 8px; }
.empty-state p { font-size: 14px; }

/* ============ LOADING ============ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: #94a3b8;
  gap: 12px;
}

.spinner {
  width: 24px; height: 24px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--primary-light);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============ TABS ============ */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid #e2e8f0; margin-bottom: 20px; }
.tab {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary-light); border-bottom-color: var(--primary-light); }

/* ============ PAGINATION ============ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid #f1f5f9;
  font-size: 13px;
  color: #64748b;
}

.pagination-btns { display: flex; gap: 4px; }
.page-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  background: #fff;
  color: #334155;
  transition: all 0.1s;
}
.page-btn:hover { background: #f1f5f9; }
.page-btn.active { background: var(--primary-light); color: #fff; border-color: var(--primary-light); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============ MOBILE ============ */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .topbar { padding: 0 16px; }
}

/* ============ UTILIDADES ============ */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11.5px; }
.text-muted { color: #64748b; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.font-bold { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
