/* ==========================================================================
   1. VARIÁVEIS DE CROP & RESET (Paleta base e regras globais)
   ========================================================================== */
:root {
    /* Cores Principais da Marca */
    --primary-color: #008f39; /* Verde Agro/John Deere */
    --primary-hover: #006f2c; /* Verde mais escuro para estados de hover */
    --secondary-color: #2c3e50; /* Azul/cinza escuro para textos fortes */
    --accent-color: #e67e22; /* Laranja de alerta/destaque */
    
    /* Backgrounds & Bordas (O Soil) */
    --bg-body: #f0f2f5; /* Cinza claro para o fundo da página */
    --bg-card: #ffffff; /* Branco puro para os containers */
    --border-color: #e5e7eb; /* Bordas sutis para separar elementos */
    
    /* Cores de Tipografia */
    --text-main: #1f2937; /* Texto escuro principal para leitura */
    --text-muted: #6b7280; /* Texto secundário para info menos importante */
    
    /* Sombras e Arredondamentos */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05); /* Profundidade leve */
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); /* Profundidade média */
    --radius: 12px; /* Arredondamento padrão */
}

/* Reset Universal */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   2. HEADER (Marca de topo e navegação)
   ========================================================================== */
header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 2rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

/* Voltando para a fonte e tamanho originais */
header h1 {
    font-size: 1.8rem; 
    font-weight: 800;
    letter-spacing: -0.5px;
}

header h1 .title-green {
    color: #00e227; 
}

header h1 .title-orange {
    color: #ff6221; 
}

/* Preto e do mesmo tamanho do resto */
header h1 .title-web {
    color: #000000; 
}

header h4.desc {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* 2. Faz o link herdar exatamente o visual da frase para não dar diferença */
header h4.desc a {
    color: inherit; 
    font-weight: inherit; 
    text-decoration: none;
    transition: all 0.2s ease;
    border-bottom: 1px dotted transparent;
}

/* 3. O efeito verde John Deere apenas ao passar o mouse */
header h4.desc a:hover {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Links do Header (Links Acadêmicos) */
.cursos {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.cursos a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s;
    border-bottom: 1px dotted transparent;
}

.cursos a:hover {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* ==========================================================================
   3. LAYOUT DO MAIN FIELD (Estrutura de grid para o painel)
   ========================================================================== */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: 350px 1fr; /* Coluna fixa à esquerda para form, direita para histórico */
    gap: 2rem;
    align-items: start;
}

section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

h2 {
    font-size: 1.25rem;
    color: var(--secondary-color);
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--bg-body);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ==========================================================================
   4. INPUTS DE SEEDING & FORMULÁRIOS (Elementos de entrada de dados)
   ========================================================================== */
.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
}

/* Campos de input padronizados */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="file"] {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.2s;
    background-color: #fafafa;
    color: var(--text-main);
}

input:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(0, 143, 57, 0.1); /* Anel de foco verde */
}

.grid-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Botão de Ação Principal (Processar) */
.process-btn {
    width: 100%;
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    padding: 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.process-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 143, 57, 0.2);
}

