/* Design system compartilhado com o TGGS (mesmas cores/fontes/sidebar). */

:root {
  --radius: 0.625rem;

  --background: oklch(0.975 0.007 225);
  --foreground: oklch(0.16 0.04 245);

  --card: oklch(1 0 0);
  --card-foreground: oklch(0.16 0.04 245);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.16 0.04 245);

  --primary: oklch(0.35 0.11 240);
  --primary-foreground: oklch(0.99 0.003 220);

  --secondary: oklch(0.94 0.018 225);
  --secondary-foreground: oklch(0.25 0.06 240);

  --muted: oklch(0.94 0.014 225);
  --muted-foreground: oklch(0.50 0.025 235);

  --accent: oklch(0.68 0.13 198);
  --accent-foreground: oklch(0.12 0.04 240);

  --teal: oklch(0.70 0.12 192);
  --teal-foreground: oklch(0.12 0.04 240);

  --success: oklch(0.58 0.15 152);
  --success-foreground: oklch(0.99 0 0);
  --warning: oklch(0.74 0.17 72);
  --warning-foreground: oklch(0.18 0.05 58);
  --destructive: oklch(0.58 0.23 22);
  --destructive-foreground: oklch(0.99 0 0);

  --border: oklch(0.88 0.014 225);
  --input: oklch(0.91 0.014 225);
  --ring: oklch(0.48 0.10 230);

  --sidebar: oklch(0.19 0.055 242);
  --sidebar-foreground: oklch(0.93 0.012 220);
  --sidebar-primary: oklch(0.70 0.12 192);
  --sidebar-primary-foreground: oklch(0.12 0.04 240);
  --sidebar-accent: oklch(0.25 0.052 242);
  --sidebar-accent-foreground: oklch(0.96 0.01 220);
  --sidebar-border: oklch(0.27 0.045 242);
  --sidebar-ring: oklch(0.52 0.11 215);

  --gradient-hero: linear-gradient(135deg, oklch(0.19 0.055 242), oklch(0.30 0.09 225));
  --gradient-accent: linear-gradient(135deg, oklch(0.53 0.13 215), oklch(0.70 0.12 192));
  --shadow-card: 0 1px 4px oklch(0.16 0.04 245 / 0.07), 0 1px 2px oklch(0.16 0.04 245 / 0.04);
  --shadow-elevated: 0 12px 32px -10px oklch(0.16 0.04 245 / 0.16);
  --shadow-sidebar: 2px 0 16px -4px oklch(0.16 0.04 245 / 0.25);

  --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-display: "Sora", "Inter", ui-sans-serif, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  letter-spacing: -0.025em;
}

a { color: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: oklch(0.91 0.014 225); border-radius: 9999px; }
::-webkit-scrollbar-thumb { background: oklch(0.55 0.05 235 / 0.7); border-radius: 9999px; border: 2px solid oklch(0.91 0.014 225); }
::-webkit-scrollbar-thumb:hover { background: oklch(0.40 0.08 240 / 0.85); }

/* ── Layout com sidebar ─────────────────────────────────────────── */

.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.app-sidebar {
  width: 256px;
  flex-shrink: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: var(--sidebar-foreground);
  border-right: 1px solid var(--sidebar-border);
  box-shadow: var(--shadow-sidebar);
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
  transition: transform 0.25s ease-in-out;
  z-index: 50;
}

.app-sidebar-brand {
  height: 4.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 1rem;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.app-sidebar-brand .sidebar-logo {
  height: 2.5rem;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.brand-badge {
  width: 2rem;
  height: 2rem;
  border-radius: 0.6rem;
  background: var(--gradient-accent);
  display: grid;
  place-items: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.app-sidebar nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.5rem;
}

.sidebar-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: color-mix(in oklch, var(--sidebar-foreground) 55%, transparent);
  padding: 0.4rem 0.6rem;
  margin-top: 0.75rem;
}

.sidebar-section-label:first-child { margin-top: 0; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.65rem;
  margin: 0.1rem 0;
  border-radius: 0.6rem;
  font-size: 0.8125rem;
  text-decoration: none;
  color: color-mix(in oklch, var(--sidebar-foreground) 68%, transparent);
  transition: background-color 0.15s, color 0.15s;
  position: relative;
}

.sidebar-link:hover {
  background: color-mix(in oklch, var(--sidebar-accent) 55%, transparent);
  color: var(--sidebar-foreground);
}

.sidebar-link.active {
  background: var(--sidebar-accent);
  color: var(--sidebar-accent-foreground);
  font-weight: 500;
}

.sidebar-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 1.1rem;
  border-radius: 999px;
  background: var(--sidebar-primary);
}

