/* ==========================================================================
   1. ESTRUTURA GLOBAL (APP SHELL)
   ========================================================================== */
html, body {
    height: 100%;
    margin: 0;
    font-family: 'Segoe UI', Roboto, -apple-system, sans-serif;
    overflow: hidden; 
    background-color: #f8f9fa;
    -webkit-tap-highlight-color: transparent;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

body {
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   2. HEADER & BRANDING
   ========================================================================== */
header {
    height: 60px;
    background-color: #2c3e50;
    color: white;
    display: flex;
    align-items: center;
    padding: 0 15px; 
    justify-content: flex-start; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    z-index: 1100;
    position: relative;
}

.btn-menu {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    margin-right: 15px;
    padding: 5px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-title {
    font-size: 1.1rem;
    font-weight: 750;
    letter-spacing: 0.5px;
    margin: 0;
    margin-top: 2px; /* Txt Pedalgrafia */
}

.brand-logo img {
    width: 37px; 
    height: 37px;
    object-fit: contain;
    margin-top: 4px; /* Logo Pedalgrafia */
}

.wheel {
    transform-origin: center;
    animation: spinWheel 3s linear infinite;
    will-change: transform;
}

@keyframes spinWheel {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .wheel { animation: none; }
}

/* ==========================================================================
   2.1. REDES SOCIAIS NO CABEÇALHO (Cores Sólidas)
   ========================================================================== */
.header-social {
    display: flex;
    /* 🔻 POSICIONAMENTO: Distância entre o texto "Pedalgrafia" e os botões */
    margin-left: 85px; 
    /* 🔻 POSICIONAMENTO: Espaçamento ENTRE os dois botões */
    gap: 12px;
}

.header-social a {
    display: flex;
    align-items: center;
    justify-content: center;
    
    /* 🔻 DIMENSÕES: Largura e Altura do botão */
    width: 35px;
    height: 35px;
    
    border-radius: 50%; /* Mantém o formato circular perfeito */
    text-decoration: none;
    
    /* 🔻 DIMENSÕES: Tamanho do ícone (o desenho do FB/IG) */
    font-size: 20px; 
    color: #ffffff; /* Ícone sempre branco */
    
    /* Removemos a borda para evitar saltos de tamanho */
    border: none; 
}

/* Cor de fundo sólida do Instagram */
.social-ig {
    background-color: #e1306c;
}

/* Cor de fundo sólida do Facebook */
.social-fb {
    background-color: #1877f2;
}

/* ==========================================================================
   3. ELEMENTOS DE INTERFACE (MAPA, SIDEBAR & LOADER)
   ========================================================================== */

.sidebar {
    position: fixed;
    left: 0;
    top: 60px;
    width: 300px;
    height: calc(100vh - 60px);
    background-color: #ffffff;
    z-index: 2000; 
    display: flex; 
    flex-direction: column;
    transform: translateX(-100%); 
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 2px 0 12px rgba(0,0,0,0.15);
}

.sidebar.is-open {
    transform: translateX(0);
}

.sidebar .content {
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
    padding: 25px;
    /* CORREÇÃO DO BURACO NEGRO: Reduzido para 60px para a Revista subir */
    padding-bottom: 40px; 
    text-align: center; /* NOVO: Centraliza todo o texto e elementos em linha da sidebar */
}

.btn-close-sidebar {
    position: absolute;
    right: 15px;
    top: 15px;
    background: #ecf0f1;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-weight: bold;
    color: #2c3e50;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    font-size: 18px;
}

#map {
    position: absolute;
    top: 60px; 
    left: 0;
    width: 100%;
    height: calc(100vh - 60px);
    z-index: 1;
    background-color: #2c3e50; 
    touch-action: pan-x pan-y;
}

#map-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(44, 62, 80, 0.9); 
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #ecf0f1;
    transition: opacity 0.5s ease-out;
}

/* ==========================================================================
   4. GAMIFICAÇÃO & RANKING (CONTA GIROS)
   ========================================================================== */

.ranking-section {
    background: #fdfdfd;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 2px;
    border-top: 4px solid #08245a;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.ranking-title {
    font-size: 0.85rem;
    color: #2c3e50;
    font-weight: bold;
    margin-bottom: 5px;
    text-transform: uppercase;
}

.ranking-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.card-checkin {
    background: linear-gradient(135deg, #f1c40f 0%, #07426f 100%);
    border-radius: 12px;
    padding: 18px;
    color: #2c3e50;
    box-shadow: 0 10px 20px rgba(241, 196, 15, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.4);
    margin-top: 15px;
    text-align: center;
}

.animated-pulse {
    animation: goldShadowPulse 2s infinite;
}

@keyframes goldShadowPulse {
    0% { box-shadow: 0 0 0 0 rgba(241, 196, 15, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(241, 196, 15, 0); }
    100% { box-shadow: 0 0 0 0 rgba(241, 196, 15, 0); }
}

.btn-checkin {
    width: 100%;
    min-height: 48px;
    padding: 12px;
    background-color: #2c3e50;
    color: #f1c40f;
    border: none;
    border-radius: 8px;
    font-weight: 800;
    text-transform: uppercase;
    cursor: pointer;
    margin-top: 10px;
}

/* ==========================================================================
   4.1. ESTILOS DE PATROCÍNIO (CONTA GIROS E POP-UPS)
   ========================================================================== */

.token-container {
    background: linear-gradient(270deg, #9c800f, #ff3e00, #9c800f);
    background-size: 600% 600%;
    animation: flowBG 5s ease infinite;
    padding: 25px 40px 40px 40px;
    border-radius: 15px;
    text-align: center;
    color: white;
    margin-top: 10px;
    margin-bottom: 5px;
    border: 2px solid rgba(255,255,255,0.2);
}

@keyframes flowBG {
    0%{background-position:0% 50%}
    50%{background-position:100% 50%}
    100%{background-position:0% 50%}
}

.token-code {
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: 4px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    user-select: all; 
}

.premium-pulse {
    animation: premiumPulseAnim 2s infinite;
}

@keyframes premiumPulseAnim {
    0% { stroke-width: 3px; stroke-opacity: 1; }
    50% { stroke-width: 10px; stroke-opacity: 0.3; }
    100% { stroke-width: 3px; stroke-opacity: 1; }
}

.sidebar-details {
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 5px;
    background: #fff;
    border: 1px solid #eee;
}

.sidebar-details.premium {
    border-left: 6px solid #f1c40f;
    background: linear-gradient(to right, #fffdf2, #ffffff);
    box-shadow: 0 4px 12px rgba(241, 196, 15, 0.1);
}

.sidebar-details pre {
    white-space: pre-wrap;
    font-family: inherit;
    font-size: 0.85rem;
    color: #34495e;
    background: rgba(0,0,0,0.03);
    padding: 10px;
    border-radius: 5px;
}

/* ==========================================================================
   5. NOVOS COMPONENTES v8.8 (REVISTA, ANUNCIANTE & FEEDBACK)
   ========================================================================== */

/* 5.1. CARD DA REVISTA E ALINHAMENTO LATERAL TOTAL */
.revista-card {
    /* Blindagem Lateral para 100% igualar às rotas */
    width: 100%;
    box-sizing: border-box;
    margin-left: 0;
    margin-right: 0;

    /* Cores e bordas */
    background-color: #ffffff; /* Restaurado o fundo branco */
    border-radius: 12px;
    border: 1px solid #e0e0e0; /* Borda suave */
    box-shadow: 0 4px 6px rgba(0,0,0,0.05); /* Sombra suave original */
    
    /* Controle de Margens Externas (Aproximar/Afastar de blocos vizinhos) */
    margin-top: 10px; 
    margin-bottom: 10px;

    /* Controle de Margens Internas (O Respiro) */
    padding-top: 2px; /* Ajuste fino do título da revista */
    padding-right: 15px;
    padding-bottom: 15px;
    padding-left: 15px;
    
    /* Garantia de alinhamento interno */
    display: flex;
    flex-direction: column;
    align-items: center; 
    text-align: center;
}

.revista-capa {
    width: 100%;
    max-width: 200px;
    height: auto;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 10px; /* Controle do espaço vertical entre a imagem e o botão */
    background: #ecf0f1;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.btn-ler-revista {
    margin-top: 0;
    display: block; 
    width: 100%;
    max-width: 200px; 
    background-color: #34495e;
    color: #ffffff;
    text-align: center;
    padding: 12px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.9rem;
    transition: background 0.3s ease;
    cursor: pointer;
    box-sizing: border-box; 
    border: none;
}

.btn-ler-revista:hover { 
    background-color: #2c3e50; 
    transform: translateY(-1px); 
}

/* 5.2. INTERFACE DO ANUNCIANTE (Pilar 1) */
.anunciante-box {
    background: #fdfdfd;
    border-radius: 10px;
    padding: 15px;
    margin: 20px 0;
    border: 2px dashed #bdc3c7;
}

.input-token {
    width: 100%;
    box-sizing: border-box;
    font-size: 1.5rem;
    text-align: center;
    letter-spacing: 4px;
    padding: 10px;
    margin: 10px 0;
    border: 2px solid #2c3e50;
    border-radius: 8px;
    background: #fff;
    color: #2c3e50;
    text-transform: uppercase;
}

/* 5.3. FEEDBACK & SUGESTÕES (Pilar 17) */
.sugestao-section {
    margin-top: 10px; /* Reduzido para aproximar do texto anterior */
    padding-top: 15px;
    border-top: 1px solid #eee;
    text-align: center; /* Garante que o texto de feedback obedeça o fluxo central */
}

.sugestao-section p {
    font-size: 0.75rem;
    color: #7f8c8d;
    margin-top: -5px;
    margin-bottom: 10px;
}

.sugestao-textarea {
    width: 100%;
    box-sizing: border-box;
    height: 80px;
    border-radius: 8px;
    border: 1px solid #ccc;
    padding: 10px;
    font-family: inherit;
    font-size: 0.85rem;
    resize: none;
    margin-bottom: 8px; /* Ajuste entre a caixa de texto e o botão */
}

/* ==========================================================================
   5.4. ROTAS GPX PREMIUM E PLANOS COMERCIAIS (NOVO)
   ========================================================================== */

#rotas-container {
    margin-bottom: -2px; /* Garante que a Revista cole mais perto das rotas */
    width: 100%; /* Força o container a usar todo o espaço */
}

.rota-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    /* Blindagem para garantir largura de 100% igual à da Revista */
    width: 100%;
    box-sizing: border-box;
}

.rota-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15) !important;
}

/* Diferenciação Visual do Plano PREMIUM (Golden) */
.rota-card.plano-golden {
    background: linear-gradient(to right, #ffffff, #fffdf2) !important;
    border-right: 5px solid #f1c40f; /* Destaque lateral direito em Ouro */
}

/* Interações de Botão no Card */
#rotas-container a {
    transition: background-color 0.2s ease, transform 0.1s ease;
}

#rotas-container a:active {
    transform: scale(0.98);
}

