/* ═══════════════════════════════════════════════════════════════════
   MR Design System — Estilos globales
   Paleta corporativa Multiriesgos
   ■ Azul marino oscuro  #060D45
   ■ Azul medio          #1530B8
   ■ Azul brillante      #4A7AFF
   ═══════════════════════════════════════════════════════════════════ */

/* ── Variables CSS ──────────────────────────────────────────────── */
:root {
    --mr-primary:        #1530B8;
    --mr-primary-dark:   #0D1F8A;
    --mr-primary-light:  #2B48D4;
    --mr-accent:         #4A7AFF;
    --mr-accent-hover:   #3366EE;
    --mr-sidebar-width:  260px;
    --mr-sidebar-bg:     linear-gradient(180deg, #1a3a5c 0%, #2c5282 100%);
    --mr-sidebar-text:   #BDC8F0;
    --mr-sidebar-active: #4A7AFF;
    --mr-topbar-height:  64px;
    --mr-border-radius:  0.5rem;
    --mr-shadow-sm:      0 2px 8px rgba(6,13,69,.08);
    --mr-shadow-md:      0 4px 20px rgba(6,13,69,.14);
    --mr-shadow-lg:      0 8px 32px rgba(6,13,69,.20);
    --mr-font:           'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Reset y base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    height: 100%;
    font-family: var(--mr-font);
    font-size: 14px;
    color: #2d3748;
    background: #f0f4f8;
    overflow-x: hidden;
}

/* ── Layout principal ───────────────────────────────────────────── */
.mr-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────── */
.mr-sidebar {
    width: var(--mr-sidebar-width);
    min-height: 100vh;
    background: var(--mr-sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    transition: transform .3s ease, width .3s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,.25);
}

.mr-sidebar.collapsed {
    transform: translateX(calc(-1 * var(--mr-sidebar-width)));
}

.mr-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    min-height: var(--mr-topbar-height);
    text-decoration: none;
}

.mr-sidebar-logo {
    height: 38px;
    width: 38px;
    object-fit: contain;
    border-radius: 50%;
    background: #fff;
    padding: 3px;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(74,122,255,.4);
}

.mr-sidebar-brand-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: .3px;
    line-height: 1.2;
}

.mr-sidebar-brand-sub {
    font-size: .7rem;
    color: var(--mr-accent);
    font-weight: 500;
    letter-spacing: .5px;
    text-transform: uppercase;
}

/* ── Menú de navegación ─────────────────────────────────────────── */
.mr-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.1) transparent;
    list-style: none;
    margin: 0;
}

.mr-nav::-webkit-scrollbar { width: 4px; }
.mr-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.mr-nav-section {
    display: block;
    padding: 16px 20px 6px;
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(200,216,232,.4);
}

.mr-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: var(--mr-sidebar-text);
    text-decoration: none;
    font-size: .875rem;
    font-weight: 400;
    border-left: 3px solid transparent;
    transition: all .2s ease;
    position: relative;
}

.mr-nav-item i {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
    color: rgba(200,216,232,.6);
    transition: color .2s;
}

.mr-nav-item:hover {
    background: rgba(255,255,255,.06);
    color: #fff;
    border-left-color: rgba(74,122,255,.4);
}

.mr-nav-item:hover i { color: var(--mr-accent); }

.mr-nav-item.active {
    background: rgba(74,122,255,.15);
    color: #fff;
    font-weight: 600;
    border-left-color: var(--mr-accent);
}

.mr-nav-item.active i { color: var(--mr-accent); }

/* ── Submenú colapsable ─────────────────────────────────────────── */
.mr-subnav {
    list-style: none;
    padding: 0 0 4px 36px;
    margin: 0;
}

.mr-subnav .mr-nav-item {
    font-size: .82rem;
    padding: 8px 20px 8px 0;
    border-left: none;
    border-radius: 4px;
}

.mr-subnav .mr-nav-item:hover {
    border-left: none;
    background: rgba(255,255,255,.04);
    padding-left: 6px;
}

.mr-subnav .mr-nav-item.active {
    border-left: none;
    background: rgba(74,122,255,.12);
    padding-left: 6px;
}

.mr-nav-arrow {
    font-size: .75rem;
    transition: transform .2s;
    margin-left: auto;
}

.mr-nav-item[aria-expanded="true"] .mr-nav-arrow {
    transform: rotate(180deg);
}

/* ── Sidebar footer ─────────────────────────────────────────────── */
.mr-sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.08);
}

.mr-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--mr-border-radius);
    transition: background .2s;
}

.mr-user-info:hover { background: rgba(255,255,255,.06); }

.mr-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--mr-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.mr-user-name {
    font-size: .8rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mr-user-role {
    font-size: .7rem;
    color: var(--mr-accent);
    font-weight: 500;
}

/* ── Topbar ─────────────────────────────────────────────────────── */
.mr-topbar {
    height: var(--mr-topbar-height);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: var(--mr-shadow-sm);
    gap: 16px;
}

.mr-topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: #2d3748;
}

