/* ==========================================================================
   CONSOLA CMA
   ========================================================================== */

:root {
    --navy: #001A70;
    --navy-dark: #000E38;
    --green: #00B74F;
    --mint: #B2E9CA;
    --ink: #1B2436;
    --muted: #5B6B85;
    --border: #E3E5EA;
    --bg: #F7F8FA;
    --white: #FFFFFF;
    --err: #D3273E;
    --err-bg: #FDECEE;
    --warn: #B98400;
    --warn-bg: #FFF6E0;
    --font: "Segoe UI","Helvetica Neue",Arial,sans-serif;
}

/* ==========================================================================
   RESET
   ========================================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 14px;
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    display: block;
    max-width: 100%;
}

/* ==========================================================================
   LAYOUT
   ========================================================================== */

.admin-shell {
    display: flex;
    min-height: 100vh;
}

.admin-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.admin-content {
    flex: 1;
    padding: 28px;
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */

.admin-sidebar {
    width: 280px;
    background: var(--navy-dark);
    color: #fff;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
    border-right: 1px solid rgba(255,255,255,.05);
}

.admin-sidebar__brand {
    padding: 22px 24px;
    font-size: 1.45rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

    .admin-sidebar__brand span {
        color: var(--green);
    }

/* Scroll */

.admin-sidebar::-webkit-scrollbar {
    width: 8px;
}

.admin-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.admin-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.18);
    border-radius: 999px;
}

    .admin-sidebar::-webkit-scrollbar-thumb:hover {
        background: rgba(255,255,255,.28);
    }

.admin-sidebar {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.25) transparent;
}

/* ==========================================================================
   MENÚ LATERAL
   ========================================================================== */

.admin-nav {
    display: flex;
    flex-direction: column;
    padding: 14px 0;
}

/* ==========================================================================
   TÍTULOS DE SECCIÓN
   ========================================================================== */

.admin-menu-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 14px 22px;
    color: rgba(255,255,255,.45);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .10em;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
    transition: all .20s ease;
}

    .admin-menu-title:hover {
        color: #fff;
        background: rgba(255,255,255,.04);
    }

    .admin-menu-title > div {
        display: flex;
        align-items: center;
        gap: 10px;
    }

        .admin-menu-title > div i {
            width: 18px;
            text-align: center;
            font-size: .90rem;
        }

/* ==========================================================================
   FLECHA
   ========================================================================== */

.menu-toggle {
    font-size: .80rem;
    transition: transform .25s ease;
}

    .menu-toggle.rotate {
        transform: rotate(180deg);
    }

/* ==========================================================================
   SUBMENÚ
   ========================================================================== */

.admin-nav-group {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    max-height: 0;
    transition: max-height .35s ease;
}

    .admin-nav-group.open {
        max-height: 600px;
    }

    /* ==========================================================================
   ITEMS
   ========================================================================== */

    .admin-nav-group > div {
        margin: 0;
        padding: 0;
    }

        .admin-nav-group > div > a {
            display: flex;
            align-items: center;
            gap: 12px;
            position: relative;
            padding: 12px 22px 12px 42px;
            color: rgba(255,255,255,.82);
            font-size: .90rem;
            transition: all .20s ease;
        }

            .admin-nav-group > div > a i {
                width: 18px;
                text-align: center;
                flex-shrink: 0;
                font-size: .95rem;
            }

            .admin-nav-group > div > a:hover {
                background: rgba(255,255,255,.05);
                color: #fff;
            }

            .admin-nav-group > div > a.active {
                color: #fff;
                background: rgba(255,255,255,.08);
            }

                .admin-nav-group > div > a.active::before {
                    content: "";
                    position: absolute;
                    left: 0;
                    top: 0;
                    width: 3px;
                    height: 100%;
                    background: var(--green);
                }

        .admin-nav-group > div > a {
            transform: translateX(0);
        }

            .admin-nav-group > div > a:hover {
                transform: translateX(4px);
            }
    /* ==========================================================================
   ANIMACIÓN
   ========================================================================== */

    .admin-nav-group a {
        transform: translateX(0);
    }

        .admin-nav-group a:hover {
            transform: translateX(4px);
        }

/* ==========================================================================
   TOPBAR
   ========================================================================== */