.sidebar-link .icon {
  width: 1.75rem;
  height: 1.75rem;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 0.5rem;
  color: color-mix(in oklch, var(--sidebar-foreground) 40%, transparent);
  transition: background-color 0.15s, color 0.15s;
}

.sidebar-link .icon svg { width: 62%; height: 62%; }

.sidebar-link:hover .icon {
  color: color-mix(in oklch, var(--sidebar-foreground) 70%, transparent);
}

.sidebar-link.active .icon {
  background: color-mix(in oklch, var(--sidebar-primary) 20%, transparent);
  color: var(--sidebar-primary);
}

.sidebar-link span.label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: uppercase;
  font-size: 0.8125rem;
}

.app-sidebar-footer {
  border-top: 1px solid var(--sidebar-border);
  padding: 0.6rem;
  flex-shrink: 0;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-header {
  height: 3.5rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem;
  background: color-mix(in oklch, var(--card) 80%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.app-header-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--foreground);
}

.app-header-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.app-header-user .avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: var(--gradient-accent);
  color: var(--primary-foreground);
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
}

.app-header-user .who {
  line-height: 1.2;
}

.app-header-user .who .name {
  font-size: 0.8125rem;
  font-weight: 600;
}

.app-header-user .who .role {
  font-size: 0.6875rem;
  color: var(--muted-foreground);
}

.app-header-user .icon-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 0.6rem;
  display: grid;
  place-items: center;
  color: var(--muted-foreground);
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}

.app-header-user .icon-btn:hover {
  background: var(--muted);
  color: var(--foreground);
}

.app-header-user .icon-btn svg { width: 1.05rem; height: 1.05rem; }

.sidebar-toggle {
  display: none;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.6rem;
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.sidebar-toggle svg { width: 1.25rem; height: 1.25rem; }

.app-content {
  flex: 1;
  padding: 1rem;
}

@media (min-width: 768px) {
  .app-content { padding: 1.5rem; }
}

@media (min-width: 1024px) {
  .app-content { padding: 1.75rem; }
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 40;
}

@media (max-width: 960px) {
  .app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
  }
  .app-shell.sidebar-open .app-sidebar { transform: translateX(0); }
  .app-shell.sidebar-open .sidebar-backdrop { display: block; }
  .sidebar-toggle { display: inline-flex; }
}

/* ── Componentes legados reestilizados (cards, botões, tabelas) ───── */

.page-header {
  padding-bottom: 1.1rem;
  margin-bottom: 1.1rem;
  border-bottom: 1px solid var(--border);
}

.page-title {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--foreground);
  line-height: 1.2;
  margin: 0;
}

.page-subtitle {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  margin-top: 0.25rem;
  line-height: 1.4;
}

.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  overflow-x: auto;
  margin-bottom: 1.25rem;
}

.btn {
  background: var(--primary);
  color: var(--primary-foreground);
  padding: 0.55rem 1.1rem;
  border: none;
  border-radius: 0.55rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  margin: 0.25rem;
  transition: opacity 0.15s, background-color 0.15s;
}

.btn:hover { opacity: 0.88; }

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
}

.btn-accent { background: var(--accent); color: var(--accent-foreground); }
.btn-success { background: var(--success); color: var(--success-foreground); }
.btn-warning { background: var(--warning); color: var(--warning-foreground); }
.btn-danger, .btn-destructive { background: var(--destructive); color: var(--destructive-foreground); }

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.9rem;
  font-size: 0.85rem;
}

table th, table td {
  padding: 0.6rem 0.7rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

table th {
  background: var(--sidebar);
  color: var(--sidebar-foreground);
  position: sticky;
  top: 0;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

table th:hover { background: var(--sidebar-accent); }
table tr:hover { background: var(--muted); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 1rem;
  border-radius: var(--radius);
  text-align: center;
  box-shadow: var(--shadow-card);
}

.stat-card h3 {
  font-size: 1.5em;
  margin: 0 0 0.3rem;
  color: var(--primary);
}

.stat-card p {
  color: var(--muted-foreground);
  font-size: 0.8125em;
  margin: 0;
}

@media print {
  .app-sidebar, .app-header, .sidebar-toggle, .btn { display: none !important; }
  .app-content { padding: 0; }
  body { background: white; }
}
