/**
 * LAYOUT.CSS
 * Utilitários de layout no padrão Tailwind v4.
 *
 * Motivação: o bundle do Basecoat (basecoat.css) é a versão CDN pré-compilada
 * e não inclui utilities soltas (grid-cols-*, gap-*, flex-*, items-*,
 * text-*, etc.). Este arquivo define manualmente, no mesmo nome/semântica do
 * Tailwind, o subconjunto de utilities que os templates/páginas do Gris
 * precisam. Conforme novas páginas forem adicionadas, estender este arquivo
 * em vez de criar CSS pontuais.
 *
 * Convenções:
 * - Step de spacing/sizing segue Tailwind v4: calc(var(--spacing) * N).
 * - Breakpoints Tailwind v4: md = 48rem, lg = 64rem, xl = 80rem.
 * - Tokens de cor/raio vêm de theme-shadcn.css.
 */

/* --- Display --- */
.block { display: block; }
.inline-block { display: inline-block; }
.inline-flex { display: inline-flex; }
.flex { display: flex; }
.grid { display: grid; }
.hidden { display: none !important; }
.d-none { display: none !important; }

/* --- Flex direction --- */
.flex-row { flex-direction: row; }
.flex-col { flex-direction: column; }

/* --- Alignment --- */
.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }

/* --- Flex grow/shrink --- */
.flex-1 { flex: 1 1 0%; }
.flex-auto { flex: 1 1 auto; }
.flex-none { flex: none; }
.flex-shrink-0 { flex-shrink: 0; }
.min-w-0 { min-width: 0; }

/* --- Grid template columns --- */
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

/* --- Gap --- */
.gap-0 { gap: 0; }
.gap-1 { gap: calc(var(--spacing) * 1); }
.gap-2 { gap: calc(var(--spacing) * 2); }
.gap-3 { gap: calc(var(--spacing) * 3); }
.gap-4 { gap: calc(var(--spacing) * 4); }
.gap-5 { gap: calc(var(--spacing) * 5); }
.gap-6 { gap: calc(var(--spacing) * 6); }
.gap-8 { gap: calc(var(--spacing) * 8); }

/* --- Margin reset (caso a página queira zerar o default do elemento) --- */
.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

/* --- Margin scale (Tailwind v4 spacing) --- */
.mb-1 { margin-bottom: calc(var(--spacing) * 1); }
.mb-2 { margin-bottom: calc(var(--spacing) * 2); }
.mb-3 { margin-bottom: calc(var(--spacing) * 3); }
.mb-4 { margin-bottom: calc(var(--spacing) * 4); }
.mb-6 { margin-bottom: calc(var(--spacing) * 6); }
.mb-8 { margin-bottom: calc(var(--spacing) * 8); }
.mt-1 { margin-top: calc(var(--spacing) * 1); }
.mt-2 { margin-top: calc(var(--spacing) * 2); }
.mt-3 { margin-top: calc(var(--spacing) * 3); }
.mt-4 { margin-top: calc(var(--spacing) * 4); }
.mt-6 { margin-top: calc(var(--spacing) * 6); }
.mt-8 { margin-top: calc(var(--spacing) * 8); }

/* --- Position --- */
.relative { position: relative; }

/* --- Sizing --- */
.w-full { width: 100%; }
.w-8 { width: calc(var(--spacing) * 8); }
.w-9 { width: calc(var(--spacing) * 9); }
.w-10 { width: calc(var(--spacing) * 10); }
.w-11 { width: calc(var(--spacing) * 11); }
.w-12 { width: calc(var(--spacing) * 12); }
.h-full { height: 100%; }
.h-8 { height: calc(var(--spacing) * 8); }
.h-9 { height: calc(var(--spacing) * 9); }
.h-10 { height: calc(var(--spacing) * 10); }
.h-11 { height: calc(var(--spacing) * 11); }
.h-12 { height: calc(var(--spacing) * 12); }

/* --- Max width --- */
.max-w-md { max-width: 28rem; }
.max-w-lg { max-width: 32rem; }
.max-w-xl { max-width: 36rem; }
.max-w-2xl { max-width: 42rem; }
.max-w-3xl { max-width: 48rem; }

/* --- Border radius --- */
.rounded-none { border-radius: 0; }
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-2xl { border-radius: var(--radius-2xl); }
.rounded-full { border-radius: 9999px; }

/* --- Background color --- */
.bg-background { background-color: var(--color-background); }
.bg-card { background-color: var(--color-card); }
.bg-muted { background-color: var(--color-muted); }
.bg-accent { background-color: var(--color-accent); }
.bg-primary { background-color: var(--color-primary); }

