/* =============================================
   SIG-GCM — Design System Principal
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ---- Variáveis (Light Mode — padrão) ---- */
:root {
  --primary:       #1d4ed8;
  --primary-light: #2563eb;
  --primary-dark:  #1e3a8a;
  --secondary:     #f1f5f9;
  --surface:       #ffffff;
  --surface-2:     #f8fafc;
  --border:        #e2e8f0;
  --text:          #1e293b;
  --text-muted:    #64748b;
  --success:       #16a34a;
  --success-bg:    #dcfce7;
  --warning:       #d97706;
  --warning-bg:    #fef3c7;
  --danger:        #dc2626;
  --danger-bg:     #fee2e2;
  --info:          #0284c7;
  --info-bg:       #e0f2fe;
  --sidebar-w:     260px;
  --header-h:      60px;
  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 4px 24px rgba(0,0,0,0.08);
  --transition:    0.2s ease;
}

/* ---- Modo Escuro ---- */
html.dark-mode {
  --primary:       #1d4ed8;
  --primary-light: #3b82f6;
  --primary-dark:  #1e3a8a;
  --secondary:     #0f172a;
  --surface:       #1e293b;
  --surface-2:     #263348;
  --border:        #334155;
  --text:          #e2e8f0;
  --text-muted:    #94a3b8;
  --success:       #22c55e;
  --success-bg:    #14532d;
  --warning:       #f59e0b;
  --warning-bg:    #78350f;
  --danger:        #ef4444;
  --danger-bg:     #7f1d1d;
  --info:          #38bdf8;
  --info-bg:       #0c4a6e;
  --shadow:        0 4px 24px rgba(0,0,0,0.35);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--secondary);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--primary-light); text-decoration: none; }
a:hover { color: var(--info); }
img { max-width: 100%; }

/* ========================================
   LAYOUT AUTH (Login, Alterar Senha)
   ======================================== */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(29,78,216,0.2) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(56,189,248,0.1) 0%, transparent 50%),
    var(--secondary);
  padding: 1rem;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
  animation: fadeInUp 0.4s ease;
}

.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2rem;
  text-align: center;
}
.auth-logo-icon {
  width: 80px;
  height: 80px;
  background: transparent;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
  box-shadow: none;
}
.auth-logo h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
}
.auth-logo span {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ========================================
   FORMS
   ======================================== */
.form-group { margin-bottom: 1.25rem; }

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}
.form-control::placeholder { color: #4b5563; }

textarea.form-control { min-height: 100px; resize: vertical; }

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='%2394a3b8' d='M7 7l3-3 3 3M7 13l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px;
  padding-right: 2.5rem;
}

.input-group {
  position: relative;
}
.input-group .input-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
}
.input-group .form-control { padding-left: 2.5rem; }

.input-group .toggle-password {
  position: absolute;
  right: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
}
.input-group .toggle-password:hover { color: var(--text); }

/* ========================================
   BOTÕES
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  box-shadow: 0 4px 12px rgba(59,130,246,0.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  box-shadow: 0 6px 20px rgba(59,130,246,0.4);
  transform: translateY(-1px);
  color: #fff;
}
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #16a34a; color: #fff; transform: translateY(-1px); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-warning { background: var(--warning); color: #000; }
.btn-secondary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-secondary:hover { background: var(--border); color: var(--text); }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-lg { padding: 0.85rem 1.75rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; }

/* ========================================
   ALERTAS / FLASH
   ======================================== */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  animation: fadeIn 0.3s ease;
}
.alert-success { background: var(--success-bg); border-left: 3px solid var(--success); color: #bbf7d0; }
.alert-error   { background: var(--danger-bg);  border-left: 3px solid var(--danger);  color: #fecaca; }
.alert-warning { background: var(--warning-bg); border-left: 3px solid var(--warning); color: #fde68a; }
.alert-info    { background: var(--info-bg);    border-left: 3px solid var(--info);    color: #bae6fd; }

/* ========================================
   LAYOUT PRINCIPAL (sidebar + content)
   ======================================== */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  min-height: var(--header-h);
}
.sidebar-brand-icon {
  width: 42px; height: 42px;
  background: transparent;
  border-radius: 0;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.sidebar-brand-text { line-height: 1.2; }
.sidebar-brand-text strong { font-size: 0.95rem; font-weight: 800; color: var(--text); }
.sidebar-brand-text small { font-size: 0.65rem; color: var(--text-muted); display: block; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 0.75rem 0; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.nav-section { margin-bottom: 0.25rem; }
.nav-section-label {
  padding: 0.5rem 1.25rem 0.3rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #475569;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  position: relative;
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}
.nav-item.active {
  background: rgba(59,130,246,0.12);
  color: var(--primary-light);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--primary-light);
  border-radius: 0 2px 2px 0;
}
.nav-item .nav-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
}

/* Sub-nav accordion */
.nav-group-toggle { justify-content: space-between; }
.nav-group-toggle .chevron { font-size: 0.75rem; transition: transform var(--transition); }
.nav-group-toggle.open .chevron { transform: rotate(90deg); }
.nav-sub { overflow: hidden; max-height: 0; transition: max-height 0.3s ease; }
.nav-sub.open { max-height: 500px; }
.nav-sub .nav-item { padding-left: 2.75rem; font-size: 0.83rem; }

/* User area na sidebar */
.sidebar-user {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.sidebar-user-avatar {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.9rem; color: #fff;
  flex-shrink: 0; overflow: hidden;
}
.sidebar-user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-info strong { font-size: 0.82rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info span { font-size: 0.7rem; color: var(--text-muted); text-transform: capitalize; }
.sidebar-user-logout { color: var(--text-muted); font-size: 1rem; transition: color var(--transition); }
.sidebar-user-logout:hover { color: var(--danger); }

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

/* Header */
.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 90;
}
.topbar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
}
.topbar-title {
  flex: 1;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.topbar-actions { display: flex; align-items: center; gap: 0.5rem; }
.topbar-btn {
  width: 36px; height: 36px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  text-decoration: none;
}
.topbar-btn:hover { border-color: var(--primary-light); color: var(--primary-light); }
.topbar-btn .badge-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  background: var(--danger);
  border-radius: 50%;
  border: 1.5px solid var(--surface);
}

/* Page content */
.page-content { padding: 1.5rem; flex: 1; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.page-header h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
}
.page-header .breadcrumb {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* ========================================
   CARDS / STATS
   ======================================== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: transform var(--transition), border-color var(--transition);
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--primary-light); }

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.stat-card-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stat-card-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}
.stat-card-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 0.35rem;
}
.stat-card-sub { font-size: 0.78rem; color: var(--text-muted); }

