/* ========================================
   SISTEMA VÉRTICE - ESTILOS GLOBAIS
   ======================================== */

/* ==========================================
   RESET E CONFIGURAÇÕES BÁSICAS
   ========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ==========================================
   DASHBOARD E LAYOUT PRINCIPAL
   ========================================== */

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f6fa;
    overflow-x: hidden;
}

/* Header fixo */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    z-index: 1000;
    border-bottom: 1px solid #e0e0e0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo {
    height: 45px;
    width: auto;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
    color: #2c3e50;
}

.header-right .user-info {
    text-align: right;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
    color: #2c3e50;
}

.user-email {
    font-size: 12px;
    color: #7f8c8d;
}

.btn-logout {
    padding: 8px 20px;
    background: transparent;
    color: #dc3545;
    border: 2px solid #dc3545;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
}

.btn-logout:hover {
    background: #dc3545;
    color: white;
    transform: translateY(-1px);
}

/* Sidebar fixa */
.sidebar {
    position: fixed;
    top: 70px;
    left: 0;
    width: 260px;
    height: calc(100vh - 70px);
    background: white;
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
    overflow-y: auto;
    z-index: 900;
}

.sidebar-menu {
    list-style: none;
    padding: 15px 0;
}

.menu-item {
    margin: 5px 0;
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 15px 25px;
    color: #2c3e50;
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 15px;
    border-left: 3px solid transparent;
}

.menu-link:hover {
    background: #f8f9fa;
    border-left-color: #0f4c75;
    color: #0f4c75;
}

.menu-link.active {
    background: #e8f4f8;
    border-left-color: #0f4c75;
    color: #0f4c75;
    font-weight: 600;
}

.menu-icon {
    margin-right: 12px;
    font-size: 18px;
}

/* Conteúdo principal */
.main-content {
    margin-left: 260px;
    margin-top: 70px;
    padding: 30px;
    min-height: calc(100vh - 70px);
}

.content-header {
    margin-bottom: 30px;
}

.content-title {
    font-size: 28px;
    color: #2c3e50;
    font-weight: 600;
}

.content-body {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    min-height: 500px;
}

/* Dashboard específico */
.dashboard-welcome {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px;
    border-radius: 12px;
    margin-bottom: 30px;
}

.dashboard-welcome h2 {
    font-size: 32px;
    margin-bottom: 10px;
}

.dashboard-welcome p {
    font-size: 16px;
    opacity: 0.9;
}

/* Scrollbar customizada da sidebar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #0f4c75;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #1b262c;
}

/* Responsivo - Dashboard */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .header-left {
        gap: 10px;
    }

    .logo {
        height: 35px;
    }

    .header-right .user-info {
        display: none;
    }
}

/* ==========================================
   PÁGINAS DE AUTENTICAÇÃO (Login, Solicitar Senha, Definir Senha)
   ========================================== */

.auth-page {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0f4c75 0%, #1b262c 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 440px;
    padding: 50px 40px;
    text-align: center;
}

.logo-container {
    margin-bottom: 40px;
}

.logo-container img {
    max-width: 280px;
    height: auto;
}

/* Títulos e subtítulos nas páginas auth */
.login-container h2 {
    color: #0f4c75;
    margin-bottom: 10px;
    font-size: 24px;
}

.login-container .subtitle {
    color: #666;
    margin-bottom: 30px;
    font-size: 14px;
    line-height: 1.5;
}

.auth-page .form-group {
    margin-bottom: 25px;
    text-align: left;
}

.auth-page .form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
    font-size: 14px;
}

.auth-page .form-group input,
.auth-page .form-group textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    transition: all 0.3s ease;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.auth-page .form-group input:focus,
.auth-page .form-group textarea:focus {
    outline: none;
    border-color: #0f4c75;
    box-shadow: 0 0 0 3px rgba(15, 76, 117, 0.1);
}

.auth-page .form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.btn-login {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #0f4c75 0%, #1b262c 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(15, 76, 117, 0.3);
}

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

.btn-login:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-recuperar {
    width: 100%;
    padding: 14px;
    background: transparent;
    color: #0f4c75;
    border: 2px solid #0f4c75;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 15px;
    text-decoration: none;
    display: inline-block;
}

.btn-recuperar:hover {
    background: #0f4c75;
    color: white;
    transform: translateY(-2px);
}

.btn-voltar {
    width: 100%;
    padding: 14px;
    background: transparent;
    color: #666;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 15px;
    text-decoration: none;
    display: inline-block;
}

.btn-voltar:hover {
    background: #f5f5f5;
    border-color: #999;
    transform: translateY(-2px);
}

.footer-text {
    margin-top: 30px;
    color: #666;
    font-size: 13px;
}

.info-box {
    background: #f8f9fa;
    border-left: 4px solid #0f4c75;
    padding: 15px;
    border-radius: 8px;
    margin-top: 25px;
    text-align: left;
}

.info-box p {
    color: #555;
    font-size: 14px;
    line-height: 1.6;
    margin: 0;
}

