/* Importação da Fonte Poppins */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

* {
  /*user-select: none !important;*/
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: #f8f9fa;
    color: #343a40;
    margin: 0;
    padding: 0;
    overflow: hidden; 
}

/* --- Sidebar Wrapper (Fixo/Scrollável) --- */
#wrapper { 
    display: flex; 
    width: 100%;
    height: 100vh; /* Ocupa 100% da altura da viewport */
    overflow: hidden;
}

#sidebar-wrapper {
    /* Removemos min-height e definimos height fixa com scroll */
    height: 100vh;
    overflow-y: auto; 
    width: 250px;
    margin-left: 0;
    transition: all 0.3s ease;
    background-color: #1d2f5e;
    color: #fff;
    flex-shrink: 0;
    border-right: 1px solid rgba(0,0,0,0.1);
}

#sidebar-wrapper .sidebar-heading {
    /* Reduzi o padding vertical de 1.0rem para 0.8rem */
    padding: 0.8rem 1.2rem; 
    font-size: 1.1rem; /* Reduzi de 1.2rem para 1.1rem */
    font-weight: bold;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

/* Ajuste para o texto não quebrar layout ao lado do botão */
#sidebar-wrapper .sidebar-heading span {
    white-space: nowrap;
}

#sidebar-wrapper .list-group-item {
    background-color: transparent;
    color: #FFFFFF;
    border: none;
    /* Reduzi o padding vertical de 1rem para 0.6rem */
    padding: 0.6rem 1.5rem; 
    white-space: nowrap;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

/* Nova regra para diminuir a fonte do texto do menu */
#sidebar-wrapper .list-group-item span {
    font-size: 0.85rem; /* Tamanho menor (padrão costuma ser 1rem) */
    font-weight: 400;   /* Ajuste opcional da espessura */
}

/* Ajuste proporcional dos ícones para não parecerem grandes demais */
#sidebar-wrapper .list-group-item i {
    min-width: 30px;
    text-align: center;
    font-size: 0.9rem; 
}

#sidebar-wrapper .list-group-item:hover,
#sidebar-wrapper .list-group-item.active {
    background-color: rgba(255,255,255,0.1);
    color: #fff;
    text-decoration: none;
}

#sidebar-wrapper .list-group-item i {
    min-width: 30px;
    text-align: center;
}

/* --- Toggled State (Collapsed) --- */
#wrapper.toggled #sidebar-wrapper { width: 80px; }
/* Esconde o texto "TagConnect", mas mantém o botão visível */
#wrapper.toggled #sidebar-wrapper .sidebar-heading span { display: none; }
/* Centraliza o botão toggle quando colapsado */
#wrapper.toggled #sidebar-wrapper .sidebar-heading { 
    justify-content: center !important; 
    padding: 1rem 0;
}
/* Localize este bloco no seu CSS e substitua o padding */
#wrapper.toggled #sidebar-wrapper .list-group-item { 
    justify-content: center; 
    padding: 0.6rem 0; /* Agora coincide exatamente com o menu aberto */
    height: 39.5px;
}

/* Ajuste do cabeçalho colapsado para manter a consistência */
#wrapper.toggled #sidebar-wrapper .sidebar-heading { 
    justify-content: center !important; 
    padding: 0.8rem 0; /* Ajustado para alinhar com o novo padding do heading */
}
#wrapper.toggled #sidebar-wrapper .list-group-item i { margin-right: 0 !important; }

/* Esconde labels dos menus */
#wrapper.toggled #sidebar-wrapper span { display: none; }

/* --- Page Content (Scrollável Independentemente) --- */
#page-content-wrapper {
    width: 100%;
    flex-grow: 1;
    min-width: 0;
    height: 100vh;      /* Altura total */
    overflow-y: auto;   /* Scroll independente do conteúdo principal */
    
    /* Adicionado para o Mapa funcionar em tela cheia */
    display: flex;
    flex-direction: column;
}

