/* ============================================
   FZTM Platform - Global UX Enhancements
   By Andrea Zedda, PhD (Bioengineering)
   andrea.zedda@outlook.it
   ============================================ */

/* ========== ANIMATIONS & TRANSITIONS ========== */

/* Smooth transitions for all interactive elements */
* {
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

/* 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;
    }
}

/* Fade in animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* Slide in from right */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-right {
    animation: slideInRight 0.4s ease-out;
}

/* Scale pop-in */
@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.pop-in {
    animation: popIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Pulse effect */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.pulse {
    animation: pulse 2s infinite;
}

/* Shimmer loading effect */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.shimmer {
    background: linear-gradient(to right, #f6f7f8 0%, #edeef1 20%, #f6f7f8 40%, #f6f7f8 100%);
    background-size: 2000px 100%;
    animation: shimmer 2s linear infinite;
}

/* Rotate on hover */
.rotate-hover:hover {
    transform: rotate(180deg);
    transition: transform 0.5s ease;
}

/* ========== LOADING STATES ========== */

/* Skeleton loaders */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
    border-radius: 4px;
}

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

.skeleton-text {
    height: 16px;
    margin: 8px 0;
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin: 12px 0;
}

.skeleton-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

/* Spinner */
.spinner {
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-left-color: #007bff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

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

/* Progress bar with animation */
.progress-animated .progress-bar {
    animation: progress-animation 2s ease-out forwards;
}

@keyframes progress-animation {
    from {
        width: 0;
    }
}

/* ========== HOVER EFFECTS ========== */

/* Card lift on hover */
.card-lift {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-lift:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15) !important;
}

/* Button press effect */
.btn-press:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

/* Glow on hover */
.glow-on-hover {
    transition: box-shadow 0.3s ease;
}

.glow-on-hover:hover {
    box-shadow: 0 0 20px rgba(0, 123, 255, 0.5);
}

/* Border animation */
.border-animate {
    position: relative;
    overflow: hidden;
}

.border-animate::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #007bff, transparent);
    animation: border-slide 3s linear infinite;
}

@keyframes border-slide {
    to {
        left: 100%;
    }
}

/* ========== INTERACTIVE FEEDBACK ========== */

/* Success feedback */
@keyframes success-bounce {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
}

.success-feedback {
    animation: success-bounce 0.5s ease;
}

/* Error shake */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    75% {
        transform: translateX(10px);
    }
}

.error-shake {
    animation: shake 0.5s ease;
}

/* Input focus glow */
.form-control:focus,
.form-select:focus {
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
    transform: translateY(-2px);
    transition: all 0.3s ease;
}

/* ========== TOOLTIPS & POPOVERS ========== */

/* Enhanced tooltip */
.tooltip-enhanced {
    position: relative;
    display: inline-block;
}

.tooltip-enhanced::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 8px 12px;
    background: #333;
    color: white;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
}

.tooltip-enhanced:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ========== BADGES & LABELS ========== */

/* Pulsing badge */
.badge-pulse {
    animation: pulse 2s infinite;
}

/* Badge with notification dot */
.badge-notification {
    position: relative;
}

.badge-notification::before {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: #dc3545;
    border-radius: 50%;
    border: 2px solid white;
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

/* ========== CARDS & CONTAINERS ========== */

/* Card with gradient border */
.card-gradient-border {
    position: relative;
    background: white;
    border: none;
}

.card-gradient-border::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #667eea, #764ba2, #f093fb);
    border-radius: 8px;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s;
}

.card-gradient-border:hover::before {
    opacity: 1;
}

/* Glass morphism effect */
.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
}

/* ========== FORMS ========== */

/* Floating label effect */
.form-floating-enhanced label {
    transition: all 0.3s ease;
}

.form-floating-enhanced input:focus ~ label,
.form-floating-enhanced input:not(:placeholder-shown) ~ label {
    transform: translateY(-1.5rem) scale(0.85);
    color: #007bff;
}

/* Input with icon */
.input-with-icon {
    position: relative;
}

.input-with-icon input {
    padding-left: 40px;
}

.input-with-icon i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    transition: color 0.3s;
}

