/* ============================================================
   AramsTech PM — Animations & Micro-interactions
   ============================================================ */

/* ── Keyframes ──────────────────────────────────────────────── */

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

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

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

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

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

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

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

@keyframes pulse-ring {
    0%   { transform: scale(0.8); opacity: 1; }
    100% { transform: scale(1.8); opacity: 0; }
}

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

@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

@keyframes countUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes progressFill {
    from { width: 0%; }
}

@keyframes borderGlow {
    0%, 100% { border-color: var(--color-primary); box-shadow: 0 0 8px var(--color-primary-glow); }
    50%       { border-color: var(--color-accent);  box-shadow: 0 0 20px var(--color-accent-glow); }
}

@keyframes alertPulse {
    0%, 100% { box-shadow: 0 0 0 0 hsla(5, 80%, 58%, 0.4); }
    50%       { box-shadow: 0 0 0 8px hsla(5, 80%, 58%, 0); }
}

@keyframes navIndicatorSlide {
    from { opacity: 0; transform: scaleY(0); }
    to   { opacity: 1; transform: scaleY(1); }
}

@keyframes ripple {
    from { transform: scale(0); opacity: 0.6; }
    to   { transform: scale(4); opacity: 0; }
}

@keyframes toastSlideIn {
    from { transform: translateX(110%); opacity: 0; }
    to   { transform: translateX(0);   opacity: 1; }
}

@keyframes toastSlideOut {
    from { transform: translateX(0);   opacity: 1; }
    to   { transform: translateX(110%); opacity: 0; }
}

/* ── Page Transitions ───────────────────────────────────────── */
.page-enter {
    animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.main-content {
    animation: fadeInUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ── Card Animations ────────────────────────────────────────── */
.card {
    transition: transform var(--transition-base),
                box-shadow var(--transition-base),
                border-color var(--transition-base);
}
.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg), 0 0 0 1px var(--border-strong);
}

.kpi-card {
    animation: fadeInUp 0.5s ease both;
}
.kpi-card:nth-child(1) { animation-delay: 0.05s; }
.kpi-card:nth-child(2) { animation-delay: 0.10s; }
.kpi-card:nth-child(3) { animation-delay: 0.15s; }
.kpi-card:nth-child(4) { animation-delay: 0.20s; }
.kpi-card:nth-child(5) { animation-delay: 0.25s; }
.kpi-card:nth-child(6) { animation-delay: 0.30s; }

/* ── Staggered List ─────────────────────────────────────────── */
.stagger-list > * {
    animation: fadeInUp 0.4s ease both;
}
.stagger-list > *:nth-child(1)  { animation-delay: 0.05s; }
.stagger-list > *:nth-child(2)  { animation-delay: 0.10s; }
.stagger-list > *:nth-child(3)  { animation-delay: 0.15s; }
.stagger-list > *:nth-child(4)  { animation-delay: 0.20s; }
.stagger-list > *:nth-child(5)  { animation-delay: 0.25s; }
.stagger-list > *:nth-child(6)  { animation-delay: 0.30s; }
.stagger-list > *:nth-child(7)  { animation-delay: 0.35s; }
.stagger-list > *:nth-child(8)  { animation-delay: 0.40s; }

/* ── Table Row Animations ───────────────────────────────────── */
tbody tr {
    transition: background-color var(--transition-fast);
    animation: fadeInLeft 0.3s ease both;
    border-left: 3px solid transparent;
}
tbody tr:hover {
    background: var(--bg-hover);
    border-left-color: var(--color-primary);
}
tbody tr:nth-child(1) { animation-delay: 0.02s; }
tbody tr:nth-child(2) { animation-delay: 0.04s; }
tbody tr:nth-child(3) { animation-delay: 0.06s; }
tbody tr:nth-child(4) { animation-delay: 0.08s; }
tbody tr:nth-child(5) { animation-delay: 0.10s; }
tbody tr:nth-child(6) { animation-delay: 0.12s; }
tbody tr:nth-child(7) { animation-delay: 0.14s; }
tbody tr:nth-child(8) { animation-delay: 0.16s; }

/* ── Modal Animations ───────────────────────────────────────── */
.modal-overlay {
    animation: fadeIn 0.2s ease both;
}
.modal-box {
    animation: scaleIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* ── Toast Notifications ────────────────────────────────────── */
.toast {
    animation: toastSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.toast.dismissing {
    animation: toastSlideOut 0.3s ease forwards;
}

/* ── Alert Pulse (Critical) ─────────────────────────────────── */
.alert-critical {
    animation: alertPulse 2s ease-in-out infinite;
}

.pulse-dot {
    position: relative;
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-danger);
}
.pulse-dot::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--color-danger);
    animation: pulse-ring 1.5s ease-out infinite;
}

/* ── Skeleton Loading ───────────────────────────────────────── */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-card) 25%,
        var(--bg-elevated) 50%,
        var(--bg-card) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

/* ── Progress Bar ───────────────────────────────────────────── */
.progress-bar-fill {
    animation: progressFill 1s cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: 0.2s;
}

/* ── Button Ripple ──────────────────────────────────────────── */
.btn {
    position: relative;
    overflow: hidden;
}
.btn .ripple-effect {
    position: absolute;
    border-radius: 50%;
    width: 100px;
    height: 100px;
    margin-top: -50px;
    margin-left: -50px;
    background: rgba(255,255,255,0.15);
    animation: ripple 0.6s linear;
    pointer-events: none;
}

/* ── Sidebar Nav Active Indicator ───────────────────────────── */
.nav-item.active .nav-indicator {
    animation: navIndicatorSlide 0.3s ease both;
}

/* ── Spinner ────────────────────────────────────────────────── */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-default);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

/* ── Counter Roll Up ────────────────────────────────────────── */
.counter-value {
    animation: countUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: 0.3s;
}

/* ── Input Focus Glow ───────────────────────────────────────── */
.form-input:focus, .form-select:focus, .form-textarea:focus {
    animation: none; /* override if needed */
    box-shadow: 0 0 0 3px var(--color-primary-glow);
}

/* ── Chart Fade In ──────────────────────────────────────────── */
.chart-wrapper {
    animation: fadeIn 0.6s ease 0.4s both;
}

/* ── Sidebar Collapse ───────────────────────────────────────── */
.sidebar {
    transition: width var(--transition-slow) cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar .nav-label {
    transition: opacity var(--transition-base), transform var(--transition-base);
    white-space: nowrap;
    overflow: hidden;
}
.sidebar.collapsed .nav-label {
    opacity: 0;
    transform: translateX(-10px);
    width: 0;
}

/* ── Dropdown ───────────────────────────────────────────────── */
.dropdown-menu {
    animation: scaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
    transform-origin: top right;
}

/* ── Number animate on scroll ───────────────────────────────── */
[data-count] {
    transition: all 0.5s ease;
}
