/* ================================================================
   style.css — Coração PET
   Reset, variáveis de design e layout global
================================================================ */

/* ── Reset & Base ────────────────────────────────────────────── */
*, *::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(--color-bg);
  color: var(--color-text);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Design Tokens ───────────────────────────────────────────── */
:root {
  /* Paleta principal: Azul | Vermelho | Branco */
  --blue-900: #0f1e4a;
  --blue-800: #1a2f6e;
  --blue-700: #1a3a8f;
  --blue-600: #1a56db;
  --blue-500: #2563eb;
  --blue-400: #3b82f6;
  --blue-100: #dbeafe;
  --blue-50:  #eff6ff;

  --red-600:  #e02424;
  --red-500:  #ef4444;
  --red-100:  #fee2e2;
  --red-50:   #fef2f2;

  --white:    #ffffff;
  --gray-50:  #f8f9fb;
  --gray-100: #f1f4f8;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e0;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-700: #334155;
  --gray-900: #1e2a4a;

  /* Semânticos */
  --color-bg:         var(--gray-50);
  --color-surface:    var(--white);
  --color-text:       var(--gray-900);
  --color-text-muted: var(--gray-500);
  --color-border:     var(--gray-200);

  --color-primary:       var(--blue-600);
  --color-primary-dark:  var(--blue-800);
  --color-primary-light: var(--blue-100);
  --color-danger:        var(--red-600);
  --color-danger-light:  var(--red-100);

  /* Espaçamento */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Tipografia */
  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  1.875rem;

  /* Bordas e sombras */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 3px rgba(26,86,219,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(26,86,219,.12), 0 2px 6px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 40px rgba(26,86,219,.15), 0 4px 12px rgba(0,0,0,.08);

  /* Sidebar */
  --sidebar-width: 260px;
  --sidebar-collapsed: 70px;
  --topbar-height: 64px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: linear-gradient(160deg, var(--blue-900) 0%, var(--blue-700) 60%, var(--blue-600) 100%);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width var(--transition), transform var(--transition);
  overflow: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-5);
  border-bottom: 1px solid rgba(255,255,255,.12);
  flex-shrink: 0;
}

.sidebar-logo-icon {
  font-size: 2rem;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.15);
  border-radius: var(--radius-md);
  flex-shrink: 0;
  overflow: hidden; /* garante que a imagem respeite o border-radius */
}

/* Imagem de logo dentro do ícone da sidebar */
.sidebar-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-md);
  display: block;
}

.sidebar-logo-text { display: flex; flex-direction: column; overflow: hidden; }
.sidebar-logo-name {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--white);
  white-space: nowrap;
  letter-spacing: -.3px;
}
.sidebar-logo-sub {
  font-size: var(--text-xs);
  color: rgba(255,255,255,.6);
  white-space: nowrap;
}

/* Navegação */
.sidebar-nav { flex: 1; padding: var(--space-4) 0; overflow-y: auto; }
.sidebar-nav-list { list-style: none; display: flex; flex-direction: column; gap: var(--space-1); padding: 0 var(--space-3); }

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.nav-link::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.08);
  opacity: 0;
  transition: opacity var(--transition);
  border-radius: var(--radius-md);
}

.nav-link:hover { color: var(--white); }
.nav-link:hover::before { opacity: 1; }

.nav-link.active {
  background: rgba(255,255,255,.18);
  color: var(--white);
  font-weight: 600;
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
}
.nav-link.active .nav-icon { transform: scale(1.1); }

.nav-icon { font-size: 1.15rem; width: 24px; text-align: center; flex-shrink: 0; transition: transform var(--transition); }
.nav-label { transition: opacity var(--transition), width var(--transition); }

.sidebar-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.35);
  font-size: var(--text-xs);
  flex-shrink: 0;
}

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

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--white);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.topbar-toggle {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 22px;
  height: 16px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.topbar-toggle span {
  display: block;
  height: 2px;
  background: var(--color-text);
  border-radius: 2px;
  transition: all var(--transition);
}

.topbar-title {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  flex: 1;
}

.topbar-actions { display: flex; gap: var(--space-3); align-items: center; }

/* ── Page Area ───────────────────────────────────────────────── */
.page-area { flex: 1; padding: var(--space-6) var(--space-8); }

/* ── Global Loader ───────────────────────────────────────────── */
.global-loader {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  backdrop-filter: blur(4px);
}
.global-loader.active { opacity: 1; pointer-events: all; }

.loader-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--color-primary-light);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,30,74,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  backdrop-filter: blur(3px);
  padding: var(--space-4);
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal-overlay.active .modal { transform: translateY(0) scale(1); opacity: 1; }

.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(24px) scale(0.97);
  opacity: 0;
  transition: all var(--transition);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-6);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.modal-title { font-size: var(--text-xl); font-weight: 700; color: var(--color-text); }
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--gray-400);
  cursor: pointer;
  line-height: 1;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.modal-close:hover { color: var(--color-danger); background: var(--red-50); }

.modal-body { flex: 1; padding: var(--space-6); overflow-y: auto; }

/* ── Toast ───────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  font-weight: 500;
  max-width: 360px;
  pointer-events: all;
  animation: toastIn 0.35s cubic-bezier(0.34,1.56,0.64,1) forwards;
  border-left: 4px solid transparent;
}
.toast.removing { animation: toastOut 0.25s ease forwards; }

.toast-success { background: var(--white); border-color: var(--blue-500); color: var(--blue-800); }
.toast-error   { background: var(--white); border-color: var(--red-600); color: var(--red-600); }
.toast-info    { background: var(--white); border-color: var(--blue-400); color: var(--gray-700); }

.toast-icon { font-size: 1.1rem; flex-shrink: 0; }

@keyframes toastIn  { from { opacity:0; transform:translateX(24px); } to { opacity:1; transform:none; } }
@keyframes toastOut { from { opacity:1; transform:none; } to { opacity:0; transform:translateX(12px); } }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .topbar-toggle { display: flex; }
  .page-area { padding: var(--space-4); }
}

@media (max-width: 480px) {
  .topbar { padding: 0 var(--space-4); }
  .toast-container { right: var(--space-3); bottom: var(--space-3); }
  .toast { max-width: 90vw; }
}