.info-box strong {
    display: block;
    margin-bottom: 5px;
    color: #0f4c75;
}

/* Informações do usuário (definir senha) */
.user-info {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 25px;
    text-align: left;
    font-size: 14px;
    line-height: 1.8;
}

.user-info strong {
    color: #0f4c75;
    font-weight: 600;
}

/* Dica de senha */
.password-hint {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

@media (max-width: 480px) {
    .login-container {
        padding: 40px 30px;
    }
    
    .logo-container img {
        max-width: 220px;
    }
}

/* ==========================================
   ALERTAS E MENSAGENS
   ========================================== */

.alert {
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 25px;
    font-size: 14px;
    animation: slideDown 0.3s ease;
}

.alert-error {
    background: #fee;
    color: #c33;
    border: 1px solid #fcc;
}

.alert-success {
    background: #efe;
    color: #3c3;
    border: 1px solid #cfc;
}

.alert-success a {
    color: #0f4c75;
    font-weight: bold;
    text-decoration: underline;
    word-break: break-all;
    display: block;
    margin-top: 10px;
}

.alert-success a:hover {
    color: #1b262c;
}

.alert-warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

.alert-info {
    background: #d1ecf1;
    border: 1px solid #17a2b8;
    color: #0c5460;
}

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

/* ==========================================
   CARDS DE ESTATÍSTICAS
   ========================================== */

.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-number {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 14px;
    opacity: 0.9;
}

/* Variações de cor dos cards */
.stat-card.blue {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
}

.stat-card.green {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
}

.stat-card.orange {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
}

.stat-card.red {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

/* ==========================================
   FILTROS
   ========================================== */

.filters-container {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 30px;
    border: 1px solid #e0e0e0;
}

.filters-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-label {
    font-size: 13px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 6px;
}

.filter-input,
.filter-select {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: white;
}

.filter-input:focus,
.filter-select:focus {
    outline: none;
    border-color: #0f4c75;
    box-shadow: 0 0 0 3px rgba(15, 76, 117, 0.1);
}

.filter-actions {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: #0f4c75;
    color: white;
}

.btn-primary:hover {
    background: #1b262c;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(15, 76, 117, 0.3);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-export {
    background: #27ae60;
    color: white;
}

.btn-export:hover {
    background: #229954;
}

/* ==========================================
   TABELAS
   ========================================== */

.table-container {
    overflow-x: auto;       /* ← rolagem horizontal mantida */
    margin-top: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    /* REMOVIDO: max-height e overflow-y (eliminando scroll interno) */
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 12px;        /* ← REDUZIDO de 14px para 12px */
}

.data-table thead {
    background: #f8f9fa;    
}

.data-table th {
    padding: 10px 8px;      /* ← REDUZIDO levemente */
    text-align: center;
    font-weight: 600;
    color: #2c3e50;
    border-bottom: 2px solid #dee2e6;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.data-table th:hover {
    background: #e9ecef;
}

.data-table td {
    padding: 8px;           /* ← REDUZIDO levemente */
    border-bottom: 1px solid #f0f0f0;
    vertical-align: top;
}

.data-table tbody tr:hover {
    background: #f8f9fa;
}

.data-table tbody tr:nth-child(even) {
    background: #fafafa;
}

.data-table tbody tr:nth-child(even):hover {
    background: #f8f9fa;
}

/* Células específicas */
.valor-cell {
    text-align: right;
    font-weight: 600;
    color: #0f4c75;
}

.data-cell {
    white-space: nowrap;
}

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

.link-cell a {
    color: #0f4c75;
    text-decoration: none;
}

.link-cell a:hover {
    text-decoration: underline;
}

.objeto-cell {
    max-width: 400px;
    line-height: 1.4;
}

/* Células com texto truncado (clicável para expandir) */
.truncate-cell {
    max-width: 300px;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    cursor: pointer;
    position: relative;
    word-break: break-word;
    padding-right: 20px;  /* espaço para o ícone */
    transition: all 0.2s ease;
}

/* Ícone de expandir/colapsar */
.truncate-cell::before {
    content: '▼';
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 10px;
    color: #0f4c75;
    font-weight: 700;
    background: white;
    padding: 2px 4px;
    border-radius: 3px;
    opacity: 0.7;
}

.truncate-cell:hover::before {
    opacity: 1;
    background: #e8f4f8;
}

.truncate-cell.expanded {
    -webkit-line-clamp: unset;
    max-height: none;
    background: #fafafa;
}

.truncate-cell.expanded::before {
    content: '▲';
    color: #dc3545;
}

/* Colunas com largura limitada */
.col-observacao {
    max-width: 280px !important;
    word-break: break-word;
}

.col-licitacao {
    max-width: 200px !important;
    word-break: break-all;
}

.col-objeto {
    max-width: 300px !important;
}

/* ==========================================
   BADGES
   ========================================== */

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-edital {
    background: #e3f2fd;
    color: #1976d2;
}

.badge-contrato {
    background: #f3e5f5;
    color: #7b1fa2;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
}

.badge-info {
    background: #d1ecf1;
    color: #0c5460;
}

/* ==========================================
   GRÁFICOS
   ========================================== */

.charts-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.chart-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    min-height: 280px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
    flex-wrap: wrap;
    gap: 8px;
}

.chart-title {
    font-size: 13px;
    font-weight: 700;
    color: #2c3e50;
    flex: 1;
    text-align: center;
}

.chart-toggle {
    display: flex;
    gap: 5px;
}

.toggle-btn {
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid #ddd;
    border-radius: 20px;
    background: white;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toggle-btn:hover {
    border-color: #0f4c75;
    color: #0f4c75;
}

.toggle-btn.active {
    background: #0f4c75;
    color: white;
    border-color: #0f4c75;
}

.chart-canvas {
    flex: 1;
    max-height: 220px;
}

@media (max-width: 768px) {
    .charts-container {
        grid-template-columns: 1fr;
    }
}

/* ==========================================
   PAGINAÇÃO
   ========================================== */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 25px;
    padding: 20px;
}

.pagination-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.pagination-btn:hover:not(:disabled) {
    background: #0f4c75;
    color: white;
    border-color: #0f4c75;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-btn.active {
    background: #0f4c75;
    color: white;
    border-color: #0f4c75;
}

.pagination-info {
    font-size: 14px;
    color: #666;
}

.pagination-dots {
    padding: 8px;
    color: #999;
    font-weight: bold;
}

/* ==========================================
   MENSAGENS DE ESTADO
   ========================================== */

.no-data {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.no-data-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

/* ==========================================
   LOADING
   ========================================== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0f4c75;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================
   STICKY HEADER (via JS clone)
   ========================================== */
.sticky-header-clone {
    position: fixed;
    top: 70px;
    z-index: 500;
    background: #f8f9fa;
    border-collapse: collapse;
    font-size: 12px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    pointer-events: none;
    display: none;
}

.sticky-header-clone th {
    padding: 10px 8px;
    text-align: center;
    font-weight: 600;
    color: #2c3e50;
    border-bottom: 2px solid #dee2e6;
    white-space: nowrap;
    background: #f8f9fa;
    border-right: 1px solid #dee2e6;
}

/* ==========================================
   FILTROS POR COLUNA (universal - todas as views)
   ========================================== */

/* Ícone de lupa no cabeçalho */
.filter-icon {
    display: inline-block;
    margin-left: 5px;
    cursor: pointer;
    font-size: 11px;
    opacity: 0.35;
    transition: opacity 0.2s;
    vertical-align: middle;
    user-select: none;
}

.filter-icon:hover {
    opacity: 1;
}

/* Coluna com filtro ativo: vermelho */
.th-filtered {
    color: #dc3545 !important;
    background: #fff0f0 !important;
}

.th-filtered .filter-icon {
    opacity: 1;
    color: #dc3545;
}

/* Popup do filtro */
.filter-popup {
    position: fixed;
    background: white;
    border: 1px solid #ddd;
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    padding: 14px;
    min-width: 240px;
    z-index: 9999;
}

.filter-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 12px;
    font-weight: 700;
    color: #2c3e50;
}

.filter-popup-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #999;
    padding: 0 4px;
    line-height: 1;
}

