/* ============================================================
   AutoPelu — capa de movimiento para los paneles (owner / admin / closer)
   Se activa sólo cuando motion.js agrega .ap-panel al <body>.
   ============================================================ */
.ap-panel {
    --ap-glow-1: #6C5CE7;
    --ap-glow-2: #00CEC9;
    --ap-glow-3: #FD79A8;
    --ap-ease: cubic-bezier(.2, .8, .2, 1);
}

/* ── Fondo aurora animado ── */
.ap-panel::before,
.ap-panel::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    filter: blur(110px);
    pointer-events: none;
    z-index: -1;
    opacity: .22;
    animation: apAurora 24s ease-in-out infinite alternate;
}
.ap-panel::before { width: 560px; height: 560px; background: var(--ap-glow-1); top: -180px; right: -120px; }
.ap-panel::after { width: 460px; height: 460px; background: var(--ap-glow-2); bottom: -200px; left: 20%; opacity: .14; animation-duration: 30s; animation-delay: -10s; }
@keyframes apAurora {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-80px, 60px) scale(1.15); }
    100% { transform: translate(40px, -40px) scale(.95); }
}
.ap-panel main { background-color: transparent !important; }

/* ── Entrada escalonada del contenido ── */
.ap-panel .ap-enter {
    opacity: 0;
    transform: translateY(22px);
    animation: apRise .7s var(--ap-ease) forwards;
    animation-delay: calc(var(--i, 0) * 70ms);
}
@keyframes apRise { to { opacity: 1; transform: none; } }

/* ── Sidebar ── */
.ap-panel #sidebar {
    background: linear-gradient(180deg, rgba(20, 20, 45, .96), rgba(12, 12, 30, .98)) !important;
    border-right: 1px solid rgba(255, 255, 255, .06);
}
.ap-panel #sidebar .offcanvas-title,
.ap-panel .sidebar-brand {
    letter-spacing: 1px;
}
.ap-panel #sidebar .offcanvas-title i,
.ap-panel .sidebar-brand i { display: inline-block; animation: apWiggle 5s ease-in-out infinite; }
@keyframes apWiggle { 0%, 90%, 100% { transform: rotate(0); } 93% { transform: rotate(-12deg); } 96% { transform: rotate(10deg); } }

.ap-panel #sidebar .nav-link,
.ap-panel .sidebar .nav-link {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    transition: transform .35s var(--ap-ease), background-color .35s, color .35s, padding-left .35s var(--ap-ease);
}
.ap-panel #sidebar .nav-link:hover,
.ap-panel .sidebar .nav-link:hover {
    background: rgba(255, 255, 255, .06);
    padding-left: 1.4rem;
}
.ap-panel #sidebar .nav-link i,
.ap-panel .sidebar .nav-link i { display: inline-block; transition: transform .4s var(--ap-ease); }
.ap-panel #sidebar .nav-link:hover i,
.ap-panel .sidebar .nav-link:hover i { transform: scale(1.2) rotate(-6deg); }
.ap-panel #sidebar .nav-link.active,
.ap-panel .sidebar .nav-link.active {
    background: linear-gradient(135deg, var(--ap-glow-1), #8b7cf6) !important;
    box-shadow: 0 8px 22px rgba(108, 92, 231, .45);
}
.ap-panel #sidebar .nav-link.active::after,
.ap-panel .sidebar .nav-link.active::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .25) 50%, transparent 70%);
    transform: translateX(-100%);
    animation: apShine 4s ease-in-out infinite;
}
@keyframes apShine { 0%, 60% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* ── Topbar ── */
.ap-panel main > header {
    background: rgba(255, 255, 255, .04) !important;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, .08) !important;
}

