/* =====================================================================
   DifriSul WMS - Tema central (paleta compartilhada por MAUI + Web)
   ---------------------------------------------------------------------
   SUBSTITUA os valores abaixo pelos tokens da paleta do projeto Angular.
   Todos os componentes referenciam estas variaveis, entao trocar a paleta
   e' feito SOMENTE aqui.
   ===================================================================== */
:root {
    /* ---- Paleta principal (PLACEHOLDER - trocar pelos hex do Angular) ---- */
    --brand-primary: #0d47a1;          /* cor primaria */
    --brand-primary-dark: #09367a;     /* primaria escura (hover/active) */
    --brand-primary-light: #5472d3;    /* primaria clara */
    --brand-on-primary: #ffffff;       /* texto sobre primaria */

    --brand-accent: #ff8f00;           /* cor de destaque/acao */
    --brand-on-accent: #1a1a1a;

    --brand-success: #2e7d32;
    --brand-warning: #ed6c02;
    --brand-danger: #c62828;
    --brand-info: #0277bd;

    /* ---- Neutros / superficies ---- */
    --surface-bg: #f4f6f9;
    --surface-card: #ffffff;
    --surface-border: #e2e6ec;
    --surface-hover: #eef2f7;
    --surface-muted: #f1f1f1;   /* campos calculados/desabilitados + caixas do inventario */
    --input-bg: #ffffff;        /* fundo dos inputs/selects */
    --danger-bg: #ffecec;       /* realce de modo subtrair / erro em campos */

    --text-primary: #1a2027;
    --text-secondary: #5b6770;
    --text-muted: #8a949e;

    /* ---- Tipografia / formas ---- */
    --font-base: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-1: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .06);
    --shadow-2: 0 4px 12px rgba(16, 24, 40, .12);

    --appbar-height: 56px;
    --space: 16px;
}

