/* =========================================== */
/* === ESTILOS GLOBAIS E RESET ================ */
/* =========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body, html {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    background-color: #f4f4f4;
    color: #333;
    height: 100%;
    width: 100%;
}

/* =========================================== */
/* === LAYOUT PRINCIPAL E MAPA ================ */
/* =========================================== */
.map-section {
    display: flex;
    flex-direction: column;
    align-items: center; 
    justify-content: center; 
    text-align: center;
    min-height: 100vh; 
    padding: 20px;
}

.map-section h1 {
    margin-bottom: 10px;
    font-size: 2.5rem;
}

#map {
    width: 90vw; 
    max-width: 1000px; 
    height: 65vh; 
    border: 1px solid #ccc;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 8px;
    z-index: 1; /* Garante que o mapa fique abaixo dos popups */
}


/* =========================================== */
/* === CONTAINER DE BUSCA ==================== */
/* =========================================== */
.search-container {
    width: 90vw;
    max-width: 600px;
    margin-bottom: 20px;
    z-index: 2; /* Fica acima do mapa */
}

#search-form {
    display: flex;
    width: 100%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-radius: 8px;
    overflow: hidden; 
}

#search-input {
    flex-grow: 1; 
    border: 1px solid #ccc;
    padding: 12px 15px;
    font-size: 1rem;
    border-radius: 8px 0 0 8px; 
}

#search-form button {
    padding: 12px 20px;
    border: none;
    background-color: #007bff;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s ease;
    border-radius: 0 8px 8px 0; 
}

#search-form button:hover {
    background-color: #0056b3;
}

#search-status {
    text-align: center;
    margin-top: 10px;
    min-height: 20px;
    color: #555;
    font-style: italic;
}

/* =========================================== */
/* === POPUP LOGIN/CADASTRO ================== */
/* =========================================== */
#login-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001; /* Fica acima de tudo */
}

#login-button {
    background-color: #007bff;
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}
#login-button:hover {
    background-color: #0056b3;
}

#login-form {
    background: white;
    padding: 20px;
    padding-top: 40px; /* Espaço para o botão X */
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    width: 300px; /* Um pouco maior para os novos campos */
    position: absolute; /* Mudado de relative para absolute */
    top: 0;
    right: 0;
    transform: scale(0.8) translateY(-20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease-in-out;
    display: grid; /* Usar grid para alinhar itens */
    gap: 15px; /* Espaçamento entre os campos */
}

#login-container.active #login-form {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

#login-container.active #login-button {
    opacity: 0;
    pointer-events: none;
}

/* --- Campos e Botões do Formulário --- */
#login-form h3 {
    text-align: center;
    margin-bottom: 5px;
}

#login-form input[type="text"],
#login-form input[type="password"],
#login-form input[type="email"],
#login-form input[type="tel"] {
    width: 100%;
    padding: 12px 15px;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 4px; /* Cantos arredondados */
}

#login-form button[type="submit"] {
    width: 100%; /* Ocupa toda a largura */
    padding: 12px 20px;
    border: none;
    background-color: #007bff;
    color: white;
    font-size: 1.1rem; /* Um pouco maior */
    cursor: pointer;
    transition: background-color 0.3s ease;
    border-radius: 4px; /* Cantos arredondados */
}
#login-form button[type="submit"]:hover {
    background-color: #0056b3;
}

#login-status {
    text-align: center;
    min-height: 20px;
    font-size: 0.9em;
}

/* --- Botão Fechar (X) --- */
#close-login-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 1.8rem;
    color: #aaa;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
}
#close-login-btn:hover {
    color: #333;
}

/* --- Lógica de Ocultar/Mostrar Campos de Cadastro --- */
#login-form.mode-login .signup-field {
    display: none; /* Esconde campos de cadastro no modo login */
}
#login-form.mode-signup .signup-field:active {
    display: block; /* Mostra campos de cadastro no modo signup */
}

/* --- Link para Alternar Modo --- */
#toggle-link {
    text-align: center;
    font-size: 0.9em;
    margin-top: 10px;
    color: #555;
}
#toggle-link a {
    color: #007bff;
    text-decoration: none;
    cursor: pointer;
}
#toggle-link a:hover {
    text-decoration: underline;
}


/* =========================================== */
/* === MENU DO USUÁRIO LOGADO =============== */
/* =========================================== */
#user-menu-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
}

#user-button {
    background-color: #28a745; 
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    user-select: none; 
}
#user-button:hover {
    background-color: #218838;
}

#user-dropdown {
    background: white;
    padding: 8px 0; 
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    width: 240px;
    position: absolute;
    top: 55px; 
    right: 0;
    transform: scale(0.95) translateY(-10px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease-in-out;
    z-index: 1000;
}

#user-menu-container.active #user-dropdown {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

#user-dropdown ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

#user-dropdown ul li a {
    display: block;
    padding: 12px 20px;
    text-decoration: none;
    color: #333;
    font-size: 1rem;
}
#user-dropdown ul li a:hover {
    background-color: #f4f4f4;
}

#user-dropdown ul li:first-child {
    border-bottom: 1px solid #eee; 
}

/* =========================================== */
/* === RESPONSIVIDADE ======================== */
/* =========================================== */
@media (max-width: 768px) {
    .map-section h1 {
        font-size: 1.8rem;
    }
    #map {
        width: 95vw; 
        height: 60vh;
    }
    #login-form {
        width: 90vw; /* Ocupa mais espaço em telas pequenas */
        max-width: 320px;
    }
}


/* --- NOVO: Ícone de Menor Preço com Cifrão ($) --- */
.lowest-price-div-icon {
    /* Pega o pino azul padrão como base */
    background-image: url('https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon-2x.png'); 
    background-size: 25px 41px;
    width: 25px;
    height: 41px;
    
    /* Aplica o mesmo filtro DOURADO que você já usava */
    filter: brightness(1) sepia(77) hue-rotate(0deg) saturate(500%);
    
    /* Prepara para o texto */
    position: relative;
    border-radius: .5rem; /* Evita bordas quadradas estranhas */
}

.lowest-price-div-icon::after {
    content: '$'; /* O seu cifrão! */
    top: 6px;  /* Ajuste vertical */
    top: 2px;
    left: 0px;
    right: 2px;
    text-align: center;
    font-size: 20px;
    font-weight: bold;
     color: yellow;
    text-shadow: 2px -1px 1px black; /* Sombra para legibilidade */
}
.leaflet-popup-content-wrapper{min-width: 220px;}

/* --- Link "Mais Produtos" no Popup --- */
.popup-compare-link {
    display: block;
    margin-top: 10px;
    padding: 8px;
    background-color: #007bff;
    color: white !important; /* Força a cor do texto */
    text-decoration: none;
    border-radius: 4px;
    text-align: center;
    font-weight: bold;
}
.popup-compare-link:hover {
    background-color: #0056b3;
    color: white !important;
}
/* --- Estilos do Popup --- */
.popup-horarios {
    margin-top: 8px;
}
.popup-horarios summary {
    cursor: pointer;
    font-weight: bold;
    color: #007bff;
    outline: none;
    user-select: none;
}
.popup-horarios summary:hover {
    text-decoration: underline;
}
.popup-horarios-content {
    padding-top: 5px;
    color: #555;
    border-top: 1px dashed #eee;
    margin-top: 5px;
}
.popup-update-time {
    display: block;
    font-size: 0.9em;
    color: #DDD;
    margin-top: 8px;
}