.admin-topbar {
    height: 68px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 28px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
}

.admin-breadcrumb {
    color: var(--muted);
    font-size: .82rem;
}

.admin-topbar__user {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--muted);
    font-size: .85rem;
}

/* ==========================================================================
   TARJETAS
   ========================================================================== */

.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 2px 10px rgba(0,0,0,.03);
}

.card-title {
    color: var(--navy);
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 22px;
}

/* ==========================================================================
   BOTONES
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: 42px;
    padding: 0 18px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: .90rem;
    font-weight: 600;
    transition: background .20s, color .20s, transform .15s, box-shadow .20s;
}

.btn-sm { padding: .3rem .65rem; font-size: .75rem; }

    .btn:hover {
        transform: translateY(-1px);
    }

    .btn:active {
        transform: translateY(0);
    }

.btn-primary {
    background: var(--navy);
    color: white;
}

    .btn-primary:hover {
        background: #002894;
    }

.btn-success {
    background: var(--green);
    color: white;
}

    .btn-success:hover {
        background: #009D44;
    }

.btn-secondary {
    background: #F5F6F8;
    color: var(--ink);
    border: 1px solid var(--border);
}

    .btn-secondary:hover {
        background: #ECEEF2;
    }

.btn-danger {
    background: var(--err);
    color: white;
}

    .btn-danger:hover {
        background: #B92238;
    }

/* ==========================================================================
   FORMULARIOS
   ========================================================================== */

.form-group {
    margin-bottom: 20px;
}

    .form-group label:not(.admin-toggle) {
        display: block;
        margin-bottom: 8px;
        color: var(--ink);
        font-size: .85rem;
        font-weight: 600;
    }

.form-control {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: white;
    font-size: .92rem;
    font-family: inherit;
    transition: border-color .20s, box-shadow .20s;
}
.form-control:focus { outline: 2px solid var(--navy); outline-offset: 1px; }
.field-validation-error { color: var(--err); font-size: .78rem; display: block; margin-top: .25rem; }
.form-hint { color: var(--muted); font-size: .78rem; margin: -.15rem 0 .4rem; }

