/* ============================================================
   ANIMACIONES Y MICROINTERACCIONES DE CONATRADEC
   ============================================================ */

:root {
    --motion-fast: 160ms;
    --motion-normal: 260ms;
    --motion-slow: 620ms;
    --motion-ease: cubic-bezier(.2, .75, .25, 1);
    --motion-bounce: cubic-bezier(.2, .9, .25, 1.2);
}

/* ------------------------------------------------------------
   LOGIN Y MASCOTA
   ------------------------------------------------------------ */

.login-page {
    grid-template-columns: minmax(620px, 1.2fr) minmax(430px, .8fr);
    overflow: hidden;
}

.login-visual {
    isolation: isolate;
    padding: clamp(42px, 5vw, 76px);
}

.login-visual::before {
    position: absolute;
    inset: auto auto -170px -120px;
    z-index: -1;
    width: 420px;
    height: 420px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 50%;
    content: "";
    animation: loginRing 14s linear infinite;
}

.login-visual-content {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(280px, .92fr);
    align-items: center;
    gap: clamp(20px, 3vw, 54px);
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
}

.login-copy {
    position: relative;
    z-index: 3;
    animation: loginCopyIn 760ms var(--motion-ease) both;
}

.login-copy .login-logo {
    animation: logoPop 620ms var(--motion-bounce) 120ms both;
}

.login-copy .eyebrow {
    animation: revealUp 520ms var(--motion-ease) 160ms both;
}

.login-copy h1 {
    max-width: 620px;
    font-size: clamp(38px, 4.5vw, 62px);
    animation: revealUp 620ms var(--motion-ease) 230ms both;
}

.login-copy > p:not(.eyebrow) {
    animation: revealUp 620ms var(--motion-ease) 310ms both;
}

.login-feature-list span {
    opacity: 0;
    transform: translateX(-18px);
    animation: featureIn 460ms var(--motion-ease) forwards;
}

.login-feature-list span:nth-child(1) { animation-delay: 400ms; }
.login-feature-list span:nth-child(2) { animation-delay: 480ms; }
.login-feature-list span:nth-child(3) { animation-delay: 560ms; }

.login-feature-list span i {
    transition: transform var(--motion-normal) var(--motion-ease);
}

.login-feature-list span:hover i {
    transform: translateY(-2px) scale(1.12);
}

.login-mascot-stage {
    position: relative;
    z-index: 2;
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: clamp(430px, 55vh, 650px);
}

.login-mascot {
    position: relative;
    z-index: 3;
    display: block;
    width: min(100%, 520px);
    max-height: 72vh;
    object-fit: contain;
    filter: drop-shadow(0 28px 28px rgba(8, 20, 16, .28));
    transform-origin: 50% 92%;
    will-change: transform, opacity;
    animation:
        mascotEnter 920ms var(--motion-bounce) both,
        mascotFloat 4.8s ease-in-out 920ms infinite;
}

.mascot-glow {
    position: absolute;
    z-index: 1;
    width: min(90%, 440px);
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(242, 201, 76, .28), rgba(242, 201, 76, 0) 68%);
    filter: blur(2px);
    animation: glowPulse 4s ease-in-out infinite;
}

.mascot-ground-shadow {
    position: absolute;
    right: 14%;
    bottom: 8%;
    left: 14%;
    z-index: 2;
    height: 30px;
    border-radius: 50%;
    background: rgba(7, 18, 14, .3);
    filter: blur(15px);
    animation: shadowPulse 4.8s ease-in-out 920ms infinite;
}

