/* ========================================
   ENHANCED UI ANIMATIONS & STYLES
   ======================================== */

/* Smooth Page Transitions */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

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

/* Page Content Animation */
main {
    animation: fadeIn 0.5s ease-out;
}

/* Card Animations */
.card {
    animation: fadeIn 0.6s ease-out;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Enhanced Buttons */
.btn {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    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.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.btn-primary {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0056b3 0%, #003d82 100%);
}

.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
    border: none;
}

.btn-success:hover {
    background: linear-gradient(135deg, #1e7e34 0%, #155724 100%);
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    z-index: 1000;
    animation: float 3s ease-in-out infinite;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.fab:active {
    transform: scale(0.95);
}

/* Counter Animation */
.animated-counter {
    animation: countUp 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-weight: 600;
}

/* Skeleton Loader */
.skeleton {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.1) 25%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0.1) 75%
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

.skeleton-card {
    background-color: #f5f5f5;
    border-radius: 8px;
    height: 200px;
    animation: pulse 1.5s ease-in-out infinite;
}

/* Loading Spinner (Enhanced) */
.spinner-border {
    animation: rotate 1s linear infinite;
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
}

.toast {
    animation: slideInRight 0.3s ease-out, slideInRight 0.3s ease-in 3.7s reverse;
    background: white;
    border-left: 4px solid;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    margin-bottom: 1rem;
    max-width: 400px;
}

.toast.success {
    border-left-color: #28a745;
    background: linear-gradient(135deg, #f0f9f4 0%, #ffffff 100%);
}

.toast.error {
    border-left-color: #dc3545;
    background: linear-gradient(135deg, #fdf4f5 0%, #ffffff 100%);
}

.toast.info {
    border-left-color: #17a2b8;
    background: linear-gradient(135deg, #f0f8fa 0%, #ffffff 100%);
}

.toast.warning {
    border-left-color: #ffc107;
    background: linear-gradient(135deg, #fffaf0 0%, #ffffff 100%);
}

/* Progress Ring */
.progress-ring {
    transition: stroke-dashoffset 0.5s ease;
}

.progress-ring-circle {
    transition: stroke-dashoffset 0.5s ease;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    animation: fadeIn 0.6s ease-out;
}

.empty-state-icon {
    font-size: 4rem;
    opacity: 0.5;
    margin-bottom: 1rem;
    animation: float 3s ease-in-out infinite;
}

.empty-state-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
}

.empty-state-text {
    color: #999;
    margin-bottom: 2rem;
}

/* Metric Cards */
.metric-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    animation: scaleIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
}

.metric-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.4);
}

.metric-card.success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    box-shadow: 0 10px 30px rgba(40, 167, 69, 0.3);
}

.metric-card.success:hover {
    box-shadow: 0 15px 40px rgba(40, 167, 69, 0.4);
}

.metric-card.warning {
    background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
    box-shadow: 0 10px 30px rgba(255, 193, 7, 0.3);
}

.metric-card.warning:hover {
    box-shadow: 0 15px 40px rgba(255, 193, 7, 0.4);
}

.metric-card.danger {
    background: linear-gradient(135deg, #dc3545 0%, #fd7e14 100%);
    box-shadow: 0 10px 30px rgba(220, 53, 69, 0.3);
}

.metric-card.danger:hover {
    box-shadow: 0 15px 40px rgba(220, 53, 69, 0.4);
}

.metric-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0.5rem 0;
}

.metric-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.metric-change {
    font-size: 0.85rem;
    opacity: 0.8;
    margin-top: 0.5rem;
}

.metric-change.up::before {
    content: '↑ ';
}

.metric-change.down::before {
    content: '↓ ';
}

/* Form Enhancements */
.form-control,
.form-select {
    border: 2px solid transparent;
    transition: all 0.3s ease;
    border-radius: 8px;
}

.form-control:focus,
.form-select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    transform: translateY(-2px);
}

.form-control::placeholder {
    color: #aaa;
    opacity: 1;
}

/* Input Validation */
.form-control.is-valid {
    border-color: #28a745;
}

