/* ==========================================================================
   InStock — Design System
   Paleta extraida da marca (css/image/instock-logo.png): vermelho de destaque,
   azul-ardosia escuro como base e cinza-azulado para textos secundarios.
   Este arquivo define os tokens e os componentes reutilizados por todas as
   telas. Carregue-o antes de qualquer CSS de componente.
   ========================================================================== */

:root {
    /* --- Marca --- */
    --brand-red: #e1121c;
    --brand-red-dark: #b70d16;
    --brand-red-soft: rgba(225, 18, 28, 0.12);

    --slate-900: #12242c;
    --slate-800: #1a3440;
    --slate-700: #23404e;
    --slate-600: #2f5a6b;
    --slate-500: #3d7186;
    --slate-400: #6d8b9b;
    --slate-300: #94a7b5;
    --slate-200: #c3d0d8;
    --slate-100: #e2e8ec;
    --slate-050: #f1f5f7;

    /* --- Superficies --- */
    --canvas: #eef2f5;
    --surface: #ffffff;
    --surface-muted: #f7f9fb;
    --border: #dde5ea;
    --border-strong: #c6d3db;

    /* --- Texto --- */
    --text: #16303b;
    --text-muted: #5c7480;
    --text-faint: #8ba0ac;
    --text-on-dark: #eef4f7;

    /* --- Estados --- */
    --success: #12855c;
    --success-soft: #e2f4ec;
    --warning: #b06a00;
    --warning-soft: #fdf0dc;
    --danger: #c62828;
    --danger-soft: #fbe6e6;
    --info: #1f6f97;
    --info-soft: #e3f0f7;

    /* --- Formas --- */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-pill: 999px;

    /* --- Elevacao --- */
    --shadow-xs: 0 1px 2px rgba(18, 36, 44, 0.06);
    --shadow-sm: 0 1px 3px rgba(18, 36, 44, 0.08), 0 1px 2px rgba(18, 36, 44, 0.04);
    --shadow: 0 4px 12px rgba(18, 36, 44, 0.08), 0 1px 3px rgba(18, 36, 44, 0.05);
    --shadow-lg: 0 12px 32px rgba(18, 36, 44, 0.14), 0 4px 8px rgba(18, 36, 44, 0.06);

    /* --- Espacamento --- */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-10: 40px;

    /* --- Tipografia --- */
    --font: 'Roboto', -apple-system, 'Segoe UI', Arial, sans-serif;
    --fs-xs: 12px;
    --fs-sm: 13px;
    --fs-base: 14px;
    --fs-md: 16px;
    --fs-lg: 20px;
    --fs-xl: 26px;
    --fs-2xl: 34px;

    --transition: 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Base
   ========================================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Componentes que definem `display` (cards, alertas, flex em geral) passam por
   cima do atributo `hidden`, que só vale como display:none por padrão. Sem
   isto, um elemento marcado como hidden continua aparecendo. */
[hidden] {
    display: none !important;
}

body {
    font-family: var(--font);
    font-size: var(--fs-base);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
    margin: 0;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text);
    letter-spacing: -0.01em;
}

/* ==========================================================================
   Cartoes e paineis
   ========================================================================== */

.is-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.is-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-5) var(--sp-6);
    border-bottom: 1px solid var(--border);
}

.is-card__title {
    font-size: var(--fs-md);
    font-weight: 700;
}

.is-card__subtitle {
    margin-top: 2px;
    font-size: var(--fs-xs);
    color: var(--text-muted);
    font-weight: 400;
}

.is-card__body {
    padding: var(--sp-6);
}

/* ==========================================================================
   Cabecalho de pagina
   ========================================================================== */

.is-page {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: var(--sp-6) var(--sp-6) var(--sp-10);
    text-align: left;
}

.is-page__head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--sp-4);
    margin-bottom: var(--sp-6);
}

.is-page__title {
    font-size: var(--fs-xl);
}

.is-page__lead {
    margin-top: var(--sp-1);
    font-size: var(--fs-base);
    color: var(--text-muted);
}

.is-page__actions {
    display: flex;
    gap: var(--sp-3);
    flex-wrap: wrap;
}

