/*
=================================
  Estilos Gerais e Variáveis
=================================
*/
:root {
    --sidebar-width: 260px;
    --topbar-height: 56px;
    --primary-color: #0d6efd;
    --text-color: #212529;
}

body {
    background-color: #f8f9fa;
    color: var(--text-color);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

h2, .h2 {
    font-size: calc(1.3rem + .6vw);
}

@media (min-width: 1200px) {
    h2, .h2 {
        font-size: 2rem;
    }
}

/*
=================================
  Layout Principal (Sidebar e Conteúdo)
  Abordagem Mobile-First
=================================
*/

/* --- BARRA SUPERIOR (MOBILE) --- */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background-color: #ffffff;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    z-index: 1040;
}

.topbar-title {
    font-weight: 500;
    margin-left: 1rem;
}

/* --- SIDEBAR (MENU LATERAL) --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    z-index: 1050;
    background-color: #fff;
    border-right: 1px solid #dee2e6;
    padding: 1rem 0;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
}

.sidebar.show {
    transform: translateX(0);
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
}

.sidebar-logo {
    display: block;
    max-width: 150px;
    margin: 0 auto 1.5rem auto;
}

.sidebar-item {
    display: flex;
    align-items: center;
    padding: 0.8rem 1.5rem;
    color: #495057;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-item:hover {
    background-color: #e9ecef;
    color: var(--primary-color);
}

.sidebar-item.active {
    background-color: #e9f2ff;
    color: var(--primary-color);
    font-weight: 500;
    border-left-color: var(--primary-color);
}

.submenu-item {
    padding-left: 3rem; /* Adiciona um recuo para itens de submenu */
    font-size: 0.9rem;
    border-left: none !important; /* Remove a borda colorida do item ativo */
}


/* --- CONTEÚDO PRINCIPAL --- */
.main-content {
    padding: 1rem;
    padding-top: calc(var(--topbar-height) + 1rem); /* Espaço para a topbar fixa */
}

/*
=================================
  Ajustes para Telas Maiores (Desktop)
=================================
*/
@media (min-width: 992px) { /* Breakpoint 'lg' do Bootstrap */
    .main-content {
        padding: 2rem;
        margin-left: var(--sidebar-width);
    }

    .sidebar {
        transform: translateX(0);
    }
}

/*
=================================
  Otimizações de Componentes para Telas Menores
=================================
*/

/* --- Indicadores (KPI Cards) --- */
.kpi-card .card-text {
    font-size: 2.5rem; /* Reduz o tamanho da fonte dos números em telas pequenas */
    font-weight: 700;
}

.kpi-card .card-title {
    font-size: 1rem;
}

/* --- Botões e Títulos de Seção --- */
.section-header {
    display: flex;
    flex-direction: column; /* Empilha o título e o botão em telas pequenas */
    align-items: flex-start;
    gap: 0.75rem; /* Adiciona um espaço entre o título e o botão */
    margin-bottom: 1.5rem;
}

.section-header h2 {
    margin-bottom: 0;
}

.section-header > div {
    display: flex;
    width: 100%;
    justify-content: flex-end; /* Alinha os botões à direita em mobile */
}

/* --- Formulários --- */
/* Garante que botões de formulário ocupem a largura total para facilitar o toque */
#form-movimentacao .btn {
    width: 100%;
}

/* --- Tabelas --- */
/* Melhora a legibilidade em tabelas responsivas */
.table-responsive {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
}

/* Garante que o dropdown de ações na tabela seja visível */
.table-responsive {
    overflow-x: auto;
    overflow-y: visible;
}

/* Estilos para o Modal de Ações Mobile */
#actionsModalBody .btn {
    display: flex;
    align-items: center;
    width: 100%;
    text-align: left;
    margin-bottom: 0.5rem;
}
/*
=================================
  Ajustes para Telas Maiores (Desktop) - Continuação
=================================
*/
@media (min-width: 768px) { /* A partir do breakpoint 'md' */
    /* --- Indicadores (KPI Cards) --- */
    .kpi-card .card-text {
        font-size: 3.5rem; /* Retorna ao tamanho original em telas maiores */
    }
    
    /* --- Botões e Títulos de Seção --- */
    /* Alinha o título e o botão lado a lado novamente */
    .section-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .section-header > div {
        width: auto;
        justify-content: flex-start; /* Reseta o alinhamento para desktop */
    }

    /* --- Formulários --- */
    /* Botões de formulário voltam ao tamanho automático */
    #form-movimentacao .btn {
        width: auto;
    }
}