.form-control.is-valid:focus {
    border-color: #28a745;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

.form-control.is-invalid {
    border-color: #dc3545;
}

.form-control.is-invalid:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.invalid-feedback {
    animation: slideInLeft 0.3s ease-out;
    display: block;
}

/* Table Enhancements */
.table {
    border-collapse: separate;
    border-spacing: 0;
}

.table tbody tr {
    transition: all 0.2s ease;
}

.table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
    transform: scale(1.01);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

.table th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #f5f5f5 0%, #ffffff 100%);
}

/* Timeline */
.timeline {
    position: relative;
    padding: 1rem 0;
}

.timeline-item {
    display: flex;
    margin-bottom: 2rem;
    animation: slideInLeft 0.6s ease-out;
}

.timeline-dot {
    width: 16px;
    height: 16px;
    background: #007bff;
    border-radius: 50%;
    margin-right: 1.5rem;
    margin-top: 4px;
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.1);
    flex-shrink: 0;
}

.timeline-content {
    flex-grow: 1;
}

/* Badge Enhancements */
.badge {
    animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    padding: 0.5rem 0.75rem;
    font-weight: 600;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.badge:hover {
    transform: scale(1.05);
}

.badge-primary {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
}

.badge-success {
    background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
}

.badge-warning {
    background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
    color: white;
}

.badge-danger {
    background: linear-gradient(135deg, #dc3545 0%, #fd7e14 100%);
}

/* Alert Enhancements */
.alert {
    animation: slideInLeft 0.4s ease-out;
    border-radius: 8px;
    border-left: 4px solid;
    padding: 1rem 1.25rem;
}

.alert-success {
    background: linear-gradient(135deg, #f0f9f4 0%, #ffffff 100%);
    border-left-color: #28a745;
}

.alert-danger {
    background: linear-gradient(135deg, #fdf4f5 0%, #ffffff 100%);
    border-left-color: #dc3545;
}

.alert-warning {
    background: linear-gradient(135deg, #fffaf0 0%, #ffffff 100%);
    border-left-color: #ffc107;
}

.alert-info {
    background: linear-gradient(135deg, #f0f8fa 0%, #ffffff 100%);
    border-left-color: #17a2b8;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    transition: background 0.2s;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Breadcrumbs */
.breadcrumb {
    animation: fadeIn 0.5s ease-out;
    background: transparent;
}

.breadcrumb-item {
    transition: all 0.2s ease;
}

.breadcrumb-item:hover a {
    color: #007bff;
    text-decoration: none;
}

.breadcrumb-item.active {
    font-weight: 600;
    color: #333;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .fab {
        bottom: 1rem;
        right: 1rem;
        width: 48px;
        height: 48px;
        font-size: 20px;
    }

    .toast-container {
        left: 1rem;
        right: 1rem;
    }

    .toast {
        max-width: none;
    }

    .metric-value {
        font-size: 1.75rem;
    }

    .card:hover {
        transform: translateY(-2px);
    }

    .table tbody tr:hover {
        transform: scale(1);
    }
}

/* Dark Theme Support (respects the app's data-bs-theme toggle) */
:root[data-bs-theme="dark"] .skeleton-card {
    background-color: #2a2a2a;
}

:root[data-bs-theme="dark"] .table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

:root[data-bs-theme="dark"] .table {
    color: #dcdcdc;
}

:root[data-bs-theme="dark"] .table thead {
    background-color: #1f1f1f;
    color: #f0f0f0;
}

:root[data-bs-theme="dark"] .table tbody {
    background-color: #151515;
}

:root[data-bs-theme="dark"] .table td,
:root[data-bs-theme="dark"] .table th {
    border-color: #333;
}

:root[data-bs-theme="dark"] .form-control,
:root[data-bs-theme="dark"] .form-select {
    background-color: #2a2a2a;
    color: #fff;
    border-color: #444;
}

:root[data-bs-theme="dark"] .form-control:focus,
:root[data-bs-theme="dark"] .form-select:focus {
    background-color: #2a2a2a;
    color: #fff;
    border-color: #007bff;
}

:root[data-bs-theme="dark"] .form-control::placeholder {
    color: #777;
}

:root[data-bs-theme="dark"] .empty-state-title {
    color: #ccc;
}

:root[data-bs-theme="dark"] .empty-state-text {
    color: #999;
}

:root[data-bs-theme="dark"] .breadcrumb-item.active {
    color: #ccc;
}

:root[data-bs-theme="dark"] .toast {
    background: #2a2a2a;
    color: #fff;
}

:root[data-bs-theme="dark"] .toast.success {
    background: linear-gradient(135deg, rgba(40, 167, 69, 0.2) 0%, rgba(32, 201, 151, 0.1) 100%);
    color: #20c997;
}

:root[data-bs-theme="dark"] .toast.error {
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.2) 0%, rgba(253, 126, 20, 0.1) 100%);
    color: #ff7a7a;
}

:root[data-bs-theme="dark"] .toast.info {
    background: linear-gradient(135deg, rgba(23, 162, 184, 0.2) 0%, rgba(102, 200, 223, 0.1) 100%);
    color: #66c8df;
}

:root[data-bs-theme="dark"] .toast.warning {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.2) 0%, rgba(255, 152, 0, 0.1) 100%);
    color: #ffc107;
}

:root[data-bs-theme="dark"] .metric-card {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

:root[data-bs-theme="dark"] .metric-card:hover {
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
}

:root[data-bs-theme="dark"] .metric-card .btn-light,
:root[data-bs-theme="dark"] .metric-card .btn-outline-light {
    background-color: rgba(255, 255, 255, 0.25) !important;
    color: white !important;
    border-color: rgba(255, 255, 255, 0.5) !important;
    transition: all 0.3s ease;
}

:root[data-bs-theme="dark"] .metric-card .btn-light:hover,
:root[data-bs-theme="dark"] .metric-card .btn-outline-light:hover {
    background-color: rgba(255, 255, 255, 0.35) !important;
    border-color: rgba(255, 255, 255, 0.7) !important;
    backdrop-filter: blur(2px);
}

:root[data-bs-theme="dark"] .metric-card .btn-light:active,
:root[data-bs-theme="dark"] .metric-card .btn-outline-light:active {
    background-color: rgba(255, 255, 255, 0.45) !important;
}

:root[data-bs-theme="dark"] .card {
    border-color: #333;
}

:root[data-bs-theme="dark"] .card-footer {
    background-color: #1f1f1f;
    border-top-color: #333 !important;
}

:root[data-bs-theme="dark"] .card-header {
    background-color: #1f1f1f;
    border-bottom-color: #333;
}

:root[data-bs-theme="dark"] .card,
:root[data-bs-theme="dark"] .card-body {
    background-color: #141414;
    color: #e0e0e0;
}

:root[data-bs-theme="dark"] .card-title,
:root[data-bs-theme="dark"] .card-text,
:root[data-bs-theme="dark"] .card-subtitle {
    color: #e8e8e8;
}

:root[data-bs-theme="dark"] .badge {
    background-color: rgba(255, 255, 255, 0.15);
    color: #e0e0e0;
}

:root[data-bs-theme="dark"] .badge.bg-primary {
    background-color: rgba(0, 123, 255, 0.3) !important;
    color: #66b3ff;
}

:root[data-bs-theme="dark"] .badge.bg-success {
    background-color: rgba(40, 167, 69, 0.3) !important;
    color: #52d176;
}

:root[data-bs-theme="dark"] .badge.bg-warning {
    background-color: rgba(255, 193, 7, 0.3) !important;
    color: #ffd966;
}

:root[data-bs-theme="dark"] .badge.bg-danger {
    background-color: rgba(220, 53, 69, 0.3) !important;
    color: #ff7a7a;
}

:root[data-bs-theme="dark"] .alert {
    background-color: #1f1f1f;
    border-color: #333;
    color: #d0d0d0;
}

:root[data-bs-theme="dark"] .alert-success {
    background-color: rgba(40, 167, 69, 0.1);
    border-color: rgba(40, 167, 69, 0.3);
    color: #52d176;
}

:root[data-bs-theme="dark"] .alert-danger {
    background-color: rgba(220, 53, 69, 0.1);
    border-color: rgba(220, 53, 69, 0.3);
    color: #ff7a7a;
}

:root[data-bs-theme="dark"] .alert-warning {
    background-color: rgba(255, 193, 7, 0.1);
    border-color: rgba(255, 193, 7, 0.3);
    color: #ffd966;
}

:root[data-bs-theme="dark"] .alert-info {
    background-color: rgba(23, 162, 184, 0.1);
    border-color: rgba(23, 162, 184, 0.3);
    color: #66c8df;
}

:root[data-bs-theme="dark"] .dropdown-menu {
    background-color: #2a2a2a;
    border-color: #333;
}

:root[data-bs-theme="dark"] .dropdown-item {
    color: #d0d0d0;
}

:root[data-bs-theme="dark"] .dropdown-item:hover,
:root[data-bs-theme="dark"] .dropdown-item:focus {
    background-color: #3a3a3a;
    color: #fff;
}

:root[data-bs-theme="dark"] .dropdown-divider {
    border-color: #333;
}

:root[data-bs-theme="dark"] .nav-tabs {
    border-bottom-color: #333;
}

:root[data-bs-theme="dark"] .nav-tabs .nav-link {
    color: #999;
}

:root[data-bs-theme="dark"] .nav-tabs .nav-link:hover {
    color: #d0d0d0;
    border-color: #333;
}

:root[data-bs-theme="dark"] .nav-tabs .nav-link.active {
    background-color: #2a2a2a;
    color: #fff;
    border-color: #333 #333 #2a2a2a;
}

:root[data-bs-theme="dark"] .list-group-item {
    background-color: #1f1f1f;
    border-color: #333;
    color: #d0d0d0;
}

:root[data-bs-theme="dark"] .list-group-item:hover {
    background-color: #2a2a2a;
    color: #fff;
}

:root[data-bs-theme="dark"] .list-group-item.active {
    background-color: #007bff;
    border-color: #007bff;
}

:root[data-bs-theme="dark"] .list-group-item-action {
    background-color: #1f1f1f;
    color: #e0e0e0;
}

:root[data-bs-theme="dark"] .list-group-item-action:hover,
:root[data-bs-theme="dark"] .list-group-item-action:focus {
    background-color: #2a2a2a;
    color: #fff;
}

:root[data-bs-theme="dark"] .pagination .page-link {
    background-color: #1f1f1f;
    border-color: #333;
    color: #d0d0d0;
}

:root[data-bs-theme="dark"] .pagination .page-link:hover {
    background-color: #2a2a2a;
    border-color: #444;
    color: #fff;
}

:root[data-bs-theme="dark"] .pagination .page-item.active .page-link {
    background-color: #007bff;
    border-color: #007bff;
}

:root[data-bs-theme="dark"] .modal-content {
    background-color: #1f1f1f;
    border-color: #333;
    color: #d0d0d0;
}

:root[data-bs-theme="dark"] .modal-header {
    border-bottom-color: #333;
}

:root[data-bs-theme="dark"] .modal-footer {
    border-top-color: #333;
}

:root[data-bs-theme="dark"] .modal-title {
    color: #fff;
}

:root[data-bs-theme="dark"] .btn-close {
    filter: invert(1);
}

:root[data-bs-theme="dark"] .input-group-text {
    background-color: #2a2a2a;
    border-color: #444;
    color: #d0d0d0;
}

:root[data-bs-theme="dark"] ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

:root[data-bs-theme="dark"] ::-webkit-scrollbar-track {
    background: #1f1f1f;
}

:root[data-bs-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

:root[data-bs-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Print helpers */
@media print {
    .no-print {
        display: none !important;
    }

    .container-fluid {
        margin: 0 !important;
        padding: 0 !important;
    }

    .card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}