.filter-popup-close:hover {
    color: #dc3545;
}

.filter-popup-input {
    width: 100%;
    padding: 9px 11px;
    border: 1.5px solid #ddd;
    border-radius: 7px;
    font-size: 13px;
    margin-bottom: 10px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.filter-popup-input:focus {
    outline: none;
    border-color: #0f4c75;
    box-shadow: 0 0 0 3px rgba(15, 76, 117, 0.1);
}

.filter-date-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #2c3e50;
    margin-top: 8px;
    margin-bottom: 4px;
}

.filter-date-label:first-of-type {
    margin-top: 0;
}

.filter-popup-actions {
    display: flex;
    gap: 6px;
}

.filter-popup-actions .btn {
    flex: 1;
    padding: 7px 10px;
    font-size: 12px;
    justify-content: center;
}

/* Barra de filtros ativos */
.active-filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 10px 14px;
    background: #fff5f5;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 12px;
}

.active-filters-bar strong {
    color: #dc3545;
    margin-right: 4px;
}

.active-filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #dc3545;
    color: white;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.active-filter-tag button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 13px;
    padding: 0;
    line-height: 1;
    margin-left: 2px;
}

.btn-clear-filters {
    background: white;
    color: #dc3545;
    border: 1.5px solid #dc3545;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    margin-left: auto;
    transition: all 0.2s;
}

.btn-clear-filters:hover {
    background: #dc3545;
    color: white;
}

/* ==========================================
   RESPONSIVO
   ========================================== */

@media (max-width: 768px) {
    .stats-container,
    .filters-row,
    .charts-container {
        grid-template-columns: 1fr;
    }
    
    .filter-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
}