/* =============================================================================
   Sigef - Estilos Globais
   ============================================================================= */

/* Layout base */
html, body.sigef-body-layout {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #f4f5f7;
}

body.sigef-body-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* =============================================================================
   Cabeçalho
   ============================================================================= */
.sigef-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 56px;
    background: #1a73e8;
    color: #ffffff;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.sigef-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sigef-header-logo {
    width: 36px;
    height: 36px;
}

.sigef-logo {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.sigef-subtitle {
    font-size: 0.85rem;
    opacity: 0.85;
}

.sigef-header-right {
    font-size: 0.875rem;
    opacity: 0.9;
}

.sigef-user {
    font-size: 0.875rem;
}

/* =============================================================================
   Wrapper: sidebar + main
   ============================================================================= */
.sigef-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sigef-sidebar {
    width: 220px;
    flex-shrink: 0;
    background: #ffffff;
    border-right: 1px solid #dde1e7;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.sigef-menu {
    width: 100% !important;
    border: none !important;
}

/* Sidebar footer (logout) */
.sigef-sidebar-footer {
    padding: 8px;
    border-top: 1px solid #dde1e7;
}

.sigef-logout-btn,
.sigef-logout-btn.ui-button {
    width: 100% !important;
    background: #e53e3e !important;
    border: none !important;
    font-size: 0.82rem !important;
}

.sigef-logout-btn:hover,
.sigef-logout-btn.ui-button:hover {
    background: #c53030 !important;
}

/* Conteúdo principal */
.sigef-main {
    flex: 1;
    overflow-y: auto;
}

.sigef-content {
    padding: 16px;
}

/* =============================================================================
   Dashboard
   ============================================================================= */

/* Cabeçalho do dashboard */
.dash-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
}

.dash-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.dash-saudacao {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1e293b;
}

.dash-usuario {
    font-size: 0.9rem;
    color: #64748b;
    background: #f1f5f9;
    padding: 3px 10px;
    border-radius: 20px;
}

.dash-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dash-atualizacao {
    font-size: 0.8rem;
    color: #94a3b8;
}

.dash-btn-atualizar.ui-button {
    background: #1a73e8 !important;
    border: none !important;
    border-radius: 6px !important;
    font-size: 0.82rem !important;
}

/* Grid de cards */
.dash-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin-bottom: 20px;
}

/* Card base */
.dash-card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.15s, box-shadow 0.15s;
}

.dash-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}

/* Ícone no topo do card */
.dash-card-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 72px;
}