.process-btn:disabled {
    background-color: #9ca3af; /* Cinza enquanto processa */
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Mensagens de Feedback de Status */
#status-message {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.status-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.status-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ==========================================================================
   5. CARTÕES DE ANÁLISE DE YIELD (Lista de histórico e Accordion)
   ========================================================================== */
.analise-item {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    border-left: 5px solid var(--primary-color); /* Marcador verde à esquerda */
    overflow: hidden;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
}

.analise-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Cabeçalho Clicável para o Accordion */
.analise-header-clickable {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
}

.analise-header-clickable:hover {
    background-color: #f0fdf4; /* Verde muito claro no hover */
}

.analise-info h3 {
    font-size: 1rem;
    color: var(--secondary-color);
    margin-bottom: 4px;
}

/* Badges para Metadados */
.badges-row {
    display: flex;
    gap: 10px;
    margin-top: 5px;
    flex-wrap: wrap;
}

.badge {
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
}

.badge-id { 
    background: #374151; 
    color: #f9fafb;      
    font-family: 'Courier New', Courier, monospace; 
    letter-spacing: 1px;
    border: 1px solid #1f2937;
    text-transform: lowercase;
}

.badge-pasta { background: #e0f2fe; color: #0369a1; }
.badge-date { background: #fff; color: #9ca3af; padding-left: 0; font-weight: 400; }

/* Botões de Ação dentro dos Cartões */
.actions-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

.delete-btn {
    background: transparent;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.delete-btn:hover { background: #fee2e2; }

/* Detalhes Ocultos (Corpo do Accordion) */
.analise-details {
    padding: 0 1.5rem 1.5rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background-color: #fafafa;
    animation: slideDown 0.3s ease-out;
}

/* Botões de Download de Arquivo */
.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.download-btn.excel {
    background-color: #dcfce7;
    color: #166534;
    padding: 10px 16px;
    border: 1px solid #bbf7d0;
    width: 100%;
    justify-content: center;
    margin-bottom: 1rem;
    margin-top: 1rem;
}

.download-btn.excel:hover {
    background-color: #166534;
    color: white;
}

/* Grid de Gráficos Gerados */
.graficos-container h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}

.graficos-list-ul {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    padding: 0;
    list-style: none;
}

.graficos-list-ul li a {
    display: block;
    padding: 8px 12px;
    background: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.2s;
}

.graficos-list-ul li a:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #fff;
}

/* Toggle Global do Accordion */
.section-header-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1rem;
    transition: background 0.2s;
}

.section-header-toggle:hover { background-color: #f9fafb; }
.section-header-toggle h2 { margin: 0; border: none; padding: 0; }
.arrow-icon { font-size: 1.2rem; color: var(--text-muted); transition: transform 0.3s ease; }
.rotate-down { transform: rotate(90deg); } /* Classe utilitária para setas */
.hidden { display: none !important; } /* Classe utilitária para esconder elementos */

/* ==========================================================================
   6. FOOTER E RESPONSIVIDADE (Raiz e adaptação mobile)
   ========================================================================== */
footer {
    margin-top: 3rem;        /* Reduzido de 8rem para aproximar do main */
    border-top: 1px solid var(--border-color);
    padding: 3rem 0;         
    background: var(--bg-card);
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    width: 100%;             
}

.footer {
    display: grid;
    grid-template-columns: 1fr 1fr; 
    gap: 2rem; /* Reduzi um pouco o gap para os cartões não ficarem tão soltos na tela larga */
    max-width: 1200px; /* Exatamente a mesma largura do main */
    padding: 0 20px;   /* O mesmo respiro lateral do main */
    margin: 0 auto;
    text-align: left; 
}

/* Nova classe para fazer a seção atravessar as duas colunas do Grid */
.full-width-section {
    grid-column: 1 / -1; 
    margin-bottom: 0.5rem;
}

.footer section h2.foot {
    font-size: 1.1rem;
    color: #ff6221; /* Laranja oficial do NMAP */
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}

/* Listas verticais da Equipe e Agradecimentos */
.equipe-list, 
.agradecimentos-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: 1rem;
}

/* Estilo dos Links do Footer */
footer a.lattes {
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    border-bottom: 1px dotted transparent;
}

footer a.lattes:hover {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    padding-left: 5px; /* Movimento leve para indicar interatividade */
}

/* Animações */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Breakpoints Responsivos (Tablet/Mobile) */
@media (max-width: 900px) {
    main {
        grid-template-columns: 1fr; /* Colapsa o grid do field para uma coluna */
    }
    header { padding: 1rem; }
}

@media (max-width: 768px) {
    .footer {
        grid-template-columns: 1fr; /* Colapsa o footer para uma coluna */
        text-align: center;
    }
    footer a.lattes:hover {
        padding-left: 0; /* Remove o shift no hover em mobile para evitar saltos no layout */
    }
}

/* ==========================================================================
   7. AUTENTICAÇÃO E SEGURANÇA (Login, Reset Password, Modais)
   ========================================================================== */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh; /* Ocupa a altura total da viewport */
    background-color: var(--bg-body);
    margin: 0;
}

.auth-card {
    width: 100%;
    max-width: 400px; /* Restringe a largura do form de login */
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

.forgot-link-container {
    margin-top: 1.2rem;
    text-align: center;
}

.forgot-link-container a {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-decoration: none;
    transition: color 0.2s;
}

.forgot-link-container a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Overlay de tela cheia para modais (ex: Esqueci a Senha) */
.modal-backdrop {
    display: none; /* Escondido por padrão */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6); /* Fundo escurecido */
    backdrop-filter: blur(4px); /* Efeito de desfoque para foco */
    z-index: 9999; /* Prioridade máxima para ficar acima de todos os elementos */
}

/* Container do Modal Centralizado */
#modal-recuperacao {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Mecanismo de centralização precisa */
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    width: 90%;
    max-width: 400px;
}

