/**
 * Team Portal Micro-interactions CSS
 * 
 * @description تأثيرات دقيقة وتفاعلية لتحسين تجربة المستخدم
 * @version 1.0.0
 * @since 3.0.0
 * 
 * Features:
 * - Button Ripple Effect
 * - Card Hover Glow
 * - Number Counter Animation
 * - Skeleton Loading
 * - Smooth Transitions
 * - Interactive Feedback
 */

/* ==================== Ripple Effect ==================== */

.tp-ripple {
    position: relative;
    overflow: hidden;
    transform: translate3d(0, 0, 0);
}

.tp-ripple::after {
    content: '';
    display: block;
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.3) 10%, transparent 10.01%);
    background-repeat: no-repeat;
    background-position: 50%;
    transform: scale(10, 10);
    opacity: 0;
    transition: transform 0.5s, opacity 1s;
}

.tp-ripple:active::after {
    transform: scale(0, 0);
    opacity: 0.3;
    transition: 0s;
}

/* Button-specific ripple */
.tp-btn.tp-ripple::after {
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.4) 10%, transparent 10.01%);
}

.tp-btn-primary.tp-ripple::after {
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.5) 10%, transparent 10.01%);
}

/* ==================== Card Hover Glow ==================== */

.tp-card-glow {
    position: relative;
    transition: all var(--tp-transition-base, 200ms) ease;
}