.dash-icon-espera   { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.dash-icon-planta   { background: linear-gradient(135deg, #22c55e, #4ade80); }
.dash-icon-embarque { background: linear-gradient(135deg, #3b82f6, #60a5fa); }

.dash-card-icon {
    font-size: 2rem !important;
    color: rgba(255,255,255,0.92);
}

/* Corpo do card */
.dash-card-body {
    padding: 16px 20px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.dash-card-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Número grande */
.dash-card-total {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1;
    color: #0f172a;
}

.dash-card-espera   .dash-card-total { color: #b45309; }
.dash-card-planta   .dash-card-total { color: #15803d; }
.dash-card-embarque .dash-card-total { color: #1d4ed8; }

/* Detalhes com linhas coloridas */
.dash-card-detalhes {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 2px;
}

.dash-detalhe {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.82rem;
    color: #475569;
}

.dash-detalhe-cor {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.1);
}

.dash-detalhe-label {
    flex: 1;
}

.dash-detalhe-valor {
    font-weight: 700;
    color: #1e293b;
    min-width: 28px;
    text-align: right;
}

/* Barra proporcional */
.dash-propbar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: #f1f5f9;
    margin-top: 2px;
}

.dash-propbar-seg {
    height: 100%;
    transition: width 0.4s ease;
    min-width: 0;
}

.dash-propbar-ambas       { background: #fde68a; }
.dash-propbar-carga       { background: #fed7aa; }
.dash-propbar-descarga    { background: #bfdbfe; }
.dash-propbar-planta-saida  { background: #bbf7d0; }
.dash-propbar-planta-entrada { background: #86efac; }
.dash-propbar-emb-saida   { background: #93c5fd; }
.dash-propbar-emb-entrada { background: #bfdbfe; }

/* Link "Ver detalhes" */
.dash-card-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #1a73e8;
    text-decoration: none;
    margin-top: 4px;
    transition: gap 0.15s;
}

.dash-card-link:hover {
    gap: 8px;
    text-decoration: underline;
}

/* Faixa resumo consolidado */
.dash-resumo {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 18px 24px;
    gap: 0;
}

.dash-resumo-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.dash-resumo-label {
    font-size: 0.75rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.dash-resumo-valor {
    font-size: 1.9rem;
    font-weight: 800;
    color: #1e293b;
}

.dash-resumo-espera   { color: #b45309; }
.dash-resumo-planta   { color: #15803d; }
.dash-resumo-embarque { color: #1d4ed8; }

.dash-resumo-sep {
    width: 1px;
    height: 48px;
    background: #e2e8f0;
}

/* Responsivo: empilha em telas menores */
@media (max-width: 900px) {
    .dash-cards { grid-template-columns: 1fr; }
}

/* =============================================================================
   Rodapé
   ============================================================================= */
.sigef-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    background: #f5f5f5;
    color: #666;
    font-size: 0.8rem;
    border-top: 1px solid #ddd;
    flex-shrink: 0;
}

/* =============================================================================
   Utilitários
   ============================================================================= */
.mb-3 { margin-bottom: 1rem; }
.text-center { text-align: center; }

/* =============================================================================
   Visão da Logística
   ============================================================================= */

/* Barra superior com título e botão atualizar */
.logistica-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.logistica-titulo {
    font-size: 1.1rem;
    font-weight: 700;
    color: #333;
}

/* Seção (bloco com header + tabela) */
.logistica-secao {
    margin-bottom: 18px;
    border: 1px solid #dde1e7;
    border-radius: 4px;
    overflow: hidden;
}

/* Cabeçalho da seção */
.logistica-secao-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    font-weight: 600;
    font-size: 0.92rem;
}

.logistica-secao-titulo {
    display: flex;
    align-items: center;
    gap: 6px;
}

.logistica-total {
    font-weight: 400;
    font-size: 0.85rem;
    opacity: 0.85;
}

/* Cores dos cabeçalhos de seção */
.espera-header   { background: #f59e0b; color: #fff; }
.planta-header   { background: #22c55e; color: #fff; }
.embarque-header { background: #3b82f6; color: #fff; }


/* Badge de total no cabeçalho da seção */
.logistica-total-badge {
    background: rgba(255,255,255,0.25);
    border-radius: 12px;
    padding: 2px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.5px;
}

/* Barra de legenda dentro do cabeçalho da tabela (f:facet header) */
.tbl-legenda-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 6px 4px;
    font-size: 0.8rem;
    color: #333;
}

.tbl-legenda-titulo {
    font-weight: 700;
    color: #555;
    margin-right: 4px;
}

/* Cada item da legenda: quadradinho colorido + texto + contagem */
.tbl-legenda-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px 3px 6px;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.12);
    font-size: 0.79rem;
}

/* Quadradinho colorido (herda background do pai via row-* classes) */
.tbl-legenda-cor {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    border: 1px solid rgba(0,0,0,0.2);
    flex-shrink: 0;
}

/* Aplica a cor de fundo ao quadradinho conforme a classe do item pai */
.tbl-legenda-item.row-espera-ambas   .tbl-legenda-cor { background: #fde68a; }
.tbl-legenda-item.row-espera-carga   .tbl-legenda-cor { background: #fed7aa; }
.tbl-legenda-item.row-espera-descarga .tbl-legenda-cor { background: #bfdbfe; }
.tbl-legenda-item.row-espera-saida   .tbl-legenda-cor { background: #fef08a; }
.tbl-legenda-item.row-espera-entrada .tbl-legenda-cor { background: #fef9c3; }
.tbl-legenda-item.row-planta-saida   .tbl-legenda-cor { background: #bbf7d0; }
.tbl-legenda-item.row-planta-entrada .tbl-legenda-cor { background: #dcfce7; }
.tbl-legenda-item.row-embarque-saida   .tbl-legenda-cor { background: #bfdbfe; }
.tbl-legenda-item.row-embarque-entrada .tbl-legenda-cor { background: #dbeafe; }

/* Fundo claro nos itens de legenda (não colorido — só o quadradinho é colorido) */
.tbl-legenda-item.row-espera-ambas,
.tbl-legenda-item.row-espera-carga,
.tbl-legenda-item.row-espera-descarga,
.tbl-legenda-item.row-espera-saida,
.tbl-legenda-item.row-espera-entrada,
.tbl-legenda-item.row-planta-saida,
.tbl-legenda-item.row-planta-entrada,
.tbl-legenda-item.row-embarque-saida,
.tbl-legenda-item.row-embarque-entrada {
    background: #fff !important;
}

/* Separador e total à direita */
.tbl-legenda-total {
    margin-left: auto;
    font-size: 0.82rem;
    color: #444;
    white-space: nowrap;
}

/* Tabela */
.logistica-table {
    width: 100%;
    font-size: 0.82rem;
}

/* Scroll horizontal para tabelas com muitas colunas */
.logistica-table-scroll,
.logistica-table-scroll .ui-datatable-tablewrapper {
    overflow-x: auto !important;
}

.logistica-table-scroll table {
    min-width: max-content;
}

/* Células e cabeçalhos não quebram linha */
.logistica-table th,
.logistica-table td,
.logistica-table-scroll th,
.logistica-table-scroll td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Cores das linhas — ESPERA */
.row-espera-saida   td { background-color: #fef08a !important; }
.row-espera-entrada td { background-color: #fef9c3 !important; }
.row-espera-ambas   td { background-color: #fde68a !important; }
.row-espera-carga   td { background-color: #fed7aa !important; }
.row-espera-descarga td { background-color: #bfdbfe !important; }

/* Cores das linhas — PLANTA */
.row-planta-saida   td { background-color: #bbf7d0 !important; }
.row-planta-entrada td { background-color: #dcfce7 !important; }

/* Cores das linhas — EMBARQUE */
.row-embarque-saida   td { background-color: #bfdbfe !important; }
.row-embarque-entrada td { background-color: #dbeafe !important; }

/* Hover nas linhas */
.logistica-table .ui-datatable-even:hover td,
.logistica-table .ui-datatable-odd:hover td,
.logistica-table tr:hover td {
    filter: brightness(0.94);
}

/* Cursor pointer nas tabelas com seleção */
.tbl-selectable .ui-datatable-data tr {
    cursor: pointer;
}

/* =============================================================================
   Dialog — Detalhes Motorista na Planta
   ============================================================================= */

.dlg-planta-grid {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
    font-size: 0.85rem;
}

.dlg-planta-grid td {
    padding: 5px 10px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.dlg-planta-grid tr:last-child td {
    border-bottom: none;
}

.dlg-label {
    font-weight: 700;
    color: #333;
    white-space: nowrap;
    width: 80px;
    background: #f8f9fa;
    font-size: 0.8rem;
}

.dlg-valor {
    color: #222;
    min-width: 70px;
    font-size: 0.85rem;
}

.dlg-obs-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 8px 0 4px;
    border-top: 1px solid #e2e8f0;
}

.dlg-obs-row label {
    font-weight: 600;
    font-size: 0.85rem;
    color: #555;
}

.btn-fechar,
.btn-fechar:hover,
.btn-fechar:focus {
    background-color: #dc2626 !important;
    border-color: #dc2626 !important;
    color: #fff !important;
}

/* =============================================================================
   Barra de Filtros (Orçamentos, Pedidos de Venda, etc.)
   ============================================================================= */

.filtro-panel {
    background: #ffffff;
    border: 1px solid #dde1e7;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 14px;
}

.filtro-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}

.filtro-campo {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.filtro-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #555;
    white-space: nowrap;
}

.filtro-input .ui-inputtext,
.filtro-input.ui-inputtext {
    width: 160px;
}

.filtro-input-sm .ui-inputtext,
.filtro-input-sm.ui-inputtext {
    width: 80px;
}

.filtro-date .ui-inputtext {
    width: 120px;
}

.filtro-acoes {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-left: auto;
}

/* =============================================================================
   Dialog de Detalhe — Orçamentos / Pedidos de Venda
   ============================================================================= */

.dlg-detalhe {
    padding: 4px 0;
}

.dlg-fieldset {
    margin-bottom: 14px;
}

/* =============================================================================
   Loading Overlay Global
   ============================================================================= */
#sigef-loading {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.32);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

#sigef-loading.ativo {
    display: flex;
}

.sigef-loading-box {
    background: #ffffff;
    border-radius: 12px;
    padding: 32px 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.22);
}

.sigef-loading-box span {
    font-size: 0.92rem;
    font-weight: 600;
    color: #444;
    letter-spacing: 0.02em;
}

.sigef-spinner {
    width: 46px;
    height: 46px;
    border: 5px solid #e3ecff;
    border-top-color: #1a73e8;
    border-radius: 50%;
    animation: sigef-spin 0.75s linear infinite;
}

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