/* ==========================================================================
   Botoes
   ========================================================================== */

.is-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: 9px 16px;
    font-family: inherit;
    font-size: var(--fs-base);
    font-weight: 500;
    line-height: 1.2;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color var(--transition), border-color var(--transition),
                color var(--transition), box-shadow var(--transition);
}

.is-btn:focus-visible {
    outline: 2px solid var(--slate-500);
    outline-offset: 2px;
}

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

.is-btn--primary {
    background: var(--brand-red);
    color: #fff;
    box-shadow: var(--shadow-xs);
}
.is-btn--primary:hover { background: var(--brand-red-dark); }

.is-btn--dark {
    background: var(--slate-700);
    color: #fff;
    box-shadow: var(--shadow-xs);
}
.is-btn--dark:hover { background: var(--slate-800); }

.is-btn--ghost {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
}
.is-btn--ghost:hover {
    background: var(--surface-muted);
    border-color: var(--slate-300);
}

.is-btn--danger {
    background: var(--danger);
    color: #fff;
}
.is-btn--danger:hover { background: #a71d1d; }

.is-btn--sm {
    padding: 5px 10px;
    font-size: var(--fs-xs);
}

.is-btn--icon {
    padding: 7px;
    width: 32px;
    height: 32px;
}

/* ==========================================================================
   Formularios
   ========================================================================== */

.is-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: var(--sp-4);
}

.is-label {
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text-muted);
}

.is-input,
.is-select,
.is-textarea {
    width: 100%;
    padding: 9px 12px;
    font-family: inherit;
    font-size: var(--fs-base);
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.is-input::placeholder,
.is-textarea::placeholder { color: var(--text-faint); }

.is-input:focus,
.is-select:focus,
.is-textarea:focus {
    outline: none;
    border-color: var(--slate-500);
    box-shadow: 0 0 0 3px rgba(61, 113, 134, 0.15);
}

.is-input.error,
.is-select.error {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px var(--brand-red-soft);
}

.is-textarea {
    min-height: 110px;
    resize: vertical;
}

.is-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235c7480' d='M6 8.5 1.5 4h9z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.is-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0 var(--sp-5);
}

/* ==========================================================================
   Tabelas
   ========================================================================== */

.is-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.is-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-base);
}

.is-table thead th {
    padding: var(--sp-3) var(--sp-4);
    text-align: left;
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.is-table tbody td {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.is-table tbody tr:last-child td { border-bottom: none; }

.is-table tbody tr {
    transition: background-color var(--transition);
}

.is-table tbody tr:hover { background: var(--surface-muted); }

.is-table--clickable tbody tr { cursor: pointer; }

/* As regras de `thead th` / `tbody td` acima têm mais especificidade que as
   utilitárias .is-right / .is-center, o que deixava o cabeçalho desalinhado
   da coluna. Estas regras devolvem a palavra final para a utilitária. */
.is-table th.is-right,
.is-table td.is-right { text-align: right; }

.is-table th.is-center,
.is-table td.is-center { text-align: center; }

.is-table__empty {
    padding: var(--sp-10) var(--sp-4);
    text-align: center;
    color: var(--text-faint);
}

/* ==========================================================================
   Badges
   ========================================================================== */

.is-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    font-size: var(--fs-xs);
    font-weight: 600;
    line-height: 1.5;
    border-radius: var(--radius-pill);
    background: var(--slate-100);
    color: var(--slate-600);
    white-space: nowrap;
}

.is-badge--success { background: var(--success-soft); color: var(--success); }
.is-badge--warning { background: var(--warning-soft); color: var(--warning); }
.is-badge--danger  { background: var(--danger-soft);  color: var(--danger); }
.is-badge--info    { background: var(--info-soft);    color: var(--info); }
.is-badge--brand   { background: var(--brand-red-soft); color: var(--brand-red-dark); }

/* ==========================================================================
   KPI / metricas
   ========================================================================== */

.is-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--sp-4);
}

.is-kpi {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: var(--sp-4);
    padding: var(--sp-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.is-kpi::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--accent, var(--slate-400));
}