.input-with-icon input:focus ~ i {
    color: #007bff;
}

/* Checkbox/Radio custom */
.form-check-custom {
    position: relative;
    padding-left: 2rem;
}

.form-check-custom input[type="checkbox"] {
    position: absolute;
    opacity: 0;
}

.form-check-custom label::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 20px;
    height: 20px;
    border: 2px solid #007bff;
    border-radius: 4px;
    transition: all 0.3s;
}

.form-check-custom input:checked ~ label::before {
    background: #007bff;
}

.form-check-custom input:checked ~ label::after {
    content: '✓';
    position: absolute;
    left: 4px;
    top: 0;
    color: white;
    font-weight: bold;
}

/* ========== TABLES ========== */

/* Row hover effect */
.table-hover-enhanced tbody tr {
    transition: all 0.3s ease;
}

.table-hover-enhanced tbody tr:hover {
    background-color: #f8f9fa;
    transform: scale(1.01);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Alternating row colors */
.table-striped-enhanced tbody tr:nth-child(odd) {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Cell highlight on click */
.table-cell-highlight td {
    cursor: pointer;
    transition: background-color 0.2s;
}

.table-cell-highlight td:hover {
    background-color: rgba(13, 110, 253, 0.1);
}

/* ========== BUTTONS ========== */

/* Button with ripple effect */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transition: transform 0.5s;
}

.btn-ripple:active::after {
    transform: translate(-50%, -50%) scale(2);
    opacity: 0;
}

/* Button group spacing */
.btn-group-spaced .btn {
    margin: 0 4px;
}

/* Icon button */
.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

/* ========== UTILITY CLASSES ========== */

/* Text animations */
.text-gradient {
    background: linear-gradient(45deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Shadow utilities */
.shadow-soft {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
}

.shadow-strong {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15) !important;
}

/* Cursor utilities */
.cursor-pointer {
    cursor: pointer;
}

.cursor-wait {
    cursor: wait;
}

.cursor-not-allowed {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Overflow utilities */
.overflow-visible {
    overflow: visible !important;
}

.overflow-hidden-smooth {
    overflow: hidden;
    transition: max-height 0.3s ease;
}

/* ========== RESPONSIVE UTILITIES ========== */

/* Hide on mobile */
@media (max-width: 767px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Show only on mobile */
@media (min-width: 768px) {
    .show-mobile-only {
        display: none !important;
    }
}

/* Stack on mobile */
@media (max-width: 767px) {
    .stack-mobile {
        flex-direction: column !important;
    }
    
    .stack-mobile > * {
        width: 100% !important;
        margin-bottom: 1rem;
    }
}

/* ========== PRINT STYLES ========== */

@media print {
    .no-print {
        display: none !important;
    }
    
    .page-break-before {
        page-break-before: always;
    }
    
    .page-break-after {
        page-break-after: always;
    }
    
    .page-break-avoid {
        page-break-inside: avoid;
    }
}

/* ========== ACCESSIBILITY ========== */

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Skip to content link */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: #007bff;
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 9999;
}

.skip-to-content:focus {
    top: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    * {
        border-color: currentColor !important;
    }
}

/* 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;
    }
}

/* ========== DARK MODE SUPPORT - DISABLED ========== */

@media (prefers-color-scheme: dark) {
    .dark-mode-aware {
        background-color: #ffffff !important;
        color: #4b5563 !important;
    }
    
    .dark-mode-aware .card {
        background-color: #ffffff !important;
        border-color: #d1d5db !important;
    }
    
    .dark-mode-aware input,
    .dark-mode-aware select,
    .dark-mode-aware textarea {
        background-color: #ffffff !important;
        color: #4b5563 !important;
        border-color: #d1d5db !important;
    }
}

/* ========== PERFORMANCE OPTIMIZATIONS ========== */

/* GPU acceleration for animations */
.gpu-accelerated {
    will-change: transform;
    transform: translateZ(0);
}

/* Prevent layout shift */
.prevent-layout-shift {
    content-visibility: auto;
    contain-intrinsic-size: 500px;
}

/* ========== END ========== */
