/* ========================================
   DIGESTO MUNICIPAL
   ======================================== */

#digesto {
    background: #fff;
    padding-bottom: 4rem;
}

.digesto-contenedor {
    padding: 2rem 0;
}

/* Buscador y Filtros */
.digesto-buscador {
    background: #fff;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 2rem;
}

.form-busqueda-digesto .input-group-text {
    background: var(--color-primary);
    color: #fff;
    border: none;
}

.form-busqueda-digesto .form-control,
.form-busqueda-digesto .form-select {
    border: 1px solid #e0e0e0;
    padding: 0.75rem 1rem;
    font-size: 1rem;
}

.form-busqueda-digesto .form-control:focus,
.form-busqueda-digesto .form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 0.2rem rgba(24, 108, 180, 0.15);
}

.form-busqueda-digesto .btn-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
    padding: 0.75rem 1.5rem;
    font-weight: 600;
}

.form-busqueda-digesto .btn-primary:hover {
    background: #125a96;
    border-color: #125a96;
}

.filtros-activos {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Tabla de Normas */
.digesto-listado {
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    isolation: isolate;
    /* Fuerza un nuevo contexto de apilamiento para un recorte perfecto */
}

.digesto-listado .table-responsive {
    border-radius: 1rem;
    overflow: hidden;
}

.digesto-tabla {
    margin-bottom: 0;
    border-collapse: collapse;
    /* Volvemos a collapse para un recorte más simple por parte del contenedor */
    border: none ;
}

.digesto-tabla thead {
    background: #fff;
    color: var(--color-primary);
    border-bottom: 2px solid #f0f0f0 ;
}

.digesto-tabla thead th {
    padding: 1rem;
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    /* Asegura que no haya bordes de Bootstrap */
    background-color: #fff;
    /* Forzamos el color en el th también */
    color: var(--color-primary);
}

.digesto-tabla tbody tr {
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s ease;
}

.digesto-tabla tbody tr:hover {
    background: #f8f9fa;
}

.digesto-tabla tbody td {
    padding: 1rem;
    vertical-align: middle;
}

.norma-numero {
    font-weight: 700;
    color: var(--color-primary);
    white-space: nowrap;
    width: 100px;
}

.norma-titulo strong {
    display: block;
    color: #333;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.norma-resumen {
    font-size: 0.85rem;
    color: #666;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.norma-categoria {
    width: 150px;
}

.norma-categoria .badge {
    font-weight: 500;
    font-size: 0.8rem;
    background-color: var(--color-secondary);
    border: 1px solid var(--color-secondary);
    color: #fff;
}

.norma-estado {
    width: 120px;
}

.norma-estado .badge {
    font-weight: 500;
    font-size: 0.8rem;
}

.norma-anio {
    width: 80px;
    text-align: center;
    font-weight: 600;
}

.norma-documento {
    width: 100px;
}

.digesto-tabla .norma-documento .btn.btn-outline-success {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.35rem 0.65rem;
    border-radius: 0.6rem;
    line-height: 1;
    font-weight: 600;
    color: var(--color-success);
    border-color: var(--color-success);
}

.digesto-tabla .norma-documento .btn.btn-outline-success:hover {
    background: var(--color-success);
    border-color: var(--color-success);
    color: #fff;
}

.digesto-tabla .norma-documento .btn.btn-outline-success:focus {
    box-shadow: none;
    outline: 2px solid var(--color-success);
    outline-offset: 2px;
}

/* ========================================
   LISTADO DE NORMAS - DISEÑO MODERNO (Cards)
   ======================================== */

.digesto-lista-moderna {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 1rem;
}

.norma-item-card {
    background: #fff;
    border-radius: 1rem;
    padding: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.06);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    overflow: hidden;
    display: flex;
    align-items: stretch;
}

.norma-item-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
    border-color: var(--color-success);
}

/* Columna de Número y Año */
.norma-card-aside {
    background: #f8fafc;
    width: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-right: 1px solid #f0f0f0;
    padding: 1rem;
    flex-shrink: 0;
}

.card-aside-nro {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--color-primary);
    line-height: 1;
}

.card-aside-anio {
    font-size: 0.85rem;
    font-weight: 700;
    color: #a0aec0;
    margin-top: 0.25rem;
}

