/* Reset + layout base + utilitários + toasts/loading + tela de login */

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

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.modal-open {
  overflow: hidden;
}

h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: -0.01em;
}

a {
  color: var(--color-blue);
  text-decoration: none;
}

.mono {
  font-family: var(--font-mono);
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-muted { color: var(--text-muted); }
.text-teal { color: var(--color-teal); }
.text-red { color: var(--color-red); }
.text-amber { color: var(--color-amber); }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ---- Layout da aplicação ---- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.main-area {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}

.page-container {
  flex: 1;
  padding: 24px 28px 48px;
  max-width: none;
  width: 100%;
}

/* ---- Cards genéricos ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title i {
  color: var(--color-blue);
}

/* ---- Cabeçalho de página + barra de filtros ---- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.page-header h2 {
  font-size: 20px;
}

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

.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filters-bar .search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 340px;
}

.filters-bar .search-box i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.filters-bar .search-box input {
  padding-left: 36px;
  width: 100%;
}

/* ---- Estado vazio ---- */
.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 40px;
  color: var(--text-dim);
  display: block;
  margin-bottom: 10px;
}

/* ---- Abas ---- */
.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.tab {
  background: none;
  border: none;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition);
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--color-blue);
  border-bottom-color: var(--color-blue);
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 6px;
}

/* ---- Toasts ---- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  min-width: 260px;
  max-width: 400px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

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

.toast i { font-size: 18px; }
.toast-success i { color: var(--color-teal); }
.toast-error i { color: var(--color-red); }
.toast-warning i { color: var(--color-amber); }
.toast-info i { color: var(--color-blue); }

/* ---- Loading overlay ---- */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: var(--overlay);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--text-muted);
}

.loading-spinner {
  width: 42px;
  height: 42px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--color-blue);
  border-radius: 50%;
  animation: girar 0.8s linear infinite;
}

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

/* ---- Tela de login ---- */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 900;
  background:
    radial-gradient(1000px 580px at 90% 10%, var(--color-blue-dim), transparent 68%),
    var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
  border-top: 4px solid var(--color-red-visual);
}

.login-brand {
  margin: 0 auto 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--brand-sidebar);
}

.login-brand-image {
  display: block;
  width: min(100%, 300px);
  height: auto;
  margin: 0 auto;
}

.login-card .login-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 24px;
}

.login-footer {
  margin-top: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}

/* ---- Responsivo básico ---- */
@media (max-width: 900px) {
  .main-area { margin-left: 0; }
  .page-container { padding: 20px 16px 40px; }
  body.sidebar-mobile-open { overflow: hidden; }
}

@media (max-width: 520px) {
  .page-container { padding: 16px 12px 32px; }
  .login-card { padding: 30px 24px; }
  .login-brand { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
