﻿/* =========================================================
   REDEFINIÇÃO E GESTÃO DE VARIÁVEIS (Design System)
   ========================================================= */
   :root {
    /* Cores Principais baseadas em Saúde Mental (Cores suaves) */
    --primary: #4A90E2;    /* Azul Suave */
    --secondary: #81C784;  /* Verde Mint */
    --accent: #FFB74D;     /* Laranja Suave */
    --background: #F7F9FC; /* Off-White/Cinza claro */
    --text-main: #2C3E50;
    --text-muted: #7F8C8D;
    --white: #FFFFFF;

    /* Glassmorphism System (iPhone Effect) */
    --glass-bg: rgba(255, 255, 255, 0.65); /* Transparência suave */
    --glass-blur: blur(15px);              /* Desfoque intenso */
    --glass-border: 1px solid rgba(255, 255, 255, 0.3); /* Borda sutil */
    --glass-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);    /* Sombra profunda mas leve */
    
    /* Outros */
    --radius-lg: 18px; /* Formas mais arredondadas/orgânicas */
    --radius-md: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); /* Transição suave */
    --header-height: 80px;
    --footer-height: 50px;
}

/* Reset básico */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased; /* Fontes mais nítidas no Mac/iOS */
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; /* Fontes nativas do sistema (iPhone feeling) */
    background-color: var(--background);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden; /* Controlamos o scroll internamente */
    display: flex;
    flex-direction: column;
}

/* =========================================================
   UTILITÁRIOS AVANÇADOS (UI/UX)
   ========================================================= */

/* Classe mestra para Efeito Glass (iPhone) */
.glass-effect {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur); /* Suporte Safari */
    border: var(--glass-border);
    box-shadow: var(--glass-shadow);
}

/* UX: Scroll Elástico e Nativo do iPhone */
.native-scroll {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* ESSENCIAL PARA EFEITO ELÁSTICO DO IPHONE */
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: rgba(0,0,0,0.1) transparent;
}

/* Estilização da Barra de Scroll (Minimalista iOS) */
.native-scroll::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.native-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.native-scroll::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.native-scroll::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.2);
}

