/* ================================================
   ANIMATIONS & TRANSITIONS
   Modern micro-interactions for Hospital ETL
   ================================================ */

/* ================================================
   PAGE TRANSITIONS
   ================================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Apply page animations */
.dashboard-wrapper,
.page-content {
    animation: fadeIn 0.4s ease-out;
}

/* ================================================
   BUTTON RIPPLE EFFECT
   ================================================ */

.btn {
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

/* ================================================
   CARD ANIMATIONS
   ================================================ */

.stat-card {
    animation: fadeInScale 0.4s ease-out backwards;
}

.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }
.stat-card:nth-child(5) { animation-delay: 0.25s; }
.stat-card:nth-child(6) { animation-delay: 0.3s; }

/* ================================================
   MODAL ANIMATIONS
   ================================================ */

.modal.fade .modal-dialog {
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
    transform: translateY(-50px);
}

.modal.show .modal-dialog {
    transform: translateY(0);
}

.modal-backdrop.fade {
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

.modal-backdrop.show {
    opacity: 1;
}

/* ================================================
   TABLE ROW ANIMATIONS
   ================================================ */

.activity-table tbody tr {
    animation: fadeInUp 0.3s ease-out backwards;
}

.activity-table tbody tr:nth-child(1) { animation-delay: 0.05s; }
.activity-table tbody tr:nth-child(2) { animation-delay: 0.1s; }
.activity-table tbody tr:nth-child(3) { animation-delay: 0.15s; }
.activity-table tbody tr:nth-child(4) { animation-delay: 0.2s; }
.activity-table tbody tr:nth-child(5) { animation-delay: 0.25s; }

/* ================================================
   LOADING SPINNER ANIMATIONS
   ================================================ */

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.spinner-border {
    animation: spin 0.75s linear infinite;
}

.spinner-grow {
    animation: pulse 0.75s ease-in-out infinite;
}

/* ================================================
   PROGRESS BAR ANIMATIONS
   ================================================ */

@keyframes progress-shine {
    0% {
        background-position: -200% center;
    }
    100% {
        background-position: 200% center;
    }
}

.progress-bar-animated {
    background-size: 200% 100%;
    animation: progress-shine 2s linear infinite;
}

/* ================================================
   TOAST SLIDE OUT ANIMATION
   ================================================ */

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.toast-item.removing {
    animation: slideOut 0.3s ease-out forwards;
}

/* ================================================
   SKELETON LOADING ANIMATION
   ================================================ */

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton {
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

/* ================================================
   HOVER EFFECTS
   ================================================ */

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

.hover-bounce:hover {
    animation: bounce 0.6s ease-in-out;
}

/* ================================================
   ICON ANIMATIONS
   ================================================ */

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.icon-spin {
    animation: rotate 2s linear infinite;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.icon-shake {
    animation: shake 0.5s ease-in-out;
}

/* ================================================
   FOCUS ANIMATIONS
   ================================================ */

.form-control:focus,
.form-select:focus {
    animation: focusGlow 0.3s ease-out;
}

@keyframes focusGlow {
    0% {
        box-shadow: 0 0 0 0 rgba(68, 190, 221, 0.4);
    }
    100% {
        box-shadow: 0 0 0 0.2rem rgba(68, 190, 221, 0.15);
    }
}

/* ================================================
   UTILITY ANIMATION CLASSES
   ================================================ */

.animate-fade-in {
    animation: fadeIn 0.4s ease-out;
}

.animate-slide-in-right {
    animation: slideInRight 0.4s ease-out;
}

.animate-slide-in-left {
    animation: slideInLeft 0.4s ease-out;
}

.animate-slide-in-up {
    animation: slideInUp 0.4s ease-out;
}

.animate-scale {
    animation: fadeInScale 0.4s ease-out;
}

/* Delay Classes */
.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }

/* ================================================
   SMOOTH SCROLLING
   ================================================ */

html {
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: var(--radius-md);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: var(--radius-md);
    transition: background var(--transition-base);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Dark scrollbar for code editor */
.CodeMirror::-webkit-scrollbar-track {
    background: #1e1e1e;
}

.CodeMirror::-webkit-scrollbar-thumb {
    background: #3e3e3e;
}

.CodeMirror::-webkit-scrollbar-thumb:hover {
    background: #4e4e4e;
}

/* ================================================
   ACCORDION ANIMATIONS
   ================================================ */

.accordion-button:not(.collapsed) {
    background: var(--primary-50);
    color: var(--primary-600);
}

.accordion-button:focus {
    box-shadow: 0 0 0 0.2rem rgba(68, 190, 221, 0.15);
}

.accordion-body {
    animation: fadeInUp 0.3s ease-out;
}

/* ================================================
   TOOLTIP ANIMATIONS
   ================================================ */

[data-bs-toggle="tooltip"] {
    cursor: help;
}

.tooltip {
    font-size: var(--font-size-xs);
}

.tooltip-inner {
    background: var(--gray-800);
    border-radius: var(--radius-md);
    padding: var(--spacing-2) var(--spacing-3);
}

/* ================================================
   DROPDOWN ANIMATIONS
   ================================================ */

.dropdown-menu {
    animation: fadeInScale 0.2s ease-out;
    transform-origin: top;
}

/* ================================================
   BADGE ANIMATIONS
   ================================================ */

.badge {
    transition: all var(--transition-base);
}

.badge:hover {
    transform: scale(1.05);
}

/* ================================================
   FOCUS VISIBLE (Accessibility)
   ================================================ */

*:focus-visible {
    outline: 2px solid var(--primary-400);
    outline-offset: 2px;
}

button:focus-visible,
.btn:focus-visible {
    outline: 2px solid var(--primary-400);
    outline-offset: 2px;
}