.coffee-bean {
    position: absolute;
    z-index: 4;
    display: block;
    width: 22px;
    height: 31px;
    border: 2px solid rgba(255, 255, 255, .16);
    border-radius: 55% 45% 55% 45%;
    background: linear-gradient(145deg, #c96b2d, #6e2e12);
    box-shadow: 0 7px 14px rgba(8, 18, 14, .2);
    opacity: .84;
}

.coffee-bean::after {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 50%;
    width: 2px;
    border-radius: 50%;
    background: rgba(255, 220, 180, .5);
    content: "";
    transform: rotate(14deg);
}

.bean-one {
    top: 16%;
    left: 2%;
    animation: beanDriftOne 5.4s ease-in-out infinite;
}

.bean-two {
    top: 7%;
    right: 8%;
    width: 17px;
    height: 25px;
    animation: beanDriftTwo 6.2s ease-in-out .8s infinite;
}

.bean-three {
    right: 0;
    bottom: 20%;
    width: 19px;
    height: 28px;
    animation: beanDriftOne 5.8s ease-in-out 1.4s infinite reverse;
}

.login-panel {
    position: relative;
}

.login-panel::before,
.login-panel::after {
    position: absolute;
    border-radius: 50%;
    content: "";
    pointer-events: none;
}

.login-panel::before {
    top: -110px;
    right: -95px;
    width: 260px;
    height: 260px;
    background: rgba(59, 101, 91, .06);
}

.login-panel::after {
    bottom: -120px;
    left: -80px;
    width: 240px;
    height: 240px;
    background: rgba(242, 201, 76, .09);
}

.login-card {
    position: relative;
    z-index: 2;
    animation: loginCardIn 760ms var(--motion-ease) 100ms both;
}

.login-card::before {
    position: absolute;
    top: 0;
    right: 30px;
    left: 30px;
    height: 3px;
    border-radius: 0 0 10px 10px;
    background: linear-gradient(90deg, var(--green-700), var(--yellow), var(--brown));
    content: "";
    transform-origin: left;
    animation: accentGrow 780ms var(--motion-ease) 500ms both;
}

.login-card-header,
.login-field-user,
.login-field-password,
.login-submit,
.login-note {
    opacity: 0;
    transform: translateY(15px);
    animation: revealUp 480ms var(--motion-ease) forwards;
}

.login-card-header { animation-delay: 320ms; }
.login-field-user { animation-delay: 410ms; }
.login-field-password { animation-delay: 490ms; }
.login-submit { animation-delay: 570ms; }
.login-note { animation-delay: 650ms; }

.login-submit {
    position: relative;
    overflow: hidden;
    box-shadow: 0 11px 24px rgba(59, 101, 91, .2);
}

.login-submit::after {
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 20%, rgba(255, 255, 255, .24) 50%, transparent 80%);
    content: "";
    transform: translateX(-125%);
    transition: transform 620ms ease;
}

.login-submit:hover::after {
    transform: translateX(125%);
}

.login-submit:hover:not(:disabled) {
    box-shadow: 0 15px 30px rgba(59, 101, 91, .27);
    transform: translateY(-2px);
}

.login-submit:active:not(:disabled) {
    transform: translateY(0) scale(.99);
}

.login-card .input-with-icon > i {
    transition: color var(--motion-fast) ease, transform var(--motion-fast) ease;
}

.login-card .input-with-icon:focus-within > i {
    color: var(--green-700);
    transform: translateY(-50%) scale(1.08);
}

.login-card .form-control {
    transition:
        border-color var(--motion-fast) ease,
        box-shadow var(--motion-fast) ease,
        transform var(--motion-fast) ease;
}

.login-card .form-control:focus {
    transform: translateY(-1px);
}

.login-card .alert-error {
    animation: alertDrop 420ms var(--motion-bounce) both;
}

.mobile-mascot-logo {
    overflow: visible;
    border-radius: 0;
    background: transparent;
}

.mobile-mascot-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 10px 15px rgba(36, 63, 56, .18));
    animation: mascotFloat 4.8s ease-in-out infinite;
}

.login-page.is-processing .login-card {
    box-shadow: 0 28px 70px rgba(36, 63, 56, .17);
}

.login-page.is-processing .login-mascot {
    animation: mascotWorking 760ms ease-in-out infinite;
}

.login-page.is-processing .mascot-ground-shadow {
    animation: shadowWorking 760ms ease-in-out infinite;
}

.login-page.has-error .login-mascot {
    animation:
        mascotError 520ms ease both,
        mascotFloat 4.8s ease-in-out 520ms infinite;
}

/* ------------------------------------------------------------
   DASHBOARD
   ------------------------------------------------------------ */

.executive-header {
    animation: revealUp 560ms var(--motion-ease) both;
}

.executive-kpi-grid > * {
    opacity: 0;
    transform: translateY(22px) scale(.98);
    animation: dashboardCardIn 560ms var(--motion-ease) forwards;
}

.executive-kpi-grid > *:nth-child(1) { animation-delay: 80ms; }
.executive-kpi-grid > *:nth-child(2) { animation-delay: 140ms; }
.executive-kpi-grid > *:nth-child(3) { animation-delay: 200ms; }
.executive-kpi-grid > *:nth-child(4) { animation-delay: 260ms; }
.executive-kpi-grid > *:nth-child(5) { animation-delay: 320ms; }
.executive-kpi-grid > *:nth-child(6) { animation-delay: 380ms; }

.dashboard-main-grid > .panel,
.dashboard-alerts-table {
    opacity: 0;
    transform: translateY(20px);
    animation: revealUp 620ms var(--motion-ease) forwards;
}