/* ==========================================================================
   7. GESTÃO DE LOGOS NO MAPA E NA BARRA LATERAL (NOVO ITEM 7)
   ========================================================================== */

.poi-logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 80px;
    height: 40px;
    margin-left: auto; /* Empurra para o extremo direito */
    border-radius: 4px;
    background-color: transparent;
}

.poi-logo-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* Garante logotipo (quadrado ou retangular) */
}

/* ==========================================================================
   8. RESPONSIVIDADE & RODAPÉ
   ========================================================================== */

.pg-toast {
    position: fixed;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: #2c3e50;
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    z-index: 9999;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transition: opacity 0.5s, transform 0.5s;
    
    /* 🔻 AJUSTES DE TAMANHO AQUI 🔻 */
    max-width: 80%; /* Impede que a caixa ocupe a tela toda no celular */
    width: max-content; 
    white-space: pre-line; /* Permite que o texto quebre em várias linhas */
    text-align: center; /* Centraliza o texto se ele quebrar linha */
    font-size: 0.85rem; /* Ajuste o tamanho da fonte se achar necessário */
    line-height: 1.4; /* Espaçamento entre as linhas */
}

.pg-toast.sucesso { background-color: #27ae60; }
.pg-toast.error { background-color: #e74c3c; }
.pg-toast.warning { background-color: #074e05; color: #fff; } /* Adicionei uma cor específica para o warning do GPS */

@media (max-width: 480px) {
    .sidebar {
        width: 100%; 
        height: calc(100vh - 60px);
        top: 60px;
    }
    
    .revista-capa {
        max-width: 140px; 
    }
}

footer {
    position: fixed;
    bottom: 0;
    width: 100%;
    height: 40px; 
    background-color: #ecf0f1;
    color: #7f8c8d;
    text-align: center;
    line-height: 40px;
    font-size: 0.75rem;
    border-top: 1px solid #dcdde1;
    z-index: 1100;
}

/* ==========================================================================
   9. REFRESH UX: Truncamento Dinâmico (Common POIs Only)
   ========================================================================== */

/* Wrapper que segura a descrição do ponto comum */
.poi-popup .common-desc-wrapper {
    position: relative;
    margin-bottom: 5px;
}

/* O texto em si, com transição suave */
.poi-popup .common-desc-text {
    transition: max-height 0.3s ease;
    overflow: hidden;
    color: #555;
    font-size: 0.9rem;
    line-height: 1.4;
    font-style: italic;
    margin: 8px 0 0 0;
}

/* ESTADO 1 (PADRÃO): ~4 linhas via CSS */
.poi-popup .common-desc-text.is-truncated {
    display: -webkit-box;
    -webkit-line-clamp: 4; /* Navegadores WebKit/Blink (Chrome, Safari, Edge) */
    line-clamp: 4;         /* Padrão W3C (Compatibilidade VSCode) */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ESTADO 2 (EXPANDIDO): Mostra tudo */
.poi-popup .common-desc-text.is-expanded {
    -webkit-line-clamp: unset;
    line-clamp: unset;
}

/* O Botão / Seta (Sombra azul suave para link) */
.poi-popup .common-read-more-btn {
    display: block;
    text-align: center;
    color: #3498db; 
    font-size: 0.8rem;
    font-weight: bold;
    cursor: pointer;
    margin-top: 2px;
    user-select: none;
    text-decoration: none;
}

/* Ícone da seta */
.poi-popup .common-read-more-btn i {
    margin-left: 3px;
    font-size: 0.8rem;
}