.admin-toggle { position: relative; display: flex; align-items: center; gap: .65rem; cursor: pointer; font-weight: 400; margin-bottom: 0; }
.admin-toggle input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.admin-toggle__track { position: relative; width: 38px; height: 21px; background: #CBD5E1; border-radius: 11px; transition: .2s; flex-shrink: 0; }
.admin-toggle__track::before {
  content: ""; position: absolute; width: 15px; height: 15px; background: #fff; border-radius: 50%;
  top: 3px; left: 3px; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.admin-toggle input[type="checkbox"]:checked + .admin-toggle__track { background: var(--green); }
.admin-toggle input[type="checkbox"]:checked + .admin-toggle__track::before { transform: translateX(17px); }
.admin-toggle input[type="checkbox"]:focus-visible + .admin-toggle__track { outline: 2px solid var(--navy); outline-offset: 2px; }
.admin-toggle__label { font-size: .85rem; color: var(--ink); }

.alert { padding: .75rem 1rem; border-radius: .4rem; font-size: .85rem; margin-bottom: 1rem; }
.alert-ok { background: #E5F9ED; color: #008F3D; border: 1px solid #b8ecce; }
.alert-warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #f0dca0; }
.alert-error { background: var(--err-bg); color: var(--err); border: 1px solid #f3c1c8; }
.alert-info { background: #E7ECFB; color: var(--navy); border: 1px solid #c7d3f5; }

.toast-success,
.toast-error,
.toast-info {
    position: fixed;
    right: 24px;
    bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    padding: 15px 20px;
    border-radius: 10px;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0,0,0,.18);
    z-index: 9999;
    animation: toastIn .30s ease;
    transition: opacity .30s ease, transform .30s ease;
}

    .toast-success i,
    .toast-error i,
    .toast-info i {
        font-size: 1.2rem;
    }

    .toast-success.hide,
    .toast-error.hide,
    .toast-info.hide {
        opacity: 0;
        transform: translateY(18px);
    }

.toast-success { background: #16A34A; }
.toast-error { background: var(--err); }
.toast-info { background: var(--navy); }

@keyframes toastIn {

    from {
        opacity: 0;
        transform: translateY(18px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,14,56,.55); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-content { background: var(--white); border-radius: .5rem; width: 90%; max-width: 420px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; font-size: 1rem; font-weight: 700; color: var(--navy); }
.modal-body { padding: 1.25rem; font-size: .85rem; line-height: 1.5; color: var(--ink); }
.modal-footer { padding: .9rem 1.25rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .5rem; }

.modal-content--form { max-width: 560px; text-align: left; }
.modal-content--form .modal-body { max-height: 70vh; overflow-y: auto; }
.modal-content--form .form-group { margin-bottom: 1rem; }
.modal-content--form .form-group:last-child { margin-bottom: 0; }

.modal-content--form label:not(.admin-toggle) { display: block; font-size: .8rem; font-weight: 600; color: var(--ink); margin-bottom: .3rem; }
.modal-content--form .admin-checkbox-line { display: flex; align-items: center; gap: .4rem; font-weight: 400; font-size: .85rem; margin-bottom: .4rem; }
.modal-content--form .admin-checkbox-line label { display: inline; font-weight: 400; margin: 0; }

.spinner {
  display: inline-block; width: 13px; height: 13px; border: 2px solid rgba(255,255,255,.4);
  border-radius: 50%; border-top-color: #fff; animation: admin-spin .7s linear infinite; margin-right: .35rem;
}
@keyframes admin-spin { to { transform: rotate(360deg); } }
.btn.loading { pointer-events: none; opacity: .75; }

.admin-tabla-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.admin-tabla-head .card-title { margin: 0; }
.admin-tabla-vacio { color: var(--muted); font-size: .85rem; }
.admin-table-wrap { overflow-x: auto; }

.filter-bar { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1.25rem; padding: 1rem; background: var(--white); border: 1px solid var(--border); border-radius: .5rem; }
.filter-bar .form-group { margin-bottom: 0; min-width: 160px; }

table.admin-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.admin-table th, .admin-table td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--border); }
.admin-table th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: var(--bg); }

/* Drag-and-drop de filas (Constructor de Formularios, mismo mecanismo de
   arrastrar/soltar que Landing Partners: dragstart/dragover/dragleave/drop/
   dragend con las clases "dragging"/"drag-over"). Partners nunca les dio
   estilo propio a esas dos clases -- se agrega aquí, en el CSS compartido, en
   vez de en un archivo nuevo, para que ambas pantallas (y cualquier lista con
   este mismo mecanismo en el futuro) reutilicen el mismo feedback visual. */
.admin-table tbody tr[draggable="true"] { cursor: grab; }
.admin-table tbody tr[draggable="true"]:active { cursor: grabbing; }
.admin-table tbody tr.dragging { opacity: .4; }
.admin-table tbody tr.drag-over { box-shadow: inset 0 2px 0 var(--navy); background: rgba(0,26,112,.04); }
.admin-drag-handle { display: inline-flex; align-items: center; justify-content: center; width: 1.5rem; color: var(--muted); }

.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 600; }
.badge-ok { background: #E5F9ED; color: #008F3D; }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-err { background: var(--err-bg); color: var(--err); }
.badge-info { background: #E7ECFB; color: var(--navy); }

/* ==========================================================================
   TÍTULO DE PÁGINA (fuera de .card) — REQ-ADM-011, Formularios y Enrutamiento.
   ========================================================================== */

.admin-page-title {
    color: var(--navy);
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 1.25rem;
}

.admin-panel-subtitle {
    color: var(--ink);
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 .75rem;
}

.admin-mt { margin-top: 1rem; }
.admin-muted { color: var(--muted); font-style: italic; }

/* ==========================================================================
   TABS — REQ-ADM-011, Formularios y Enrutamiento. 
   ========================================================================== */

.admin-tabs {
    display: flex;
    gap: 1.75rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.25rem;
    overflow-x: auto;
}

.admin-tab {
    background: none;
    border: none;
    padding: .6rem .1rem;
    font-size: .9rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    transition: color .15s, border-color .15s;
}

.admin-tab:hover { color: var(--ink); }

.admin-tab.active {
    color: var(--navy);
    border-bottom-color: var(--navy);
}

.admin-tab:focus-visible {
    outline: 2px solid var(--navy);
    outline-offset: 2px;
}

.admin-tab-panel {
    animation: adminTabFade .15s ease;
}

.admin-tab-panel[hidden] {
    display: none;
}

@keyframes adminTabFade {

    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }

}

/* Panel de regla condicional (Constructor de Formularios) */
.admin-regla-panel {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: .5rem;
}

.admin-regla-texto {
    font-size: .88rem;
    color: var(--ink);
    margin: 0;
}

/* Paginación (Gestión de Leads, REQ-ADM-013) */
.admin-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.admin-pagination__info {
    color: var(--muted);
    font-size: .82rem;
}

.admin-pagination__controls {
    display: flex;
    gap: .5rem;
}

.auth-shell {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient( 145deg, var(--navy) 0%, var(--navy-dark) 100% );
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--white);
    border-radius: 12px;
    padding: 36px;
    box-shadow: 0 20px 50px rgba(0,0,0,.20);
}

.auth-card__logo {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 8px;
}

    .auth-card__logo span {
        color: var(--green);
    }

.auth-card__subtitle {
    text-align: center;
    color: var(--muted);
    margin-bottom: 28px;
}

.auth-card .btn {
    width: 100%;
}

/* ==========================================================================
   ANIMACIONES
   ========================================================================== */

.fade-in {
    animation: fadeIn .25s ease;
}

@keyframes fadeIn {

    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Animación de apertura del menú */

@keyframes slideDown {

    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.admin-nav-group.open {
    animation: slideDown .25s ease;
}

/* ==========================================================================
   UTILIDADES
   ========================================================================== */

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--muted);
}

.hidden {
    display: none !important;
}

.w-100 {
    width: 100%;
}

.d-flex {
    display: flex;
}

.align-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-1 {
    gap: .5rem;
}

.gap-2 {
    gap: 1rem;
}

.mt-1 {
    margin-top: .5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-3 {
    margin-top: 1.5rem;
}

.mb-1 {
    margin-bottom: .5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width:1100px) {

    .admin-sidebar {
        width: 240px;
    }
}

@media (max-width:900px) {

    .admin-topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
        height: auto;
        padding: 18px;
    }
}

@media (max-width:768px) {

    .admin-shell {
        flex-direction: column;
    }

    .admin-sidebar {
        width: 100%;
        min-height: auto;
    }

    .admin-main {
        width: 100%;
    }

    .admin-content {
        padding: 18px;
    }
}

@media (max-width:576px) {

    .btn {
        width: 100%;
    }

    .card {
        padding: 18px;
    }
}

/* ==========================================================
   LISTA DE CASILLAS
   Seleccion multiple sobre un conjunto cerrado de valores
   (ej. roles de un usuario). Se ofrece la lista en vez de un
   campo de texto libre porque un valor mal escrito se
   guardaria sin error visible.
========================================================== */

.lista-casillas {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem .75rem;
  padding: .75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-soft, #f7f8fa);
}

.lista-casillas__item {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin: 0;
  padding: .3rem .6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  font-size: .8125rem;
  font-weight: 500;
  cursor: pointer;
}

  .lista-casillas__item:hover {
    border-color: var(--primary, #1b3a6b);
  }

  .lista-casillas__item input {
    margin: 0;
    cursor: pointer;
  }

  /* :has() permite marcar visualmente la casilla activa sin JS. Si el
     navegador no lo soporta, la casilla sigue funcionando: solo se pierde
     el resaltado. */
  .lista-casillas__item:has(input:checked) {
    border-color: var(--primary, #1b3a6b);
    background: var(--primary-soft, #eef3fb);
  }

/* ==========================================================
   BARRA DE FILTROS
   Fila de campos sobre un listado. Se envia por GET para que
   la busqueda quede en la URL y se pueda compartir o recargar
   sin reenviar el formulario.
========================================================== */

.filtros-barra {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: .75rem;
}

  .filtros-barra .form-group {
    flex: 1 1 12rem;
    min-width: 10rem;
    margin: 0;
  }

.filtros-barra__acciones {
  display: flex;
  gap: .5rem;
  /* Se alinean con el borde inferior de los campos, no con su etiqueta. */
  align-items: flex-end;
}
