/* Smooth Theme Transition Animations */

/* Universal transition for all theme-related properties */
*, *::before, *::after {
    transition: 
        background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Body and main containers */
body, html {
    transition: 
        background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Cards and panels */
.card, .card-header, .card-body, .card-footer {
    transition: 
        background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Navigation elements */
.navbar, .navbar-nav, .nav-link, .dropdown-menu, .dropdown-item {
    transition: 
        background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Buttons */
.btn, .btn:hover, .btn:focus, .btn:active {
    transition: 
        background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Form elements */
.form-control, .form-select, .form-check-input {
    transition: 
        background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Tables */
.table, .table td, .table th, .table thead th {
    transition: 
        background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Alerts and badges */
.alert, .badge {
    transition: 
        background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Modal elements */
.modal-content, .modal-header, .modal-body, .modal-footer {
    transition: 
        background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Progress bars and other components */
.progress, .progress-bar {
    transition: 
        background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Special handling for theme toggle button */
.theme-toggle, #theme-toggle {
    position: relative;
    overflow: hidden;
    transition: 
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle:hover, #theme-toggle:hover {
    transform: scale(1.1);
}

/* Smooth transition for icons in theme toggle */
.theme-toggle i, #theme-toggle i {
    transition: 
        opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Ripple effect for theme toggle */
.ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0);
    animation: ripple 0.6s ease-out;
    pointer-events: none;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin-top: -10px;
    margin-left: -10px;
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Page transition loading state */
.theme-transition-loading {
    pointer-events: none;
    position: relative;
}

.theme-transition-loading::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: 9999;
    pointer-events: none;
}

/* Ensure smooth transitions for custom elements */
.sidebar, .offcanvas, .offcanvas-header, .offcanvas-body {
    transition: 
        background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* List groups */
.list-group, .list-group-item {
    transition: 
        background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Ensure charts and other dynamic content transitions smoothly */
canvas {
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Handle focus states smoothly */
:focus, :focus-visible {
    transition: 
        outline-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.1s !important;
    }
}

/* Special handling for text selections */
::selection {
    transition: 
        background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Scrollbar transitions (webkit browsers) */
::-webkit-scrollbar-track {
    transition: background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

::-webkit-scrollbar-thumb {
    transition: background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}