/* ===================== Tema escuro ===================== */
[data-theme="dark"] {
    --brand-primary: #1f6fd6;
    --brand-primary-dark: #1559aa;
    --brand-primary-light: #28456f;   /* cabecalho de tabela no escuro */
    --brand-on-primary: #ffffff;

    --brand-accent: #ffa726;
    --brand-on-accent: #1a1a1a;

    --brand-success: #66bb6a;
    --brand-warning: #ffb74d;
    --brand-danger: #ef5350;
    --brand-info: #4fc3f7;

    --surface-bg: #0f1216;
    --surface-card: #1a1f26;
    --surface-border: #2c333d;
    --surface-hover: #232b34;
    --surface-muted: #262c34;
    --input-bg: #11151b;
    --danger-bg: #3a2222;

    --text-primary: #e6e9ed;
    --text-secondary: #aab3bd;
    --text-muted: #7e8893;

    --shadow-1: 0 1px 3px rgba(0,0,0,.5), 0 1px 2px rgba(0,0,0,.4);
    --shadow-2: 0 6px 16px rgba(0,0,0,.6);
}
/* Banners/badges com cores literais -> variantes escuras (texto ja vem das vars) */
[data-theme="dark"] .banner--error { background: #3a2222; border-color: #5c2f2f; }
[data-theme="dark"] .banner--info  { background: #16303d; border-color: #244e60; }
[data-theme="dark"] .badge--success { background: #1e3a26; }
[data-theme="dark"] .badge--warning { background: #3a2f1a; }
[data-theme="dark"] .badge--danger  { background: #3a2222; }
[data-theme="dark"] .badge--info    { background: #16303d; }

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-base);
    background: var(--surface-bg);
    color: var(--text-primary);
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 600; }

/* ===================== Layout / App bar ===================== */
.wms-shell { display: flex; flex-direction: column; min-height: 100vh; }

.wms-appbar {
    height: var(--appbar-height);
    background: var(--brand-primary);
    color: var(--brand-on-primary);
    display: flex; align-items: center; gap: 12px;
    padding: 0 12px;
    box-shadow: var(--shadow-1);
    position: sticky; top: 0; z-index: 30;
}
.wms-appbar__titlebox { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; line-height: 1.1; }
.wms-appbar__title { font-size: 1.05rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wms-appbar__env {
    align-self: flex-start; margin-top: 2px;
    display: inline-flex; align-items: center; gap: 5px;
    font-size: .64rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    padding: 1px 8px; border-radius: 999px; line-height: 1.5;
}
.wms-appbar__env::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.wms-appbar__env--hml { background: #f5a623; color: #3a2700; }
.wms-appbar__env--prod { background: #1f9d57; color: #ffffff; }
.wms-appbar__btn {
    background: transparent; border: none; color: inherit;
    width: 40px; height: 40px; border-radius: 50%;
    display: grid; place-items: center; cursor: pointer; font-size: 1.25rem;
}
.wms-appbar__btn:hover { background: rgba(255,255,255,.15); }

.wms-content { flex: 1; padding: var(--space); max-width: 920px; width: 100%; margin: 0 auto; }

/* ===================== Drawer / Nav ===================== */
.wms-drawer-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40;
}
.wms-drawer {
    position: fixed; top: 0; left: 0; bottom: 0; width: 280px; max-width: 85vw;
    background: var(--surface-card); z-index: 50; box-shadow: var(--shadow-2);
    display: flex; flex-direction: column; transform: translateX(0);
}
.wms-drawer__header {
    background: var(--brand-primary); color: var(--brand-on-primary);
    padding: 20px 16px;
}
.wms-drawer__header small { opacity: .85; }
.wms-drawer__nav { overflow-y: auto; padding: 8px 0; }
.wms-navlink {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 18px; color: var(--text-primary); text-decoration: none;
    font-size: .95rem; border-left: 3px solid transparent;
}
.wms-navlink:hover { background: var(--surface-hover); }
.wms-navlink.active {
    background: var(--surface-hover);
    border-left-color: var(--brand-primary);
    color: var(--brand-primary); font-weight: 600;
}
.wms-navlink .ico { width: 22px; text-align: center; }

/* ===================== Cards / grid de modulos ===================== */
.module-grid {
    display: grid; gap: 14px;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.module-tile {
    background: var(--surface-card); border: 1px solid var(--surface-border);
    border-radius: var(--radius); padding: 18px 14px; text-align: center;
    text-decoration: none; color: var(--text-primary);
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    box-shadow: var(--shadow-1); transition: transform .08s, box-shadow .12s;
    min-height: 120px; justify-content: center;
}
.module-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.module-tile .ico {
    width: 48px; height: 48px; border-radius: 12px;
    background: var(--brand-primary); color: var(--brand-on-primary);
    display: grid; place-items: center; font-size: 1.4rem;
}
.module-tile .label { font-weight: 600; font-size: .9rem; }

/* Espaçamentos compactos (uso em coletor — menos scroll). Padrão global de todas as telas. */
.card {
    background: var(--surface-card); border: 1px solid var(--surface-border);
    border-radius: var(--radius); box-shadow: var(--shadow-1);
    padding: 6px 10px; margin-bottom: 8px;
}
.card--row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 0 10px; font-size: .82rem; }
.kv dt { color: var(--text-secondary); }
.kv dd { margin: 0; font-weight: 500; }

/* ===================== Form / inputs ===================== */
.field { margin-bottom: 8px; }
.field label { display: block; font-size: .8rem; color: var(--text-secondary); margin-bottom: 2px; font-weight: 600; }
.input, .select {
    width: 100%; padding: 2px 12px; font-size: 1rem;
    border: 1px solid var(--surface-border); border-radius: var(--radius-sm);
    background: var(--input-bg); color: var(--text-primary);
}
.input:focus, .select:focus { outline: 2px solid var(--brand-primary-light); border-color: var(--brand-primary); }
/* Placeholder no texto como escrito (sem herdar o uppercase do campo). */
.input::placeholder, .select::placeholder { text-transform: none; }
[data-theme="dark"] .input::placeholder, [data-theme="dark"] .select::placeholder { color: var(--text-muted); }
[data-theme="dark"] .input:disabled, [data-theme="dark"] .select:disabled { opacity: .85; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 3px 14px; font-size: 1rem; font-weight: 600;
    border: none; border-radius: var(--radius-sm); cursor: pointer;
    background: var(--brand-primary); color: var(--brand-on-primary);
    transition: background .12s; min-height: 30px;
}
.btn:hover { background: var(--brand-primary-dark); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn--block { width: 100%; }
.btn--accent { background: var(--brand-accent); color: var(--brand-on-accent); }
.btn--danger { background: var(--brand-danger); }
.btn--ghost { background: transparent; color: var(--brand-primary); border: 1px solid var(--brand-primary); }

.searchbar { display: flex; gap: 8px; margin-bottom: 9px; }
.searchbar .input { flex: 1; }

/* ----- Menu de botoes (estilo do app original: borda azul, icone a esquerda) ----- */
.menu-list { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.menu-btn {
    display: flex; align-items: center; gap: 16px;
    background: var(--surface-card); color: var(--brand-primary);
    border: 2px solid var(--brand-primary); border-radius: var(--radius);
    padding: 22px 24px; text-decoration: none; font-size: 1.05rem; font-weight: 600;
    box-shadow: var(--shadow-1); transition: background .12s, transform .08s; min-height: 64px;
}
.menu-btn:hover { background: var(--surface-hover); transform: translateY(-1px); }
.menu-btn .ico { font-size: 1.5rem; width: 32px; text-align: center; }
.menu-btn .menu-btn__label { flex: 1; text-align: center; }

.menu-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.menu-back {
    background: transparent; border: none; color: var(--brand-primary);
    font-size: 1.6rem; cursor: pointer; line-height: 1; padding: 4px 8px;
}
.menu-header h2 { color: var(--brand-primary); margin: 0; }

/* ===================== Estados / badges ===================== */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    font-size: .75rem; font-weight: 600; background: var(--surface-hover); color: var(--text-secondary);
}
.badge--success { background: #e6f4ea; color: var(--brand-success); }
.badge--warning { background: #fdf0e3; color: var(--brand-warning); }
.badge--danger { background: #fdecec; color: var(--brand-danger); }
.badge--info { background: #e4f1f8; color: var(--brand-info); }

.banner { padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: .9rem; }
.banner--error { background: #fdecec; color: var(--brand-danger); border: 1px solid #f5c6c6; }
.banner--info { background: #e4f1f8; color: var(--brand-info); border: 1px solid #bfe0f2; }

.center-state { text-align: center; color: var(--text-muted); padding: 40px 16px; }

.spinner {
    width: 34px; height: 34px; border: 3px solid var(--surface-border);
    border-top-color: var(--brand-primary); border-radius: 50%;
    animation: spin .8s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== Login ===================== */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
    background: linear-gradient(160deg, var(--brand-primary), var(--brand-primary-dark)); }
.login-card { background: var(--surface-card); border-radius: var(--radius);
    box-shadow: var(--shadow-2); padding: 28px; width: 100%; max-width: 380px; }
.login-card h1 { text-align: center; color: var(--brand-primary); font-size: 1.5rem; letter-spacing: .3px; }
.login-logo { text-align: center; margin-bottom: 8px; font-size: 2rem; }
