: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;
}

/* --- SCROLLBAR GERAL (Mais bonita) --- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ===========================
   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;
    gap: 20px;
}
h1 { margin: 0; font-size: 1.5rem; display: flex; align-items: center; gap: 10px; font-weight: 600; white-space: nowrap; }
.logo-icon { color: var(--primary); font-size: 1.8rem; }

.header-actions { display: flex; gap: 10px; align-items: center; }

.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; font-size: 0.9rem;
    display: flex; align-items: center; gap: 8px;
}
.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;
    /* REMOVIDO: text-transform: uppercase; */
}
.tab-btn.active { color: var(--primary); border-bottom: 3px solid var(--primary); background: rgba(255,255,255,0.02); }

.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: 600; 
    /* REMOVIDO: text-transform: uppercase; */
}

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;
    min-width: 180px;
}
select { padding-right: 35px; }
select:focus, input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(227, 53, 13, 0.2); }

.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); 
}

/* ===========================
   SEARCH BAR
   =========================== */
.search-bar-container { position: relative; margin: 0 20px; flex-grow: 1; max-width: 400px; }
#poke-search {
    width: 100%; padding: 10px 40px 10px 15px; background: rgba(255,255,255,0.05);
    border: 1px solid var(--border); border-radius: 20px; color: white; font-size: 0.9rem; transition: 0.2s;
}
#poke-search:focus {
    border-color: var(--primary); background: rgba(255,255,255,0.08); box-shadow: 0 0 0 3px rgba(227, 53, 13, 0.1);
}
.search-icon {
    position: absolute; right: 15px; top: 50%; transform: translateY(-50%);
    opacity: 0.5; pointer-events: none; font-size: 0.9rem;
}

/* ===========================
   VIEWS & GRID
   =========================== */
.view {
    display: none !important; width: 100%; flex-grow: 1; position: relative; min-height: 0;
}
.view.active#view-dex { display: block !important; overflow-y: auto !important; height: 100%; }
.view.active#view-map { display: flex !important; flex-direction: column; overflow: hidden !important; height: 100%; }

#grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); 
    gap: 20px; padding: 25px; 
    overflow-y: visible !important;
    height: auto !important;
    padding-bottom: 20px; 
}

/* ===========================
   MAPA & TOOLBAR
   =========================== */
#map-container { 
    flex-grow: 1; 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); }
#color { width: 35px; height: 35px; border: none; border-radius: 50%; padding: 0; overflow: hidden; align-self: center; cursor: pointer; }

/* ===========================
   CARDS POKÉMON
   =========================== */
.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; }

/* Capitalização corrigida para o card */
.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);
    
    scrollbar-width: thin; 
    scrollbar-color: #444 transparent;
}

.modal-content::-webkit-scrollbar { width: 6px; }
.modal-content::-webkit-scrollbar-track { background: transparent; margin: 20px 0; }
.modal-content::-webkit-scrollbar-thumb { background: #444; border-radius: 10px; }
.modal-content::-webkit-scrollbar-thumb:hover { background: #666; }

.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; }

/* Capitalização corrigida para o modal */
.modal-title h2 { text-transform: capitalize; margin: 0; }

.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); }
/* Removido uppercase do titulo dos boxes também */
.specs-title { color: var(--info); font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; font-size: 0.8rem; 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; }

/* ===========================
   LANDING PAGE & TOAST
   =========================== */
#landing-page {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: var(--bg-dark);
    background-image: radial-gradient(circle at center, #1a1a1e 0%, #000 100%);
    z-index: 9999;
    display: flex; align-items: center; justify-content: center; text-align: center;
    padding: 20px;
}
.hero-content { max-width: 500px; animation: fadeIn 0.8s ease-out; }
.hero-logo { font-size: 3rem; margin-bottom: 10px; justify-content: center; }
.hero-subtitle { color: var(--text-sec); font-size: 1.1rem; margin-bottom: 40px; }
.auth-buttons { display: flex; flex-direction: column; gap: 15px; }
.hero-btn {
    padding: 15px 25px; border: none; border-radius: 50px; font-size: 1rem;
    font-weight: 600; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
    font-family: inherit; display: flex; align-items: center; justify-content: center; gap: 10px;
}
.hero-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.3); }
.login-btn { background: white; color: #333; }
.guest-btn { background: transparent; border: 2px solid var(--border); color: var(--text-main); }
.guest-btn:hover { border-color: var(--primary); color: var(--primary); }
.divider { color: var(--text-sec); font-size: 0.8rem; display: flex; align-items: center; justify-content: center; gap: 10px; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--border); width: 100%; }
.hero-note { font-size: 0.75rem; color: #555; margin-top: 20px; }

.toast-msg {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    background: var(--accent); color: #000; padding: 10px 20px; border-radius: 25px;
    font-weight: bold; box-shadow: 0 5px 15px rgba(0,0,0,0.3); z-index: 10000;
    animation: fadeUp 0.3s ease-out;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeUp { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ===========================
   RODAPÉ E ANÚNCIOS
   =========================== */
.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; }

/* ===========================
   CHAT IA WIDGET
   =========================== */
#ai-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Poppins', sans-serif;
}

#chat-toggle-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 12px 20px;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    transition: transform 0.2s;
}

#chat-toggle-btn:hover { transform: scale(1.05); }

#chat-container {
    position: absolute;
    bottom: 50px;
    right: 0;
    width: 350px;
    height: 500px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    overflow: hidden;
}

#chat-container.hidden { display: none; }

.chat-header {
    background: var(--bg-dark);
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.chat-header h3 { margin: 0; font-size: 1rem; color: var(--accent); }
.chat-header button { background: none; border: none; color: #fff; cursor: pointer; font-size: 1.2rem; }

#chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.message.bot {
    background: #333;
    align-self: flex-start;
    color: #eee;
}

.message.user {
    background: var(--info);
    align-self: flex-end;
    color: #fff;
}

.chat-input-area {
    padding: 10px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    background: var(--bg-dark);
}

.chat-input-area input {
    flex: 1;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #444;
    background: #222;
    color: #fff;
}

.chat-input-area button {
    background: var(--accent);
    border: none;
    padding: 0 15px;
    border-radius: 4px;
    cursor: pointer;
    color: #000;
    font-weight: bold;
}

/* RESPONSIVIDADE SEGURA (Só para não quebrar no celular) */
@media (max-width: 768px) {
    .footer-content { text-align: center; }
    .social-links { justify-content: center; }
    
    header { flex-wrap: wrap; gap: 10px; }
    .search-bar-container { order: 3; width: 100%; max-width: none; margin: 10px 0; }
    
    .toolbar {
        top: auto; bottom: 30px; 
        width: 90%; justify-content: space-between;
        padding: 10px 20px;
    }
}