/* Cuerpo de la Card */
.norma-card-main {
    flex-grow: 1;
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.norma-card-title {
    margin: 0 0 0.5rem 0;
}

.norma-card-title a {
    color: #2d3748;
    font-size: 1.25rem;
    font-weight: 700;
    text-decoration: none;
    line-height: 1.3;
    transition: color 0.2s ease;
}

.norma-card-title a:hover {
    color: var(--color-primary);
}

.norma-card-resumen {
    color: #718096;
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Acciones y Badges (Derecha) */
.norma-card-actions {
    padding: 1.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    border-left: 1px dashed #e2e8f0;
    width: 280px;
    flex-shrink: 0;
}

.card-badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: nowrap;
    justify-content: flex-end;
}

.card-badge {
    font-size: 0.72rem;
    font-weight: 800;
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
    text-transform: uppercase;
    color: #fff;
    display: inline-block;
}

.btn-card-detalle {
    background: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
    padding: 0.5rem 1.25rem;
    border-radius: 0.75rem;
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-card-detalle:hover {
    background: var(--color-primary);
    color: #fff;
}

/* Responsive Cards */
@media (max-width: 992px) {
    .norma-item-card {
        flex-direction: column;
    }

    .norma-card-aside {
        width: 100%;
        flex-direction: row;
        gap: 0.5rem;
        height: auto;
        padding: 0.75rem;
        border-right: none;
        border-bottom: 1px solid #f0f0f0;
    }

    .norma-card-actions {
        width: 100%;
        flex-direction: row;
        align-items: center;
        border-left: none;
        border-top: 1px dashed #e2e8f0;
        padding: 1rem 1.5rem;
    }

    .norma-card-main {
        padding: 1.5rem;
    }
}

/* ========================================
   DETALLE DE NORMA - DISEÑO PREMIUM (Dos Columnas)
   ======================================== */

#digesto-detalle {
    background: #fff;
    padding-bottom: 5rem;
}

.digesto-detalle-contenedor {
    padding: 3rem 0;
}

/* Layout de dos columnas */
.norma-detalle-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 2rem;
    align-items: start;
}

/* Columna Principal */
.norma-col-principal {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Columna Lateral (Sidebar) */
.norma-col-sidebar {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    position: sticky;
    top: 2rem;
}

/* Cards Premium */
.norma-card {
    background: #fff;
    border-radius: 1.25rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.05);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Header de la Norma (Principal) */
.norma-header-main {
    padding: 3rem;
    border-bottom: 1px solid #f0f0f0;
}

.norma-detalle-titulo {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--color-primary);
    line-height: 1.2;
    margin-bottom: 1.5rem;
    letter-spacing: -0.02em;
}

.norma-detalle-resumen {
    font-size: 1.15rem;
    line-height: 1.8;
    color: #4a5568;
    margin: 0;
}

/* Sección de descarga destacada */
.norma-documento-card {
    padding: 2.5rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.documento-info {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.documento-icon {
    width: 60px;
    height: 60px;
    background: #fff;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: #e53e3e;
    /* Rojo PDF */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.documento-text h4 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 0.25rem 0;
    color: #2d3748;
}

.documento-text p {
    font-size: 0.9rem;
    color: #718096;
    margin: 0;
}

.btn-descargar-principal {
    background: var(--color-primary);
    color: #fff;
    padding: 1rem 2rem;
    border-radius: 0.75rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    transition: all 0.3s ease;
    border: none;
    box-shadow: 0 4px 14px rgba(30, 58, 95, 0.2);
}

.btn-descargar-principal:hover {
    background: #152d47;
    color: #fff;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(30, 58, 95, 0.3);
}

/* Sidebar Widgets */
.sidebar-widget {
    padding: 1.75rem;
}

.widget-title {
    font-size: 0.85rem;
    font-weight: 800;
    color: #a0aec0;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.widget-title i {
    color: var(--color-success);
}

/* Info List en Sidebar */
.info-sidebar-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.info-sidebar-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.info-sidebar-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #718096;
}

.info-sidebar-value {
    font-size: 1rem;
    font-weight: 600;
    color: #2d3748;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.info-sidebar-value i {
    color: var(--color-primary);
    width: 20px;
}

/* Badges de Sidebar */
.sidebar-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #fff;
}

.sidebar-badge-estado {
    display: inline-block;
}

.badge-vigente {
    background: var(--color-success);
}

.badge-no-vigente {
    background: #dc3545;
}

.badge-modificada {
    background: var(--color-primary);
}

/* Relaciones en Sidebar */
.relaciones-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.relacion-card-link {
    display: block;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 0.75rem;
    text-decoration: none;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.relacion-card-link:hover {
    background: #fff;
    border-color: var(--color-success);
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.relacion-nro {
    display: block;
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--color-primary);
    margin-bottom: 0.25rem;
}

.relacion-tit {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #4a5568;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Ajustes Responsivos */
@media (max-width: 1200px) {
    .norma-detalle-layout {
        grid-template-columns: 1fr;
    }

    .norma-col-sidebar {
        position: static;
        order: 2;
    }

    .norma-col-principal {
        order: 1;
    }
}

@media (max-width: 768px) {
    .norma-header-main {
        padding: 2rem;
    }

    .norma-detalle-titulo {
        font-size: 1.75rem;
    }

    .norma-documento-card {
        flex-direction: column;
        align-items: flex-start;
        padding: 2rem;
    }

    .btn-descargar-principal {
        width: 100%;
        justify-content: center;
    }
}