/* ================================================================
   CNC Modern — Animations, Micro-interactions & Effects
   ================================================================ */

/* ─── KEYFRAMES ─── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(66, 105, 93, 0.25); }
    50%      { box-shadow: 0 0 0 8px rgba(66, 105, 93, 0); }
}

@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.06); }
}

@keyframes titleUnderline {
    from { width: 0; }
    to   { width: 100%; }
}

@keyframes gradientShift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-4px); }
}

@keyframes ripple {
    0%   { transform: scale(0); opacity: 0.5; }
    100% { transform: scale(4); opacity: 0; }
}

/* ─── VIEW TRANSITIONS ─── */
::view-transition-old(root) {
    animation: 200ms ease-out both fadeOut;
}

::view-transition-new(root) {
    animation: 300ms ease-out both fadeIn;
}

@keyframes fadeOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

.js-view-transitions a {
    transition: opacity 0.15s ease;
}

/* ─── ENTRANCE ANIMATIONS ─── */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.animate-on-scroll.visible {
    opacity: 1;
    transform: translateY(0);
}

.visible-delay-1 { transition-delay: 0.08s; }
.visible-delay-2 { transition-delay: 0.16s; }
.visible-delay-3 { transition-delay: 0.24s; }
.visible-delay-4 { transition-delay: 0.32s; }
.visible-delay-5 { transition-delay: 0.4s; }

/* ─── PAGE TITLE (animated underline) ─── */
.page-title {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding-bottom: 0.5rem;
}

.page-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--cnc-primary), var(--cnc-secondary));
    border-radius: 2px;
    animation: titleUnderline 0.6s ease forwards 0.2s;
}

.page-title-anim {
    animation: fadeInUp 0.4s ease;
}

/* ─── TABLE ROWS (staggered entrance) ─── */
.table tbody tr {
    animation: fadeInUp 0.35s ease both;
}

.table tbody tr:nth-child(1)  { animation-delay: 0.03s; }
.table tbody tr:nth-child(2)  { animation-delay: 0.06s; }
.table tbody tr:nth-child(3)  { animation-delay: 0.09s; }
.table tbody tr:nth-child(4)  { animation-delay: 0.12s; }
.table tbody tr:nth-child(5)  { animation-delay: 0.15s; }
.table tbody tr:nth-child(6)  { animation-delay: 0.18s; }
.table tbody tr:nth-child(7)  { animation-delay: 0.21s; }
.table tbody tr:nth-child(8)  { animation-delay: 0.24s; }
.table tbody tr:nth-child(9)  { animation-delay: 0.27s; }
.table tbody tr:nth-child(10) { animation-delay: 0.30s; }

.table tbody tr:hover {
    background: rgba(66, 105, 93, 0.04) !important;
    transform: scale(1.001);
    box-shadow: 0 1px 8px rgba(66, 105, 93, 0.06);
}

/* ─── STATUS BADGES ─── */
.badge-estado {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3em 0.75em;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    transition: all var(--cnc-transition);
}

.badge-estado.borrador     { background: rgba(108, 117, 125, 0.1); color: #6c757d; }
.badge-estado.recibida     { background: rgba(13, 110, 253, 0.1); color: #0d6efd; }
.badge-estado.pendiente    { background: rgba(255, 193, 7, 0.12); color: #997404; }
.badge-estado.requerimientos { background: rgba(253, 126, 20, 0.12); color: #c25a02; }
.badge-estado.justificada  { background: rgba(111, 66, 193, 0.1); color: #6f42c1; }
.badge-estado.aceptada     { background: rgba(25, 135, 84, 0.1); color: #198754; }
.badge-estado.rechazada    { background: rgba(220, 53, 69, 0.1); color: #b02a37; }

/* ─── CARDS (hover lift) ─── */
.card {
    transition: all var(--cnc-transition-slow);
}

.card:hover {
    box-shadow: var(--cnc-shadow-lg);
    transform: translateY(-2px);
}

.card .section-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--cnc-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--cnc-border);
    position: relative;
}

.card .section-title::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 40px;
    height: 2px;
    background: var(--cnc-secondary);
    border-radius: 1px;
}

/* ─── BUTTONS (ripple effect) ─── */
.btn {
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), rgba(255, 255, 255, 0.15) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.3s;
}

.btn:active::after {
    opacity: 1;
}

/* ─── ALERTS (slide-in) ─── */
.alert {
    animation: slideDown 0.3s ease;
}

/* ─── MODAL ENHANCEMENTS ─── */
.modal.fade .modal-dialog {
    transform: scale(0.96) translateY(8px);
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.modal.fade.show .modal-dialog {
    transform: scale(1) translateY(0);
}

.modal-content {
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.15);
}

.modal-header .btn-close {
    transition: all var(--cnc-transition);
}

.modal-header .btn-close:hover {
    transform: rotate(90deg);
    opacity: 0.7;
}

/* ─── SECTION HEADERS ─── */
h2, h3 {
    color: var(--cnc-primary);
    font-weight: 700;
}

/* ─── DASHBOARD CARDS ─── */
.card-lottie {
    transition: all var(--cnc-transition-slow);
    cursor: pointer;
}

.card-lottie:hover {
    transform: translateY(-4px);
    box-shadow: var(--cnc-shadow-lg);
}

.card-lottie .lottie-wrap {
    overflow: hidden;
    border-radius: var(--cnc-radius) var(--cnc-radius) 0 0;
}

.card-lottie .lottie-wrap img {
    transition: transform 0.4s ease;
}

.card-lottie:hover .lottie-wrap img {
    transform: scale(1.04);
}

/* ─── LOTTIE CONTAINERS ─── */
.lottie-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #f0f2f5;
    border-radius: var(--cnc-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.lottie-wrap .lottie-player {
    width: 100%;
    height: 100%;
}

.lottie-wrap .lottie-fallback {
    display: none;
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
}

.lottie-wrap.is-fallback .lottie-fallback { display: block; }
.lottie-wrap.is-fallback .lottie-player { display: none; }

/* ─── ICONS IN TABLES ─── */
td .bi-check-circle {
    animation: scaleIn 0.3s ease;
}

td .bi-exclamation-octagon {
    animation: pulseGlow 2s infinite;
}

/* ─── FORM FOCUS EFFECT ─── */
.form-control:focus,
.form-select:focus {
    border-color: var(--cnc-primary);
    box-shadow: 0 0 0 3px rgba(66, 105, 93, 0.08);
    transform: translateY(-1px);
}

/* ─── SKELETON LOADING ─── */
.skeleton {
    background: linear-gradient(90deg, rgba(66, 105, 93, 0.04) 25%, rgba(66, 105, 93, 0.08) 50%, rgba(66, 105, 93, 0.04) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--cnc-radius-xs);
}

/* ─── SCROLL-TO-TOP ─── */
.scroll-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--cnc-primary);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transform: translateY(10px);
    transition: all var(--cnc-transition);
    z-index: 1050;
    box-shadow: var(--cnc-shadow-md);
}

.scroll-top.visible {
    opacity: 1;
    transform: translateY(0);
}

.scroll-top:hover {
    background: var(--cnc-primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--cnc-shadow-lg);
}

/* ─── GLASS EFFECT (subtle) ─── */
.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ─── GRADIENT TEXT ─── */
.gradient-text {
    background: linear-gradient(135deg, var(--cnc-primary), var(--cnc-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ─── HOVER LIFT ─── */
.hover-lift {
    transition: all var(--cnc-transition-slow);
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: var(--cnc-shadow-lg);
}
