/**
 * Team Portal Animations CSS
 * Advanced animations and micro-interactions
 * 
 * @package TeamPortal
 * @since Phase 6.1.3
 * @version 1.0.0
 */

/* ==========================================================================
   CSS Variables
   ========================================================================== */

:root {
    --tp-anim-duration-fast: 200ms;
    --tp-anim-duration-normal: 300ms;
    --tp-anim-duration-slow: 500ms;
    --tp-anim-duration-very-slow: 800ms;
    
    --tp-easing-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --tp-easing-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --tp-easing-elastic: cubic-bezier(0.68, -0.6, 0.32, 1.6);
    
    --tp-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --tp-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.15);
    --tp-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.2);
    --tp-shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.25);
}

/* ==========================================================================
   Page Transitions
   ========================================================================== */

body {
    opacity: 0;
    transition: opacity var(--tp-anim-duration-slow) var(--tp-easing-smooth);
}

body.tp-page-loaded {
    opacity: 1;
}

body.tp-page-exiting {
    opacity: 0;
}

/* ==========================================================================
   Card Animations
   ========================================================================== */

.tp-card,
.large-tab-card,
.info-card,
.stat-card {
    position: relative;
    overflow: hidden;
    transition: all var(--tp-anim-duration-normal) var(--tp-easing-smooth);
}

/* Lift effect */
.tp-lift {
    transform: translateY(-8px);
    box-shadow: var(--tp-shadow-lg) !important;
}

/* Ripple effect */
.tp-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    width: 20px;
    height: 20px;
    animation: tp-ripple-animation 600ms ease-out;
    pointer-events: none;
}

@keyframes tp-ripple-animation {
    from {
        transform: scale(0);
        opacity: 1;
    }
    to {
        transform: scale(20);
        opacity: 0;
    }
}

/* Card entrance animations */
.tp-fade-in-up {
    animation: tp-fade-in-up 500ms var(--tp-easing-smooth) backwards;
}

@keyframes tp-fade-in-up {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tp-fade-in {
    animation: tp-fade-in 400ms var(--tp-easing-smooth) backwards;
}

@keyframes tp-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.tp-fade-out {
    animation: tp-fade-out 300ms var(--tp-easing-smooth) forwards;
}

@keyframes tp-fade-out {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* ==========================================================================
   Button Animations
   ========================================================================== */

.tp-animated {
    position: relative;
    overflow: hidden;
    transition: all var(--tp-anim-duration-fast) var(--tp-easing-smooth);
}

.tp-scale-down {
    transform: scale(0.95);
}

.tp-pulse-focus {
    animation: tp-pulse 1s infinite;
}

@keyframes tp-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(102, 126, 234, 0);
    }
}

/* ==========================================================================
   Loading States
   ========================================================================== */

/* Global loader */
.tp-global-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transition: all var(--tp-anim-duration-normal) var(--tp-easing-smooth);
}

.tp-global-loader.tp-show {
    opacity: 1;
    visibility: visible;
}

.tp-loader-content {
    text-align: center;
    color: #fff;
}

.tp-loader-content p {
    margin-top: 16px;
    font-size: 14px;
}

/* Spinner */
.tp-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: tp-spin 800ms linear infinite;
    margin: 0 auto;
}

.tp-spinner-small {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: tp-spin 600ms linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes tp-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Loading button */
.tp-loading {
    pointer-events: none;
    opacity: 0.7;
}

/* ==========================================================================
   Scroll Animations
   ========================================================================== */

.tp-scroll-animate {
    opacity: 0;
    transform: translateY(50px);
    transition: all 600ms var(--tp-easing-smooth);
}

.tp-scroll-animate.tp-in-view {
    opacity: 1;
    transform: translateY(0);
}

.tp-slide-in {
    opacity: 0;
    transform: translateX(-50px);
    transition: all 600ms var(--tp-easing-smooth);
}

.tp-slide-in.tp-in-view {
    opacity: 1;
    transform: translateX(0);
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */

.tp-toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    max-width: 400px;
}

.tp-toast {
    background: #fff;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 12px;
    box-shadow: var(--tp-shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateX(120%);
    opacity: 0;
    transition: all var(--tp-anim-duration-normal) var(--tp-easing-bounce);
}

.tp-toast.tp-toast-show {
    transform: translateX(0);
    opacity: 1;
}

.tp-toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

.tp-toast-message {
    flex: 1;
    font-size: 14px;
    color: #333;
}

.tp-toast-close {
    flex-shrink: 0;
    background: transparent;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    color: #999;
    font-size: 18px;
    line-height: 1;
    transition: all var(--tp-anim-duration-fast);
}

.tp-toast-close:hover {
    background: #f0f0f0;
    color: #333;
}

/* Toast types */
.tp-toast-success .tp-toast-icon {
    background: #27ae60;
    color: #fff;
}

.tp-toast-error .tp-toast-icon {
    background: #e74c3c;
    color: #fff;
}

.tp-toast-warning .tp-toast-icon {
    background: #f39c12;
    color: #fff;
}

.tp-toast-info .tp-toast-icon {
    background: #3498db;
    color: #fff;
}

/* ==========================================================================
   Skeleton Loaders
   ========================================================================== */

.tp-skeleton {
    padding: 16px 0;
}

.tp-skeleton-line {
    height: 16px;
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    border-radius: 4px;
    margin-bottom: 12px;
    animation: tp-skeleton-loading 1.5s ease-in-out infinite;
}

@keyframes tp-skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ==========================================================================
   Modal Animations
   ========================================================================== */

.tp-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all var(--tp-anim-duration-normal) var(--tp-easing-smooth);
}

.tp-modal-backdrop.tp-show {
    opacity: 1;
    visibility: visible;
}

.tp-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    max-width: 600px;
    width: 90%;
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--tp-shadow-xl);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all var(--tp-anim-duration-normal) var(--tp-easing-bounce);
}