/* ── Tarjetas ── */
.ap-panel .glass-card,
.ap-panel .glassmorphism-card,
.ap-panel main .card {
    position: relative;
    transition: transform .45s var(--ap-ease), box-shadow .45s var(--ap-ease), border-color .45s;
}
.ap-panel .glass-card::before,
.ap-panel .glassmorphism-card::before,
.ap-panel main .card::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, var(--ap-glow-1), var(--ap-glow-2), var(--ap-glow-3));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity .45s;
    pointer-events: none;
    z-index: 1;
}
.ap-panel .glass-card:not(:has(.modal)):hover,
.ap-panel .glassmorphism-card:not(:has(.modal)):hover,
.ap-panel main .card:not(:has(.modal)):hover {
    transform: translateY(-4px);
    box-shadow: 0 18px 40px rgba(0, 0, 0, .35), 0 0 0 1px rgba(108, 92, 231, .15);
}
.ap-panel .glass-card:hover::before,
.ap-panel .glassmorphism-card:hover::before,
.ap-panel main .card:hover::before { opacity: 1; }
/* Las tarjetas grandes (tablas) no se levantan tanto */
.ap-panel .card:has(.table):hover,
.ap-panel .glass-card:has(.table):hover { transform: translateY(-1px); }

/* Spotlight que sigue al mouse */
.ap-panel .ap-spot { background-image: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(108, 92, 231, .12), transparent 45%) !important; }

/* Iconos de las tarjetas de stats */
.ap-panel .glass-card > i.fs-1,
.ap-panel .glassmorphism-card i.fs-1 { display: inline-block; animation: apFloat 4s ease-in-out infinite; }
@keyframes apFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* ── Tablas ── */
.ap-panel .table tbody tr { transition: background-color .25s, transform .25s var(--ap-ease); }
.ap-panel .table-hover tbody tr:not(:has(.modal)):hover { transform: translateX(4px); }
.ap-panel .table tbody tr.ap-row-in { opacity: 0; animation: apRowIn .5s var(--ap-ease) forwards; animation-delay: calc(var(--r, 0) * 40ms + 250ms); }
@keyframes apRowIn { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }

/* ── Botones ── */
.ap-panel .btn { position: relative; overflow: hidden; transition: transform .25s var(--ap-ease), box-shadow .25s, background-color .25s, color .25s; }
.ap-panel .btn:hover { transform: translateY(-1px); }
.ap-panel .btn:active { transform: translateY(0) scale(.97); }
.ap-panel .btn-primary,
.ap-panel .btn-gradient {
    background: linear-gradient(135deg, var(--ap-glow-1), var(--ap-glow-2)) !important;
    background-size: 200% auto !important;
    border: none !important;
    transition: background-position .5s, transform .25s var(--ap-ease), box-shadow .25s;
}
.ap-panel .btn-primary:hover,
.ap-panel .btn-gradient:hover { background-position: right center !important; box-shadow: 0 8px 22px rgba(108, 92, 231, .4); }
.ap-ripple {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    background: rgba(255, 255, 255, .35);
    animation: apRipple .6s linear;
    pointer-events: none;
}
@keyframes apRipple { to { transform: scale(4); opacity: 0; } }

/* ── Badges ── */
.ap-panel .badge { transition: transform .25s var(--ap-ease); }
.ap-panel tr:hover .badge { transform: scale(1.06); }
.ap-panel .badge.bg-warning { animation: apBadgePulse 2.4s ease-in-out infinite; }
@keyframes apBadgePulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(241, 196, 15, .5); } 50% { box-shadow: 0 0 0 6px rgba(241, 196, 15, 0); } }

/* ── Formularios ── */
.ap-panel .form-control,
.ap-panel .form-select { transition: border-color .3s, box-shadow .3s, background-color .3s, transform .3s var(--ap-ease) !important; }
.ap-panel .form-control:focus,
.ap-panel .form-select:focus { transform: translateY(-1px); }

/* ── Modales ── */
.ap-panel .modal.fade .modal-dialog { transform: translateY(30px) scale(.96); transition: transform .4s var(--ap-ease); }
.ap-panel .modal.show .modal-dialog { transform: none; }
.ap-panel .modal-content { backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }

/* ── Scrollbar ── */
.ap-panel ::-webkit-scrollbar { width: 8px; height: 8px; }
.ap-panel ::-webkit-scrollbar-thumb { background: linear-gradient(var(--ap-glow-1), var(--ap-glow-2)); border-radius: 8px; }
.ap-panel ::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) {
    .ap-panel *, .ap-panel *::before, .ap-panel *::after, .ap-panel::before, .ap-panel::after { animation: none !important; transition: none !important; }
    .ap-panel .ap-enter, .ap-panel .table tbody tr.ap-row-in { opacity: 1; transform: none; }
}