.dashboard-main-grid > .panel:nth-child(1) { animation-delay: 260ms; }
.dashboard-main-grid > .panel:nth-child(2) { animation-delay: 320ms; }
.dashboard-main-grid > .panel:nth-child(3) { animation-delay: 380ms; }
.dashboard-main-grid > .panel:nth-child(4) { animation-delay: 440ms; }
.dashboard-main-grid > .panel:nth-child(5) { animation-delay: 500ms; }
.dashboard-main-grid > .panel:nth-child(6) { animation-delay: 560ms; }
.dashboard-alerts-table { animation-delay: 620ms; }

.executive-kpi-grid > *,
.quick-actions-grid a,
.stat-card,
.user-card {
    transition:
        transform var(--motion-normal) var(--motion-ease),
        box-shadow var(--motion-normal) var(--motion-ease),
        border-color var(--motion-normal) ease;
}

.executive-kpi-grid > *:hover,
.stat-card:hover,
.user-card:hover {
    border-color: rgba(59, 101, 91, .24);
    box-shadow: 0 18px 42px rgba(36, 63, 56, .12);
    transform: translateY(-4px);
}

.dashboard-bar-fill {
    transform: scaleY(0);
    transform-origin: bottom;
    animation: dashboardBarGrow 900ms var(--motion-ease) 460ms forwards;
}

.dashboard-live-indicator i {
    animation: livePulse 1.9s ease-in-out infinite;
}

.followup-ring {
    animation: ringReveal 780ms var(--motion-bounce) 420ms both;
}

.quick-actions-grid a:hover {
    box-shadow: 0 12px 24px rgba(36, 63, 56, .1);
    transform: translateY(-3px);
}

.quick-actions-grid a i,
.table-action i {
    transition: transform var(--motion-normal) var(--motion-ease);
}

.quick-actions-grid a:hover i {
    transform: translateY(-2px) scale(1.12);
}

.table-action:hover i {
    transform: translateX(3px);
}

/* ------------------------------------------------------------
   MICROINTERACCIONES GENERALES
   ------------------------------------------------------------ */

.btn-primary,
.btn-secondary,
.btn-link,
.icon-button,
.menu-button,
.table-action {
    transition:
        transform var(--motion-fast) ease,
        box-shadow var(--motion-fast) ease,
        background-color var(--motion-fast) ease,
        border-color var(--motion-fast) ease,
        color var(--motion-fast) ease;
}

.btn-primary:hover:not(:disabled),
.btn-secondary:hover:not(:disabled) {
    transform: translateY(-2px);
}

.btn-primary:active:not(:disabled),
.btn-secondary:active:not(:disabled),
.icon-button:active,
.menu-button:active,
.table-action:active {
    transform: scale(.97);
}

.nav-menu a i {
    transition: transform var(--motion-normal) var(--motion-ease);
}

.nav-menu a:hover i,
.nav-menu a.active i {
    transform: translateX(2px) scale(1.06);
}

.sidebar.open {
    box-shadow: 20px 0 50px rgba(13, 28, 23, .18);
}

.sidebar-overlay {
    animation: overlayFade 200ms ease both;
}

.modal-backdrop {
    animation: overlayFade 200ms ease both;
}

.modal-card {
    transform-origin: center top;
    animation: modalIn 280ms var(--motion-ease) both;
}

.empty-state > i,
.dashboard-empty > i {
    animation: emptyIconFloat 3.6s ease-in-out infinite;
}

.loading-state {
    animation: loadingFade 340ms ease both;
}

/* ------------------------------------------------------------
   KEYFRAMES
   ------------------------------------------------------------ */

