/* --- 1. Importação da Fonte e Definição de Variáveis --- */

/* Importa a fonte 'Poppins' do Google Fonts para um visual mais moderno */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
    --color-primary: #4f46e5; /* Anil moderno */
    --color-primary-hover: #4338ca;
    --color-danger: #ef4444;
    --color-danger-hover: #dc2626;
    --color-success: #22c55e;
    --color-success-hover: #16a34a;
    --color-secondary: #6c757d;
    --color-background: #f8f9fa; /* Cinza muito claro */
    --color-surface: #ffffff; /* Fundo dos elementos */
    --color-border: #dee2e6;
    --color-text-primary: #212529;
    --color-text-secondary: #6c757d;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --border-radius: 8px;
}


/* --- 2. Reset Básico e Estilos Globais --- */

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--color-background);
    color: var(--color-text-primary);
    line-height: 1.6;
}

/* --- 3. Layout Principal e Cabeçalho --- */

.main {
    padding: 2rem;
    max-width: 1400px;
    margin: auto;
}

.content-header {
    background: linear-gradient(90deg, #343a40, #212529);
    color: white;
    padding: 1.5rem 0;
    text-align: center;
    margin-bottom: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
}

.content-header h1 {
    margin: 0;
    font-size: 1.75rem;
    letter-spacing: 1px;
}

/* --- 4. Controles (Busca, Filtros, Botões) --- */

.controls-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.search-bar {
    display: flex;
    gap: 0.5rem;
    flex-grow: 1;
}

input, select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px hsla(243, 80%, 60%, 0.2);
}

button {
    cursor: pointer;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 100px;
    color: white;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.search-bar button {
    background-color: var(--color-secondary);
}

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

.filters {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    background-color: var(--color-surface);
    padding: 1rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex-grow: 1;
}

.filter-group label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

/* --- 5. Tabela de Dados (Desktop) --- */

.table-container {
    background-color: var(--color-surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    overflow-x: auto; /* Garante que funcione em telas médias */
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

thead th {
    background-color: #f9fafb;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background-color: rgba(79, 70, 229, 0.05);
}

.btn-delete {
    background-color: var(--color-danger);
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-salvar-responsavel {
    background-color: var(--color-success);
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* --- 6. Modal de Adição --- */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(17, 24, 39, 0.6);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal {
    background-color: var(--color-surface);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    width: 90%;
    max-width: 450px;
}

.modal h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    text-align: center;
}

#formAdicionar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.modal-actions button {
    flex: 1;
}

/* Adicione este novo bloco no final da seção do Modal */
.modal-actions .btn-primary {
    background-color: var(--color-primary);
}

.modal-actions .btn-primary:hover {
    background-color: var(--color-primary-hover);
}

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

/* --- 7. Estilos para o campo de Responsável de Saída --- */

/* Esconde o elemento quando a classe 'hidden' é aplicada */
.hidden {
    display: none !important;
}

/* Container do responsável de saída */
.container-responsavel-saida {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%; /* Ajuste para preencher o espaço disponível */
    justify-content: flex-end; /* Alinha os elementos à direita */
}

/* Estilo do botão de editar (ícone de lápis) */
.btn-editar-responsavel {
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: 1.25rem;
    padding: 0;
    line-height: 1;
    transform: none; /* Remove a animação do botão global */
    box-shadow: none;
    height: auto;
    width: auto;
}

.btn-editar-responsavel:hover {
    color: var(--color-primary-hover);
}

/* Estilo do campo de edição quando visível */
.edicao-responsavel {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-grow: 1; /* Permite que o container de edição se estenda */
}

.edicao-responsavel input {
    width: 100%; /* Garante que o input preencha o espaço */
    max-width: none;
}

/* Estilo do texto simples */
.responsavel-saida-texto {
    font-weight: 500;
    color: var(--color-text-primary);
    flex-grow: 1; /* Permite que o texto se estenda */
    text-align: right; /* Alinha o texto à direita */
}

/* ############################################# */
/* ###       8. RESPONSIVIDADE PARA CELULAR      ### */
/* ############################################# */

@media (max-width: 800px) {
    .main {
        padding: 1rem;
    }

    .controls-container, .filters {
        flex-direction: column;
        align-items: stretch;
    }

    /* --- Tabela Responsiva (Layout de Cards) --- */

    table thead {
        display: none;
    }

    table, tbody, tr, td {
        display: block;
        width: 100%;
    }

    table tr {
        margin-bottom: 1rem;
        border: 1px solid var(--color-border);
        border-radius: var(--border-radius);
        box-shadow: var(--shadow-sm);
    }
    
    table tbody tr:hover {
        background-color: var(--color-surface); /* Desativa o hover da linha inteira */
    }

    table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 1rem;
        text-align: right;
    }

    table td:last-child {
        border-bottom: none;
    }

    table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--color-text-primary);
        text-align: left;
        margin-right: 1rem;
    }
    
    .container-responsavel-saida {
        flex-direction: row; /* Volta a ser row em mobile */
        justify-content: space-between; /* Espaço entre texto/ícone e input/botão */
        align-items: center;
        gap: 0.5rem;
        width: 100%;
    }

    .edicao-responsavel {
        flex-direction: row;
        justify-content: flex-end;
    }
    
    .edicao-responsavel input {
        text-align: right;
    }
}