/*!
 * WEB SKELETONS AI KIT — PRE-FABRICATED UI COMPONENTS & LOCKED GRIDS (v1.0.0)
 * Inclui Reset Blindado, Contratos Estruturais para IA, Botões Pré-Fabricados,
 * Cards, Badges, Inputs, Tabelas, Modais e Modo Raio-X de Auditoria.
 */

/* ---------------------------------------------------------------------------
 * 1. RESET DEFENSIVO & BLINDAGEM CONTRA OVERFLOW DE IA
 * --------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-canvas);
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  overflow-x: hidden;
}

/* Blindagem crítica: impede que tabelas, códigos ou imagens quebrem células CSS Grid */
.l-grid > *,
.l-shell > *,
main,
aside,
section,
article,
div {
  min-width: 0;
}

img, svg, video, canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

/* ---------------------------------------------------------------------------
 * 2. PROTOCOLO AI-LOCK & RAIO-X DE INSPEÇÃO DE ESQUELETO
 * --------------------------------------------------------------------------- */
body.ai-xray-active [data-ai-lock="structural"] {
  outline: 2px dashed #ef4444 !important;
  outline-offset: -2px !important;
  position: relative;
}

body.ai-xray-active [data-ai-lock="structural"]::after {
  content: "🔒 LOCKED: " attr(data-ai-name);
  position: absolute;
  top: 4px;
  right: 4px;
  background: #ef4444;
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  z-index: 999;
  pointer-events: none;
  letter-spacing: 0.04em;
}

body.ai-xray-active [data-ai-slot] {
  outline: 2px solid #10b981 !important;
  outline-offset: -2px !important;
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(16, 185, 129, 0.04),
    rgba(16, 185, 129, 0.04) 8px,
    transparent 8px,
    transparent 16px
  ) !important;
  position: relative;
}

body.ai-xray-active [data-ai-slot]::before {
  content: "✨ AI-SLOT: " attr(data-ai-slot);
  position: absolute;
  top: 4px;
  left: 4px;
  background: #10b981;
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  z-index: 999;
  pointer-events: none;
  letter-spacing: 0.04em;
}

/* ---------------------------------------------------------------------------
 * 3. SISTEMA DE BOTÕES PRÉ-FABRICADOS (.btn)
 * --------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.25;
  padding: 0.625rem 1.125rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  transition: all var(--duration-fast) var(--ease-standard);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring-focus);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

/* Variantes de Cor/Estilo */
.btn-primary {
  background-color: var(--brand-600);
  color: var(--text-on-brand);
  box-shadow: var(--shadow-xs);
}
.btn-primary:hover {
  background-color: var(--brand-700);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}
.btn-secondary:hover {
  background-color: var(--bg-subtle);
  border-color: var(--border-strong);
}

.btn-outline {
  background-color: transparent;
  color: var(--brand-600);
  border-color: var(--brand-600);
}
.btn-outline:hover {
  background-color: var(--brand-50);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background-color: var(--bg-elevated);
  color: var(--text-primary);
}

.btn-danger {
  background-color: var(--accent-rose);
  color: #ffffff;
}
.btn-danger:hover {
  background-color: #e11d48;
}

.btn-success {
  background-color: var(--accent-emerald);
  color: #ffffff;
}
.btn-success:hover {
  background-color: #059669;
}

.btn-glass {
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(10px);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
}
.btn-glass:hover {
  background: rgba(255, 255, 255, 0.24);
}

/* Tamanhos e Formatos de Botão */
.btn-xs { padding: 0.35rem 0.65rem; font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn-sm { padding: 0.45rem 0.85rem; font-size: var(--text-xs); }
.btn-lg { padding: 0.8rem 1.5rem; font-size: var(--text-base); border-radius: var(--radius-lg); }
.btn-pill { border-radius: var(--radius-full); }
.btn-block { width: 100%; }
.btn-icon { padding: 0.6rem; aspect-ratio: 1 / 1; }

.btn-group {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}
.btn-group .btn {
  border-radius: 0;
  border: none;
  border-right: 1px solid var(--border-subtle);
}
.btn-group .btn:last-child {
  border-right: none;
}

/* ---------------------------------------------------------------------------
 * 4. CARDS, BADGES, INPUTS & TABELAS PRÉ-FABRICADOS
 * --------------------------------------------------------------------------- */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--duration-normal) var(--ease-standard),
              transform var(--duration-normal) var(--ease-standard);
}
.card-interactive:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  background-color: var(--brand-50);
  color: var(--brand-700);
}
.badge-success { background-color: var(--state-success-bg); color: var(--state-success-fg); }
.badge-warning { background-color: var(--state-warning-bg); color: var(--state-warning-fg); }
.badge-danger  { background-color: var(--state-danger-bg);  color: var(--state-danger-fg); }
.badge-purple  { background-color: #f3e8ff; color: #6d28d9; }

.input-field {
  width: 100%;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.input-field:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--ring-focus);
}

.skeleton-box {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-subtle) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.8s infinite;
  border-radius: var(--radius-md);
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}
.data-table th {
  background-color: var(--bg-elevated);
  font-weight: 600;
  color: var(--text-secondary);
}

/* Barra Flutuante de Inspecao de Esqueleto (Developer Toolbar em cada Template) */
.ai-dev-toolbar {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0f172a;
  color: #f8fafc;
  padding: 8px 12px;
  border-radius: 9999px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  border: 1px solid #334155;
  font-size: 12px;
}
.ai-dev-toolbar button {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #475569;
  padding: 5px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.ai-dev-toolbar button:hover {
  background: #2563eb;
  border-color: #3b82f6;
}