.icon-blue  { background: rgba(59,130,246,0.15); color: var(--primary-light); }
.icon-green { background: rgba(34,197,94,0.15);  color: var(--success); }
.icon-red   { background: rgba(239,68,68,0.15);  color: var(--danger); }
.icon-yellow{ background: rgba(245,158,11,0.15); color: var(--warning); }
.icon-cyan  { background: rgba(56,189,248,0.15); color: var(--info); }
.icon-purple{ background: rgba(168,85,247,0.15); color: #a855f7; }

/* ========================================
   TABELAS
   ======================================== */
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  flex-wrap: wrap;
}
.table-header h3 { font-size: 0.95rem; font-weight: 700; }

.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
table thead th {
  padding: 0.7rem 1rem;
  font-size: 0.73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-align: left;
}
table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
table tbody tr:last-child { border-bottom: none; }
table tbody tr:hover { background: var(--surface-2); }
table tbody td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  vertical-align: middle;
}

/* ========================================
   BADGES DE STATUS
   ======================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  font-size: 0.73rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: #4ade80; }
.badge-danger  { background: var(--danger-bg);  color: #f87171; }
.badge-warning { background: var(--warning-bg); color: #fbbf24; }
.badge-info    { background: var(--info-bg);    color: #38bdf8; }
.badge-secondary { background: var(--border); color: var(--text-muted); }
.badge-primary { background: rgba(59,130,246,0.2); color: var(--primary-light); }

/* ========================================
   COMUNICADOS URGENTES
   ======================================== */
.comunicado-urgente {
  border: 1px solid var(--danger);
  background: var(--danger-bg);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  animation: pulseBorder 2s ease infinite;
}
@keyframes pulseBorder {
  0%, 100% { border-color: var(--danger); }
  50%       { border-color: transparent; }
}
.comunicado-urgente-icon { font-size: 1.5rem; flex-shrink: 0; animation: pulse 1s ease infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ========================================
   OVERLAY / SIDEBAR MOBILE
   ======================================== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 280px;
  max-width: 400px;
  animation: slideInRight 0.3s ease;
}
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOutRight { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }
.toast.hiding { animation: slideOutRight 0.3s ease forwards; }
.toast-icon { font-size: 1.2rem; flex-shrink: 0; }
.toast-body { flex: 1; font-size: 0.875rem; }
.toast-close { color: var(--text-muted); cursor: pointer; background: none; border: none; font-size: 1rem; }
.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-info    { border-left: 3px solid var(--info); }

/* ========================================
   MAPA
   ======================================== */
.map-container { height: 450px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }

/* ========================================
   ANIMAÇÕES
   ======================================== */
@keyframes fadeIn    { from { opacity: 0; }                              to { opacity: 1; } }
@keyframes fadeInUp  { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ========================================
   RESPONSIVO — MOBILE
   ======================================== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.5);
  }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; }
  .topbar-toggle { display: flex; align-items: center; justify-content: center; }
  .cards-grid { grid-template-columns: 1fr 1fr; }
  .page-content { padding: 1rem; }
  .topbar { padding: 0 1rem; }
}

@media (max-width: 480px) {
  .cards-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 1.75rem 1.25rem; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* ========================================
   IMPRESSÃO
   ======================================== */
@media print {
  .sidebar, .topbar, .btn, .no-print { display: none !important; }
  .main-content { margin: 0; }
  .page-content { padding: 0; }
  body { background: #fff; color: #000; }
  .stat-card, .table-wrapper { border: 1px solid #ccc; box-shadow: none; }
}
