/* =========================================================
   COMPONENTES REUTILIZÁVEIS
   Carregado em toda página administrativa (ver templates/layouts/base.html)
   — nenhum módulo deve reimplementar seu próprio card/botão/badge/tabela.
   Tokens (cores, raio, sombra) vêm de app.css.
   ========================================================= */


/* =========================================================
   CARD
   ========================================================= */

.card {
    background: var(--color-surface);

    border: 1px solid var(--color-border);

    border-radius: var(--radius-lg);

    padding: 20px;

    box-shadow: var(--shadow-sm);
}


/* =========================================================
   SECTION HEADER (cabeçalho de bloco dentro de um card)
   ========================================================= */

.section-header {
    display: flex;

    align-items: center;

    gap: 12px;

    margin-bottom: 16px;
}

.section-icon {
    width: 38px;
    height: 38px;

    flex-shrink: 0;

    display: flex;

    align-items: center;
    justify-content: center;

    border-radius: var(--radius-md);

    background: var(--color-primary-light);

    color: var(--color-primary);
}

.section-icon svg {
    width: 19px;
    height: 19px;
}

.section-header label {
    margin: 0;

    font-size: 0.9rem;

    font-weight: 650;
}

.section-description {
    display: block;

    margin-top: 3px;

    color: var(--color-text-secondary);

    font-size: 0.75rem;
}


/* =========================================================
   FORM / INPUT
   ========================================================= */

label {
    display: block;

    margin-bottom: 7px;

    font-size: 0.85rem;
    font-weight: 600;

    color: var(--color-text);
}

.form-group {
    display: flex;

    flex-direction: column;
}

.field-hint {
    margin-top: 6px;

    color: var(--color-text-muted);

    font-size: 0.72rem;
}

.optional {
    margin-left: 3px;

    color: var(--color-text-muted);

    font-size: 0.72rem;
    font-weight: 400;
}

.input-wrapper {
    position: relative;

    width: 100%;
}

.input-icon {
    position: absolute;

    left: 13px;
    top: 50%;

    transform: translateY(-50%);

    width: 18px;
    height: 18px;

    color: var(--color-text-muted);

    pointer-events: none;

    z-index: 2;
}

.input-control {
    width: 100%;

    min-height: 46px;

    padding: 11px 13px;

    border: 1px solid var(--color-border);

    border-radius: var(--radius-md);

    background: var(--color-surface);

    color: var(--color-text);

    font-size: 0.95rem;

    outline: none;

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}

.input-wrapper .input-control {
    padding-left: 42px;
}

.input-control::placeholder {
    color: var(--color-text-muted);
}

.input-control:hover {
    border-color: var(--color-border-strong);
}

.input-control:focus {
    border-color: var(--color-primary);

    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.input-control:disabled {
    background: var(--color-background);

    color: var(--color-text-muted);

    cursor: not-allowed;
}

select.input-control {
    cursor: pointer;
}


/* =========================================================
   BUTTONS
   ========================================================= */

.btn {
    min-height: 46px;

    padding: 11px 18px;

    border: none;

    border-radius: var(--radius-md);

    display: inline-flex;

    align-items: center;
    justify-content: center;

    gap: 8px;

    font-size: 0.9rem;
    font-weight: 600;

    cursor: pointer;

    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        transform 0.1s ease,
        box-shadow 0.15s ease,
        opacity 0.15s ease;
}

.btn svg {
    width: 18px;
    height: 18px;

    flex-shrink: 0;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.55;

    cursor: not-allowed;

    transform: none;
    box-shadow: none;
}

.btn-primary {
    background: var(--color-primary);

    color: var(--color-on-primary);
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-hover);

    box-shadow: 0 4px 10px rgba(15, 117, 188, 0.28);
}

.btn-success {
    width: 100%;

    background: var(--color-success);

    color: #ffffff;
}

.btn-success:hover:not(:disabled) {
    background: var(--color-success-hover);

    box-shadow: 0 4px 10px rgba(22, 163, 74, 0.24);
}

.btn-danger {
    background: var(--color-danger);

    color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
    background: var(--color-danger-hover);

    box-shadow: 0 4px 10px rgba(220, 38, 38, 0.24);
}

.btn-secondary {
    background: var(--color-background);

    color: var(--color-text);

    border: 1px solid var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-surface-hover);

    border-color: var(--color-border-strong);
}

.btn-icon {
    width: 46px;

    padding: 0;

    flex-shrink: 0;
}


/* =========================================================
   BADGE / STATUS
   ========================================================= */

