/* ==========================================================================
   ILICILEX - ESTILO INSTITUCIONAL PREMIUM (INSPIRADO EN PORTAL JURÍDIC GENCAT)
   ========================================================================== */

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

:root {
    /* Paleta Institucional */
    --color-header-bg: #1c1c1c;      /* Negro/Gris muy oscuro para cabecera corporativa */
    --color-primary: #0a4435;        /* Verde Palmeral Institucional */
    --color-primary-light: #155d49;  /* Verde Palmeral más claro */
    --color-accent: #b21f24;         /* Rojo/Granate institucional para alertas/botones principales (inspiración Gencat) */
    --color-accent-hover: #91161a;
    --color-border: #dcdcdc;         /* Gris de borde limpio */
    --color-bg-light: #f5f5f5;       /* Fondo gris claro neutro */
    --color-bg-white: #ffffff;
    --color-text-dark: #222222;      /* Texto de lectura */
    --color-text-muted: #555555;     /* Texto secundario */
    --color-accent-gold: #c4a475;    /* Oro viejo secundario */
    
    /* Estados */
    --color-vigente: #2e7d32;
    --color-derogado: #c62828;
    --color-modificado: #ef6c00;

    /* Fuentes */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-serif: 'Lora', Georgia, serif;
    
    /* Variables de Estructura */
    --max-width: 1200px;
    --radius-sm: 4px;
    --radius-md: 6px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05);
}

/* Modo Lectura / Modo Noche */
[data-theme="dark"] {
    --color-bg-light: #121212;
    --color-bg-white: #1e1e1e;
    --color-text-dark: #e0e0e0;
    --color-text-muted: #aaaaaa;
    --color-border: #333333;
    --color-header-bg: #0c0c0c;
    --color-primary: #155d49;
    --color-primary-light: #217e65;
}

/* Reset de Estilos */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--color-bg-light);
    color: var(--color-text-dark);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--color-accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Cabecera Superior Corporativa (Gencat style) */
.site-header {
    background-color: var(--color-header-bg);
    color: #ffffff;
    border-bottom: 3px solid var(--color-primary);
}

.header-top-bar {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0.6rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-gencat-style {
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: -0.5px;
    color: #ffffff;
}

.logo-gencat-style span {
    font-weight: 400;
    color: #cccccc;
    font-size: 0.9rem;
    border-left: 1px solid #555555;
    padding-left: 0.75rem;
    margin-left: 0.75rem;
}

.header-top-links {
    display: flex;
    gap: 1.5rem;
    color: #cccccc;
}

.header-top-links a {
    color: #cccccc;
}

.header-top-links a:hover {
    color: #ffffff;
    text-decoration: none;
}

/* Barra de Navegación Principal */
.main-nav-bar {
    background-color: #ffffff;
    border-bottom: 1px solid var(--color-border);
}

.main-nav-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-menu {
    display: flex;
    list-style: none;
}

.nav-item {
    border-right: 1px solid #eeeeee;
}

.nav-link {
    display: block;
    padding: 1.2rem 1.8rem;
    color: #333333;
    font-weight: 500;
    font-size: 0.95rem;
    border-bottom: 3px solid transparent;
}

.nav-link:hover {
    color: var(--color-primary);
    text-decoration: none;
    background-color: #fafafa;
}

.nav-link.active {
    color: var(--color-accent);
    font-weight: 700;
    border-bottom-color: var(--color-accent);
}

/* Contenido Principal */
.site-content {
    flex: 1;
    background-color: #ffffff;
}

/* Sección Buscador Principal (Home) */
.home-search-section {
    background-color: #ffffff;
    padding: 4rem 2rem 3.5rem;
    text-align: center;
    border-bottom: 1px solid #eaeaea;
}

.search-title {
    font-size: 2.1rem;
    font-weight: 400;
    color: #111111;
    margin-bottom: 0.5rem;
}

.search-subtitle {
    font-size: 1rem;
    color: var(--color-text-muted);
    margin-bottom: 2rem;
}

.search-box-gencat {
    max-width: 650px;
    margin: 0 auto;
}

.search-input-group {
    display: flex;
    border: 1px solid #a0a0a0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 1rem;
}

.search-input-gencat {
    flex: 1;
    padding: 0.85rem 1.2rem;
    font-size: 1.05rem;
    border: none;
    outline: none;
    font-family: var(--font-sans);
    color: var(--color-text-dark);
}

.search-btn-gencat {
    background-color: var(--color-accent);
    border: none;
    width: 55px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.search-btn-gencat:hover {
    background-color: var(--color-accent-hover);
}

.search-btn-gencat svg {
    width: 20px;
    height: 20px;
    fill: #ffffff;
}

/* Checkboxes de Opciones debajo del buscador */
.search-options {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    font-size: 0.9rem;
    color: var(--color-text-dark);
    margin-bottom: 1rem;
}

.search-options label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
}

.search-options input[type="checkbox"] {
    accent-color: var(--color-accent);
    width: 15px;
    height: 15px;
}

/* Layout del Home de Dos Columnas */
.home-columns-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 3rem 2rem;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 3.5rem;
}

