/* ==============================================================================
   HABITANTES.ORG — Sistema de Diseño Moderno y Mobile-First (2026)
   ============================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
    --primary: #0284c7;
    --primary-hover: #0369a1;
    --primary-light: #e0f2fe;
    --primary-dark: #075985;
    
    --slate-900: #0f172a;
    --slate-800: #1e293b;
    --slate-700: #334155;
    --slate-600: #475569;
    --slate-500: #64748b;
    --slate-400: #94a3b8;
    --slate-300: #cbd5e1;
    --slate-200: #e2e8f0;
    --slate-100: #f1f5f9;
    --slate-50:  #f8fafc;
    
    --emerald-600: #059669;
    --emerald-50:  #ecfdf5;
    --emerald-border: #a7f3d0;
    
    --rose-600: #e11d48;
    --rose-50:  #fff1f2;
    --rose-border: #fecdd3;
    
    --amber-600: #d97706;
    --amber-50:  #fffbeb;

    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    color: var(--slate-800);
    background-color: #f8fafc;
    line-height: 1.6;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.container {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ==============================================================================
   Cabecera y Navegación
   ============================================================================== */
.site-header {
    background: #ffffff;
    border-bottom: 1px solid var(--slate-200);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
    gap: 20px;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 22px;
    color: var(--slate-900);
    text-decoration: none !important;
}

.brand-logo .logo-icon {
    font-size: 26px;
}

.brand-logo span {
    color: var(--primary);
}

.header-search {
    flex: 1;
    max-width: 460px;
    position: relative;
}

.search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrap input {
    width: 100%;
    height: 42px;
    padding: 0 40px 0 16px;
    border-radius: 30px;
    border: 1px solid var(--slate-300);
    background: var(--slate-50);
    font-size: 14px;
    font-family: var(--font-body);
    transition: all 0.2s ease;
}

.search-input-wrap input:focus {
    outline: none;
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.search-icon-btn {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    font-size: 16px;
    color: var(--slate-400);
    cursor: pointer;
}

.header-nav {
    display: flex;
    gap: 16px;
    align-items: center;
}

.header-nav a {
    font-weight: 600;
    font-size: 14px;
    color: var(--slate-700);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}

.header-nav a:hover {
    background: var(--slate-100);
    color: var(--primary);
}

.header-nav a.btn-cta {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.header-nav a.btn-cta:hover {
    background: var(--primary);
    color: #ffffff;
}

/* ==============================================================================
   Migas de Pan (Breadcrumbs)
   ============================================================================== */
.breadcrumbs-bar {
    background: #ffffff;
    border-bottom: 1px solid var(--slate-200);
    padding: 10px 0;
    font-size: 13px;
    color: var(--slate-500);
}

.breadcrumbs-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.breadcrumbs-list li::after {
    content: "›";
    margin-left: 6px;
    color: var(--slate-400);
}

.breadcrumbs-list li:last-child::after {
    display: none;
}

.breadcrumbs-list a {
    color: var(--slate-600);
}

.breadcrumbs-list a:hover {
    color: var(--primary);
}

.breadcrumbs-list .current {
    color: var(--slate-900);
    font-weight: 600;
}

/* ==============================================================================
   Hero & Cabecera de Página
   ============================================================================== */
.page-hero {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #ffffff;
    padding: 40px 0 35px;
    margin-bottom: 30px;
    border-bottom: 3px solid var(--primary);
}

.hero-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.12);
    color: #38bdf8;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    width: fit-content;
}

.page-hero h1 {
    font-family: var(--font-heading);
    font-size: 32px;
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -0.5px;
}

.page-hero .hero-subtitle {
    font-size: 16px;
    color: var(--slate-300);
    max-width: 800px;
}

