/* ═══════════════════════════════════════════════════
   Boardroom Transitions & Micro-Animations
   Shared across all pages for consistent polish
   Inspired by: smooth, contextual AI bar interactions
   ═══════════════════════════════════════════════════ */

/* ── Base Timing Functions ── */
:root {
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-out: cubic-bezier(0, 0, 0.2, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 400ms;
    --duration-stagger: 50ms;
}

/* ── Card Hover Lifts ── */
.card,
.agent-card,
.integration-item,
.action-card {
    transition: transform var(--duration-normal) var(--ease-smooth),
                box-shadow var(--duration-normal) var(--ease-smooth);
}

.card:hover,
.agent-card:hover,
.integration-item:hover,
.action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25), 0 2px 8px rgba(0, 0, 0, 0.15);
}

.card:active,
.agent-card:active {
    transform: translateY(0px);
    transition-duration: var(--duration-fast);
}

/* ── Task Row Interactions ── */
.list-row,
.task-row,
#task-table tbody tr {
    transition: background var(--duration-fast) var(--ease-smooth),
                transform var(--duration-fast) var(--ease-smooth),
                opacity var(--duration-normal) var(--ease-smooth);
}

.list-row:hover,
.task-row:hover,
#task-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.list-row:active,
.task-row:active,
#task-table tbody tr:active {
    transform: scale(0.995);
}

/* ── Task Row Stagger Fade-In ── */
@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.list-row,
#task-table tbody tr {
    animation: fadeSlideIn var(--duration-slow) var(--ease-out) both;
}

/* Stagger delays for first 20 rows */
.list-row:nth-child(1), #task-table tbody tr:nth-child(1) { animation-delay: 0ms; }
.list-row:nth-child(2), #task-table tbody tr:nth-child(2) { animation-delay: 30ms; }
.list-row:nth-child(3), #task-table tbody tr:nth-child(3) { animation-delay: 60ms; }
.list-row:nth-child(4), #task-table tbody tr:nth-child(4) { animation-delay: 90ms; }
.list-row:nth-child(5), #task-table tbody tr:nth-child(5) { animation-delay: 120ms; }
.list-row:nth-child(6), #task-table tbody tr:nth-child(6) { animation-delay: 150ms; }
.list-row:nth-child(7), #task-table tbody tr:nth-child(7) { animation-delay: 180ms; }
.list-row:nth-child(8), #task-table tbody tr:nth-child(8) { animation-delay: 210ms; }
.list-row:nth-child(9), #task-table tbody tr:nth-child(9) { animation-delay: 240ms; }
.list-row:nth-child(10), #task-table tbody tr:nth-child(10) { animation-delay: 270ms; }
.list-row:nth-child(n+11), #task-table tbody tr:nth-child(n+11) { animation-delay: 300ms; }

/* ── Filter Pills ── */
.mobile-filter-pill,
.filter-pill,
.mobile-view-tab {
    transition: transform var(--duration-fast) var(--ease-spring),
                background var(--duration-fast) var(--ease-smooth),
                box-shadow var(--duration-fast) var(--ease-smooth),
                color var(--duration-fast) var(--ease-smooth);
}

.mobile-filter-pill:active,
.filter-pill:active,
.mobile-view-tab:active {
    transform: scale(0.92);
}

.mobile-filter-pill.active,
.filter-pill.active,
.mobile-view-tab.active {
    transform: scale(1);
}

/* ── Stat Number Count-Up Animation ── */
@keyframes countPop {
    0% { transform: scale(0.5); opacity: 0; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.stat-value,
.stat-number,
.pill-count,
.card-badge {
    animation: countPop var(--duration-slow) var(--ease-spring) both;
}

/* ── Sidebar Slide ── */
.sidebar {
    transition: transform var(--duration-slow) var(--ease-smooth) !important;
}

/* ── Global Header Tab Underline ── */
.global-header a,
.global-header .nav-link {
    position: relative;
}

.global-header a::after,
.global-header .nav-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--accent-green, #22c55e);
    transition: width var(--duration-normal) var(--ease-smooth),
                left var(--duration-normal) var(--ease-smooth);
    border-radius: 1px;
}

.global-header a:hover::after,
.global-header .nav-link:hover::after,
.global-header a.active::after,
.global-header .nav-link.active::after {
    width: 100%;
    left: 0;
}

/* ── Button Press Effects ── */
button,
.btn,
[onclick] {
    transition: transform var(--duration-fast) var(--ease-spring),
                opacity var(--duration-fast) var(--ease-smooth);
}

button:active,
.btn:active,
[onclick]:active {
    transform: scale(0.96);
}

/* ── Status Badge Pulse ── */
@keyframes subtlePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.sync-indicator,
.status-dot.working,
.agent-status-dot.working {
    animation: subtlePulse 2s var(--ease-in-out) infinite;
}

/* ── Tooltip / Popover Entrance ── */
@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(4px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.tooltip,
.popover,
.dropdown-menu,
.context-menu {
    animation: popIn var(--duration-normal) var(--ease-spring) both;
}

/* ── Page Load Fade ── */
@keyframes pageFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.main,
#main-content {
    animation: pageFadeIn var(--duration-slow) var(--ease-smooth) both;
}

/* ── Smooth Scrolling ── */
html {
    scroll-behavior: smooth;
}

/* ── Loading Skeleton Shimmer ── */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.loading,
.skeleton {
    background: linear-gradient(90deg,
        rgba(255,255,255,0.03) 25%,
        rgba(255,255,255,0.08) 50%,
        rgba(255,255,255,0.03) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* ── Toggle/Switch Animations ── */
.toggle,
.switch {
    transition: background var(--duration-normal) var(--ease-smooth);
}

.toggle::after,
.switch::after {
    transition: transform var(--duration-normal) var(--ease-spring);
}

/* ── Chart Bar Grow Animation ── */
@keyframes barGrow {
    from { transform: scaleX(0); transform-origin: left; }
    to { transform: scaleX(1); transform-origin: left; }
}

.api-bar-fill,
.progress-bar-fill {
    animation: barGrow var(--duration-slow) var(--ease-out) both;
    animation-delay: 200ms;
}

/* ── Reduce Motion for Accessibility ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
