/* =============================================================
   SGE 2.0 — Global (Reset + Tipografia + Layout Base)
   ============================================================= */

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

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--gradient-page);
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--primary-light);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

ul, ol {
  list-style: none;
}

button {
  cursor: pointer;
  font-family: inherit;
}

input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
}

/* ── Scrollbar global ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.4);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.6);
}

/* ── Layout do App ── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  overflow-y: auto;
  background: var(--gradient-dark);
}

.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--spacing-2xl);
}

.app-content {
  flex: 1;
  padding: var(--spacing-2xl);
  overflow-y: auto;
}

/* ── Títulos ── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.9rem; }

/* ── Utilitários de texto ── */
.text-primary   { color: var(--primary); }
.text-success   { color: var(--success); }
.text-danger    { color: var(--danger); }
.text-warning   { color: var(--warning); }
.text-muted     { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-center    { text-align: center; }
.text-right     { text-align: right; }
.fw-600         { font-weight: 600; }
.fw-700         { font-weight: 700; }

/* ── Utilitários de layout ── */
.flex           { display: flex; }
.flex-center    { display: flex; align-items: center; justify-content: center; }
.flex-between   { display: flex; align-items: center; justify-content: space-between; }
.flex-gap-sm    { gap: var(--spacing-sm); }
.flex-gap-md    { gap: var(--spacing-md); }
.flex-gap-lg    { gap: var(--spacing-lg); }
.flex-wrap      { flex-wrap: wrap; }
.flex-col       { flex-direction: column; }
.align-center   { align-items: center; }

.w-100          { width: 100%; }
.mt-sm          { margin-top: var(--spacing-sm); }
.mt-md          { margin-top: var(--spacing-md); }
.mt-lg          { margin-top: var(--spacing-lg); }
.mt-xl          { margin-top: var(--spacing-xl); }
.mb-sm          { margin-bottom: var(--spacing-sm); }
.mb-md          { margin-bottom: var(--spacing-md); }
.mb-lg          { margin-bottom: var(--spacing-lg); }
.mb-xl          { margin-bottom: var(--spacing-xl); }

.hidden         { display: none !important; }
.invisible      { visibility: hidden; }

/* ── Animações ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.fade-in {
  animation: fadeIn 0.4s ease forwards;
}

/* ── Loading overlay ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-spinner-sm {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── Toast container ── */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: var(--spacing-md) var(--spacing-xl);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  min-width: 280px;
  max-width: 420px;
  border-left: 4px solid var(--primary-light);
  animation: fadeInDown 0.3s ease forwards;
  pointer-events: auto;
  font-size: 0.9rem;
  font-weight: 500;
}

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

.toast i {
  font-size: 1rem;
  flex-shrink: 0;
}

.toast.toast-success i { color: var(--success); }
.toast.toast-error i   { color: var(--danger); }
.toast.toast-warning i { color: var(--warning); }
.toast.toast-info i    { color: var(--info); }

.toast-hide {
  animation: fadeIn 0.3s ease reverse forwards;
}

/* ── Page header (módulos) ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-xl);
  flex-wrap: wrap;
  gap: var(--spacing-md);
}

.page-header-left {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.page-header-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.page-header-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.page-header-icon {
  width: 48px;
  height: 48px;
  background: var(--gradient-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

/* ── Dividers ── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--spacing-xl) 0;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: var(--spacing-2xl) var(--spacing-xl);
  color: var(--text-secondary);
}

.empty-state i {
  font-size: 3rem;
  color: var(--text-muted);
  margin-bottom: var(--spacing-md);
  display: block;
}

.empty-state h3 {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-sm);
}

.empty-state p {
  font-size: 0.9rem;
  color: var(--text-muted);
}