/* Botões Modernos */
.btn-primary, .btn-secondary, .tab-btn, .btn-danger {
    padding: 10px 20px;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.btn-primary { background-color: var(--primary); color: var(--white); }
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-secondary { background-color: rgba(0,0,0,0.05); color: var(--text-main); }
.btn-secondary:hover { background-color: rgba(0,0,0,0.1); }

.btn-danger { background-color: #ff4d4f; color: var(--white); }

/* Badges coloridos (UX: Carga cognitiva) */
.badge {
    padding: 5px 10px;
    border-radius: 20px;
    color: var(--white);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

/* =========================================================
   LAYOUT PRINCIPAL (HEADER, MAIN, FOOTER)
   ========================================================= */

header {
    height: var(--header-height);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    border-radius: 0 0 20px 20px; /* Borda arredondada no fundo */
}

.header-container {
    max-width: 1600px;
    height: 100%;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-area { display: flex; align-items: center; gap: 12px; }
.logo-img { height: 45px; }
.logo-text { font-size: 1.5rem; font-weight: 800; color: var(--primary); }
.logo-text span { color: var(--text-main); font-weight: 400; }

.nav-links { display: flex; align-items: center; gap: 10px; }

/* Menu Hambúrguer (display none no desktop) */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    flex-direction: column;
    gap: 6px;
    z-index: 1100;
}

.mobile-menu-toggle span {
    display: block;
    width: 28px;
    height: 3px;
    background-color: var(--primary);
    border-radius: 3px;
    transition: var(--transition);
}

/* Área de Upload Excel */
.file-input-wrapper { position: relative; overflow: hidden; display: inline-block; }
.file-input-wrapper input[type=file] {
    font-size: 100px;
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    cursor: pointer;
}

/* Tabs */
.tab-btn { background: transparent; color: var(--text-muted); }
.tab-btn:hover { color: var(--text-main); background: rgba(0,0,0,0.03); }
.tab-btn.active { background: rgba(74, 144, 226, 0.1); color: var(--primary); }

/* Filtros */
.filters-bar {
    position: fixed;
    top: calc(var(--header-height) + 15px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 900;
    padding: 10px 25px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: 600;
}

.styled-select {
    padding: 8px 15px;
    border-radius: 20px;
    border: var(--glass-border);
    background: rgba(255,255,255,0.8);
    color: var(--text-main);
    cursor: pointer;
}

/* Main Content */
main {
    flex: 1;
    margin-top: var(--header-height);
    margin-bottom: var(--footer-height);
    position: relative;
    overflow: hidden;
}

.content-wrapper {
    display: flex;
    height: 100%;
    width: 100%;
}

/* Sidebar Responsiva */
.project-sidebar {
    width: 380px; /* Largura padrão desktop */
    height: 100%;
    display: flex;
    flex-direction: column;
    border-radius: 20px 0 0 0;
    border-right: var(--glass-border);
    border-top: none;
    z-index: 800;
    transition: var(--transition);
}

.sidebar-header {
    padding: 25px 20px 15px 20px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.sidebar-header h2 { font-weight: 800; font-size: 1.4rem; }

.scrollable-content { flex: 1; padding: 10px; }

/* View Sections */
.view-section {
    flex: 1;
    height: 100%;
    display: none; /* Escondido por padrão */
    opacity: 0;
    transition: opacity 0.4s ease;
}

.view-section.active { display: flex; opacity: 1; }

/* Mapa */
#map { width: 100%; height: 100%; z-index: 100; }

/* Tabela Responsiva */
.table-view-container { padding: 30px; }
.table-responsive {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-lg);
    padding: 10px;
}

.fl-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    min-width: 800px; /* UX: Garante que a tabela não quebre em mobile, ativando scroll horizontal */
}

.fl-table thead th {
    text-align: left;
    padding: 15px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 2px solid rgba(0,0,0,0.05);
}

.fl-table tbody td {
    padding: 15px;
    border-bottom: 1px solid rgba(0,0,0,0.03);
    vertical-align: middle;
}

.fl-table tbody tr:last-child td { border-bottom: none; }
.fl-table tbody tr:hover { background-color: rgba(74, 144, 226, 0.03); }

/* Footer */
footer {
    height: var(--footer-height);
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-radius: 20px 20px 0 0;
}

/* =========================================================
   CARDS E POPUPS (UI)
   ========================================================= */

/* Project Card (Sidebar) */
.project-card {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: 18px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid rgba(0,0,0,0.03);
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.project-card:hover {
    transform: translateY(-3px) scale(1.01);
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
}

.card-header { display: flex; justify-content: space-between; align-items: start; gap: 10px; margin-bottom: 8px; }
.card-header h3 { font-size: 1.05rem; font-weight: 700; flex: 1; }
.card-meta { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 10px; }

/* Popup do Mapa (Glassmorphism) */
.popup-custom .leaflet-popup-content-wrapper {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--radius-md);
    padding: 5px;
    border: var(--glass-border);
}

.popup-custom .leaflet-popup-tip { background: rgba(255, 255, 255, 0.8); backdrop-filter: blur(10px); }

.popup-content h3 { font-weight: 800; margin-bottom: 5px; font-size: 1.1rem; }
.popup-content p { margin: 2px 0; font-size: 0.85rem; }

/* =========================================================
   MODAL (GLASS EFFECT & RESPONSIVO)
   ========================================================= */

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

.modal-content {
    width: 100%;
    max-width: 650px;
    max-height: 90vh;
    border-radius: var(--radius-lg);
    padding: 30px;
    position: relative;
}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.modal-header h3 { font-weight: 800; font-size: 1.4rem; color: var(--primary); }
.close-modal { background: transparent; border: none; font-size: 2rem; color: var(--text-muted); cursor: pointer; }

/* Formulário Moderno */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1sfr); /* Grid de 2 colunas fluido */
    gap: 15px;
    margin-bottom: 15px;
}

#add-form input, #add-form textarea, #add-form select {
    width: 100%;
    padding: 12px 15px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(0,0,0,0.08);
    background: rgba(255,255,255,0.7);
    font-size: 0.9rem;
    transition: var(--transition);
}