.is-kpi__icon {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    font-size: var(--fs-md);
    background: var(--accent-soft, var(--slate-050));
    color: var(--accent, var(--slate-600));
}

.is-kpi__label {
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.is-kpi__value {
    margin-top: 2px;
    font-size: var(--fs-2xl);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.is-kpi__hint {
    margin-top: 4px;
    font-size: var(--fs-xs);
    color: var(--text-faint);
}

/* ==========================================================================
   Modais
   ========================================================================== */

.is-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-5);
    background: rgba(18, 36, 44, 0.55);
    backdrop-filter: blur(2px);
    overflow-y: auto;
}

.is-modal[hidden],
.is-modal.hidden { display: none; }

.is-modal__box {
    width: 100%;
    max-width: 560px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: is-modal-in 180ms ease-out;
}

@keyframes is-modal-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

.is-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-5) var(--sp-6);
    border-bottom: 1px solid var(--border);
}

.is-modal__body { padding: var(--sp-6); }

.is-modal__foot {
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-6);
    border-top: 1px solid var(--border);
    background: var(--surface-muted);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.is-modal__close {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    font-size: var(--fs-lg);
    line-height: 1;
    color: var(--text-faint);
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color var(--transition), color var(--transition);
}

.is-modal__close:hover {
    background: var(--slate-050);
    color: var(--text);
}

/* ==========================================================================
   Alertas inline
   ========================================================================== */

.is-alert {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    margin-bottom: var(--sp-4);
    font-size: var(--fs-base);
    border-radius: var(--radius);
    border: 1px solid transparent;
}

.is-alert--success { background: var(--success-soft); color: var(--success); border-color: rgba(18, 133, 92, 0.2); }
.is-alert--error   { background: var(--danger-soft);  color: var(--danger);  border-color: rgba(198, 40, 40, 0.2); }
.is-alert--info    { background: var(--info-soft);    color: var(--info);    border-color: rgba(31, 111, 151, 0.2); }

/* ==========================================================================
   Paginacao
   ========================================================================== */

.is-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
    padding: var(--sp-4);
}

.is-pagination a,
.is-pagination span {
    display: grid;
    place-items: center;
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all var(--transition);
}

.is-pagination a:hover {
    border-color: var(--slate-300);
    color: var(--text);
}

.is-pagination .active {
    background: var(--slate-700);
    border-color: var(--slate-700);
    color: #fff;
}

/* ==========================================================================
   Utilitarios
   ========================================================================== */

.is-stack   { display: flex; flex-direction: column; gap: var(--sp-5); }
.is-row     { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.is-grow    { flex: 1; }
.is-muted   { color: var(--text-muted); }
.is-faint   { color: var(--text-faint); }
.is-num     { font-variant-numeric: tabular-nums; }
.is-right   { text-align: right; }
.is-center  { text-align: center; }
.is-nowrap  { white-space: nowrap; }
.is-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;
}

.is-empty {
    display: grid;
    place-items: center;
    gap: var(--sp-2);
    padding: var(--sp-10) var(--sp-5);
    text-align: center;
    color: var(--text-faint);
}

.is-empty i { font-size: 28px; opacity: 0.5; }

/* Telas legadas embutidas por iframe: 60px e a altura da barra de navegacao. */
.is-frame {
    display: block;
    width: 100%;
    height: calc(100vh - 60px);
    border: none;
    background: var(--canvas);
}

/* Barras de rolagem discretas e consistentes */
.is-scroll {
    scrollbar-width: thin;
    scrollbar-color: var(--slate-200) transparent;
}
.is-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.is-scroll::-webkit-scrollbar-track { background: transparent; }
.is-scroll::-webkit-scrollbar-thumb {
    background: var(--slate-200);
    border-radius: var(--radius-pill);
}
.is-scroll::-webkit-scrollbar-thumb:hover { background: var(--slate-300); }

@media (max-width: 720px) {
    .is-page { padding: var(--sp-4) var(--sp-4) var(--sp-8); }
    .is-page__title { font-size: var(--fs-lg); }
    .is-kpi__value { font-size: var(--fs-xl); }
}
