/*
 * =========================================
 * CSS COMPARTILHADO - SISTEMA DE DOCUMENTOS
 * =========================================
 * 
 * Este arquivo contém todos os estilos compartilhados entre:
 * - Dashboard administrativo (/dashboard)  
 * - Listagem pública de documentos (/documentos)
 * 
 * IMPORTANTE: Qualquer alteração aqui afeta ambas as páginas!
 * 
 * Criado em: 23/08/2025
 * Autor: Sistema Vade Mecum - Defensoria Pública MT
 */

/* ========================================= */
/* SEÇÃO: LAYOUT PRINCIPAL */
/* ========================================= */

/* Container principal das páginas - compartilhado entre dashboard e documentos públicos */
.main-container {
    max-width: 1750px;
    margin: 0 auto;
    padding: var(--space-6);
}

/* ========================================= */
/* SEÇÃO: BOTÕES BASE */
/* ========================================= */

/* Botão base */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

/* Botão primário */
.btn-primary {
    background: var(--primary-600);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-700);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    color: var(--white);
}

/* Botão secundário */
.btn-secondary {
    background: var(--white);
    color: var(--gray-700);
    border: 2px solid var(--gray-200);
}

.btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
    color: var(--gray-700);
}

/* Botões pequenos */
.btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
    font-weight: 500;
}

/* Cores dos botões pequenos */
.btn-view {
    background: var(--primary-50);
    color: var(--primary-700);
    border: 1px solid var(--primary-200);
}

.btn-view:hover {
    background: var(--primary-100);
    color: var(--primary-800);
}

.btn-edit {
    background: var(--warning-50);
    color: var(--warning-700);
    border: 1px solid var(--warning-200);
}

.btn-edit:hover {
    background: var(--warning-100);
    color: var(--warning-800);
}

.btn-delete {
    background: var(--error-50);
    color: var(--error-700);
    border: 1px solid var(--error-200);
}

.btn-delete:hover {
    background: var(--error-100);
    color: var(--error-800);
}

/* ========================================= */
/* SEÇÃO: BUSCA E FILTROS */
/* ========================================= */

/* Container principal de busca e filtros */
.search-and-filters,
.controls-section {
    display: grid;
    grid-template-columns: 1fr 180px 150px 150px;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
    align-items: end;
}

/* Container de busca */
.search-container {
    position: relative;
    width: 100%;
}

/* Campo de busca */
.search-input {
    width: 100%;
    padding: var(--space-3) var(--space-4) var(--space-3) var(--space-12);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    font-size: var(--text-base);
    transition: all 0.2s ease;
    background: var(--white);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
}

.search-input::placeholder {
    color: var(--gray-400);
}

/* Ícone de busca */
.search-icon {
    position: absolute;
    left: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    pointer-events: none;
}

/* Grupos de filtros */
.filter-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

/* Labels dos filtros */
.filter-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--gray-700);
}

/* Selects de filtros */
.filter-select {
    width: 100%;
    padding: var(--space-3);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    font-size: var(--text-base);
    background: var(--white);
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
}

/* Botão limpar filtros */
.clear-filters {
    grid-column: 1 / -1;
    margin-top: var(--space-4);
    text-align: center;
}

.btn-clear {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--gray-100);
    color: var(--gray-700);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 500;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.btn-clear:hover {
    background: var(--gray-200);
    transform: translateY(-1px);
}

/* ========================================= */
/* SEÇÃO: TABELAS DE DOCUMENTOS */
/* ========================================= */

/* Container da tabela */
.table-container {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    overflow: hidden;
    margin-bottom: var(--space-6);
}

/* Cabeçalho da tabela */
.table-header {
    background: linear-gradient(135deg, var(--primary-50), var(--primary-100));
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--primary-200);
}

.table-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--primary-800);
    margin: 0;
}

.table-subtitle {
    font-size: var(--text-sm);
    color: var(--primary-600);
    margin: var(--space-1) 0 0 0;
}

/* Wrapper interno da tabela - permite scroll horizontal sem afetar header */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: var(--space-4); /* Espaçamento entre header e tabela */
}

/* Tabela principal */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.table thead th {
    background: var(--gray-50);
    padding: var(--space-4) var(--space-6);
    text-align: left;
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}

.table tbody td {
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--gray-100);
    vertical-align: top;
}

.table tbody tr:hover {
    background: var(--gray-25);
}

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

/* Células de descrição com quebra de texto */
.description-cell {
    max-width: 300px;
    word-wrap: break-word;
    white-space: normal;
    line-height: 1.4;
}