@keyframes loginCopyIn {
    from {
        opacity: 0;
        transform: translateX(-28px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes loginCardIn {
    from {
        opacity: 0;
        filter: blur(8px);
        transform: translateX(38px) scale(.97);
    }
    to {
        opacity: 1;
        filter: blur(0);
        transform: translateX(0) scale(1);
    }
}

@keyframes mascotEnter {
    0% {
        opacity: 0;
        transform: translateY(95px) scale(.78) rotate(-6deg);
    }
    65% {
        opacity: 1;
        transform: translateY(-13px) scale(1.035) rotate(2deg);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1) rotate(0);
    }
}

@keyframes mascotFloat {
    0%, 100% { transform: translateY(0) rotate(-.7deg); }
    50% { transform: translateY(-13px) rotate(.8deg); }
}

@keyframes mascotWorking {
    0%, 100% { transform: translateY(0) rotate(-1deg) scale(1); }
    50% { transform: translateY(-9px) rotate(2deg) scale(1.015); }
}

@keyframes mascotError {
    0%, 100% { transform: translateX(0) rotate(0); }
    20% { transform: translateX(-10px) rotate(-2deg); }
    40% { transform: translateX(9px) rotate(2deg); }
    60% { transform: translateX(-6px) rotate(-1deg); }
    80% { transform: translateX(4px) rotate(1deg); }
}

@keyframes shadowPulse {
    0%, 100% { opacity: .65; transform: scaleX(1); }
    50% { opacity: .45; transform: scaleX(.88); }
}

@keyframes shadowWorking {
    0%, 100% { opacity: .65; transform: scaleX(1); }
    50% { opacity: .42; transform: scaleX(.82); }
}

@keyframes glowPulse {
    0%, 100% { opacity: .72; transform: scale(.96); }
    50% { opacity: 1; transform: scale(1.06); }
}

@keyframes beanDriftOne {
    0%, 100% { transform: translate(0, 0) rotate(-18deg); }
    50% { transform: translate(12px, -18px) rotate(15deg); }
}

@keyframes beanDriftTwo {
    0%, 100% { transform: translate(0, 0) rotate(16deg); }
    50% { transform: translate(-14px, 15px) rotate(-12deg); }
}

@keyframes loginRing {
    to { transform: rotate(360deg); }
}

@keyframes logoPop {
    from {
        opacity: 0;
        transform: scale(.55) rotate(-12deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotate(0);
    }
}

@keyframes revealUp {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes featureIn {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes alertDrop {
    from {
        opacity: 0;
        transform: translateY(-9px) scale(.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes accentGrow {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

@keyframes dashboardCardIn {
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes dashboardBarGrow {
    to { transform: scaleY(1); }
}

@keyframes livePulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
        filter: drop-shadow(0 0 0 rgba(59, 101, 91, 0));
    }
    50% {
        opacity: .58;
        transform: scale(.78);
        filter: drop-shadow(0 0 5px rgba(59, 101, 91, .48));
    }
}

@keyframes ringReveal {
    from {
        opacity: 0;
        transform: scale(.72) rotate(-12deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotate(0);
    }
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes overlayFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes emptyIconFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-7px); }
}

@keyframes loadingFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ------------------------------------------------------------
   ADAPTACIÓN RESPONSIVA
   ------------------------------------------------------------ */

@media (max-width: 1280px) {
    .login-page {
        grid-template-columns: minmax(570px, 1.12fr) minmax(420px, .88fr);
    }

    .login-visual {
        padding: 48px;
    }

    .login-visual-content {
        grid-template-columns: minmax(0, 1fr) minmax(245px, .78fr);
        gap: 24px;
    }

    .login-copy h1 {
        font-size: clamp(36px, 4.3vw, 52px);
    }

    .login-mascot-stage {
        min-height: 500px;
    }
}

@media (max-width: 1040px) and (min-width: 901px) {
    .login-page {
        grid-template-columns: minmax(520px, 1fr) minmax(400px, .8fr);
    }

    .login-visual {
        padding: 38px;
    }

    .login-visual-content {
        grid-template-columns: 1fr;
    }

    .login-copy {
        max-width: 470px;
    }

    .login-mascot-stage {
        position: absolute;
        right: -55px;
        bottom: -35px;
        width: 290px;
        min-height: 310px;
        opacity: .82;
    }

    .login-mascot {
        width: 290px;
    }

    .login-copy h1 {
        max-width: 450px;
        font-size: 43px;
    }
}

@media (max-width: 900px) {
    .login-page {
        display: grid;
        grid-template-columns: 1fr;
    }

    .login-panel {
        background:
            radial-gradient(circle at 10% 10%, rgba(242, 201, 76, .12), transparent 26%),
            radial-gradient(circle at 90% 90%, rgba(59, 101, 91, .1), transparent 28%),
            var(--background);
    }

    .mobile-mascot-logo {
        display: grid;
        width: 96px;
        height: 96px;
        margin-bottom: 12px;
    }
}

@media (max-width: 680px) {
    .mobile-mascot-logo {
        width: 86px;
        height: 86px;
    }

    .login-card {
        border-radius: 20px;
    }
}

/* Respeta la preferencia de accesibilidad del sistema operativo. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }

    .login-mascot,
    .mobile-mascot-logo img,
    .empty-state > i,
    .dashboard-empty > i {
        transform: none !important;
    }
}
