﻿/* ???????????????????????????????????????????????????????????????????
   MRE Components — Estilos compartidos de componentes UI SIA-PY
   Consumido por _GenericTable, _Pagination, _TableActions, modales,
   y cualquier vista que use la grilla/tabla/paginación del sistema.

   Ruta: ~/_content/WebDesignSystem/css/mre-components.css
   ??????????????????????????????????????????????????????????????????? */

:root {
    --mre-blue: #002855;
    --mre-blue-light: #0038A8;
    --mre-red: #D52B1E;
    --mre-green: #10B981;
    --soft-bg: #f8fafc;
    --border-color: #E2E8F0;
    --text-main: #1E293B;
    --text-muted: #64748B;
    --card-shadow: 0 10px 15px -3px rgba(0, 40, 85, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* ??? FORM CONTROLS ??? */

.form-control-mre {
    background-color: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    width: 100%;
    transition: all 0.3s ease;
}

.form-control-mre:focus {
    outline: none;
    border-color: var(--mre-blue-light);
    background: white;
    box-shadow: 0 0 0 4px rgba(0, 56, 168, 0.05);
}

.form-label {
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: block;
}

/* ??? BUTTONS ??? */

.btn-main {
    background: linear-gradient(135deg, var(--mre-blue) 0%, var(--mre-blue-light) 100%);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    padding: 0.6rem 1.2rem;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.5rem;
}

.btn-main:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 40, 85, 0.2);
    color: white;
}

.btn-main:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-action-icon {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-muted);
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-action-icon:hover {
    background: #F1F5F9;
    color: var(--mre-blue);
    border-color: var(--mre-blue);
}

.btn-action-icon.text-danger {
    color: var(--mre-red);
    border-color: #FECDD3;
}

.btn-action-icon.text-danger:hover {
    background: #FEE2E2;
    border-color: var(--mre-red);
}

.btn-danger-outline {
    background: #ffffff;
    color: var(--mre-red);
    border: 1.5px solid var(--mre-red);
    border-radius: 12px;
    padding: 0.6rem 1.5rem;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-danger-outline:hover:not(:disabled) {
    background: var(--mre-red);
    color: white;
    transform: translateY(-2px);
}

.btn-danger-outline:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: #E2E8F0;
    color: #94A3B8;
}

.btn-cancel-mre {
    background: white;
    border: 1px solid #CBD5E1;
    color: #475569;
    border-radius: 12px;
    padding: 0.6rem 1.5rem;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-cancel-mre:hover:not(:disabled) {
    background: #F8FAFC;
    border-color: #94A3B8;
    transform: translateY(-2px);
}

.btn-cancel-mre:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-export {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-muted);
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-export:hover {
    background: var(--mre-blue);
    color: white;
    border-color: var(--mre-blue);
}

.btn-outline-mre-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-outline-mre-primary {
    border: 2px solid var(--mre-blue);
    color: var(--mre-blue);
    font-weight: 800;
    border-radius: 12px;
    padding: 0.5rem 1.2rem;
    font-size: 0.75rem;
    background: transparent;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ??? GRID FRAME ??? */

.grid-frame {
    background: white;
    border-radius: 20px;
    box-shadow: var(--card-shadow);
    border: 1px solid #E2E8F0;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.grid-frame::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(to right, var(--mre-red), var(--mre-blue));
}

.grid-header-frame {
    background-color: #F8FAFC;
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid #E2E8F0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    overflow: visible;
    flex-shrink: 0;
}

.grid-title {
    font-weight: 800;
    text-transform: uppercase;
    margin: 0;
    color: var(--mre-blue);
    font-size: 0.85rem;
}

/* ─── COLUMN SELECTOR (grid-toolbar) ─── */

.column-selector-host {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.column-selector-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 1200;
    width: 280px;
    max-height: 320px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.14);
    padding: 12px;
}

.column-selector-title {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #64748B;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #E2E8F0;
}

/* ─── TABLE ─── */

.table-responsive {
    overflow: auto;
    flex: 1;
    min-height: 0;
}

.mre-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.mre-table th {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 1rem 1.5rem;
    border-bottom: 2px solid #E2E8F0;
    background: #fafbfc;
    white-space: nowrap;
}

.mre-table td {
    padding: 1rem 1.5rem;
    font-size: 0.9375rem;
    border-bottom: 1px solid #F1F5F9;
    vertical-align: middle;
    color: var(--text-main);
}

.mre-table tbody tr:hover {
    background: #F8FAFC;
}

.mre-table-head-sticky th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #fafbfc;
}

/* Filas inactivas */
.row-inactive td {
    color: #94A3B8;
    background-color: #F8FAFC;
}

.row-inactive .badge {
    opacity: 0.6;
    background-color: #E2E8F0 !important;
    color: #64748B !important;
}

/* ??? CHECKBOX ??? */

.mre-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    border: 2px solid var(--border-color);
    border-radius: 4px;
}

/* ??? BADGES ??? */