/* ========================================= */
/* SEÇÃO: BADGES DE STATUS */
/* ========================================= */

/* Badge base */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Badge Vigente (verde) */
.badge-active {
    background: var(--green-100);
    color: var(--green-800);
    border: 1px solid var(--green-200);
}

/* Badge Em Análise (amarelo) */
.badge-pending {
    background: var(--yellow-100);
    color: var(--yellow-800);
    border: 1px solid var(--yellow-200);
}

/* Badge Revogado (vermelho) */
.badge-revoked {
    background: var(--red-100);
    color: var(--red-800);
    border: 1px solid var(--red-200);
}

/* Badge Suspenso (laranja) */
.badge-suspended {
    background: var(--orange-100);
    color: var(--orange-800);
    border: 1px solid var(--orange-200);
}

/* Badge Alterado (azul) */
.badge-modified {
    background: var(--blue-100);
    color: var(--blue-700);
    border: 1px solid var(--blue-200);
}

/* Badge Inativo (cinza) */
.badge-inactive {
    background: rgba(107, 114, 128, 0.1);
    color: var(--gray-500);
    border: 1px solid var(--gray-200);
}

/* Badge Aviso (vermelho) */
.badge-warning {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-500);
    border: 1px solid var(--error-200);
}

/* ========================================= */
/* SEÇÃO: BOTÕES DE AÇÃO */
/* ========================================= */

/* Container para botões de ação em tabelas */
.action-buttons {
    display: flex;
    gap: var(--space-2);
    justify-content: flex-start;
    align-items: center;
}

/* Ações da tabela (no cabeçalho) */
.table-actions {
    display: flex;
    gap: var(--space-3);
}

/* Container de botões de ação */
.action-buttons {
    display: flex;
    gap: var(--space-1);
    align-items: center;
    flex-wrap: wrap;
}

/* Botões pequenos (sm) */
.btn-sm {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1-5) var(--space-3);
    border-radius: var(--radius-md);
    font-size: var(--text-xs);
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    white-space: nowrap;
}

/* Botão Visualizar */
.btn-view {
    background: var(--blue-100);
    color: var(--blue-700);
    border: 1px solid var(--blue-200);
}

