/* ==========================================================================
   Base — reset + tipografia + utilidades
   Base de leitura com escala global de 14px (87,5% de 16px)
   ========================================================================== */

html {
    font-size: 70%;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ---- Atributo [hidden] ---- */
/* Qualquer classe do projeto que declare `display` (.alert, .badge, .modo-opt,
   .card...) vence o `display:none` que o navegador dá ao atributo `hidden` via
   folha default — sem esta regra o elemento continua visível mesmo com
   `hidden` presente no HTML. É a mesma regra que o normalize.css carrega, e é
   o motivo de ela existir. Regra global para não precisar remendar
   `[hidden] { display: none; }` seletor a seletor pelo projeto. */
[hidden] {
    display: none !important;
}

body {
    font-family: var(--font-family-base);
    background-color: var(--bg-gray);
    color: var(--text-dark);
    font-size: 1.15rem;
    line-height: 1.6;
}

/* ---- Acessibilidade ---- */
.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;
}

/* ---- Headings ---- */
h1, h2, h3, h4, h5, h6 {
    font-family: inherit;
    font-weight: 600;
    color: var(--text-dark);
    line-height: 1.3;
    letter-spacing: -0.01em;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.85rem; }

p {
    margin: 0 0 1rem 0;
}

/* ---- Links ---- */
a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* ---- Código ---- */
code, pre {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9em;
}

code {
    padding: 0.1em 0.35em;
    background: var(--bg-gray);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text-dark);
}

pre {
    padding: 1rem;
    background: var(--text-dark);
    color: var(--bg-gray);
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 0 0 1rem 0;
}

pre code {
    padding: 0;
    background: transparent;
    border: none;
    color: inherit;
}

/* ---- Imagens ---- */
img, svg, video {
    display: block;
    max-width: 100%;
    height: auto;
}

hr, .divider {
    border: none;
    border-top: 1px solid var(--border-light);
    margin: 1rem 0;
}

/* ---- Texto / utilitários ---- */
.text-muted    { color: var(--text-muted); }
.text-dark     { color: var(--text-dark); }
.text-red      { color: var(--color-red); }
.text-green    { color: var(--color-green); }
.text-blue     { color: var(--color-blue); }
.text-amber    { color: var(--color-amber); }
.text-tertiary { color: var(--secondary-color); }
.text-hover    { color: var(--primary-hover); }

.text-xs   { font-size: 0.85rem; }
.text-sm   { font-size: 0.95rem; }
.text-base { font-size: 1.05rem; }
.text-lg   { font-size: 1.15rem; }
.text-xl   { font-size: 1.5rem; }

.text-hint { font-size: 0.85rem; color: var(--secondary-color); }

.text-mono {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.text-truncate {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-nowrap { white-space: nowrap; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-left   { text-align: left; }
.text-upper  { text-transform: uppercase; letter-spacing: 0.03em; }

.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }

/* ---- Flex / grid ---- */
.flex          { display: flex; }
.flex-col      { flex-direction: column; }
.flex-wrap     { flex-wrap: wrap; }
.items-center  { align-items: center; }
.items-start   { align-items: flex-start; }
.items-end     { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.justify-start   { justify-content: flex-start; }

.gap-xs   { gap: 0.25rem; }
.gap-sm   { gap: 0.5rem; }
.gap-md   { gap: 0.75rem; }
.gap-base { gap: 1rem; }
.gap-lg   { gap: 1.5rem; }

.flex-between      { display: flex; justify-content: space-between; align-items: center; }
.flex-between-wrap { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.flex-end-wrap     { display: flex; gap: 0.5rem; align-items: flex-end; flex-wrap: wrap; }

/* ---- Spacing (nomes sysrep + aliases numéricos) ---- */
.mb-0 { margin-bottom: 0; }
.mb-sm { margin-bottom: 0.5rem; }
.mb-base { margin-bottom: 1rem; }
.mb-lg { margin-bottom: 1.5rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }

.mt-0 { margin-top: 0; }
.mt-sm { margin-top: 0.5rem; }
.mt-base { margin-top: 1rem; }
.mt-lg { margin-top: 1.5rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }

.p-0    { padding: 0; }
.p-sm   { padding: 0.5rem; }
.p-base { padding: 1rem; }
.p-lg   { padding: 1.5rem; }
.p-xl   { padding: 2rem; }

.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }

/* Gap adicional (sysrep já tem gap-xs/sm/md/base/lg) */
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

/* Aliases de font-weight */
.fw-regular  { font-weight: 400; }
.fw-medium   { font-weight: 500; }
.fw-semibold { font-weight: 600; }
.fw-bold     { font-weight: 700; }

/* Stack (coluna com gap) */
.stack    { display: flex; flex-direction: column; gap: 1rem; }
.stack-sm { gap: 0.5rem; }
.stack-md { gap: 1rem; }
.stack-lg { gap: 1.5rem; }

/* Row-flex (linha com gap) */
.row-flex { display: flex; align-items: center; gap: 0.75rem; }
.row-flex.wrap    { flex-wrap: wrap; }
.row-flex.between { justify-content: space-between; }
.row-flex.end     { justify-content: flex-end; }
.row-flex.start   { justify-content: flex-start; }
.row-flex.center  { justify-content: center; }
.row-flex.gap-1 { gap: 0.25rem; }
.row-flex.gap-2 { gap: 0.5rem; }
.row-flex.gap-3 { gap: 0.75rem; }
.row-flex.gap-4 { gap: 1rem; }
.row-flex.gap-6 { gap: 1.5rem; }

/* ---- Display ---- */
.d-none        { display: none !important; }
.d-block       { display: block; }
.d-grid        { display: grid; }
.cursor-pointer { cursor: pointer; user-select: none; }

/* ---- Background ---- */
.bg-page  { background-color: var(--bg-page); }
.bg-white { background-color: var(--input-bg); }
.bg-gray  { background-color: var(--bg-gray); }

/* ---- Border ---- */
.border-b    { border-bottom: 1px solid var(--border-light); }
.border      { border: 1px solid var(--border-light); }
.rounded     { border-radius: var(--radius); }
.rounded-md  { border-radius: var(--radius-md); }

/* ---- Width ---- */
.w-full     { width: 100%; }
.w-auto     { width: auto; }
.min-w-100  { min-width: 100px; }
.min-w-120  { min-width: 120px; }
.min-w-140  { min-width: 140px; }
.min-w-200  { min-width: 200px; }

/* Widths fixos (ex.: colunas de tabela) */
.w-50       { width: 50px; }
.w-80       { width: 80px; }
.w-100      { width: 100px; }
.w-120      { width: 120px; }
.w-160      { width: 160px; }
.w-200      { width: 200px; }

/* Alinhamento margin auto */
.ml-auto    { margin-left: auto; }
.mr-auto    { margin-right: auto; }
.mx-auto    { margin-left: auto; margin-right: auto; }

/* ---- Grid ---- */
.grid {
    display: grid;
    gap: 1rem;
}

.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

.grid-auto {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

@media (max-width: 768px) {
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }
}

/* ---- Responsive helpers ---- */
.hidden-mobile { display: initial; }
.visible-mobile { display: none; }

@media (max-width: 768px) {
    .hidden-mobile { display: none !important; }
    .visible-mobile { display: initial; }
}

/* ---- Focus global ---- */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-lg);
    border: 2px solid var(--bg-gray);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

::selection {
    background: var(--wash-primary-strong);
    color: var(--text-dark);
}