.tp-card-glow::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: inherit;
    padding: 2px;
    background: linear-gradient(
        135deg,
        var(--tp-primary-400, #60a5fa),
        var(--tp-primary-600, #2563eb)
    );
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity var(--tp-transition-base, 200ms) ease;
    pointer-events: none;
}

.tp-card-glow:hover::before {
    opacity: 1;
}

.tp-card-glow:hover {
    transform: translateY(-4px);
    box-shadow: 
        0 10px 25px -5px rgba(0, 0, 0, 0.1),
        0 20px 30px -10px rgba(59, 130, 246, 0.2);
}

/* Success glow */
.tp-card-glow-success::before {
    background: linear-gradient(
        135deg,
        var(--tp-success-400, #34d399),
        var(--tp-success-600, #059669)
    );
}

.tp-card-glow-success:hover {
    box-shadow: 
        0 10px 25px -5px rgba(0, 0, 0, 0.1),
        0 20px 30px -10px rgba(16, 185, 129, 0.2);
}

/* Warning glow */
.tp-card-glow-warning::before {
    background: linear-gradient(
        135deg,
        var(--tp-warning-400, #fbbf24),
        var(--tp-warning-600, #d97706)
    );
}

.tp-card-glow-warning:hover {
    box-shadow: 
        0 10px 25px -5px rgba(0, 0, 0, 0.1),
        0 20px 30px -10px rgba(245, 158, 11, 0.2);
}

/* ==================== Number Counter Animation ==================== */

.tp-counter {
    display: inline-block;
    font-variant-numeric: tabular-nums;
}

@keyframes tp-counter-bounce {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
}

.tp-counter.tp-counting {
    animation: tp-counter-bounce 0.4s ease-in-out;
}

/* Number increment effect */
.tp-counter-increment {
    position: relative;
    display: inline-block;
}

.tp-counter-increment::after {
    content: attr(data-increment);
    position: absolute;
    top: -120%;
    left: 50%;
    transform: translateX(-50%);
    color: var(--tp-success-500, #10b981);
    font-size: 0.75em;
    font-weight: bold;
    opacity: 0;
    animation: tp-counter-increment-up 1s ease-out;
}

@keyframes tp-counter-increment-up {
    0% {
        opacity: 0;
        top: 0;
    }
    20% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        top: -120%;
    }
}

/* Number decrement effect */
.tp-counter-decrement::after {
    content: attr(data-decrement);
    color: var(--tp-danger-500, #ef4444);
    animation: tp-counter-decrement-down 1s ease-out;
}

@keyframes tp-counter-decrement-down {
    0% {
        opacity: 0;
        top: 0;
    }
    20% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        top: 120%;
    }
}

/* ==================== Skeleton Loading ==================== */

.tp-skeleton {
    background: linear-gradient(
        90deg,
        var(--tp-gray-200, #e5e7eb) 25%,
        var(--tp-gray-100, #f3f4f6) 50%,
        var(--tp-gray-200, #e5e7eb) 75%
    );
    background-size: 200% 100%;
    animation: tp-skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--tp-radius-base, 4px);
    cursor: wait;
}

@keyframes tp-skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Skeleton shapes */
.tp-skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.tp-skeleton-title {
    height: 1.5em;
    width: 60%;
    margin-bottom: 0.75em;
}

.tp-skeleton-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--tp-radius-full, 50%);
}

.tp-skeleton-button {
    height: 40px;
    width: 120px;
    border-radius: var(--tp-radius-md, 6px);
}

.tp-skeleton-card {
    height: 200px;
    border-radius: var(--tp-radius-lg, 8px);
}

/* ==================== Smooth Transitions ==================== */

.tp-transition-all {
    transition: all var(--tp-transition-base, 200ms) ease;
}

.tp-transition-fast {
    transition: all var(--tp-transition-fast, 150ms) ease;
}

.tp-transition-slow {
    transition: all var(--tp-transition-slow, 300ms) ease;
}

.tp-transition-transform {
    transition: transform var(--tp-transition-base, 200ms) ease;
}

.tp-transition-opacity {
    transition: opacity var(--tp-transition-base, 200ms) ease;
}

.tp-transition-colors {
    transition: 
        background-color var(--tp-transition-base, 200ms) ease,
        border-color var(--tp-transition-base, 200ms) ease,
        color var(--tp-transition-base, 200ms) ease;
}

/* ==================== Interactive Feedback ==================== */

/* Press effect */
.tp-press:active {
    transform: scale(0.95);
}

/* Lift effect */
.tp-lift {
    transition: transform var(--tp-transition-base, 200ms) ease;
}

.tp-lift:hover {
    transform: translateY(-2px);
}

.tp-lift:active {
    transform: translateY(0);
}

/* Bounce effect */
@keyframes tp-bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.tp-bounce:hover {
    animation: tp-bounce 0.6s ease-in-out;
}

/* Shake effect */
@keyframes tp-shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

.tp-shake {
    animation: tp-shake 0.5s ease-in-out;
}

/* Pulse effect */
@keyframes tp-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

.tp-pulse {
    animation: tp-pulse 2s ease-in-out infinite;
}

/* ==================== Loading States ==================== */

/* Spinner */
.tp-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--tp-gray-200, #e5e7eb);
    border-top-color: var(--tp-primary-500, #3b82f6);
    border-radius: 50%;
    animation: tp-spinner-rotate 0.8s linear infinite;
}

@keyframes tp-spinner-rotate {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.tp-spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.tp-spinner-lg {
    width: 60px;
    height: 60px;
    border-width: 6px;
}

/* Dots loader */
.tp-dots-loader {
    display: inline-flex;
    gap: 8px;
}

.tp-dots-loader span {
    width: 8px;
    height: 8px;
    background-color: var(--tp-primary-500, #3b82f6);
    border-radius: 50%;
    animation: tp-dots-bounce 1.4s ease-in-out infinite;
}

.tp-dots-loader span:nth-child(1) {
    animation-delay: -0.32s;
}

.tp-dots-loader span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes tp-dots-bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Progress bar pulse */
.tp-progress-pulse {
    position: relative;
    overflow: hidden;
}

.tp-progress-pulse::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: tp-progress-shimmer 2s infinite;
}

@keyframes tp-progress-shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* ==================== Focus States ==================== */

.tp-focus-ring:focus-visible {
    outline: 2px solid var(--tp-primary-500, #3b82f6);
    outline-offset: 2px;
    border-radius: var(--tp-radius-base, 4px);
}

.tp-focus-glow:focus-visible {
    outline: none;
    box-shadow: 
        0 0 0 3px rgba(59, 130, 246, 0.3),
        0 0 0 1px var(--tp-primary-500, #3b82f6);
}

/* ==================== Hover Underline ==================== */

.tp-hover-underline {
    position: relative;
    display: inline-block;
}

.tp-hover-underline::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background-color: currentColor;
    transition: width var(--tp-transition-base, 200ms) ease;
}

.tp-hover-underline:hover::after {
    width: 100%;
}

/* ==================== Badge Pulse ==================== */

.tp-badge-pulse {
    position: relative;
}

.tp-badge-pulse::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: inherit;
    background-color: inherit;
    animation: tp-badge-pulse-animation 2s ease-out infinite;
    z-index: -1;
}

@keyframes tp-badge-pulse-animation {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* ==================== Dark Mode Support ==================== */

[data-theme="dark"] .tp-skeleton {
    background: linear-gradient(
        90deg,
        var(--tp-gray-700, #374151) 25%,
        var(--tp-gray-600, #4b5563) 50%,
        var(--tp-gray-700, #374151) 75%
    );
}

[data-theme="dark"] .tp-spinner {
    border-color: var(--tp-gray-700, #374151);
    border-top-color: var(--tp-primary-400, #60a5fa);
}

[data-theme="dark"] .tp-dots-loader span {
    background-color: var(--tp-primary-400, #60a5fa);
}

/* ==================== Reduced Motion ==================== */

@media (prefers-reduced-motion: reduce) {
    .tp-ripple::after,
    .tp-skeleton,
    .tp-spinner,
    .tp-dots-loader span,
    .tp-progress-pulse::after,
    .tp-badge-pulse::before,
    .tp-bounce,
    .tp-shake,
    .tp-pulse,
    .tp-counter.tp-counting {
        animation: none !important;
    }

    .tp-transition-all,
    .tp-transition-fast,
    .tp-transition-slow,
    .tp-transition-transform,
    .tp-transition-opacity,
    .tp-transition-colors,
    .tp-lift,
    .tp-press,
    .tp-card-glow,
    .tp-hover-underline::after {
        transition: none !important;
    }
}

/* ==================== RTL Support ==================== */

[dir="rtl"] .tp-hover-underline::after {
    left: auto;
    right: 0;
}

/* ==================== Print ==================== */

@media print {
    .tp-ripple::after,
    .tp-skeleton,
    .tp-spinner,
    .tp-dots-loader {
        display: none !important;
    }
}