.btn-view:hover {
    background: var(--blue-200);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* Botão Editar */
.btn-edit {
    background: var(--amber-100);
    color: var(--amber-700);
    border: 1px solid var(--amber-200);
}

.btn-edit:hover {
    background: var(--amber-200);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* Botão Excluir */
.btn-delete {
    background: var(--red-100);
    color: var(--red-700);
    border: 1px solid var(--red-200);
}

.btn-delete:hover {
    background: var(--red-200);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* Botão PDF específico para documentos públicos */
.pdf-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 32px;
    background: var(--red-500);
    color: var(--white);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: var(--text-base);
}

.pdf-button:hover {
    background: var(--red-600);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Link para documentos */
.doc-link {
    color: var(--primary-600);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.doc-link:hover {
    color: var(--primary-700);
    text-decoration: underline;
}

/* ========================================= */
/* SEÇÃO: MODAIS DE CONFIRMAÇÃO */
/* ========================================= */

/* Overlay do modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    animation: modalFadeIn 0.3s ease forwards;
}

/* Container do modal */
.modal-container {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: auto;
    transform: scale(0.9) translateY(20px);
    animation: modalSlideIn 0.3s ease forwards;
}

/* Cabeçalho do modal */
.modal-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--gray-200);
}

.modal-title {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* Corpo do modal */
.modal-body {
    padding: var(--space-6);
}

.modal-text {
    font-size: var(--text-base);
    color: var(--gray-700);
    line-height: 1.6;
    margin-bottom: var(--space-4);
}

.modal-highlight {
    background: var(--yellow-100);
    padding: var(--space-0-5) var(--space-1);
    border-radius: var(--radius-sm);
    font-weight: 600;
}

/* Rodapé do modal */
.modal-footer {
    padding: var(--space-6);
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: var(--space-3);
    justify-content: end;
}

/* Botões do modal */
.modal-btn {
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

.modal-btn-cancel {
    background: var(--gray-200);
    color: var(--gray-800);
}

.modal-btn-cancel:hover {
    background: var(--gray-300);
}

.modal-btn-delete {
    background: var(--red-600);
    color: var(--white);
}

.modal-btn-delete:hover {
    background: var(--red-700);
}

/* ========================================= */
/* SEÇÃO: ESTADOS VAZIOS */
/* ========================================= */

/* Container para quando não há resultados */
.empty-state,
.no-results {
    text-align: center;
    padding: var(--space-12) var(--space-6);
    color: var(--gray-600);
}

.empty-icon,
.no-results-icon {
    font-size: 4rem;
    color: var(--gray-300);
    margin-bottom: var(--space-4);
}

.empty-state h3,
.no-results h3 {
    font-size: var(--text-lg);
    color: var(--gray-700);
    margin-bottom: var(--space-2);
}

.empty-state p,
.no-results p {
    color: var(--gray-500);
    margin-bottom: var(--space-6);
}

/* ========================================= */
/* SEÇÃO: RESPONSIVIDADE */
/* ========================================= */

/* Tablets (768px - 1024px) */
@media (max-width: 1024px) {
    .search-and-filters,
    .controls-section {
        grid-template-columns: 1fr 180px 180px;
        gap: var(--space-3);
    }
    
    .table {
        font-size: var(--text-xs);
    }
    
    .table thead th,
    .table tbody td {
        padding: var(--space-3) var(--space-4);
    }
    
    .description-cell {
        max-width: 250px;
    }
}

/* Dispositivos móveis (max 768px) */
@media (max-width: 768px) {
    .search-and-filters,
    .controls-section {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }
    
    .filter-group {
        grid-column: 1;
    }
    
    .search-input {
        padding: var(--space-3) var(--space-4) var(--space-3) var(--space-10);
        font-size: var(--text-sm);
    }
    
    .filter-select {
        padding: var(--space-3);
        font-size: var(--text-sm);
    }
    
    .table-container {
        margin: 0 var(--space-2); /* Margem pequena mas presente */
        border-radius: var(--radius-md);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        min-width: 600px;
    }
    
    /* Wrapper da tabela em mobile */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-top: var(--space-3); /* Menos espaço em mobile */
    }
    
    .table-header {
        padding: var(--space-3) var(--space-4);
        margin: 0; /* Remove margem que pode estar causando problemas */
        word-wrap: break-word;
    }
    
    .table-title {
        font-size: var(--text-base); /* Menor em mobile */
        margin: 0;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: var(--space-1);
        align-items: stretch;
    }
    
    .btn-sm {
        justify-content: center;
        padding: var(--space-2) var(--space-3);
    }
    
    .modal-container {
        width: 95%;
        margin: var(--space-4);
    }
    
    .modal-footer {
        flex-direction: column-reverse;
    }
    
    .modal-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Dispositivos muito pequenos (max 480px) */
@media (max-width: 480px) {
    .controls-section,
    .search-and-filters {
        gap: var(--space-3);
        margin-bottom: var(--space-4);
    }
    
    .search-input {
        padding: var(--space-2) var(--space-3) var(--space-2) var(--space-8);
        font-size: var(--text-xs);
    }
    
    .search-input::placeholder {
        font-size: var(--text-xs);
    }
    
    .search-icon {
        left: var(--space-3);
        font-size: var(--text-xs);
    }
    
    .filter-select {
        padding: var(--space-2);
        font-size: var(--text-xs);
    }
    
    .filter-label {
        font-size: var(--text-xs);
    }
    
    .table thead th,
    .table tbody td {
        padding: var(--space-2) var(--space-3);
    }
    
    .description-cell {
        max-width: 200px;
        font-size: var(--text-xs);
    }
    
    .badge {
        font-size: 10px;
        padding: var(--space-0-5) var(--space-2);
    }
    
    /* Melhorias específicas da tabela para mobile pequeno */
    .table-container {
        margin: 0 var(--space-1); /* Margem ainda menor */
        border-radius: var(--radius-sm);
    }
    
    .table-header {
        padding: var(--space-2) var(--space-3);
    }
    
    .table-title {
        font-size: var(--text-sm);
        line-height: 1.2;
    }
    
    .table-subtitle {
        font-size: var(--text-xs) !important;
    }
    
    /* Wrapper da tabela em mobile muito pequeno */
    .table-wrapper {
        margin-top: var(--space-2); /* Espaço mínimo */
    }
    
    .empty-state,
    .no-results {
        padding: var(--space-8) var(--space-4);
    }
}

/* ========================================= */
/* SEÇÃO: ANIMAÇÕES */
/* ========================================= */

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modalSlideIn {
    from {
        transform: scale(0.9) translateY(20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* Animação de loading para filtros AJAX */
.table-container.loading {
    position: relative;
    pointer-events: none;
}

.table-container.loading:after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.table-container.loading:before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid var(--primary-200);
    border-top: 3px solid var(--primary-600);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 11;
}

/* Scrollbar customizada para tabelas */
.table-container::-webkit-scrollbar {
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: var(--gray-100);
}

.table-container::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: var(--radius-full);
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}