/* Custom CSS for the application */

/* Global transitions for smooth interactions */
* {
    transition: all 0.2s ease-in-out;
}

/* Custom form styling with enhanced focus */
.form-control {
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

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

/* Enhanced button styles with micro-interactions */
.btn {
    transition: all 0.15s ease-in-out;
    position: relative;
    overflow: hidden;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Loading button animation */
.btn-loading {
    position: relative;
    color: transparent !important;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

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

/* Custom button styles */
.btn-custom {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    border: none;
    color: white;
    position: relative;
}

.btn-custom:hover {
    background: linear-gradient(135deg, #0056b3 0%, #004085 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 123, 255, 0.3);
}

.btn-custom:active {
    transform: translateY(0);
}

/* Enhanced table styling with micro-interactions */
.table-hover tbody tr {
    transition: all 0.2s ease-in-out;
}

.table-hover tbody tr:hover {
    background-color: rgba(0, 123, 255, 0.05);
    transform: scale(1.005);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.table-hover tbody tr:hover .text-primary {
    color: #0056b3 !important;
    font-weight: 600;
}

/* Make all tables compact */
table {
    font-size: 0.875rem;
}

table td, table th {
    padding: 0.25rem 0.5rem;
}

/* Make table headers sticky on desktop */
.table-responsive {
    max-height: 60vh;
    overflow-y: auto;
}

.table-responsive .table .thead-dark th {
    position: sticky;
    top: 0;
    background-color: #343a40;
    color: white;
    z-index: 10;
}

.table-responsive .table .thead-light th {
    position: sticky;
    top: 0;
    background-color: #f8f9fa;
    color: #212529;
    z-index: 10;
}

/* Enhanced alert styling with animations */
.alert {
    border-radius: 0.5rem;
    border: none;
    animation: slideIn 0.3s ease-out;
    position: relative;
    overflow: hidden;
}

.alert::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: currentColor;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Enhanced card styling with hover effects */
.card {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease-in-out;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.card-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
    border-radius: 0.75rem 0.75rem 0 0 !important;
    transition: all 0.2s ease-in-out;
}

.card-body {
    transition: all 0.2s ease-in-out;
}

/* Navigation enhancements */
.navbar-brand {
    font-weight: bold;
    transition: all 0.2s ease-in-out;
}

.navbar-brand:hover {
    transform: scale(1.05);
}

.nav-link {
    transition: all 0.2s ease-in-out;
}

.nav-link:hover {
    color: #0056b3 !important;
}

/* Dropdown animations */
.dropdown-menu {
    border: none;
    border-radius: 0.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: fadeInDown 0.2s ease-out;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-item {
    transition: all 0.15s ease-in-out;
}

.dropdown-item:hover {
    background-color: rgba(0, 123, 255, 0.1);
    color: #0056b3;
    transform: translateX(5px);
}

/* Accordion enhancements */
.accordion .card-header button {
    transition: all 0.2s ease-in-out;
}

.accordion .card-header button:hover {
    background-color: rgba(0, 123, 255, 0.05);
}

.accordion .card-header button:focus {
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Loading spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease-in-out;
    pointer-events: none; /* Allow interactions underneath */
}

.spinner-overlay.interactive-block {
    pointer-events: auto; /* Block interactions when needed */
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Table loading state */
.table-loading {
    position: relative;
}

.table-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

/* Pagination enhancements */
.pagination .page-link {
    transition: all 0.2s ease-in-out;
    border-radius: 0.375rem;
}

.pagination .page-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.pagination .page-item.active .page-link {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    border-color: #007bff;
}

/* Sortable headers */
.sortable-header {
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease-in-out;
}

.sortable-header:hover {
    background-color: rgba(0, 123, 255, 0.1);
    color: #0056b3;
}

.sort-indicator {
    transition: transform 0.2s ease-in-out;
}

/* Toast notifications */
.toast {
    border-radius: 0.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: slideInRight 0.3s ease-out;
}

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

/* Enhanced responsive utilities */
@media (max-width: 768px) {
    .table-responsive {
        font-size: 0.875rem;
        border-radius: 0.375rem;
        overflow-x: auto;
    }

    .btn-sm {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }

    .card {
        margin-bottom: 1rem;
    }

    .navbar-brand {
        font-size: 1.1rem;
    }

    .dropdown-menu {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus states for accessibility */
.btn:focus,
.form-control:focus,
.nav-link:focus,
.dropdown-item:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .card {
        border: 2px solid #000;
    }

    .btn {
        border: 2px solid #000;
    }
}