.tp-modal.tp-modal-open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

body.tp-modal-open {
    overflow: hidden;
}

/* ==========================================================================
   Form Animations
   ========================================================================== */

.tp-form-field {
    position: relative;
    margin-bottom: 24px;
}

.tp-form-field label {
    position: absolute;
    top: 16px;
    right: 12px;
    font-size: 14px;
    color: #999;
    pointer-events: none;
    transition: all var(--tp-anim-duration-fast) var(--tp-easing-smooth);
}

.tp-form-field.tp-focused label,
.tp-form-field.tp-filled label {
    top: -8px;
    right: 8px;
    font-size: 12px;
    color: #667eea;
    background: #fff;
    padding: 0 4px;
}

.tp-form-field input,
.tp-form-field textarea,
.tp-form-field select {
    width: 100%;
    padding: 16px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: all var(--tp-anim-duration-fast) var(--tp-easing-smooth);
}

.tp-form-field.tp-focused input,
.tp-form-field.tp-focused textarea,
.tp-form-field.tp-focused select {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.tp-form-field.tp-error input,
.tp-form-field.tp-error textarea,
.tp-form-field.tp-error select {
    border-color: #e74c3c;
}

.tp-form-field.tp-success input,
.tp-form-field.tp-success textarea,
.tp-form-field.tp-success select {
    border-color: #27ae60;
}

/* ==========================================================================
   Utility Animations
   ========================================================================== */

/* Shake (for errors) */
.tp-shake {
    animation: tp-shake 500ms ease-in-out;
}

@keyframes tp-shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-10px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(10px);
    }
}

/* Bounce (for success) */
.tp-bounce {
    animation: tp-bounce 500ms var(--tp-easing-bounce);
}

@keyframes tp-bounce {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Pulse */
.tp-pulse {
    animation: tp-pulse-scale 1s ease-in-out infinite;
}

@keyframes tp-pulse-scale {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* Highlight flash */
.tp-highlight-flash {
    animation: tp-highlight-flash 1.5s ease-out;
}

@keyframes tp-highlight-flash {
    0%, 100% {
        background-color: transparent;
    }
    50% {
        background-color: rgba(102, 126, 234, 0.2);
    }
}

/* Rotate */
.tp-rotate {
    animation: tp-rotate 2s linear infinite;
}

@keyframes tp-rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Swing */
.tp-swing {
    animation: tp-swing 1s ease-in-out;
}

@keyframes tp-swing {
    20% {
        transform: rotate3d(0, 0, 1, 15deg);
    }
    40% {
        transform: rotate3d(0, 0, 1, -10deg);
    }
    60% {
        transform: rotate3d(0, 0, 1, 5deg);
    }
    80% {
        transform: rotate3d(0, 0, 1, -5deg);
    }
    100% {
        transform: rotate3d(0, 0, 1, 0deg);
    }
}

/* Wobble */
.tp-wobble {
    animation: tp-wobble 1s ease-in-out;
}

@keyframes tp-wobble {
    0%, 100% {
        transform: translateX(0);
    }
    15% {
        transform: translateX(-25px) rotate(-5deg);
    }
    30% {
        transform: translateX(20px) rotate(3deg);
    }
    45% {
        transform: translateX(-15px) rotate(-3deg);
    }
    60% {
        transform: translateX(10px) rotate(2deg);
    }
    75% {
        transform: translateX(-5px) rotate(-1deg);
    }
}

/* Flip */
.tp-flip {
    animation: tp-flip 600ms ease-in-out;
}

@keyframes tp-flip {
    0% {
        transform: perspective(400px) rotateY(0);
    }
    100% {
        transform: perspective(400px) rotateY(360deg);
    }
}

/* ==========================================================================
   Parallax
   ========================================================================== */

.tp-parallax {
    will-change: transform;
    transition: transform 100ms linear;
}

/* ==========================================================================
   Responsive Animations
   ========================================================================== */

@media screen and (max-width: 768px) {
    .tp-toast-container {
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .tp-toast {
        padding: 12px 16px;
    }
    
    .tp-modal {
        width: 95%;
    }
    
    /* Reduce animation intensity on mobile */
    .tp-lift {
        transform: translateY(-4px);
    }
}

/* ==========================================================================
   Reduced Motion Support
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .tp-parallax {
        transform: none !important;
    }
}

/* Disable all animations when class is added */
body.tp-no-animations * {
    animation: none !important;
    transition: none !important;
}

/* ==========================================================================
   Dark Mode Support
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    :root {
        --tp-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
        --tp-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
        --tp-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
        --tp-shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.6);
    }
    
    .tp-toast {
        background: #2d2d2d;
        color: #fff;
    }
    
    .tp-toast-message {
        color: #fff;
    }
    
    .tp-toast-close {
        color: #999;
    }
    
    .tp-toast-close:hover {
        background: #444;
        color: #fff;
    }
    
    .tp-skeleton-line {
        background: linear-gradient(
            90deg,
            #2d2d2d 25%,
            #3d3d3d 50%,
            #2d2d2d 75%
        );
    }
    
    .tp-modal {
        background: #2d2d2d;
    }
    
    .tp-form-field label {
        color: #aaa;
    }
    
    .tp-form-field input,
    .tp-form-field textarea,
    .tp-form-field select {
        background: #333;
        border-color: #444;
        color: #fff;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .tp-toast-container,
    .tp-global-loader,
    .tp-modal-backdrop,
    .tp-ripple {
        display: none !important;
    }
    
    * {
        animation: none !important;
        transition: none !important;
    }
}