.badge {
    display: inline-flex;

    align-items: center;

    margin-top: 5px;

    padding: 3px 8px;

    border-radius: var(--radius-sm);

    background: var(--color-background);

    color: var(--color-text-secondary);

    font-size: 0.7rem;
    font-weight: 600;
}

/* .situacao é o status "bolinha + texto" da Conferência Scanntech, gerado
   em static/js/scanntech-conferencia.js (classes fixas: situacao-ok,
   situacao-divergente, situacao-pendente, situacao-erro). A cor nunca é o
   único indicador — o texto e a bolinha (::before) sempre acompanham.
   Novos módulos com status semelhante devem seguir o mesmo padrão visual,
   com suas próprias classes (o nome "situacao" é específico deste módulo). */
.situacao {
    display: inline-flex;

    align-items: center;

    gap: 6px;

    padding: 4px 10px;

    border-radius: var(--radius-full);

    font-size: 0.78rem;
    font-weight: 600;

    white-space: nowrap;
}

.situacao::before {
    content: "";

    width: 7px;
    height: 7px;

    flex-shrink: 0;

    border-radius: 50%;

    background: currentColor;
}

.situacao-ok {
    background: var(--color-success-light);
    color: var(--color-success-hover);
}

.situacao-divergente {
    background: var(--color-danger-light);
    color: var(--color-danger);
}

.situacao-pendente {
    background: var(--color-warning-light);
    color: var(--color-warning-text);
}

.situacao-erro {
    background: var(--color-danger-light);
    color: var(--color-danger);
}


/* =========================================================
   ALERT
   ========================================================= */

.alert {
    display: flex;

    align-items: flex-start;

    gap: 10px;

    padding: 13px 15px;

    border: 1px solid transparent;
    border-radius: var(--radius-md);

    font-size: 0.85rem;
}

.alert svg {
    width: 18px;
    height: 18px;

    flex-shrink: 0;

    margin-top: 1px;
}

.alert-info {
    background: var(--color-primary-light);
    border-color: #CFE4F4;
    color: var(--color-primary-active);
}

.alert-success {
    background: var(--color-success-light);
    border-color: #C9EED6;
    color: var(--color-success-hover);
}

.alert-warning {
    background: var(--color-warning-light);
    border-color: #F6DFB6;
    color: var(--color-warning-text);
}

.alert-danger {
    background: var(--color-danger-light);
    border-color: #F5C7C7;
    color: var(--color-danger);
}


/* =========================================================
   TABLE
   ========================================================= */

.table-wrapper {
    overflow-x: auto;
}

.table {
    width: 100%;

    border-collapse: collapse;

    font-size: 0.9rem;
}

.table th,
.table td {
    padding: 12px 14px;

    text-align: left;
    white-space: nowrap;

    border-bottom: 1px solid var(--color-border);
}