.page-header {
    background: #fff;
    border-bottom: 1px solid #dee2e6;
    padding: 1rem 1.5rem;
    margin-bottom: .3rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.main-container { 
    padding-bottom: 4rem;
    /* Ajuste para ocupar espaço restante quando não for mapa */
    flex-grow: 1; 
    padding-top: 1rem; /* Pequeno espaçamento superior */
}

/* ========================================= */
/* --- MAP VIEW STYLES (ATUALIZADO) --- */
/* ========================================= */
#mapView {
    flex-grow: 1;
    position: relative;
    height: 100%;
    width: 100%;
    display: none; /* JS controls visibility */
}

#mapContainer {
    height: 100%;
    width: 100%;
    z-index: 1;
}

.map-overlay-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000; /* Acima do mapa Leaflet */
}

/* Marcadores Customizados CSS (Círculo Verde + Ícone) */
.custom-map-marker {
    background-color: #198754; /* Verde (Bootstrap Success) */
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 3px 8px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px; /* Tamanho do ícone fa-tag */
    color: #fff;
    position: relative; /* Necessário para posicionar o balão */
}

/* Balão com o Código da Tag (Sobre o marcador) */
.marker-label {
    position: absolute;
    bottom: 45px; /* Posiciona acima do círculo */
    left: 50%;
    transform: translateX(-50%);
    background-color: #343a40; /* Fundo escuro */
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    pointer-events: none; /* Permite clicar no marcador através da label */
}

/* Triângulo/Seta do Balão */
.marker-label::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #343a40 transparent transparent transparent;
}

/* --- Search Bar Enhancements --- */
.input-group-text {
    background-color: #fff;
    border-color: #ced4da;
}
.input-group .form-control:focus {
    box-shadow: none;
    border-color: #ced4da;
}

/* --- Cards e Views --- */
.tag-card {
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
    background-color: #fff;
    border-radius: 0.5rem;
}

/* Grid View (Default) */
.tag-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.10) !important;
}

/* --- GRID LAYOUT PARA LISTA E COMPACTA --- */
.grid-row-layout {
    display: grid;
    grid-template-columns: 90px 150px 1.5fr 1.5fr 160px 150px auto;
    gap: 15px;
    align-items: center;
    width: 100%;
}

/* List View (Horizontal Detailed) */
.list-view { padding: 0 !important; }

