/* --- VARIABLES Y BASES --- */
:root { 
    --pk-red: #e74c3c; 
    --pk-dark: #2c3e50; 
    --gold: #f1c40f; 
    --bg: #edeff1; 
}

body { 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    background: var(--bg); 
    margin: 0; 
    padding: 15px; /* Bajamos un poco el padding general en móvil */
    color: #444; 
}

@media (min-width: 600px) {
    body { padding: 20px; }
}

.container { max-width: 1100px; margin: 0 auto; }

/* --- HEADER SECTION (ESTILO POKOPIA) --- */
.header-section { 
    position: relative;
    color: rgb(255, 255, 255); 
    padding: 25px 15px; 
    border-radius: 20px; 
    border-bottom: 3px solid #ff0000; 
    text-align: center; 
    margin-bottom: 25px; 
    overflow: hidden;
}

.header-section::before {
    content: "";
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: linear-gradient(to bottom, rgb(0 0 0 / 55%) 0%, rgb(0 0 0 / 33%) 100%), 
                      url(../img/portadas/pokopia-bg.jpeg);
    background-size: cover;
    background-position: center;
    filter: blur(1.3px);
    transform: scale(1.1); 
    z-index: 1;
}

.header-section > * { position: relative; z-index: 2; }

.header-section h1 { 
    margin: 0; 
    text-transform: uppercase; 
    letter-spacing: 1px; 
    font-size: 1.8em; 
    margin-bottom: 5px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.header-section p { 
    opacity: 0.9; 
    font-size: 0.9em; 
    margin-top: 5px; 
    font-weight: 600; 
}

@media (min-width: 600px) {
    .header-section { padding: 40px 20px; margin-bottom: 30px; }
    .header-section h1 { font-size: 2.2em; letter-spacing: 2px; }
    .header-section p { font-size: 1em; }
}

/* --- BREADCRUMBS --- */
.nav-breadcrumb { margin-bottom: 15px; font-size: 0.8em; font-weight: bold; }
.nav-breadcrumb a { color: var(--pk-red); text-decoration: none; text-transform: uppercase; }

/* --- GRILLA DE HABITATS (2 COLUMNAS EN MÓVIL) --- */
.habitat-grid { 
    display: grid; 
    grid-template-columns: repeat(2, 1fr); 
    gap: 12px; 
}

@media (min-width: 600px) {
    .habitat-grid { 
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); 
        gap: 20px; 
    }
}

/* --- HABITAT CARD --- */
.habitat-card { 
    background: white; 
    border-radius: 18px; 
    overflow: hidden; 
    text-decoration: none; 
    color: inherit; 
    box-shadow: 0 6px 15px rgba(0,0,0,0.05); 
    transition: all 0.3s ease;
    border: 1px solid #eee;
    display: flex;
    flex-direction: column;
}

.habitat-card:hover { 
    transform: translateY(-5px); 
    box-shadow: 0 10px 25px rgba(0,0,0,0.1); 
    border-color: var(--pk-red); 
}

.habitat-card .img-wrapper { 
    position: relative; 
    height: 100px; 
    overflow: hidden; 
    background: #ddd; 
}

.habitat-card img { width: 100%; height: 100%; object-fit: cover; transition: 0.5s; }
.habitat-card:hover img { transform: scale(1.1); }

.habitat-card .info { padding: 12px; text-align: center; }

.habitat-card .num { 
    font-size: 0.65em; 
    font-weight: 900; 
    color: var(--pk-red); 
    opacity: 0.6; 
    display: block; 
    margin-bottom: 3px; 
}

.habitat-card h2 { 
    margin: 0; 
    font-size: 0.9em; 
    text-transform: uppercase; 
    color: var(--pk-dark); 
    letter-spacing: 0.5px; 
}

@media (min-width: 600px) {
    .habitat-card .img-wrapper { height: 130px; }
    .habitat-card .info { padding: 20px; }
    .habitat-card h2 { font-size: 1.1em; letter-spacing: 1px; }
    .habitat-card .num { font-size: 0.75em; }
}

/* --- GRILLA DE POKÉMON (DENTRO DEL HABITAT) --- */
.poke-grid { 
    display: grid; 
    grid-template-columns: repeat(2, 1fr); 
    gap: 12px; 
}

@media (min-width: 600px) {
    .poke-grid { 
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); 
        gap: 20px; 
    }
}

.poke-card { 
    background: white; 
    border-radius: 18px; 
    padding: 12px; 
    text-align: center; 
    text-decoration: none; 
    color: var(--pk-dark); 
    border: 1px solid #eee; 
    transition: 0.3s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.04);
}

.poke-card .number {
    font-size: 0.65em;
    color: #999;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.poke-card:hover { 
    border-color: var(--pk-red); 
    transform: translateY(-5px); 
    box-shadow: 0 8px 20px rgba(0,0,0,0.08); 
}