.table th {
    color: var(--color-text-secondary);

    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

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

.table .valor-monetario {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Linha divergente — gerada por static/js/scanntech-conferencia.js. */
.table tr.linha-divergente {
    background: var(--color-danger-light);
}

.table tr.linha-divergente:hover {
    filter: brightness(0.97);
}

.table .empty-state-linha {
    padding: 40px 14px !important;

    text-align: center !important;
    white-space: normal !important;

    color: var(--color-text-muted);
}


/* =========================================================
   EMPTY STATE
   ========================================================= */

.empty-state {
    padding: 44px 20px;

    text-align: center;

    background: var(--color-surface);

    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-lg);
}

.empty-state-icon {
    width: 52px;
    height: 52px;

    margin: 0 auto 14px;

    display: flex;

    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: var(--color-background);

    color: var(--color-text-secondary);
}

.empty-state-icon svg {
    width: 24px;
    height: 24px;
}

.empty-state h3 {
    margin-bottom: 6px;

    font-size: 0.95rem;
}

.empty-state p {
    max-width: 360px;

    margin: 0 auto;

    color: var(--color-text-secondary);

    font-size: 0.8rem;
    line-height: 1.5;
}


/* =========================================================
   LOADING
   ========================================================= */

.spinner {
    width: 18px;
    height: 18px;

    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;

    animation: spin 0.7s linear infinite;
}

.spinner-primary {
    border: 2px solid var(--color-primary-light);
    border-top-color: var(--color-primary);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}


/* =========================================================
   MODAL
   ========================================================= */

.modal {
    position: fixed;
    inset: 0;

    z-index: 1000;

    display: flex;

    align-items: center;
    justify-content: center;

    padding: 16px;

    background: rgba(15, 23, 42, 0.55);

    backdrop-filter: blur(3px);
}

.modal-content {
    width: 100%;
    max-width: 450px;
    max-height: calc(100vh - 32px);

    overflow-y: auto;

    background: var(--color-surface);

    border-radius: var(--radius-lg);

    box-shadow: var(--shadow-lg);

    display: flex;
    flex-direction: column;

    animation: modal-enter 0.18s ease-out;
}

@keyframes modal-enter {
    from {
        opacity: 0;

        transform: translateY(8px) scale(0.98);
    }

    to {
        opacity: 1;

        transform: translateY(0) scale(1);
    }
}

.modal-header {
    padding: 18px;

    border-bottom: 1px solid var(--color-border);

    display: flex;

    align-items: flex-start;
    justify-content: space-between;

    gap: 12px;
}

.modal-header h2 {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.35;
}

.modal-description {
    display: block;

    margin-top: 3px;

    color: var(--color-text-secondary);

    font-size: 0.75rem;
}

.modal-close {
    width: 36px;
    height: 36px;

    flex-shrink: 0;

    display: flex;

    align-items: center;
    justify-content: center;

    border: none;
    border-radius: var(--radius-md);

    background: transparent;

    color: var(--color-text-secondary);

    cursor: pointer;

    transition:
        background-color 0.15s ease,
        color 0.15s ease;
}

.modal-close:hover {
    background: var(--color-background);
    color: var(--color-text);
}

.modal-close svg {
    width: 19px;
    height: 19px;
}

.modal-body {
    padding: 18px;

    display: flex;
    flex-direction: column;

    gap: 18px;
}

.modal-footer {
    padding: 16px 18px 18px;

    border-top: 1px solid var(--color-border);

    display: flex;

    gap: 8px;
}

.modal-footer .btn-secondary {
    flex: 0 0 110px;
}

.modal-footer .btn-success,
.modal-footer .btn-primary {
    flex: 1;
}


/* =========================================================
   TOAST
   ========================================================= */

.toast {
    position: fixed;
    left: 50%;
    bottom: 20px;

    z-index: 2000;

    transform: translateX(-50%);

    max-width: calc(100% - 32px);

    padding: 12px 18px;

    border-radius: var(--radius-md);

    background: var(--color-text);

    color: #ffffff;

    font-size: 0.85rem;
    font-weight: 500;

    box-shadow: var(--shadow-lg);

    animation: toast-enter 0.2s ease-out;
}

.toast.toast-error {
    background: var(--color-danger);
}

@keyframes toast-enter {
    from {
        opacity: 0;

        transform: translateX(-50%) translateY(8px);
    }

    to {
        opacity: 1;

        transform: translateX(-50%) translateY(0);
    }
}


/* =========================================================
   ACESSO RÁPIDO (Home)
   Primeiro elemento visual da página — a Home não tem mais título próprio
   acima (ver templates/pages/home.html), só esta faixa compacta e
   horizontal com os atalhos mais usados (ver handlers.quickAccessItems).
   Não é um catálogo de módulos como a antiga Central de Módulos: fica
   pequena de propósito, a maior parte da Home é reservada ao Dashboard
   logo abaixo.
   ========================================================= */

.quick-access {
    margin-bottom: 28px;
}

/* Por ser o primeiro elemento da página (sem título de página acima), o
   título ganhou um pouco mais de presença que um label de seção comum —
   ainda longe do peso de um <h1> de page-header, só o suficiente para
   ancorar visualmente o topo da Home. */
.quick-access-title {
    margin-bottom: 14px;

    color: var(--color-text);

    font-size: 1.05rem;
    font-weight: 600;
}

.quick-access-list {
    display: flex;
    flex-wrap: wrap;

    gap: 10px;
}

.quick-access-item {
    flex: 1 1 200px;

    display: flex;

    align-items: center;

    gap: 10px;

    padding: 12px 14px;

    background: var(--color-surface);

    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);

    box-shadow: var(--shadow-sm);

    color: inherit;

    text-decoration: none;

    font-size: 0.86rem;
    font-weight: 600;

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.15s ease;
}

a.quick-access-item:hover {
    border-color: var(--color-primary);

    box-shadow: var(--shadow-md);

    transform: translateY(-1px);
}

.quick-access-icon {
    width: 18px;
    height: 18px;

    flex-shrink: 0;

    color: var(--color-primary);
}

.quick-access-name {
    flex: 1;
}

