/* ========================================= */
/* PREMIUM CSS - SIDEBAR & FROTA             */
/* ========================================= */

/* --- BARRA LATERAL (ALERTAS) --- */
.premium-sidebar-card {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.04);
    border-radius: 14px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    overflow: hidden;
    position: relative;
    margin-bottom: 12px;
}
.premium-sidebar-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 25px rgba(13, 110, 253, 0.12);
    border-color: rgba(13, 110, 253, 0.15);
}
.premium-sidebar-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--premium-accent) 0%, rgba(255,255,255,0) 100%);
    border-radius: 14px 0 0 14px;
}

/* Paleta Premium */
.premium-accent-blue { --premium-accent: #0d6efd; }
.premium-accent-orange { --premium-accent: #fd7e14; }
.premium-accent-red { --premium-accent: #dc3545; }
.premium-accent-green { --premium-accent: #198754; }

.premium-icon-box {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.06);
    flex-shrink: 0;
}
.premium-section-title {
    font-size: 0.75rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: 800;
    color: #495057;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
}
.premium-section-title i { margin-right: 8px; font-size: 0.9rem; }

/* --- CARDS DA FROTA --- */
.fleet-card-premium {
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid rgba(0,0,0,0.05);
}
.fleet-card-premium:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0,0,0,0.1) !important;
}

.placa-mercosul {
    background: #ffffff;
    border: 2px solid #343a40;
    border-top: 5px solid #0d6efd;
    border-radius: 6px;
    font-family: 'Courier New', Courier, monospace;
    font-weight: 900;
    letter-spacing: 2px;
    padding: 2px 10px;
    display: inline-block;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    color: #212529;
}

.action-dock {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 4px;
    display: flex;
    justify-content: space-between;
    border: 1px solid rgba(0,0,0,0.05);
}
.action-dock .btn {
    border-radius: 8px;
    border: none;
    transition: all 0.2s;
    background: transparent;
    color: #6c757d;
}
.action-dock .btn:hover {
    background: #ffffff;
    color: #0d6efd;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transform: scale(1.05);
}
.action-dock .btn.btn-vistoria:hover { color: #198754; }
.action-dock .btn.btn-revisao:hover { color: #fd7e14; }
.action-dock .btn.btn-avaria:hover { color: #dc3545; }

/* ========================================================================= */
/* 🚀 DESIGN PREMIUM 5.1: RELATÓRIOS E INVENTÁRIO (CORRIGIDO)                */
/* ========================================================================= */

#relatorios {
    background-color: var(--bg-app, #F3F4F6);
    padding-bottom: 3rem;
}

/* Painéis Brancos Superiores */
.saas-panel {
    background: #FFFFFF;
    border-radius: 24px;
    box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.05);
    border: 1px solid rgba(226, 232, 240, 0.8);
    padding: 1.5rem 2rem;
    height: 100%;
}

.saas-panel-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: #0F172A;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* Filtros Estilo "Stripe/Vercel" (CORRIGIDO: Sem espremer texto) */
.saas-filter-box {
    background: #F8FAFC; /* Fundo leve para definir a área de clique */
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    padding: 8px 12px; /* Respiro interno devolvido */
    transition: all 0.2s ease;
}
.saas-filter-box:hover {
    border-color: #CBD5E1;
    background: #FFFFFF;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}
.saas-filter-box:focus-within {
    background: #FFFFFF;
    border-color: var(--point-orange, #FF6B00);
    box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.15);
}
.saas-filter-label {
    font-size: 0.65rem;
    font-weight: 800;
    color: #64748B;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}
/* Filtros Estilo "Stripe/Vercel" (CORREÇÃO DO ALINHAMENTO DO SELECT) */
.saas-filter-box select.form-select,
.saas-filter-box input.form-control {
    border: none !important;
    background-color: transparent !important;
    box-shadow: none !important;
    padding: 0 0 0 8px !important; /* <-- A MÁGICA TÁ AQUI (Desgruda o texto da esquerda) */
    font-weight: 600;
    font-size: 0.95rem;
    color: #0F172A;
    cursor: pointer;
    width: 100%;
}

/* Dá um respiro luxuoso nas opções que abrem na lista */
.saas-filter-box select.form-select option {
    padding: 10px 15px; 
    font-weight: 500;
}

/* Área de Bipagem Clean */
.saas-clean-batch {
    background: #F8FAFC;
    border: 1px dashed #CBD5E1;
    border-radius: 16px;
    padding: 1.2rem;
    transition: all 0.3s;
}
.saas-clean-batch:focus-within {
    background: #FFFFFF;
    border-color: var(--point-orange, #FF6B00);
    border-style: solid;
    box-shadow: 0 4px 15px rgba(255, 107, 0, 0.1);
}
.saas-clean-batch textarea {
    background: transparent;
    border: none;
    color: #334155;
    font-family: 'Courier New', Courier, monospace;
    font-weight: 600;
    font-size: 0.9rem;
    resize: none;
    box-shadow: none !important;
    outline: none !important;
}

/* ========================================================================= */
/* 🧩 EFEITO UAU: BENTO GRID EXPLICATIVO (DASHBOARD)                         */
/* ========================================================================= */
.inventory-bento-grid {
    display: grid;
    /* Ajustado para cards um pouco maiores e confortáveis para o texto */
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    padding-top: 5px;
}

.bento-card {
    background: #ffffff;
    border: 1px solid #E2E8F0;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.03);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}
.bento-card:hover {
    border-color: #3B82F6;
    box-shadow: 0 12px 20px -5px rgba(59, 130, 246, 0.15);
    transform: translateY(-3px);
}

.bento-model-name {
    font-size: 0.8rem;
    font-weight: 800;
    color: #0F172A;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #F1F5F9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bento-label {
    font-size: 0.6rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
    display: block;
}

.bento-total-number {
    font-size: 1.8rem;
    font-weight: 900;
    color: #0F172A;
    line-height: 1;
    margin-bottom: 16px;
    letter-spacing: -1px;
}

.bento-footer {
    display: flex;
    justify-content: space-between;
    background: #F8FAFC;
    border-radius: 8px;
    padding: 8px 10px;
    margin-top: auto; /* Empurra pro final do card */
}

.bento-stat {
    display: flex;
    flex-direction: column;
}
.bento-stat-val {
    font-size: 0.85rem;
    font-weight: 800;
}
.text-matriz { color: #10B981; }
.text-transf { color: #0EA5E9; }

/* Tabela de Inventário Flutuante */
.saas-table-wrapper { background: transparent; overflow: visible !important; }
.table-responsive { overflow: visible !important; }
.saas-table { border-spacing: 0 10px; border-collapse: separate; margin-top: -10px; }
.saas-table thead th { border: none; font-size: 0.7rem; font-weight: 800; color: #64748B; text-transform: uppercase; letter-spacing: 1px; padding: 0 1.5rem 0.5rem 1.5rem; }
.saas-table tbody tr { background: #ffffff; box-shadow: 0 2px 5px rgba(0,0,0,0.02); border-radius: 16px; transition: all 0.2s ease; position: relative; z-index: 1; }
.saas-table tbody tr:hover { transform: translateY(-3px); box-shadow: 0 10px 15px -3px rgba(15, 23, 42, 0.08); z-index: 50; }
.saas-table tbody td { padding: 1rem 1.5rem; vertical-align: middle; border-top: 1px solid #F1F5F9; border-bottom: 1px solid #F1F5F9; color: #334155; font-weight: 500; }
.saas-table tbody td:first-child { border-left: 1px solid #F1F5F9; border-top-left-radius: 16px; border-bottom-left-radius: 16px; }
.saas-table tbody td:last-child { border-right: 1px solid #F1F5F9; border-top-right-radius: 16px; border-bottom-right-radius: 16px; }

/* 🌟 MENU DE AÇÕES INTELIGENTE (Hover Dropdown) */
.action-dropdown-wrapper { position: relative; display: inline-block; }
.btn-action-trigger { background: #F8FAFC; border: 1px solid #E2E8F0; color: #475569; font-weight: 700; font-size: 0.8rem; padding: 8px 16px; border-radius: 50rem; transition: all 0.2s; }
.action-dropdown-wrapper:hover .btn-action-trigger { background: #0F172A; color: #ffffff; border-color: #0F172A; }
.action-dropdown-menu { position: absolute; right: 0; top: 110%; background: #ffffff; border: 1px solid #E2E8F0; border-radius: 12px; box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1); min-width: 180px; opacity: 0; visibility: hidden; transform: translateY(-10px); transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); z-index: 1000; padding: 8px; }
.action-dropdown-wrapper:hover .action-dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.action-dropdown-menu button { display: flex; align-items: center; width: 100%; padding: 8px 12px; background: transparent; border: none; border-radius: 8px; font-size: 0.8rem; font-weight: 600; color: #334155; transition: all 0.15s; text-align: left; }
.action-dropdown-menu button i { width: 20px; text-align: center; margin-right: 8px; font-size: 0.9rem; }
.action-dropdown-menu button:hover { background: #F1F5F9; color: #0F172A; }
.action-dropdown-menu button.text-warning:hover { background: #FFF7ED; color: #C2410C !important; }
.action-dropdown-menu button.text-danger:hover { background: #FEF2F2; color: #DC2626 !important; }

/* Botões de Ação Global (Exportar, Baixa) */
.btn-action-premium { background: var(--point-orange); color: white; border-radius: 50rem; font-weight: 600; padding: 6px 16px; border: none; box-shadow: 0 4px 6px rgba(255, 107, 0, 0.2); }
.btn-action-premium:hover { background: #EA580C; color: white; transform: translateY(-1px); box-shadow: 0 6px 10px rgba(255, 107, 0, 0.3); }

/* Mágica Mobile */
@media (max-width: 991px) {
    .saas-table thead { display: none; }
    .saas-table tbody tr { display: block; padding: 1rem; margin-bottom: 1rem; }
    .saas-table tbody td { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0; border: none !important; border-bottom: 1px dashed #E2E8F0 !important; }
    .saas-table tbody td:last-child { border-bottom: none !important; margin-top: 0.5rem; }
    .saas-table tbody td::before { content: attr(data-label); font-weight: 800; font-size: 0.7rem; color: #64748B; text-transform: uppercase; }
}

/* ========================================================================= */
/* 📜 HISTÓRICO GLOBAL EM TABELA INTELIGENTE (SEM SCROLL HORIZONTAL)         */
/* ========================================================================= */

.history-filter-box {
    background: #F8FAFC; border: 1px solid #E2E8F0; border-radius: 12px; padding: 12px 16px;
}
.history-filter-box label {
    font-size: 0.75rem; font-weight: 800; color: #64748B; text-transform: uppercase; letter-spacing: 0.5px;
}

/* Arrumando o input de data para o botão "X" não invadir o calendário */
.history-date-wrapper {
    display: flex; gap: 8px; align-items: center;
}
.history-date-wrapper input {
    flex-grow: 1; border: 1px solid #CBD5E1; border-radius: 8px; padding: 6px 12px;
    font-weight: 600; color: #0F172A; outline: none; transition: 0.2s;
}
.history-date-wrapper input:focus {
    border-color: #3B82F6; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.history-date-wrapper button {
    background: #FEE2E2; color: #DC2626; border: none; border-radius: 8px;
    width: 36px; height: 36px; display: flex; justify-content: center; align-items: center;
    transition: 0.2s; cursor: pointer;
}
.history-date-wrapper button:hover { background: #FECACA; transform: scale(1.05); }

/* Tabela Premium Legível */
.table-history-premium {
    width: 100%; border-collapse: separate; border-spacing: 0;
}
.table-history-premium thead th {
    background: #0F172A; color: #FFFFFF; font-size: 0.75rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px; padding: 12px 16px;
    border: none; position: sticky; top: 0; z-index: 10;
}
.table-history-premium tbody tr {
    transition: all 0.2s; background: #FFFFFF;
}
.table-history-premium tbody tr:nth-child(even) {
    background: #F8FAFC; /* Efeito zebrado super suave */
}
.table-history-premium tbody tr:hover {
    background: #F1F5F9;
}
.table-history-premium tbody td {
    padding: 12px 16px; border-bottom: 1px solid #E2E8F0; vertical-align: middle;
    font-size: 0.85rem; color: #334155; font-weight: 500;
}

/* Coluna de Detalhes com limite para não estourar a tela */
.td-details {
    max-width: 300px; white-space: normal; line-height: 1.4;
}

/* Os Chips Mágicos de Lote de Seriais */
.serial-chip-group {
    display: flex; flex-wrap: wrap; gap: 6px;
}
.serial-chip {
    background: #EFF6FF; border: 1px solid #BFDBFE; color: #1D4ED8;
    font-family: 'Courier New', Courier, monospace; font-weight: 700; font-size: 0.8rem;
    padding: 4px 8px; border-radius: 6px;
}

/* ========================================================================= */
/* 📱 CARDS EMPILHADOS COMPACTOS E ESTREITOS (PADRÃO PERFEITO)               */
/* ========================================================================= */
@media (max-width: 768px) {
    /* Mantém a tabela empilhada verticalmente, mas com largura enxuta */
    #forecast-table-container table, 
    #forecast-table-container thead, 
    #forecast-table-container tbody, 
    #forecast-table-container th, 
    #forecast-table-container td, 
    #forecast-table-container tr {
        display: block !important;
        width: 100% !important;
    }
    
    #forecast-table-container thead {
        display: none !important;
    }
    
    /* Cada linha vira um card individual, mais compacto e estreito */
    #forecast-table-container tr {
        background: #ffffff !important;
        border: 1px solid #E2E8F0 !important;
        border-radius: 14px !important;
        margin-bottom: 12px !important;
        padding: 12px 14px !important;
        box-shadow: 0 2px 5px rgba(0,0,0,0.02);
    }
    
    /* EXibe TODAS as colunas em formato de lista limpa e legível */
    #forecast-table-container td {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 6px 0 !important;
        border: none !important;
        font-size: 0.85rem !important;
    }
    
    /* Nome do Modelo em destaque no topo do card */
    #forecast-table-container td:first-child {
        font-size: 1rem !important;
        font-weight: 800 !important;
        color: #0F172A !important;
        border-bottom: 1px solid #F1F5F9 !important;
        padding-bottom: 8px !important;
        margin-bottom: 6px !important;
    }
    #forecast-table-container td:first-child::before {
        content: "Modelo";
        font-size: 0.65rem;
        color: #64748B;
        text-transform: uppercase;
        font-weight: 700;
    }

    /* Rótulos automáticos para TODAS as informações voltarem a aparecer */
    #forecast-table-container td:nth-child(2)::before { content: "Estoque Atual:"; font-size: 0.75rem; color: #64748B; font-weight: 600; }
    #forecast-table-container td:nth-child(3)::before { content: "Saída (Mês):"; font-size: 0.75rem; color: #64748B; font-weight: 600; }
    #forecast-table-container td:nth-child(4)::before { content: "Média Diária:"; font-size: 0.75rem; color: #64748B; font-weight: 600; }
    
    /* Linha final da Previsão destacada */
    #forecast-table-container td:last-child {
        border-top: 1px dashed #E2E8F0 !important;
        padding-top: 10px !important;
        margin-top: 6px !important;
    }
    #forecast-table-container td:last-child::before { 
        content: "Previsão (Fôlego):"; 
        font-size: 0.75rem; 
        color: #0F172A; 
        font-weight: 700; 
        text-transform: uppercase;
    }
}

/* ========================================================================= */
/* 🛠️ CORREÇÃO DEFINITIVA: MENUS (DROPDOWNS) CORTADOS (ISOLADA)              */
/* ========================================================================= */

/* 1. Garante que APENAS os painéis brancos premium não cortem os menus */
.saas-panel,
.dashboard-main-content {
    overflow: visible !important;
}

/* 2. No PC, desligamos o limite apenas das tabelas premium para o menu flutuar */
@media (min-width: 992px) {
    .saas-table-wrapper {
        overflow: visible !important;
    }
}

/* 3. Garante altura mínima APENAS nas tabelas premium */
.saas-table-wrapper {
    min-height: 250px !important;
}

/* 4. No Celular, mantemos o scroll pro lado nas tabelas premium com folga no fundo */
@media (max-width: 991px) {
    .saas-table-wrapper {
        padding-bottom: 120px !important; 
    }
}

/* Efeito suave ao abrir e Z-Index Supremo mantidos globais (são seguros) */
.dropdown-menu,
.action-dropdown-menu {
    animation: fadeInDropdown 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    box-shadow: 0 15px 35px -5px rgba(0,0,0,0.15) !important;
    border-radius: 12px !important;
    border: 1px solid #E2E8F0 !important;
    z-index: 9999 !important;
}

@keyframes fadeInDropdown {
    0% { opacity: 0; transform: translateY(-5px) scale(0.98); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* ========================================================================= */
/* 🛠️ CORREÇÃO: TABELAS VAZANDO NOS CADASTROS E CONFIGURAÇÕES                */
/* ========================================================================= */

#config .table-responsive {
    /* Força a criação da barra de rolagem vertical se a tabela passar do limite */
    overflow-y: auto !important; 
    overflow-x: auto !important;
    
    /* Dá um respiro para a paginação não ficar grudada na tabela */
    margin-bottom: 10px !important; 
    
    /* Deixa a barra de rolagem mais elegante (estilo Mac/Premium) */
    scrollbar-width: thin;
}

/* Customização da barra de rolagem só para essas tabelas internas */
#config .table-responsive::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
#config .table-responsive::-webkit-scrollbar-track {
    background: #f1f5f9; 
    border-radius: 10px;
}
#config .table-responsive::-webkit-scrollbar-thumb {
    background: #cbd5e1; 
    border-radius: 10px;
}
#config .table-responsive::-webkit-scrollbar-thumb:hover {
    background: #94a3b8; 
}

/* --- Estilos da Tela de Requisições --- */

/* Fundo geral da seção para destacar os cards */
#minhas-requisicoes {
    background-color: #f8f9fa; /* Cinza bem claro, como nas referências */
    min-height: 100vh;
    padding: 1rem;
}

/* Header Escuro (Inspirado na Referência 3) */
.dark-header {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: white;
    border: 1px solid rgba(255,255,255,0.1);
}

/* Estilo do Switch (Toggle) */
.form-check-input:checked {
    background-color: #10b981; /* Verde de sucesso */
    border-color: #10b981;
}
.form-check-input {
    background-color: #e2e8f0;
    border-color: #cbd5e1;
}

/* Cards de Requisição (Inspirado na Referência 1) */
.requisicao-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background: #ffffff;
    border: 1px solid #e9ecef !important;
}

.requisicao-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.08) !important;
    border-color: #dee2e6 !important;
}

/* Caixa de ícone dentro do card */
.icon-box {
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #eff6ff !important; /* Azul bem claro */
    color: #3b82f6 !important; /* Azul primário */
}

/* Badges (Pendente, Aprovado, etc) */
.badge.bg-warning-subtle {
    background-color: #fef3c7 !important;
    color: #d97706 !important;
}
.badge.bg-success-subtle {
    background-color: #d1fae5 !important;
    color: #059669 !important;
}

/* Botões arredondados (Pill) */
.btn-outline-primary {
    border-color: #3b82f6;
    color: #3b82f6;
}
.btn-outline-primary:hover {
    background-color: #3b82f6;
    color: white;
}

/* Ajuste para o container de loading */
#minhas-requisicoes-container .spinner-border {
    width: 3rem;
    height: 3rem;
}