#add-form input:focus, #add-form textarea:focus {
    border-color: var(--primary);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

#add-form textarea { grid-column: span 2; resize: none; }
#form-publico, #form-link { grid-column: span 2; margin-bottom: 15px;}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(0,0,0,0.05);
}

/* =========================================================
   MEDIA QUERIES - RESPONSIVIDADE (O Pulo do Gato)
   ========================================================= */

/* 1. TABLETS E TELAS MÉDIAS (até 1024px) */
@media (max-width: 1024px) {
    .project-sidebar {
        width: 300px; /* Reduzimos um pouco a sidebar */
    }
}

/* 2. CELULARES E PEQUENAS TELAS (até 768px) */
@media (max-width: 768px) {
    :root {
        --header-height: 70px; /* Header menor no mobile */
    }

    /* Header Mobile */
    .mobile-menu-toggle { display: flex; } /* Mostra hambúrguer */
    
    .nav-links {
        position: fixed;
        top: 0;
        right: -100%; /* Escondido fora da tela */
        width: 280px;
        height: 100vh;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        flex-direction: column;
        padding: 100px 30px;
        box-shadow: -10px 0 30px rgba(0,0,0,0.1);
        z-index: 1050;
        transition: var(--transition);
        border-radius: 20px 0 0 20px;
    }

    /* Classe ativada via JS para abrir o menu */
    .nav-links.mobile-open {
        right: 0;
    }

    .nav-links button, .file-input-wrapper {
        width: 100%; /* Botões full-width no menu mobile */
        text-align: center;
    }

    .logo-text { font-size: 1.2rem; }
    .logo-img { height: 35px; }

    /* Layout Content */
    .content-wrapper { flex-direction: column; } /* Stack vertically */

    /* Sidebar Mobile - Vira uma aba ou esconde */
    .project-sidebar {
        width: 100%;
        height: auto;
        max-height: 40vh; /* Ocupa no máximo 40% da altura para deixar espaço pro mapa */
        position: absolute;
        bottom: 0;
        left: 0;
        border-radius: 20px 20px 0 0;
        border-right: none;
        border-top: var(--glass-border);
        box-shadow: 0 -10px 30px rgba(0,0,0,0.1);
    }
    
    .sidebar-header { padding: 15px 20px 10px 20px; }
    .sidebar-header h2 { font-size: 1.1rem; }

    /* Área do Mapa/Tabela */
    .view-section {
        height: calc(100vh - var(--header-height) - var(--footer-height));
    }

    /* Filtros Mobile */
    .filters-bar {
        width: 90%;
        font-size: 0.8rem;
        padding: 8px 15px;
    }

    /* Tabela Mobile (ativar scroll horizontal pesado) */
    .table-view-container { padding: 10px; }
    .table-responsive { border-radius: var(--radius-md); }
    .fl-table { font-size: 0.8rem; }
    
    /* Modal Mobile */
    .modal-content { padding: 20px; width: 95%; }
    .form-grid { grid-template-columns: 1fr; } /* Stack form inputs */
    #add-form textarea { grid-column: span 1; }
    .modal-header h3 { font-size: 1.2rem; }
}

/* 3. AJUSTES FINOS PARA TELAS MUITO PEQUENAS (até 480px) */
@media (max-width: 480px) {
    .header-container { padding: 0 15px; }
    .project-card { padding: 12px; }
    .card-header h3 { font-size: 0.95rem; }
}