/* Modern & Dynamic Dark Premium CSS - Sefaz XML */
:root {
    --bg-color: #090d16;
    --card-bg: rgba(17, 24, 39, 0.65);
    --card-hover-bg: rgba(24, 32, 53, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(99, 102, 241, 0.3);
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --accent-color: #a855f7;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    
    --success-bg: rgba(16, 185, 129, 0.12);
    --success-text: #34d399;
    --success-glow: rgba(16, 185, 129, 0.25);
    
    --warning-bg: rgba(245, 158, 11, 0.12);
    --warning-text: #fbbf24;
    --warning-glow: rgba(245, 158, 11, 0.25);
    
    --danger-bg: rgba(239, 68, 68, 0.12);
    --danger-text: #f87171;
    
    --info-bg: rgba(14, 165, 233, 0.12);
    --info-text: #38bdf8;
    --info-glow: rgba(14, 165, 233, 0.25);
}

/* Reset Geral */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    background-attachment: fixed;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(168, 85, 247, 0.05) 0%, transparent 40%);
}

/* Animação de Entrada */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Barra Superior - Navegação */
.top-nav {
    background: rgba(9, 13, 22, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo h1 {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 1.5rem;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.logo span {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-icon {
    font-size: 1.75rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.animate-glow {
    animation: pulse-glow 3s infinite alternate ease-in-out;
}

@keyframes pulse-glow {
    0% { filter: drop-shadow(0 0 2px rgba(99, 102, 241, 0.2)); }
    100% { filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.6)); }
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.user-welcome {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
    padding-right: 0.5rem;
}

/* Área de Conteúdo Principal */
.main-content {
    flex: 1;
    max-width: 96%;
    margin: 0 auto;
    width: 100%;
    padding: 2rem 1.5rem;
}

/* Cabeçalho da Página */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.25rem;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.header-titles h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-main);
    margin-bottom: 0.35rem;
}

.header-titles p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Botões Modernos */
.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
    filter: brightness(1.15);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    border-radius: 0.5rem;
    background: rgba(239, 68, 68, 0.08);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.15);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.btn-full {
    width: 100%;
    margin-top: 1rem;
    padding: 0.85rem;
}

.btn-action.disabled, button:disabled {
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: var(--border-color) !important;
    color: rgba(255, 255, 255, 0.25) !important;
    cursor: not-allowed;
    box-shadow: none !important;
    transform: none !important;
}

/* Grade de Estatísticas / Métricas */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.metric-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}

.metric-card.active {
    border-color: var(--primary-color);
    background-color: var(--card-hover-bg);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.25);
}

.metric-card:hover {
    transform: translateY(-5px);
    border-color: var(--border-hover);
    background-color: var(--card-hover-bg);
    box-shadow: 0 15px 30px rgba(99, 102, 241, 0.08);
}

.metric-icon {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

.metric-content h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.metric-value {
    font-family: 'Outfit', sans-serif;
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.1;
}

/* Barra de Filtros e Pesquisa */
.search-bar-container {
    margin-bottom: 2rem;
}

.search-filters {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-input-wrapper {
    position: relative;
    flex: 1;
    min-width: 290px;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    transition: color 0.3s;
}

#searchInput {
    width: 100%;
    padding: 0.85rem 1rem 0.85rem 2.75rem;
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    background: var(--card-bg);
    color: var(--text-main);
    backdrop-filter: blur(12px);
    transition: all 0.3s;
    font-family: 'Inter', sans-serif;
}

#searchInput:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--card-hover-bg);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.filter-input {
    width: 100%;
    padding: 0.85rem 1rem;
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    background: var(--card-bg);
    color: var(--text-main);
    backdrop-filter: blur(12px);
    transition: all 0.3s;
    font-family: 'Inter', sans-serif;
}
.filter-input.with-icon {
    padding-left: 2.75rem;
}
.filter-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--card-hover-bg);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}


#searchInput:focus + .search-icon {
    color: var(--primary-color);
}

.company-select {
    padding: 0.85rem 1.5rem;
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    background: var(--card-bg);
    color: var(--text-main);
    min-width: 250px;
    outline: none;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.3s;
}

.company-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Tabela de Documentos */
.table-container {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    overflow-x: auto;
    box-shadow: 0 20px 30px rgba(0, 0, 0, 0.3);
    margin-bottom: 2rem;
    position: relative;
    min-height: 250px;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    background: rgba(9, 13, 22, 0.5);
    padding: 1.15rem 1.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

td {
    padding: 1.15rem 1.0rem;
    font-size: 0.9rem;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    transition: background-color 0.2s;
}

td.chave-acesso-cell {
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

td:last-child {
    white-space: nowrap;
}

tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Tags de Status e Tipos */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.tag-success {
    background-color: var(--success-bg);
    color: var(--success-text);
    box-shadow: 0 0 10px rgba(52, 211, 153, 0.05);
}

.tag-warning {
    background-color: var(--warning-bg);
    color: var(--warning-text);
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.05);
}

.tag-info {
    background-color: var(--info-bg);
    color: var(--info-text);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.05);
}