/* --- Text color --- */
.text-foreground { color: var(--color-foreground); }
.text-muted-foreground { color: var(--color-muted-foreground); }
.text-primary { color: var(--color-primary); }
.text-primary-foreground { color: var(--color-primary-foreground); }
.text-destructive { color: var(--color-destructive); }
.text-inherit { color: inherit; }

/* --- Text size --- */
.text-xs { font-size: var(--text-xs); line-height: var(--text-xs--line-height); }
.text-sm { font-size: var(--text-sm); line-height: var(--text-sm--line-height); }
.text-base { font-size: var(--text-base); line-height: var(--text-base--line-height); }
.text-lg { font-size: var(--text-lg); line-height: var(--text-lg--line-height); }
.text-xl { font-size: var(--text-xl); line-height: var(--text-xl--line-height); }
.text-2xl { font-size: var(--text-2xl); line-height: var(--text-2xl--line-height); }
.text-3xl { font-size: var(--text-3xl); line-height: var(--text-3xl--line-height); }
.text-4xl { font-size: var(--text-4xl); line-height: var(--text-4xl--line-height); }

/* --- Font weight --- */
.font-normal { font-weight: var(--font-weight-normal); }
.font-medium { font-weight: var(--font-weight-medium); }
.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold { font-weight: var(--font-weight-bold); }

/* --- Line height --- */
.leading-none { line-height: 1; }
.leading-tight { line-height: 1.2; }
.leading-snug { line-height: 1.375; }
.leading-normal { line-height: 1.5; }
.leading-relaxed { line-height: 1.625; }

/* --- Letter spacing --- */
.tracking-tight { letter-spacing: -0.02em; }
.tracking-normal { letter-spacing: 0; }

/* --- Text wrapping --- */
.text-balance { text-wrap: balance; }
.text-pretty { text-wrap: pretty; }

/* --- Text decoration --- */
.no-underline { text-decoration: none; }

/* --- Overflow --- */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }
.overflow-x-hidden { overflow-x: hidden; }
.overflow-y-hidden { overflow-y: hidden; }

/* --- Component helpers --- */
.skeleton {
	display: block;
	width: var(--skeleton-width, 100%);
	height: var(--skeleton-height, 1rem);
}

/* --- Dialog: body rolável quando o conteúdo excede o max-height do dialog ---
 * O Basecoat aplica max-height em `dialog > *` mas não trata overflow do <section>.
 * Sem este bloco, conteúdos longos (editores ToastUI, formulários grandes) vazam
 * para fora do dialog. Mantém header e footer fixos.
 */
.dialog > div {
	overflow: hidden;
}

.dialog > div > header,
.dialog > div > footer {
	flex: 0 0 auto;
}

.dialog > div > section {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
}

/* --- Button group: grupo conectado de botões para paginações e toolbars --- */
.btn-group {
	display: inline-flex;
	align-items: stretch;
	flex-wrap: wrap;
	gap: 0;
}

.btn-group > * {
	border-radius: 0;
	margin-left: -1px;
	position: relative;
}

.btn-group > *:first-child {
	margin-left: 0;
	border-top-left-radius: var(--radius-md);
	border-bottom-left-radius: var(--radius-md);
}

.btn-group > *:last-child {
	border-top-right-radius: var(--radius-md);
	border-bottom-right-radius: var(--radius-md);
}

.btn-group > *:hover,
.btn-group > *:focus,
.btn-group > *[aria-current="page"] {
	z-index: 1;
}

.btn-group > *[disabled],
.btn-group > *[aria-disabled="true"] {
	opacity: 0.55;
	cursor: not-allowed;
}

/* --- Responsive: md = 48rem --- */
@media (min-width: 48rem) {
	.md\:grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
	.md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
	.md\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
	.md\:flex-row { flex-direction: row; }
	.md\:flex-col { flex-direction: column; }
	.md\:text-lg { font-size: var(--text-lg); line-height: var(--text-lg--line-height); }
	.md\:text-xl { font-size: var(--text-xl); line-height: var(--text-xl--line-height); }
	.md\:text-2xl { font-size: var(--text-2xl); line-height: var(--text-2xl--line-height); }
	.md\:text-3xl { font-size: var(--text-3xl); line-height: var(--text-3xl--line-height); }
	.md\:text-4xl { font-size: var(--text-4xl); line-height: var(--text-4xl--line-height); }
}

/* --- Responsive: lg = 64rem --- */
@media (min-width: 64rem) {
	.lg\:grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
	.lg\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
	.lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
	.lg\:flex-row { flex-direction: row; }
	.lg\:flex-col { flex-direction: column; }
}

/* --- Responsive: xl = 80rem --- */
@media (min-width: 80rem) {
	.xl\:grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
	.xl\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.xl\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
	.xl\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
	.xl\:flex-row { flex-direction: row; }
	.xl\:flex-col { flex-direction: column; }
}