/* ==============================================================================
   Tarjetas Métricas Demográficas
   ============================================================================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: #ffffff;
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--slate-200);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.15s, box-shadow 0.15s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.kpi-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--slate-500);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.kpi-value {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 800;
    color: var(--slate-900);
    margin: 6px 0 2px;
    line-height: 1.1;
}

.kpi-sub {
    font-size: 13px;
    color: var(--slate-600);
    display: flex;
    align-items: center;
    gap: 6px;
}

.badge-trend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
}

.badge-trend.up {
    background: var(--emerald-50);
    color: var(--emerald-600);
    border: 1px solid var(--emerald-border);
}

.badge-trend.down {
    background: var(--rose-50);
    color: var(--rose-600);
    border: 1px solid var(--rose-border);
}

/* Barra Hombres vs Mujeres */
.gender-bar-wrap {
    margin: 12px 0 6px;
}

.gender-bar {
    height: 12px;
    background: #f43f5e;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
}

.gender-bar-men {
    background: #0284c7;
    height: 100%;
}

.gender-legend {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
    color: var(--slate-600);
    margin-top: 4px;
}

.gender-legend .men { color: #0284c7; }
.gender-legend .women { color: #f43f5e; }

/* ==============================================================================
   Estructura Layout (2 Columnas)
   ============================================================================== */
.main-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 28px;
    margin-bottom: 40px;
}

.content-col {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.sidebar-col {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.card-box {
    background: #ffffff;
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--slate-200);
    box-shadow: var(--shadow-sm);
}

.card-box-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--slate-100);
    padding-bottom: 12px;
}

.card-box-title {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    color: var(--slate-900);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ==============================================================================
   Tablas Estilizadas
   ============================================================================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    text-align: left;
}

.custom-table th {
    background: var(--slate-100);
    color: var(--slate-700);
    font-weight: 700;
    padding: 12px 14px;
    border-bottom: 2px solid var(--slate-200);
    white-space: nowrap;
}

.custom-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--slate-200);
    color: var(--slate-800);
}

.custom-table tbody tr:hover {
    background: var(--slate-50);
}

.custom-table td.num {
    font-family: var(--font-heading);
    font-weight: 700;
    text-align: right;
}

.custom-table th.num {
    text-align: right;
}

/* ==============================================================================
   Hubs de Trámites y Empadronamiento (Sidebar)
   ============================================================================== */
.padron-cta-box {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    color: #ffffff;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
}

.padron-cta-box h3 {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 8px;
}

.padron-cta-box p {
    font-size: 14px;
    color: #e0f2fe;
    margin-bottom: 16px;
}

.padron-info-list {
    list-style: none;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
}

