/* Header e pesquisa rápida (parte de style.css) */
/* ============================================================
   HEADER — título da página, pesquisa rápida, menu "Novo"
   ============================================================ */
:root { --header-h: 76px; }

header {
    height: var(--header-h);
    padding: 0 20px;
}
.header-logo { height: var(--header-h); }
.header-logo img { height: 54px; max-width: 320px; }
/* min-height (e não height): o layout cresce com o conteúdo, por isso a sidebar
   sticky acompanha o scroll da página em vez de sair do ecrã com o .layout */
.layout { height: auto; min-height: calc(100vh - var(--header-h)); }
.sidebar {
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
}

/* Título + breadcrumb da página atual */
.header-left { min-width: 0; }
.header-page {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}
.header-crumb {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.1px;
    text-transform: uppercase;
    color: #8b8f70;
}
.header-page-title {
    margin: 0;
    font-size: 19px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Botão de pesquisa */
.header-search {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 44px;
    min-width: 220px;
    padding: 0 8px 0 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: #b8bd96;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.header-search:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.22);
    color: #fff;
}
.header-search:focus-visible,
.novo-btn:focus-visible {
    outline: 2px solid #a3a678;
    outline-offset: 2px;
}
.header-search-texto { flex: 1; text-align: left; }
.header-kbd,
.cmdk kbd {
    font-family: inherit;
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(0, 0, 0, 0.2);
    color: #9a9f7d;
    white-space: nowrap;
}

/* Menu "Novo" */
.novo-menu { position: relative; }
.novo-btn {
    height: 44px;
    padding: 0 14px 0 16px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
}
.novo-chevron { transition: transform 0.2s ease; opacity: 0.85; }
.novo-btn[aria-expanded="true"] .novo-chevron { transform: rotate(180deg); }
.novo-lista {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 280px;
    padding: 6px;
    background: #fff;
    color: #1a1a1a;
    border: 1px solid #e3e5dc;
    border-radius: 12px;
    box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.35);
    z-index: 200;
}
.novo-lista.aberto {
    display: block;
    animation: novoEntrar 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes novoEntrar {
    from { opacity: 0; transform: translateY(-6px) scale(0.98); }
    to { opacity: 1; transform: none; }
}
.novo-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px;
    border: 0;
    border-radius: 9px;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.novo-item:hover,
.novo-item:focus-visible { background: #f2f3ec; outline: none; }
.novo-item strong { display: block; font-size: 14px; font-weight: 600; }
.novo-item small { display: block; font-size: 12px; color: #777; margin-top: 1px; }
.novo-icone {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.novo-icone.entrada { background: rgba(39, 174, 96, 0.14); color: #1e8449; }
.novo-icone.saida { background: rgba(230, 126, 34, 0.16); color: #b9650f; }
.novo-icone.produto { background: rgba(83, 87, 53, 0.16); color: #535735; }

/* Pesquisa rápida (Ctrl+K) */
.cmdk {
    position: fixed;
    inset: 0;
    z-index: 2500;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 12vh;
}
.cmdk[hidden] { display: none; }
.cmdk-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 12, 6, 0.55);
    backdrop-filter: blur(3px);
}
.cmdk-panel {
    position: relative;
    width: min(640px, calc(100vw - 32px));
    background: #fff;
    color: #1a1a1a;
    border-radius: 14px;
    box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    animation: novoEntrar 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}
.cmdk-input-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid #e8eae0;
    color: #777;
}
.cmdk-input-row input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: #1a1a1a;
    font-family: inherit;
    font-size: 16px;
}
.cmdk kbd {
    border-color: #d6d9cb;
    background: #f3f4ee;
    color: #6b6f55;
}
.cmdk-lista {
    max-height: min(420px, 55vh);
    overflow-y: auto;
    padding: 6px;
}
.cmdk-secao {
    padding: 10px 10px 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #8b8f70;
}
.cmdk-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border-radius: 9px;
    cursor: pointer;
}
.cmdk-item.ativo { background: #eef0e3; }
.cmdk-icone {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: #f0f1ea;
    color: #535735;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}
.cmdk-texto { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cmdk-texto strong {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cmdk-texto small { font-size: 12px; color: #777; }
.cmdk-vazio { padding: 28px; text-align: center; color: #888; font-size: 14px; }
.cmdk-rodape {
    display: flex;
    gap: 16px;
    padding: 9px 14px;
    border-top: 1px solid #e8eae0;
    font-size: 12px;
    color: #888;
}
.cmdk-rodape kbd { margin-right: 4px; }

body.dark .novo-lista,
body.dark .cmdk-panel {
    background: #262a1e;
    border-color: #3a3e2e;
    color: var(--texto);
}
body.dark .novo-item:hover,
body.dark .novo-item:focus-visible,
body.dark .cmdk-item.ativo { background: #323725; }
body.dark .novo-item small,
body.dark .cmdk-texto small,
body.dark .cmdk-vazio,
body.dark .cmdk-rodape { color: var(--texto-2); }
body.dark .cmdk-input-row { border-color: #3a3e2e; color: var(--texto-2); }
body.dark .cmdk-input-row input { color: var(--texto); }
body.dark .cmdk-rodape { border-color: #3a3e2e; }
body.dark .cmdk-icone { background: #323725; color: #c8cda8; }
body.dark .cmdk kbd { border-color: #4a4d3e; background: #1c1e17; color: #9a9d8e; }

@media (max-width: 1200px) {
    .header-search { min-width: 44px; width: 44px; padding: 0; justify-content: center; }
    .header-search-texto,
    .header-kbd { display: none; }
}

@media (max-width: 768px) {
    header {
        grid-template-columns: auto minmax(0, 1fr) auto;
        padding: 0 12px;
        gap: 10px;
    }
    .header-page { display: none; }
    .header-logo { justify-self: start; }
    .header-logo img { height: 34px; max-width: 130px; }
    .novo-btn { width: 44px; padding: 0; justify-content: center; }
    .novo-texto,
    .novo-chevron { display: none; }
    .novo-lista { width: min(280px, calc(100vw - 24px)); }
    .sidebar {
        top: var(--header-h);
        height: calc(100vh - var(--header-h));
    }
    .cmdk { padding-top: 8vh; }
}

/* Unidade base / alternativa */
.opcional { font-weight: 400; color: #999; font-size: 12px; }
.unidade-alt-linha {
    display: grid;
    grid-template-columns: minmax(90px, 1fr) auto minmax(100px, 1fr) auto;
    gap: 10px;
    align-items: center;
}
.fator-texto { font-size: 14px; color: #555; white-space: nowrap; }
.qtd-linha { display: flex; gap: 10px; }
.qtd-linha input { flex: 1; min-width: 0; }
.qtd-linha select { width: 110px; flex-shrink: 0; }
.stock-alt { display: block; font-size: 11.5px; font-weight: 400; color: #777; margin-top: 2px; }
body.dark .fator-texto { color: var(--texto-2); }
body.dark .stock-alt { color: var(--texto-2); }
body.dark .opcional { color: var(--texto-2); }
@media (max-width: 560px) { .unidade-alt-linha { grid-template-columns: 1fr 1fr; } }

/* Armazéns ⇄ Localizações */
#tab-armazens .armazens-lista { max-height: none; }
.armazens-ajuda { font-size: 13px; color: #666; margin-bottom: 16px; line-height: 1.5; }
body.dark .armazens-ajuda { color: var(--texto-2); }
.armazem-linha .btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.loc-filtro {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    padding: 10px 14px;
    border-radius: 10px;
    background: #eef0e3;
    border: 1px solid #d9dcc8;
    font-size: 13px;
    color: #3d4028;
}
.loc-filtro span { flex: 1; min-width: 180px; }
body.dark .loc-filtro { background: #323725; border-color: #3a3e2e; color: var(--texto); }
.grupo .grupo-accao { margin-left: 6px; }