.column-title {
    font-size: 1.5rem;
    font-weight: 500;
    color: #111111;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #eaeaea;
    padding-bottom: 0.75rem;
}

/* Lista de Últimas Disposiciones */
.disposition-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.disposition-item {
    border-bottom: 1px solid #eeeeee;
    padding-bottom: 1.25rem;
}

.disposition-title {
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 0.4rem;
}

.disposition-title a {
    color: var(--color-accent);
}

.disposition-title a:hover {
    color: var(--color-accent-hover);
}

.disposition-meta {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.disposition-meta span {
    margin-right: 0.75rem;
}

.disposition-meta span:not(:last-child)::after {
    content: " |";
    color: #cccccc;
    margin-left: 0.75rem;
}

/* Columna Derecha (Enlaces Directos / Widgets) */
.right-widget {
    background-color: #fafafa;
    border: 1px solid var(--color-border);
    padding: 1.5rem;
    border-radius: var(--radius-sm);
    margin-bottom: 2rem;
}

.widget-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #333333;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 0.5rem;
}

.direct-links-list {
    list-style: none;
}

.direct-links-list li {
    margin-bottom: 0.75rem;
}

.direct-links-list a {
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--color-accent);
}

/* Badges Institucionales */
.badge-inst {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

.badge-inst-vigente { color: var(--color-vigente); font-weight: 700; }
.badge-inst-derogado { color: var(--color-derogado); font-weight: 700; }
.badge-inst-modificado { color: var(--color-modificado); font-weight: 700; }
.badge-inst-borrador { color: #757575; font-weight: 700; text-transform: uppercase; }

/* Buscador Page Layout */
.buscador-layout {
    max-width: var(--max-width);
    margin: 2rem auto 5rem;
    padding: 0 2rem;
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 3rem;
}

.filters-pane {
    background-color: #fafafa;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 1.5rem;
}

.filter-group {
    margin-bottom: 1.5rem;
}

.filter-group h4 {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #444444;
    margin-bottom: 0.5rem;
}

.results-pane {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Visor de Documento Estilo Gencat */
.document-layout {
    max-width: var(--max-width);
    margin: 2rem auto 5rem;
    padding: 0 2rem;
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 3rem;
}

.document-main {
    background-color: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 3rem;
    box-shadow: var(--shadow-sm);
    max-width: 100%;
    overflow-x: hidden; /* Evita que desbordamientos internos ensanchen la columna y rompan la rejilla */
}

.document-title {
    font-family: var(--font-sans);
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.3;
    color: #111111;
    margin-bottom: 1rem;
}

.document-body {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    color: #222222;
    line-height: 1.7;
    margin-top: 2rem;
}

.document-body h2 {
    font-family: var(--font-sans);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-primary);
    margin: 2.5rem 0 1rem;
    border-bottom: 2px solid var(--color-primary);
    padding-bottom: 0.25rem;
}

.document-body h3 {
    font-family: var(--font-sans);
    font-size: 1.1rem;
    font-weight: 600;
    color: #111111;
    margin: 1.5rem 0 0.5rem;
}

.document-body p {
    margin-bottom: 1.25rem;
    text-align: justify;
    text-align-last: left; /* Corrige los huecos gigantes en el justificado al final del párrafo */
}

/* Espaciado del articulado reconstruido dinámicamente */
.document-body .legal-node {
    margin-top: 2.2rem;
    margin-bottom: 0.75rem;
}

.document-body .node-text {
    margin-bottom: 1.8rem;
    text-align: justify;
    text-align-last: left; /* Evita justificado forzado en la última línea de texto libre */
    font-size: 1.05rem;
    line-height: 1.8;
}

.document-body .node-text p {
    margin-bottom: 1rem;
}


/* Sidebar Documento */
.document-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidebar-box {
    background-color: #fafafa;
    border: 1px solid var(--color-border);
    padding: 1.5rem;
    border-radius: var(--radius-sm);
}

.sidebar-box h4 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 0.5rem;
    color: #333333;
}

.info-table td {
    padding: 0.4rem 0;
    font-size: 0.85rem;
}

/* Footer Corporativo */
.site-footer {
    background-color: var(--color-header-bg);
    color: #cccccc;
    padding: 3rem 2rem 1.5rem;
    border-top: 4px solid var(--color-primary);
}

.footer-container {
    max-width: var(--max-width);
    margin: 0 auto;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 3rem;
}

.footer-brand h3 {
    color: #ffffff;
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.footer-links h4 {
    color: #ffffff;
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.footer-links a {
    color: #bbbbbb;
    font-size: 0.85rem;
}

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

.footer-bottom {
    max-width: var(--max-width);
    margin: 2rem auto 0;
    padding-top: 1.2rem;
    border-top: 1px solid #333333;
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #888888;
}

/* Botón Primario Institucional */
.btn-primary {
    background-color: var(--color-accent);
    color: #ffffff !important;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    display: inline-block;
    text-align: center;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: var(--color-accent-hover);
    text-decoration: none;
}

/* Menú de Índice Dinámico tipo Timeline (Gencat style premium) */
.index-menu {
    list-style: none;
    position: relative;
    border-left: 1px solid var(--color-border);
    padding-left: 1.25rem;
    margin-left: 0.5rem;
}

.index-menu li {
    margin-bottom: 0.8rem;
    position: relative;
}

.index-menu a {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    display: block;
    padding: 0.15rem 0;
    transition: all 0.2s ease;
}

.index-menu a::before {
    content: '';
    position: absolute;
    left: calc(-1.25rem - 4.5px);
    top: 7px;
    width: 8px;
    height: 8px;
    background-color: #dcdcdc;
    border: 2px solid var(--color-bg-white);
    border-radius: 50%;
    transition: all 0.2s ease;
}

.index-menu a:hover {
    color: var(--color-accent);
    text-decoration: none;
    padding-left: 4px;
}

.index-menu a.active {
    color: var(--color-accent);
    font-weight: 700;
}

.index-menu a.active::before {
    background-color: var(--color-accent);
    border-color: var(--color-accent);
    transform: scale(1.4);
    box-shadow: 0 0 0 3px rgba(178, 31, 36, 0.15);
}

/* Diseño de Tablas Premium de Tasas, Sanciones e Infracciones */
.document-body table {
    width: 100%;
    min-width: 800px; /* Fuerza ancho mínimo para que el scroll horizontal funcione y no se aplasten las celdas */
    border-collapse: collapse;
    margin: 0;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    background: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.document-body th {
    background-color: #fafafa;
    color: #111111;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    text-align: left;
    padding: 0.85rem 1rem;
    border-bottom: 2px solid var(--color-primary);
}

.document-body td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid #eaeaea;
    color: #333333;
    line-height: 1.5;
}

.document-body tr:nth-child(even) {
    background-color: #fbfbfb; /* Zebra Striping sutil */
}

.document-body tr:hover {
    background-color: rgba(10, 68, 53, 0.03); /* Hover sutil en verde corporativo */
}

/* Números y valores alineados al centro en las tablas */
.document-body td.align-center, .document-body th.align-center {
    text-align: center;
}

/* Números y valores alineados a la derecha (ej. importes) */
.document-body td.align-right, .document-body th.align-right {
    text-align: right;
}

/* Estilo para Listas y Sub-listas de letras (a, b, c...) y números en el articulado */
.document-body .node-text ul,
.document-body .node-text ol {
    margin-top: 0.5rem;
    margin-bottom: 1.25rem;
    padding-left: 2rem;
}

.document-body .node-text li {
    margin-bottom: 0.6rem;
    line-height: 1.8;
}

/* Soporte para sub-listas de letras (a, b, c) estilo Gencat */
.document-body .node-text ol[type="a"],
.document-body .node-text ol.list-alphabetical {
    list-style-type: lower-alpha;
}

.document-body .node-text ol[type="i"],
.document-body .node-text ol.list-roman {
    list-style-type: lower-roman;
}

/* Estilo para texto plano indentado manual que simula listas (a), b), c) ...) */
.document-body .node-text-indented {
    padding-left: 1.5rem;
    margin-bottom: 0.5rem;
    display: block;
}