.tag-danger {
    background-color: var(--danger-bg);
    color: var(--danger-text);
}

/* Textos Mono-espaçados */
.mono {
    font-family: 'Fira Code', 'Courier New', Courier, monospace;
    font-size: 0.825rem;
    color: var(--text-muted);
}

/* Paginação */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.page-info {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.pagination-buttons {
    display: flex;
    gap: 0.65rem;
}

.pagination-buttons button {
    padding: 0.65rem 1.15rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.65rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Outfit', sans-serif;
}

.pagination-buttons button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.pagination-buttons button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Estados Vazio e Carregando */
.loading-state, .empty-state {
    padding: 4.5rem;
    text-align: center;
    color: var(--text-muted);
}

.loading-state i {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.empty-state i {
    font-size: 3rem;
    color: rgba(255, 255, 255, 0.05);
    margin-bottom: 1.25rem;
    display: block;
}

.empty-state h3 {
    font-family: 'Outfit', sans-serif;
    color: var(--text-main);
    font-size: 1.35rem;
    margin-bottom: 0.5rem;
}

/* Modais e Formulários */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(4, 6, 12, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeInModal 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-content {
    background: rgba(17, 24, 39, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 1.25rem;
    width: 92%;
    max-width: 820px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6), 
                0 0 0 1px rgba(255, 255, 255, 0.05);
    transform: scale(0.98);
    animation: scaleUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes scaleUp {
    to { transform: scale(1); }
}

.modal-medium {
    max-width: 480px;
}

.modal-large {
    max-width: 900px;
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s, transform 0.2s;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.btn-close:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

.modal-body {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2.25rem;
}

.modal-description {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Tabelas e Wrappers em Modais */
.simple-table-wrapper {
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.01);
}

.simple-table {
    width: 100%;
    border-collapse: collapse;
}

.simple-table th {
    padding: 0.85rem 1rem;
    background: rgba(9, 13, 22, 0.3);
}

.simple-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

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

/* Formulários nos Modais */
.empresa-form-container, .usuario-form-container {
    background: rgba(255, 255, 255, 0.02);
    padding: 1.75rem;
    border-radius: 0.85rem;
    border: 1px solid var(--border-color);
}

.empresas-list h3, .usuarios-list h3, .empresa-form-container h3, .usuario-form-container h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #e2e8f0;
    font-size: 0.875rem;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: #ffffff;
    font-family: inherit;
    font-size: 0.925rem;
    transition: all 0.3s;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    background: rgba(15, 23, 42, 0.8);
}

.form-help-text {
    display: block;
    margin-top: 0.35rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Grid de Form */
.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 600px) {
    .form-grid-2 {
        grid-template-columns: 1fr;
    }
}

/* Layout do Usuário (List / Form lado a lado) */
.user-management-layout {
    display: grid;
    grid-template-columns: 1.25fr 1fr;
    gap: 2rem;
}

@media (max-width: 800px) {
    .user-management-layout {
        grid-template-columns: 1fr;
    }
}

/* Scrollbar Customizada */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.4);
}

/* Utility Hidden */
.hidden {
    display: none !important;
}

/* Responsividade Geral */
@media (max-width: 768px) {
    .top-nav {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        padding: 1.25rem 1rem;
    }
    
    .main-content {
        padding: 1.5rem 1rem;
    }
    
    .content-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .btn-action {
        width: 100%;
    }
}

/* Truncamento e Estilo para Chave de Acesso e Emitente para Evitar Overflow */
.chave-acesso-cell {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.2s;
}

.chave-acesso-cell:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.emitente-cell {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Otimização da Tabela de Documentos */
#docsTable th, #docsTable td {
    padding: 0.75rem 0.5rem !important;
    font-size: 0.85rem !important;
}

/* Viewer Modal Specific Styles (Full Screen) */
.modal-viewer {
    max-width: 100% !important;
    width: 100% !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    margin: 0 !important;
    border: none !important;
    display: flex;
    flex-direction: column;
    overflow: hidden !important;
}

.viewer-tabs {
    display: flex;
    background: rgba(15, 23, 42, 0.6);
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.5rem;
}

.viewer-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    padding: 0.85rem 1.25rem;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.viewer-tab:hover {
    color: var(--text-main);
}

.viewer-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.viewer-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 !important;
    overflow: hidden;
}

.viewer-pane {
    flex: 1;
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
}

#pdfFrame {
    border-radius: 0 !important;
}

.xml-viewer {
    flex: 1;
    margin: 0;
    padding: 1.5rem;
    overflow: auto;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    background: #090d16;
    color: #a7f3d0;
    border-radius: 0 !important;
}


