:root {
    color-scheme: dark;
    --primary: #e3350d;
    --bg-dark: #121214;
    --bg-card: #202024;
    --text-main: #e1e1e6;
    --text-sec: #a8a8b3;
    --accent: #04d361; 
    --info: #3b82f6;   
    --danger: #ef4444; 
    --teleport: #00bcd4;
    --tm-color: #f5a623;
    --edit: #f39c12;
    --border: rgba(255, 255, 255, 0.1);
}

* { box-sizing: border-box; }

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-dark);
    margin: 0; padding: 0; color: var(--text-main);
    height: 100vh; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; /* O corpo nunca rola */
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }

/* ===========================
   HEADER & CONTROLS
   =========================== */
header {
    background-color: rgba(18, 18, 20, 0.95); padding: 15px 25px;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--border); z-index: 100;
    flex-shrink: 0; /* Garante que o header não encolha */
}
h1 { margin: 0; font-size: 1.5rem; display: flex; align-items: center; gap: 10px; font-weight: 600; }
.logo-icon { color: var(--primary); font-size: 1.8rem; }

.btn {
    background: rgba(255,255,255,0.05); border: 1px solid var(--border);
    color: var(--text-main); padding: 8px 16px; border-radius: 12px;
    cursor: pointer; transition: 0.2s; font-family: inherit; font-weight: 500;
}
.btn:hover { background: rgba(255,255,255,0.1); transform: translateY(-1px); }

.tabs { 
    display: flex; background: var(--bg-dark); border-bottom: 1px solid var(--border); 
    flex-shrink: 0;
}
.tab-btn {
    flex: 1; padding: 15px; background: transparent; border: none;
    color: var(--text-sec); cursor: pointer; font-weight: 600; font-size: 1rem;
    border-bottom: 3px solid transparent; transition: 0.3s;
}
.tab-btn.active { color: var(--primary); border-bottom: 3px solid var(--primary); }

.controls {
    background: var(--bg-card); padding: 15px 25px;
    display: flex; gap: 15px; align-items: center;
    border-bottom: 1px solid var(--border); flex-wrap: wrap;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    flex-shrink: 0;
}
label { display: block; margin-bottom: 5px; font-size: 0.85rem; color: var(--text-sec); font-weight: 500; }

select, input[type="text"] {
    background-color: #121214; color: white;
    border: 1px solid var(--border); padding: 10px 12px;
    border-radius: 12px; font-size: 0.9rem; outline: none; cursor: pointer; font-family: inherit;
}
select { padding-right: 35px; } /* Espaço para seta */
select:focus, input:focus { border-color: var(--primary); }

.map-adder { display: flex; gap: 8px; align-items: center; background: rgba(255,255,255,0.03); padding: 5px; border-radius: 12px; border: 1px solid var(--border); }
.map-btn { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 8px; border: none; cursor: pointer; transition: 0.2s; font-size: 1.1rem; }
.btn-save { background: var(--accent); color: #000; }
.btn-del { background: var(--danger); color: white; }
.map-btn:hover { transform: scale(1.1); filter: brightness(1.1); }

.stats { margin-left: auto; font-size: 0.9rem; font-weight: 600; color: var(--primary); background: rgba(227, 53, 13, 0.1); padding: 6px 14px; border-radius: 20px; border: 1px solid rgba(227, 53, 13, 0.2); }

/* ===========================
   LAYOUT PRINCIPAL (VIEWS)
   =========================== */

/* Base para todas as views */
.view {
    display: none !important; /* Oculto por padrão */
    width: 100%;
    flex-grow: 1; /* Ocupa o espaço restante da tela */
    position: relative;
    min-height: 0; /* Corrige comportamento do Flexbox */
}

/* --- VIEW DA POKEDEX --- */
.view.active#view-dex {
    display: block !important;
    overflow-y: auto !important; /* Habilita rolagem vertical */
    height: 100%;
}

#grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); 
    gap: 20px; padding: 25px; 
    overflow-y: visible !important; /* Conteúdo flui naturalmente */
    height: auto !important;
    padding-bottom: 20px; 
}

/* --- VIEW DO MAPA --- */
.view.active#view-map {
    display: flex !important; /* Layout Flex para preencher altura */
    flex-direction: column;
    overflow: hidden !important; /* Bloqueia rolagem */
    height: 100%;
}

#map-container { 
    flex-grow: 1; /* Ocupa todo o espaço disponível no pai */
    width: 100%;
    height: 100%; 
    position: relative; 
    background: #0f0f10; 
    overflow: hidden; 
    cursor: crosshair; 
    background-image: radial-gradient(#222 1px, transparent 1px); 
    background-size: 24px 24px; 
}

#canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.toolbar { 
    position: absolute; top: 20px; left: 50%; transform: translateX(-50%); 
    background: rgba(32, 32, 36, 0.9); padding: 10px 20px; border-radius: 50px; 
    display: flex; gap: 15px; z-index: 10; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); backdrop-filter: blur(10px); 
    border: 1px solid var(--border); 
}
.tool { width: 45px; height: 45px; border: none; background: transparent; color: #bbb; border-radius: 50%; cursor: pointer; font-size: 1.4rem; display: flex; align-items: center; justify-content: center; transition: 0.2s; }
.tool.active { background: var(--primary); color: white; box-shadow: 0 0 20px rgba(227, 53, 13, 0.4); }

/* ===========================
   CARDS & MODAIS
   =========================== */
.card {
    background: var(--bg-card); border-radius: 20px; padding: 15px; text-align: center;
    border: 2px solid transparent; cursor: pointer; transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative; box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.card:hover { transform: translateY(-5px); border-color: var(--accent); box-shadow: 0 0 15px rgba(4, 211, 97, 0.2); }
.card img { width: 100px; height: 100px; object-fit: contain; filter: grayscale(100%) opacity(0.5); transition: 0.4s; }
.card.captured { background: linear-gradient(145deg, #1a2e1a, #132013); border-color: var(--accent); }
.card.captured img { filter: grayscale(0%) opacity(1) drop-shadow(0 0 8px rgba(4, 211, 97, 0.4)); }
.card.captured .card-name { color: var(--accent); }
.card-num { font-size: 0.75rem; font-weight: 700; color: #555; position: absolute; top: 12px; left: 15px; }
.card-name { font-size: 0.95rem; text-transform: capitalize; font-weight: 600; color: var(--text-sec); margin-top: 5px; }

.info-btn {
    position: absolute; top: 10px; right: 10px; width: 28px; height: 28px;
    background-color: rgba(255, 255, 255, 0.1); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; color: white; z-index: 10;
    opacity: 0; transform: translateY(-5px);
    transition: all 0.3s ease; border: 1px solid rgba(255,255,255,0.1);
}
.card:hover .info-btn { opacity: 1; transform: translateY(0); }
.info-btn:hover { background-color: var(--info); border-color: var(--info); transform: scale(1.15); box-shadow: 0 0 10px var(--info); }

/* MODAL */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); z-index: 1000;
    display: none; justify-content: center; align-items: center;
    backdrop-filter: blur(5px);
}
.modal-content {
    background: #18181b; width: 90%; max-width: 550px;
    border-radius: 24px; padding: 30px; color: white;
    box-shadow: 0 25px 50px rgba(0,0,0,0.7);
    max-height: 85vh; overflow-y: auto; position: relative;
    border: 1px solid var(--border);
}
.modal-header { display: flex; align-items: center; gap: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 20px; }
.modal-img { width: 100px; height: 100px; background: rgba(255,255,255,0.03); border-radius: 50%; padding: 10px; border: 1px solid var(--border); }
.modal-types { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.type-badge { padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }

.stat-row { display: flex; align-items: center; margin-bottom: 8px; font-size: 0.85rem; }
.stat-label { width: 90px; color: var(--text-sec); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; }
.stat-val { width: 35px; text-align: right; font-weight: bold; margin-right: 10px; }
.stat-bar-bg { flex-grow: 1; background: #333; height: 8px; border-radius: 10px; overflow: hidden; }
.stat-bar-fill { height: 100%; border-radius: 10px; background: linear-gradient(90deg, var(--info), #60a5fa); }

.specs-box { background: rgba(255,255,255,0.03); padding: 20px; border-radius: 16px; margin-top: 20px; border: 1px solid var(--border); }
.specs-title { color: var(--info); font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; }
.specs-title::before { content: '⚡'; font-size: 1rem; } 

.build-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.build-slot { background: #202024; padding: 10px; border-radius: 12px; text-align: center; font-weight: 600; text-transform: capitalize; font-size: 0.9rem; border: 1px solid var(--border); color: #fff; }
.build-slot.stab { border-color: rgba(59, 130, 246, 0.3); color: #93c5fd; }
.build-slot.cover { border-color: rgba(245, 166, 35, 0.3); color: #fde047; }

.move-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.move-tag { padding: 6px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 500; text-transform: capitalize; display: flex; align-items: center; gap: 6px; border: 1px solid rgba(255,255,255,0.1); background: rgba(255,255,255,0.02); }
.move-tag.natural { color: #86efac; border-color: rgba(4, 211, 97, 0.2); }
.move-tag.tm { color: #fcd34d; border-color: rgba(245, 166, 35, 0.2); }
.level-info { font-size: 0.7rem; opacity: 0.7; background: rgba(0,0,0,0.3); padding: 1px 5px; border-radius: 6px; margin-left: 5px; }

.user-notes { width: 100%; height: 100px; background: #121214; border: 1px solid var(--border); color: #eee; margin-top: 10px; border-radius: 12px; padding: 15px; font-family: inherit; font-size: 0.9rem; outline: none; }
.user-notes:focus { border-color: var(--primary); }
.close-modal { position: absolute; top: 20px; right: 25px; cursor: pointer; font-size: 2rem; color: var(--text-sec); transition: 0.2s; }
.close-modal:hover { color: white; }

/* ===========================
   RODAPÉ E MONETIZAÇÃO
   =========================== */
.ad-container {
    width: 100%; max-width: 728px; margin: 40px auto 0;
    background: #1a1a1a; border: 1px dashed #444; text-align: center;
    padding: 10px; border-radius: 8px; min-height: 90px;
    display: flex; align-items: center; justify-content: center;
}
.ad-placeholder { color: #555; font-size: 0.9rem; }

.app-footer {
    background-color: #0d0d0d; border-top: 3px solid var(--accent);
    color: #ccc; padding: 40px 20px; margin-top: auto; font-size: 0.9rem;
}
.footer-content {
    max-width: 1200px; margin: 0 auto; display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 30px;
}
.footer-section h3 {
    color: #fff; border-bottom: 2px solid #333; padding-bottom: 10px; margin-bottom: 15px; font-size: 1.1rem;
}
.footer-section p { line-height: 1.6; margin-bottom: 10px; color: #aaa; }
.footer-section a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
.footer-section a:hover { color: #fff; text-decoration: underline; }
.disclaimer { font-size: 0.75rem; color: #666 !important; margin-top: 10px; }

.social-links { display: flex; flex-wrap: wrap; gap: 15px; }
.social-links a { background: #222; padding: 8px 12px; border-radius: 4px; font-weight: bold; }
.social-links a:hover { background: var(--accent); color: #000; text-decoration: none; }

.kofi-button { display: inline-block; margin-top: 10px; transition: transform 0.2s; }
.kofi-button:hover { transform: scale(1.05); text-decoration: none !important; }
.kofi-button img { vertical-align: middle; border-radius: 5px; }

@media (max-width: 768px) {
    .footer-content { text-align: center; }
    .social-links { justify-content: center; }
}