#modal-recuperacao h3 {
    margin-bottom: 0.5rem;
    color: var(--secondary-color);
}

#modal-recuperacao p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 1rem;
}

.btn-cancel {
    flex: 1;
    background: #f3f4f6;
    color: var(--text-main);
    border: none;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-cancel:hover {
    background: #e5e7eb;
}

#msg-recuperacao {
    margin-top: 1rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.85rem;
}

/* ==========================================================================
   8. VISUALIZADOR DE GRÁFICOS (Pop-up / Modal)
   ========================================================================== */
#grafico-modal {
    display: flex; /* Mantém centralizado quando visível */
    justify-content: center;
    align-items: center;
    padding: 20px;
    z-index: 10000; /* Garante que fique acima de tudo */
}

.modal-content-grafico {
    position: relative;
    background: #fff;
    border-radius: var(--radius);
    padding: 10px; /* Borda branca suave ao redor da imagem */
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: zoomIn 0.2s ease-out;
}

.modal-actions-top {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    gap: 10px;
    z-index: 10;
}

/* Botões redondinhos do canto superior */
.btn-icon {
    background: rgba(255, 255, 255, 0.95);
    color: var(--secondary-color);
    border: 1px solid var(--border-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    text-decoration: none;
    font-size: 1.1rem;
    box-shadow: var(--shadow-md);
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: scale(1.1);
}

#grafico-img-display {
    max-width: 100%;
    max-height: calc(95vh - 20px); /* Não deixa a imagem vazar da tela */
    display: block;
    border-radius: 4px;
    object-fit: contain;
}

@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* ==========================================================================
   9. MENU SECUNDÁRIO E MODAL DE CONTATO
   ========================================================================== */
.menu-secundario {
    margin-top: 1.2rem;
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.menu-secundario a {
    color: var(--secondary-color);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: color 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.menu-secundario a:hover {
    color: var(--primary-color);
    transform: translateY(-2px);
}

.modal-box {
    position: relative;
    background: white;
    padding: 2.5rem;
    border-radius: var(--radius);
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: zoomIn 0.2s ease-out;
}

#contato-modal {
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

/* ==========================================================================
   10. ESTILOS PARA O BOTÃO MOSTRAR/OCULTAR SENHA
   ========================================================================== */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    width: 100%;
    padding-right: 40px; /* Deixa espaço para o texto não passar por cima do ícone */
}

.toggle-password {
    position: absolute;
    right: 10px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%; /* Ocupa a altura total do input para centralizar o ícone */
    transition: color 0.2s;
}

.toggle-password:hover {
    color: var(--primary-color); /* Fica verde quando passa o mouse */
}