.list-view .grid-row-layout {
    padding: 1rem;
    border: 1px solid #e9ecef;
    border-radius: 0.5rem;
}
.list-view:hover {
    transform: none;
    background-color: #fdfdfd;
    box-shadow: 0 0.2rem 0.5rem rgba(0,0,0,0.05) !important;
}
.list-view .cell-label {
    font-size: 0.75rem;
    color: #6c757d;
    font-weight: bold;
    margin-bottom: 2px;
    display: block;
    text-transform: uppercase;
    white-space: nowrap;
}
.list-view .cell-value {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

/* Compact View (Slim Row) */
.compact-view {
    padding: 0 !important;
    border: 1px solid #e9ecef;
    border-radius: 0.5rem;
    margin-bottom: 0;
}
.compact-view .grid-row-layout {
    padding: 0.5rem 1rem;
}
.compact-view .cell-value {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.compact-view:hover {
    background-color: #f8f9fa;
    transform: none;
    box-shadow: 0 0.1rem 0.3rem rgba(0,0,0,0.05) !important;
}

/* Responsividade das Colunas */
@media (max-width: 1200px) { 
    .list-view .cell:nth-child(4),
    .compact-view .cell-value:nth-child(4) {
        display: none !important;
    }
    .grid-row-layout {
        grid-template-columns: 90px 150px 1.5fr 160px 150px auto;
    }
}
@media (max-width: 992px) { 
    .list-view .cell:nth-child(3),
    .compact-view .cell-value:nth-child(3) {
        display: none !important;
    }
    .grid-row-layout {
        grid-template-columns: 90px 150px 160px 150px auto;
        gap: 10px;
    }
}
@media (max-width: 768px) {
    .list-view .cell:nth-child(4),
    .compact-view .cell-value:nth-child(4) {
        display: none !important;
    }
    .compact-view .cell-value:nth-child(2) {
        display: none !important;
    }
    .grid-row-layout {
        grid-template-columns: 90px 150px auto;
        gap: 10px;
    }
}

/* Status Labels */
.status-text { font-weight: 500; font-size: 0.9rem; }
.status-text.success { color: #198754; }
.status-text.error { color: #dc3545; }
.status-text.pending { color: #fd7e14; }

/* --- Pagination --- */
.pagination .page-link {
    color: #343a40;
    border: none;
    margin: 0 2px;
    border-radius: 4px;
}
.pagination .page-item.active .page-link {
    background-color: #343a40;
    color: #fff;
}
.pagination .page-item.disabled .page-link {
    color: #ccc;
    background-color: transparent;
}
.pagination .page-link:focus {
    box-shadow: none;
}

/* --- Modais --- */
.custom-modal {
    display: none;
    background-color: rgba(0, 0, 0, 0.5);
    overflow-y: auto;
    overflow-x: hidden; 
}
.form-control[readonly] { background-color: #e9ecef; opacity: 1; }
.text-truncate-custom { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- Styles do Visualizador de Log --- */
.log-viewer {
    display: block;
    width: 100%;
    max-height: 60vh;
    overflow-y: auto;
    white-space: pre-wrap;
    font-size: 0.85rem;
    background-color: #fff;
    border: 1px solid #dee2e6;
    padding: 1rem;
    border-radius: 0.25rem;
    color: #212529;
    font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
}

/* --- User Profile Styles --- */
.profile-pic-container {
    display: flex;
    justify-content: center;
}
.profile-pic-circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #dee2e6;
}

/* --- Login Page --- */
body.login-page {
    background-image: url(uploads/background.webp);
    background-position: center center;
    background-size: cover;
    background-color: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    overflow: auto; 
}
.login-container { width: 100%; max-width: 400px; padding: 15px; }
.login-card { border: none; border-radius: 1rem; }
.login-card .card-body { padding: 2.5rem !important; }
.login-card .form-control { padding-left: 10px; border-left: 0; }
.login-card .input-group-text { background-color: white; border-right: 0; }
.login-card .form-control:focus { box-shadow: none; border-color: #dee2e6; }

/* --- Animações de Modal --- */
@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalSlideInUp {
    from { opacity: 0; transform: translateY(50px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes modalFadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes modalSlideOutDown {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(50px); }
}

.custom-modal.anim-enter { animation: modalFadeIn 0.3s forwards; }
.custom-modal.anim-exit { animation: modalFadeOut 0.3s forwards; }

/* --- FLOATING CARD (MAPA ADMIN) --- */
.info-card {
    position: absolute;
    top: 20px;
    left: 60px; /* Afastado da esquerda para não cobrir os controles de zoom do Leaflet se houver */
    z-index: 2000; /* Alto Z-Index para ficar acima do mapa */
    width: 320px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    border: 1px solid rgba(255,255,255,0.5);
    transition: opacity 0.3s ease;
    overflow: hidden;
}

.info-header {
    background: linear-gradient(135deg, #1d2f5e 0%, #2b4585 100%);
    color: white;
    padding: 12px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none; /* Importante para não selecionar texto ao arrastar */
}

.info-title-group {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    white-space: nowrap;
    flex-grow: 1;
}

.info-body { padding: 15px; }
.info-item { margin-bottom: 10px; }

.info-label { 
    font-size: 0.75rem; 
    text-transform: uppercase; 
    color: #6c757d; 
    font-weight: 600; 
    letter-spacing: 0.5px; 
    margin-bottom: 2px;
}
.info-value { 
    font-size: 0.9rem; 
    color: #212529; 
    font-weight: 500; 
    word-break: break-word;
}

/* Responsividade para celular: Card vai para baixo */
@media (max-width: 576px) {
    .info-card {
        top: auto !important; /* Ignora o posicionamento do JS em telas pequenas */
        bottom: 0;
        left: 0 !important;
        right: 0;
        width: 100%;
        border-radius: 20px 20px 0 0;
        margin: 0;
        transform: none !important;
    }
}