.mr-topbar-breadcrumb {
    font-size: .8rem;
    color: #718096;
}

.mr-topbar-breadcrumb .separator { margin: 0 6px; color: #cbd5e0; }

.btn-sidebar-toggle {
    background: none;
    border: none;
    padding: 8px;
    border-radius: 8px;
    color: #4a5568;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background .2s, color .2s;
}

.btn-sidebar-toggle:hover {
    background: #f7fafc;
    color: var(--mr-primary);
}

.btn-sidebar-toggle i { font-size: 1.3rem; }

/* ── Overlay (mobile) ───────────────────────────────────────────── */
.mr-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1039;
    backdrop-filter: blur(2px);
}

.mr-overlay.show { display: block; }

/* ── Content ────────────────────────────────────────────────────── */
.mr-content {
    margin-left: var(--mr-sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left .3s ease;
}

.mr-content.expanded { margin-left: 0; }

.mr-page-body {
    flex: 1;
    padding: 28px 32px;
}

/* ── Cards ──────────────────────────────────────────────────────── */
.mr-card {
    background: #fff;
    border-radius: var(--mr-border-radius);
    box-shadow: var(--mr-shadow-sm);
    border: 1px solid #e8edf5;
    overflow: hidden;
}

.mr-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f0f4f8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.mr-card-title {
    font-size: .95rem;
    font-weight: 600;
    color: #2d3748;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mr-card-title i { color: var(--mr-primary); }

.mr-card-body { padding: 20px; }

/* ── Stats cards ────────────────────────────────────────────────── */
.mr-stat {
    background: #fff;
    border-radius: var(--mr-border-radius);
    padding: 20px;
    box-shadow: var(--mr-shadow-sm);
    border: 1px solid #e8edf5;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform .2s, box-shadow .2s;
}

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

.mr-stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.mr-stat-icon.primary   { background: rgba(21,48,184,.1);  color: var(--mr-primary); }
.mr-stat-icon.success   { background: rgba(34,197,94,.1);  color: #16a34a; }
.mr-stat-icon.warning   { background: rgba(234,179,8,.1);  color: #ca8a04; }
.mr-stat-icon.danger    { background: rgba(239,68,68,.1);  color: #dc2626; }
.mr-stat-icon.info      { background: rgba(74,122,255,.1); color: var(--mr-accent); }

.mr-stat-label {
    font-size: .75rem;
    color: #718096;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 4px;
}

.mr-stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1a202c;
    line-height: 1;
}

.mr-stat-delta {
    font-size: .75rem;
    font-weight: 500;
    margin-top: 4px;
}

.mr-stat-delta.up   { color: #16a34a; }
.mr-stat-delta.down { color: #dc2626; }

/* ── Botones ─────────────────────────────────────────────────────── */
.btn-mr-primary {
    background: var(--mr-primary);
    border-color: var(--mr-primary);
    color: #fff;
    font-weight: 500;
    border-radius: 6px;
    transition: background .2s, transform .1s;
}

.btn-mr-primary:hover {
    background: var(--mr-primary-dark);
    border-color: var(--mr-primary-dark);
    color: #fff;
    transform: translateY(-1px);
}

.btn-mr-accent {
    background: var(--mr-accent);
    border-color: var(--mr-accent);
    color: #fff;
    font-weight: 500;
    border-radius: 6px;
}

.btn-mr-accent:hover {
    background: var(--mr-accent-hover);
    border-color: var(--mr-accent-hover);
    color: #fff;
}

/* ── Tablas ──────────────────────────────────────────────────────── */
.mr-table-wrapper {
    overflow-x: auto;
    border-radius: var(--mr-border-radius);
}

.mr-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .85rem;
}

.mr-table thead th {
    background: #f8fafc;
    color: #4a5568;
    font-weight: 600;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: 12px 16px;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

.mr-table tbody tr {
    border-bottom: 1px solid #f0f4f8;
    transition: background .15s;
}

.mr-table tbody tr:hover { background: #f7fafc; }

.mr-table tbody td {
    padding: 12px 16px;
    color: #4a5568;
    vertical-align: middle;
}

/* ── Badges de estado ────────────────────────────────────────────── */
.badge-mr-active   { background: #dcfce7; color: #166534; font-weight: 600; }
.badge-mr-inactive { background: #fee2e2; color: #991b1b; font-weight: 600; }
.badge-mr-pending  { background: #fef9c3; color: #854d0e; font-weight: 600; }

/* ── Formularios ─────────────────────────────────────────────────── */
.form-control:focus, .form-select:focus {
    border-color: var(--mr-primary);
    box-shadow: 0 0 0 3px rgba(26,60,94,.12);
}

.form-label {
    font-size: .8rem;
    font-weight: 600;
    color: #4a5568;
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: 6px;
}

/* ── Login page ──────────────────────────────────────────────────── */
.mr-login-page {
    min-height: 100vh;
    background: linear-gradient(145deg, #060D45 0%, #0D1F8A 45%, #1530B8 75%, #2B48D4 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.mr-login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--mr-shadow-lg);
    overflow: hidden;
}

.mr-login-header {
    background: var(--mr-sidebar-bg);
    padding: 32px 36px 28px;
    text-align: center;
}

.mr-login-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 50%;
    background: #fff;
    padding: 8px;
    display: block;
    margin: 0 auto 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,.3), 0 0 0 4px rgba(74,122,255,.35);
}

.mr-login-header h1 {
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

.mr-login-header p {
    color: rgba(255,255,255,.6);
    font-size: .8rem;
    margin: 6px 0 0;
}

.mr-login-body { padding: 32px 36px; }

/* ── Footer ──────────────────────────────────────────────────────── */
.mr-footer {
    padding: 14px 32px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    font-size: .75rem;
    color: #a0aec0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ── Loading spinner ─────────────────────────────────────────────── */
.mr-spinner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.mr-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid #e2e8f0;
    border-top-color: var(--mr-primary);
    border-radius: 50%;
    animation: mr-spin .75s linear infinite;
}

@keyframes mr-spin { to { transform: rotate(360deg); } }

/* ── Toast notifications ─────────────────────────────────────────── */
.mr-toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 360px;
}

.mr-toast {
    background: #fff;
    border-radius: 8px;
    box-shadow: var(--mr-shadow-md);
    padding: 14px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-left: 4px solid;
    animation: mr-slideIn .3s ease;
}

@keyframes mr-slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);   opacity: 1; }
}

.mr-toast.success { border-left-color: #16a34a; }
.mr-toast.error   { border-left-color: #dc2626; }
.mr-toast.warning { border-left-color: #ca8a04; }
.mr-toast.info    { border-left-color: #2563eb; }

.mr-toast i { font-size: 1.1rem; margin-top: 1px; }
.mr-toast.success i { color: #16a34a; }
.mr-toast.error   i { color: #dc2626; }
.mr-toast.warning i { color: #ca8a04; }
.mr-toast.info    i { color: #2563eb; }

.mr-toast-msg { font-size: .85rem; color: #2d3748; font-weight: 500; }
.mr-toast-sub { font-size: .75rem; color: #718096; margin-top: 2px; }

/* ── Modal mejorado ──────────────────────────────────────────────── */
.modal-header {
    background: var(--mr-primary);
    color: #fff;
    border-bottom: none;
}

.modal-header .btn-close { filter: invert(1); }

.modal-footer { border-top: 1px solid #f0f4f8; }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 992px) {
    .mr-sidebar {
        transform: translateX(calc(-1 * var(--mr-sidebar-width)));
    }

    .mr-sidebar.mobile-open {
        transform: translateX(0);
    }

    .mr-content {
        margin-left: 0;
    }

    .mr-page-body {
        padding: 20px 16px;
    }
}

@media (max-width: 576px) {
    .mr-stat-value { font-size: 1.3rem; }
    .mr-topbar    { padding: 0 16px; }
}

/* ── Utilidades ──────────────────────────────────────────────────── */
.text-mr-primary { color: var(--mr-primary) !important; }
.text-mr-accent  { color: var(--mr-accent)  !important; }
.bg-mr-primary   { background: var(--mr-primary) !important; }
.bg-mr-dark      { background: var(--mr-sidebar-bg) !important; }

.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.border-mr { border-color: #e2e8f0 !important; }

.rounded-mr { border-radius: var(--mr-border-radius) !important; }

.shadow-mr-sm { box-shadow: var(--mr-shadow-sm) !important; }
.shadow-mr-md { box-shadow: var(--mr-shadow-md) !important; }

/* ── Impresión ───────────────────────────────────────────────── */
.mr-print-header { display: none; }

@media print {
    .mr-sidebar,
    .mr-topbar,
    .mr-footer,
    .mr-overlay,
    .mr-card-header .btn,
    .btn, .pagination,
    .input-group              { display: none !important; }

    .mr-wrapper, .mr-content  { display: block !important; padding: 0 !important; margin: 0 !important; }
    .mr-page-body             { padding: 0 !important; }
    .mr-card                  { box-shadow: none !important; border: 1px solid #dee2e6 !important; }

    .mr-print-header          { display: block !important; margin-bottom: 16px; }
    .mr-print-header h5       { font-size: 14pt; font-weight: 700; margin: 0 0 4px; }
    .mr-print-header p        { font-size: 9pt; color: #666; margin: 0; }

    table                     { font-size: 8pt !important; }
    thead                     { background: #f0f0f0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .badge                    { border: 1px solid #ccc !important; background: transparent !important; color: #333 !important; }
    a                         { color: #000 !important; text-decoration: none !important; }

    @page { margin: 15mm; }
}