.quick-access-arrow {
    width: 14px;
    height: 14px;

    flex-shrink: 0;

    color: var(--color-text-muted);

    transition: transform 0.15s ease;
}

a.quick-access-item:hover .quick-access-arrow {
    transform: translateX(2px);

    color: var(--color-primary);
}

.quick-access-item-disabled {
    color: var(--color-text-muted);

    cursor: not-allowed;

    opacity: 0.75;
}

.quick-access-item-disabled .quick-access-icon {
    color: var(--color-text-muted);
}

@media (max-width: 480px) {
    /* Uma coluna só no celular estreito — abaixo disso, o flex-basis de
       200px acima já faz 2 colunas naturalmente, sem media query. */
    .quick-access-item {
        flex: 1 1 100%;
    }
}


/* =========================================================
   DASHBOARD (Home) — GRID DE WIDGETS
   .dashboard-grid + .dashboard-widget--* são o layout genérico reutilizado
   pelas seções Financeiro e Vendas (ver templates/pages/home.html e
   static/css/modules/dashboard.css) — um widget novo (Estoque, Produtos,
   Fiscal...) só precisa de um filho a mais aqui dentro, sem redesenhar a
   Home. Estilos específicos de cada card (KPI, resumo financeiro,
   gráficos) ficam em modules/dashboard.css, carregado só pela Home.
   ========================================================= */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);

    gap: 18px;
}

.dashboard-widget--sm {
    grid-column: span 3;
}

.dashboard-widget--md {
    grid-column: span 6;
}

.dashboard-widget--lg {
    grid-column: span 12;
}

@media (max-width: 767px) {
    .dashboard-widget--sm,
    .dashboard-widget--md,
    .dashboard-widget--lg {
        grid-column: span 12;
    }
}


/* =========================================================
   MODULE GRID / MODULE CARD
   Usado por hubs simples (ex.: Estoque) — ver {{template "module-card"}} em
   templates/layouts/base.html.
   ========================================================= */

.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));

    gap: 18px;
}

.module-card {
    position: relative;

    display: flex;
    flex-direction: column;

    gap: 14px;

    padding: 20px;

    background: var(--color-surface);

    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);

    box-shadow: var(--shadow-sm);

    color: inherit;

    text-decoration: none;

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.15s ease;
}

a.module-card:hover {
    border-color: var(--color-primary);

    box-shadow: var(--shadow-md);

    transform: translateY(-2px);
}

.module-card-icon {
    width: 44px;
    height: 44px;

    display: flex;

    align-items: center;
    justify-content: center;

    border-radius: var(--radius-md);

    background: var(--color-primary-light);

    color: var(--color-primary);
}

.module-card-icon svg {
    width: 22px;
    height: 22px;
}

.module-card-body h3 {
    margin-bottom: 4px;

    font-size: 1rem;
    font-weight: 700;
}

.module-card-body p {
    color: var(--color-text-secondary);

    font-size: 0.83rem;
    line-height: 1.45;
}

.module-card-action {
    margin-top: auto;

    display: inline-flex;

    align-items: center;

    gap: 6px;

    color: var(--color-primary);

    font-size: 0.85rem;
    font-weight: 700;
}

.module-card-action svg {
    width: 15px;
    height: 15px;

    transition: transform 0.15s ease;
}

a.module-card:hover .module-card-action svg {
    transform: translateX(3px);
}

.module-card-disabled {
    cursor: default;

    opacity: 0.68;
}

.module-card-disabled .module-card-icon {
    background: var(--color-background);
    color: var(--color-text-secondary);
}

.module-card-badge-soon {
    align-self: flex-start;

    padding: 3px 9px;

    border-radius: var(--radius-full);

    background: var(--color-background);

    color: var(--color-text-muted);

    font-size: 0.7rem;
    font-weight: 700;
}

/* Reservado para indicação futura de notificação/pendência em um módulo
   (ex.: solicitações pendentes no Scanntech). Não usado ainda — nenhum
   número/contagem fictício é exibido hoje. */
.module-card-notify {
    position: absolute;
    top: 14px;
    right: 14px;

    min-width: 18px;
    height: 18px;

    padding: 0 5px;

    display: flex;

    align-items: center;
    justify-content: center;

    border-radius: var(--radius-full);

    background: var(--color-danger);

    color: #fff;

    font-size: 0.68rem;
    font-weight: 700;
}

@media (max-width: 767px) {
    .module-grid {
        grid-template-columns: 1fr;
    }
}