.poke-card img { 
    width: 75px; 
    height: 75px; 
    object-fit: contain; 
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1)); 
}

.poke-card strong { 
    display: block; 
    margin-top: 8px; 
    text-transform: uppercase; 
    font-size: 0.85em; 
    letter-spacing: 0.5px; 
}

@media (min-width: 600px) {
    .poke-card { padding: 15px; }
    .poke-card img { width: 90px; height: 90px; }
    .poke-card strong { font-size: 0.95em; }
}

/* --- ELEMENTOS DE RAREZA --- */
.rare-badge { 
    display: inline-block; 
    margin-top: 8px; 
    font-size: 0.6em; 
    font-weight: 800; 
    background: #f8f9fa; 
    padding: 4px 8px; 
    border-radius: 10px; 
    color: #888; 
    text-transform: uppercase;
    border: 1px solid #eee;
}

.stars { color: var(--gold); font-size: 0.75em; margin-top: 2px; display: block; }

/* --- BUSCADOR (HOME-SEARCH) --- */
.home-search { margin-bottom: 25px; }
.search-bar { 
    display: flex; 
    align-items: center; 
    background: #fff; 
    padding: 10px 15px; 
    border-radius: 50px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}
.search-bar input { 
    border: none; 
    outline: none; 
    width: 100%; 
    padding: 5px 10px; 
    font-size: 1em; 
}
.search-bar i { color: #ccc; }

/* Descripción del Hábitat */
.habitat-desc {
    max-width: 800px;
    margin: 15px auto;
    font-size: 1em;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
    font-style: italic;
}

/* Imagen Principal del Hábitat */
.habitat-image-main {
    margin-top: 20px;
    max-width: 450px;
    margin-left: auto;
    margin-right: auto;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    border: 3px solid rgba(255, 255, 255, 0.2);
}

.habitat-image-main img {
    width: 100%;
    display: block;
    transition: transform 0.5s ease;
}

.habitat-image-main:hover img {
    transform: scale(1.05);
}

@media (max-width: 600px) {
    .habitat-image-main { max-width: 100%; }
    .habitat-desc { font-size: 0.9em; padding: 0 10px; }
}

.materials-container {
    background: rgba(255, 255, 255, 0.685);
    border-radius: 12px;
    padding: 12px;
    margin: 15px auto 0;
    max-width: fit-content;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.materials-title {
    display: block;
    font-size: 0.75em;
    text-transform: uppercase;
    font-weight: 800;
    margin-bottom: 8px;
    color: rgb(0, 0, 0);
}

.materials-list {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.material-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.4); /* Un poco más de fondo para resaltar sobre el contenedor */
    padding: 4px 10px;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.05); /* Un borde muy sutil */
}

.material-item img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.material-item .qty {
    font-weight: 700;
    font-size: 0.85em;
    color: #000000;
}

/* Estilo para Ubicaciones (Categoría 5) */
.material-item.lugar-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(41, 128, 185, 0.1);
    border: 1px solid rgba(41, 128, 185, 0.3);
    padding: 5px 12px;
    border-radius: 8px;
    min-width: auto; /* Dejamos que crezca según el texto */
}

.material-item.lugar-item img {
    margin-right: 8px;
    width: 28px; /* Un pelín más grande para las ubicaciones */
}

.material-item.lugar-item .qty {
    color: #2980b9;
    font-weight: 800;
}

/* Materiales comunes (Categoría != 5) */
.material-item:not(.lugar-item) {
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(0,0,0,0.05);
}

/* Contenedor de las pestañas */
.tabs-container {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    border-bottom: 2px solid #f0f0f0;
}

/* Estilo de los botones */
.tab-btn {
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 600;
    color: #666;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
}

/* Estado al pasar el mouse */
.tab-btn:hover {
    color: #e74c3c;
}

/* Estado activo (la solapa seleccionada) */
.tab-btn.active {
    color: #e74c3c;
    border-bottom-color: #e74c3c;
}

/* --- CORRECCIÓN SISTEMA DE SOLAPAS --- */

/* 1. Ocultamos por defecto */
.tab-content {
    display: none; 
}

/* 2. Cuando está activa, usamos block para que el hijo (.habitat-grid) 
      pueda usar su propio display: grid libremente */
.tab-content.active {
    display: block !important;
    animation: fadeIn 0.3s ease-in-out;
}

/* 3. Aseguramos que la grilla ocupe todo el ancho */
.tab-content.active .habitat-grid {
    display: grid; /* Esto reactiva tu configuración de columnas original */
}

/* 4. Ajuste para que las pestañas no se peguen en móvil */
@media (max-width: 600px) {
    .tabs-container {
        gap: 5px;
        justify-content: space-around;
    }
    .tab-btn {
        padding: 10px 5px;
        font-size: 14px;
        flex: 1;
    }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}