.badge {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-activo {
    background: #DCFCE7;
    color: #15803D;
}

.badge-inactivo {
    background: #E2E8F0;
    color: #64748B;
}

/* ??? GRID FOOTER / PAGINATION ??? */

.grid-footer {
    padding: 1rem 1.5rem;
    background-color: #F8FAFC;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.separator-vertical {
    width: 1px;
    height: 24px;
    background: #E2E8F0;
}

.btn-pagination {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-pagination:hover:not(:disabled):not(.active) {
    background: var(--mre-blue);
    color: white;
    border-color: var(--mre-blue);
}

.btn-pagination.active,
.btn-pagination.active:disabled {
    background: var(--mre-blue);
    color: white;
    border-color: var(--mre-blue);
    opacity: 1;
    cursor: default;
}

.btn-pagination:disabled:not(.active) {
    opacity: 0.4;
    cursor: not-allowed;
    background: #F1F5F9;
    color: #94A3B8;
    border-color: #E2E8F0;
}

.page-indicator {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--mre-blue);
    padding: 0 8px;
}

/* ??? TABLE CONTAINER (flex chain) ??? */

#table-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ??? MODALES ??? */

.mre-modal {
    border-radius: 24px;
    border: none;
}

.modal-header {
    border-bottom: 1px solid #E2E8F0;
    padding: 1.5rem;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--mre-blue);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid #E2E8F0;
    padding: 1.5rem;
}

.btn-close:focus {
    box-shadow: none;
}

/* ??? VALIDATION ??? */

.validation-alert {
    background: #FFF1F2;
    border: 1px solid #FECDD3;
    color: #BE123C;
    padding: 12px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

/* ??? AUDIT HISTORY ??? */

.audit-history-container {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px dashed #E2E8F0;
}

.section-subtitle {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--mre-blue);
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.audit-table {
    width: 100%;
    font-size: 0.85rem;
}

.audit-table th {
    background: #F8FAFC;
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 800;
    text-transform: uppercase;
}

.audit-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #F1F5F9;
}

.audit-table tr:last-child td {
    border-bottom: none;
}

.badge-audit {
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
}

.badge-crear {
    background: #DCFCE7;
    color: #15803D;
}

.badge-modificar {
    background: #E0F2FE;
    color: #0369A1;
}

.badge-inactivar {
    background: #FEE2E2;
    color: #B91C1C;
}

.badge-activar {
    background: #ECFDF5;
    color: #10B981;
}

.badge-eliminar {
    background: #FEE2E2;
    color: #991B1B;
}

/* ??? CONFIRMACIÓN MODAL ??? */

.confirm-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
}

.confirm-icon.danger {
    background: #FEE2E2;
    color: var(--mre-red);
}

.confirm-list {
    background: #F8FAFC;
    border-radius: 12px;
    border: 1px solid #E2E8F0;
    padding: 1rem;
    margin: 1.5rem 0;
    max-height: 200px;
    overflow-y: auto;
    text-align: left;
}

.confirm-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    font-size: 0.9rem;
    color: #475569;
    font-weight: 600;
    border-bottom: 1px solid #EDF2F7;
}

.confirm-item:last-child {
    border-bottom: none;
}

.meta-info {
    font-size: 0.75rem;
    color: #94A3B8;
    font-weight: 600;
    margin-top: 1rem;
}

/* ??? POPUP OVERLAY (Verificación de Datos) ??? */

.mre-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 20, 50, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1060;
    padding: 1rem;
    backdrop-filter: blur(2px);
}

.mre-popup {
    background: white;
    border-radius: 20px;
    padding: 1.5rem;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.mre-popup-label {
    text-transform: uppercase;
    font-size: 0.6rem;
    font-weight: 800;
    color: var(--text-muted);
    display: block;
}

.mre-popup-value {
    font-size: 0.8rem;
    color: var(--text-main);
    display: block;
}

/* ??? HTMX INDICATOR (submit text toggle) ??? */

.htmx-request .btn-submit-text {
    display: none;
}

.htmx-indicator {
    display: none;
}

.htmx-request.htmx-indicator,
.htmx-request .htmx-indicator {
    display: inline;
}

/* ??? RESPONSIVE ??? */

@media (max-width: 768px) {
    .grid-footer {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .grid-footer > div {
        width: 100%;
        justify-content: space-between;
    }

    .btn-main {
        font-size: 0.8rem;
        padding: 0.5rem 1rem;
        width: 100%;
    }

    .mre-popup {
        max-width: 100%;
        border-radius: 16px;
        padding: 1rem;
    }

    .mre-popup .d-flex.gap-2 {
        flex-direction: column;
    }

    .mre-popup .w-50 {
        width: 100% !important;
    }
}

/* ═══ SECTION TITLE ═══ */

.section-title {
    font-size: 0.95rem;
    font-weight: 900;
    color: var(--mre-blue);
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1.5rem;
}

.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #E2E8F0;
}

/* ═══ DUAL LIST ═══ */

.dual-list-container {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.dual-list-box {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 15px;
    height: 180px;
    overflow-y: auto;
    background: #F8FAFC;
    padding: 5px;
}

.list-title {
    font-size: 0.7rem;
    font-weight: 800;
    text-align: center;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
    background: white;
    margin-bottom: 5px;
}

.list-item {
    padding: 10px 15px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 1px solid #F1F5F9;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    border-radius: 8px;
}

.list-item:hover {
    background: #F1F7FF;
    color: var(--mre-blue);
}

/* ═══ AUDITORÍA ═══ */

.audit-grid-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.audit-grid-table th {
    background: #F8FAFC;
    color: #64748B;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
}

.audit-grid-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #F1F5F9;
    font-size: 0.75rem;
}

.badge-audit {
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 0.65rem;
    font-weight: 800;
}

.tag-create {
    background: #DCFCE7;
    color: #15803D;
}

.tag-update {
    background: #E0F2FE;
    color: #0369A1;
}

.tag-delete {
    background: #FEE2E2;
    color: #DC2626;
}

.tag-inactivate {
    background: #F1F5F9;
    color: #64748B;
}