/* --- Estilos para Formulários Compactos --- */
.form-compact .form-label {
    font-size: 0.875rem; /* Fonte menor para os rótulos */
    margin-bottom: 0.25rem; /* Reduz o espaçamento abaixo do rótulo */
}

.form-compact .mb-3 {
    margin-bottom: 0.75rem !important; /* Reduz o espaçamento entre os campos */
}

/* --- Estilos para Tabelas Compactas --- */
.table-compact {
    font-size: 0.875rem; /* Fonte menor para o conteúdo da tabela */
}

/* --- Banner de Instalação do PWA --- */
.pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--primary-color);
    color: #fff;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1060;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
    transform: translateY(100%);
    transition: transform 0.3s ease-in-out;
}

.pwa-install-banner.show {
    transform: translateY(0);
}


/* Ajustes extras para melhor responsividade no dashboard */
canvas {
    max-width: 100% !important;
    height: auto !important;
}

@media (max-width: 576px) {
    .kpi-card .card-text {
        font-size: 1.8rem;
    }
    .pwa-install-banner {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }
    .kpi-card {
        padding: 0.5rem;
    }
}
/* ===== Ajuste para o relatório ocupar a tela inteira no mobile ===== */
@media (max-width: 768px) {
    #relatorios-section {
        margin: 0;
        padding: 0 !important;
        width: 100vw;
    }

    #relatorios-section .card,
    #relatorios-section .card-body,
    #relatorios-section .row,
    #relatorios-section .col-md-3,
    #relatorios-section .col-md-4,
    #relatorios-section .col-md-2 {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
    }

    .main-content {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    #resultado-relatorio {
        padding: 0 0.5rem;
    }
}
/* ===== Alinhamento e proporções da tabela de movimentações ===== */

.table-compact th,
.table-compact td {
    vertical-align: middle !important;
    text-align: center !important;
    white-space: nowrap;
}

/* Primeira coluna (Nº Mov.) mais estreita */
.table-compact th:nth-child(1),
.table-compact td:nth-child(1) {}

/* Item / Equipamento com largura maior e texto à esquerda */
.table-compact th:nth-child(2),
.table-compact td:nth-child(2) {
    text-align: left !important;
    white-space: normal;
}

/* Coluna Data centralizada */
.table-compact th:nth-child(3),
.table-compact td:nth-child(3) {}

/* Setor Solicitante centralizado */
.table-compact th:nth-child(4),
.table-compact td:nth-child(4) {}

/* Motivo com texto à esquerda e largura flexível */
.table-compact th:nth-child(5),
.table-compact td:nth-child(5) {
    text-align: left !important;
}

/* Retorna?, Status, Prazo, Data Retorno centralizados e equilibrados */
.table-compact th:nth-child(6),
.table-compact td:nth-child(6),
.table-compact th:nth-child(7),
.table-compact td:nth-child(7) {}

/* Prazo, Data Retorno */
.table-compact th:nth-child(8), .table-compact td:nth-child(8),
.table-compact th:nth-child(9), .table-compact td:nth-child(9) {}

/* Coluna Ações mais estreita */
.table-compact th:nth-child(10),
.table-compact td:nth-child(10) {
    text-align: center !important;
    width: 60px; /* Mantém uma largura mínima para o botão de ações */
}

/* Ajuste visual geral */
.table-compact { table-layout: auto; width: 100%; border-collapse: collapse; }

.table-compact th {
    background-color: #f8f9fa;
    font-weight: 600;
}

.table-compact td {
    padding: 0.5rem;
    font-size: 0.875rem;
}

/* Melhor visual no mobile */
@media (max-width: 768px) {
    .table-compact {
        font-size: 0.8rem;
    }

    .table-compact td,
    .table-compact th {
        padding: 0.35rem;
    }
}

/* ===== Transforma o texto da tabela em maiúsculas ===== */
.uppercase-table td, .uppercase-table th {
    text-transform: uppercase !important;
    font-weight: 600;
}
