/* ===================================================================
   MICRO-INTERACTIONS & PROGRESSIVE DISCLOSURE - Phase 4 Patterns 4 & 5
   Collapsible details, hover effects, and delightful animations
   =================================================================== */

/* ===== PATTERN 4: PROGRESSIVE DISCLOSURE (Collapsible Cards) ===== */

.employee-card, .card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.employee-card.collapsible {
    cursor: pointer;
}

.employee-card .card-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
}

.employee-card .expand-btn {
    background: transparent;
    border: none;
    padding: 8px;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #6b7280;
}

.employee-card .expand-btn:hover {
    color: #1f2937;
    background: #f3f4f6;
    border-radius: 4px;
}

.employee-card .chevron {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.employee-card.expanded .chevron {
    transform: rotate(180deg);
}

.employee-card .card-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.employee-card.expanded .card-details {
    max-height: 500px;
}

/* ===== PATTERN 5: HOVER EFFECTS ===== */

/* Card Lift Effect */
.employee-card:hover,
.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* Button Hover Effects */
.btn {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: scale(0.98);
}

/* Risk Badge Pulse (when at risk) */
.badge-danger, .status-danger {
    animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

/* Trip Count Rotate on Click */
.trip-count {
    display: inline-block;
    transition: transform 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    cursor: pointer;
}

.trip-count.clicked {
    animation: rotate-360 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

/* ===== PROGRESS BAR ANIMATIONS ===== */

.progress-bar {
    position: relative;
    overflow: hidden;
}

.progress-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: progress-shimmer 2s infinite;
}

@keyframes progress-shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Animated Striped Pattern for Loading */
.progress-bar.loading {
    background: repeating-linear-gradient(
        45deg,
        #3b82f6,
        #3b82f6 10px,
        #60a5fa 10px,
        #60a5fa 20px
    );
    background-size: 200% 100%;
    animation: progress-stripes 1s linear infinite;
}

@keyframes progress-stripes {
    from {
        background-position: 0 0;
    }
    to {
        background-position: 40px 0;
    }
}

/* ===== PERCENTAGE COUNTER ANIMATION ===== */

.stat-value, .metric-value {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-value.updating {
    animation: stat-update 0.3s ease-out;
}

@keyframes stat-update {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

/* ===== SPINNER ANIMATIONS ===== */

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(59, 130, 246, 0.3);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spinner-rotate 0.8s linear infinite;
}

@keyframes spinner-rotate {
    to {
        transform: rotate(360deg);
    }
}

/* Smooth Spinner with Easing */
.spinner-smooth {
    animation: spinner-smooth-rotate 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

@keyframes spinner-smooth-rotate {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* ===== RISK BADGE COLOR SHIFT ===== */

.badge-danger {
    animation: badge-color-shift 3s ease-in-out infinite;
}

@keyframes badge-color-shift {
    0%, 100% {
        background-color: #ef4444;
    }
    50% {
        background-color: #dc2626;
    }
}

/* ===== LOADING DOTS ===== */

.loading-dots {
    display: inline-flex;
    gap: 4px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: #3b82f6;
    border-radius: 50%;
    animation: loading-dots 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) {
    animation-delay: 0s;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes loading-dots {
    0%, 80%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    40% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===== SMOOTH TRANSITIONS ===== */

* {
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== FOCUS STATES (Accessibility) ===== */

.btn:focus-visible,
.employee-card:focus-visible,
.expand-btn:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* ===== REDUCE MOTION ===== */

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

    .employee-card:hover,
    .card:hover,
    .btn:hover {
        transform: none;
    }
}

/* ===== DARK MODE SUPPORT ===== */

[data-theme="dark"] .employee-card:hover,
[data-theme="dark"] .card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .expand-btn:hover {
    background: #374151;
    color: #f3f4f6;
}

/* ===== RESPONSIVE DESIGN ===== */

@media (max-width: 768px) {
    .employee-card:hover,
    .card:hover {
        transform: translateY(-2px);
    }

    .btn:hover {
        transform: scale(1.01);
    }
}

/* ===== EXPAND/COLLAPSE ALL CONTROLS ===== */

.collapse-controls {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-bottom: 16px;
}

.collapse-all-btn {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.collapse-all-btn:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.collapse-all-btn:active {
    transform: scale(0.95);
}

/* ===== PERFORMANCE OPTIMIZATION ===== */

.employee-card,
.card,
.btn {
    will-change: transform;
}

.employee-card .card-details {
    will-change: max-height;
}

/* Only animate when necessary */
.employee-card:not(.expanded) .card-details {
    will-change: auto;
}