.padron-info-list li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.btn-padron-action {
    display: block;
    width: 100%;
    text-align: center;
    background: #ffffff;
    color: var(--primary-dark);
    font-weight: 700;
    font-size: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    text-decoration: none !important;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.btn-padron-action:hover {
    background: var(--slate-100);
    transform: translateY(-1px);
}

/* ==============================================================================
   Bloques Publicitarios AdSense Anti-CLS
   ============================================================================== */
.ad-slot-box {
    margin: 24px auto;
    text-align: center;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    overflow: hidden;
}

.ad-slot-box ins.adsbygoogle {
    display: block;
    margin: 0 auto;
}

/* ==============================================================================
   Preguntas Frecuentes (FAQ Accordion)
   ============================================================================== */
.faq-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.faq-item {
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.faq-question {
    width: 100%;
    text-align: left;
    background: #ffffff;
    border: none;
    padding: 16px 20px;
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 700;
    color: var(--slate-900);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.15s;
}

.faq-question:hover {
    background: var(--slate-50);
}

.faq-question::after {
    content: "+";
    font-size: 20px;
    color: var(--primary);
    font-weight: 400;
}

.faq-item.open .faq-question::after {
    content: "−";
}

.faq-answer {
    padding: 0 20px 16px;
    background: #ffffff;
    font-size: 14px;
    color: var(--slate-700);
    line-height: 1.6;
    display: none;
}

.faq-item.open .faq-answer {
    display: block;
}

/* ==============================================================================
   Pie de Página
   ============================================================================== */
.site-footer {
    background: var(--slate-900);
    color: var(--slate-400);
    padding: 50px 0 20px;
    margin-top: 60px;
    font-size: 14px;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.footer-col h4 {
    font-family: var(--font-heading);
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
}

.footer-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.footer-links a {
    color: var(--slate-400);
}

.footer-links a:hover {
    color: #ffffff;
}

.footer-bottom {
    border-top: 1px solid var(--slate-800);
    padding-top: 20px;
    text-align: center;
    font-size: 13px;
    color: var(--slate-500);
}

/* ==============================================================================
   Adaptación Móvil
   ============================================================================== */
@media (max-width: 900px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
    .header-inner {
        flex-wrap: wrap;
        height: auto;
        padding: 12px 0;
    }
    .header-search {
        order: 3;
        width: 100%;
        max-width: 100%;
    }
    .page-hero h1 {
        font-size: 24px;
    }
}

/* ==============================================================================
   Notice / Banner Metodológico Censo INE
   ============================================================================== */
.census-notice-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 24px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.census-notice-icon {
    font-size: 24px;
    flex-shrink: 0;
    line-height: 1;
    margin-top: 2px;
}

.census-notice-content h4 {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 700;
    color: var(--slate-900);
    margin-bottom: 4px;
}

.census-notice-content p {
    font-size: 13.5px;
    color: var(--slate-600);
    line-height: 1.55;
    margin: 0;
}

/* ==============================================================================
   Mapa Interactivo de Provincias de España y Top 10 Municipios
   ============================================================================== */
.map-card-wrapper {
    background: #ffffff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--slate-200);
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.map-province-layout {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 20px;
    align-items: stretch;
}

.map-viewport {
    width: 100%;
    height: 380px;
    position: relative;
    overflow: hidden;
    background: #f8fafc;
    border-radius: var(--radius-md);
    border: 1px solid var(--slate-200);
    touch-action: none;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.map-viewport:active {
    cursor: grabbing;
}

.map-controls-bar {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 50;
}

.map-btn {
    background: #ffffff;
    color: var(--slate-800);
    border: 1px solid var(--slate-300);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.15s ease;
}

.map-btn:hover {
    background: var(--slate-100);
    color: var(--primary);
}

.map-province-g {
    cursor: pointer;
}

.map-province-g path, .map-province-g polygon, .map-province-g circle {
    fill: #cbd5e1;
    stroke: #ffffff;
    stroke-width: 0.8;
    transition: fill 0.2s ease;
}

.map-province-g:hover path, .map-province-g:hover polygon, .map-province-g:hover circle {
    fill: #38bdf8 !important;
}

.map-province-g.is-active path, .map-province-g.is-active polygon, .map-province-g.is-active circle {
    fill: #0284c7 !important;
}

.map-province-g text {
    display: none;
}

#map-tooltip {
    display: none;
    position: fixed;
    background: #0f172a;
    color: #ffffff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    pointer-events: none;
    z-index: 9999;
    box-shadow: var(--shadow-md);
    white-space: nowrap;
    border: 1px solid var(--slate-700);
}

.top-pueblos-card {
    background: #ffffff;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.top-pueblos-card h3 {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 700;
    color: var(--slate-900);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.top-pueblos-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    max-height: 310px;
}

.top-pueblos-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    border-radius: 6px;
    background: #f8fafc;
    transition: background 0.15s ease;
}

.top-pueblos-item:hover {
    background: #f1f5f9;
}

.top-pueblos-item a {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--slate-800);
    text-decoration: none;
}

.top-pueblos-item a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.top-pueblos-rank {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    margin-right: 6px;
}

.top-pueblos-badge {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    background: #e0f2fe;
    padding: 2px 8px;
    border-radius: 10px;
}

@media (max-width: 900px) {
    .map-province-layout {
        grid-template-columns: 1fr;
    }
    .map-viewport {
        height: 300px;
    }
}


