/* Enhanced Alpine.js Loading and Utilities */
[x-cloak] { 
    display: none !important; 
}


/* Enhanced HTMX Loading Indicators */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: block;
}

.htmx-request.htmx-indicator {
    display: block;
}

/* Enhanced Loading States */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: all 0.3s ease-out;
}

.dark .loading-overlay {
    background: rgba(0, 0, 0, 0.2);
}

.alpine-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease-out;
}

.dark .alpine-loader {
    background: rgba(17, 24, 39, 0.9);
}

.alpine-loader.hide {
    opacity: 0;
    pointer-events: none;
}

.loader-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid #E5E7EB;
    border-top: 2px solid #3B82F6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.dark .loader-spinner {
    border-color: #374151;
    border-top-color: #60A5FA;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

::-webkit-scrollbar-track {
    background: #F3F4F6;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #60A5FA, #3B82F6);
    border-radius: 4px;
    border: 1px solid transparent;
    background-clip: padding-box;
    transition: all 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #3B82F6, #2563EB);
    transform: scale(1.05);
}

.dark ::-webkit-scrollbar-track {
    background: #374151;
}

.dark ::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #60A5FA, #3B82F6);
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #3B82F6, #2563EB);
}

/* Modern scrollbar for table containers */
.scrollbar-modern {
    scrollbar-width: thin;
    scrollbar-color: #3B82F6 #F3F4F6;
}

.dark .scrollbar-modern {
    scrollbar-color: #60A5FA #374151;
}

.scrollbar-modern::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.scrollbar-modern::-webkit-scrollbar-track {
    background: #F9FAFB;
    border-radius: 5px;
    margin: 2px;
}

.dark .scrollbar-modern::-webkit-scrollbar-track {
    background: #111827;
}

.scrollbar-modern::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #60A5FA, #3B82F6);
    border-radius: 5px;
    border: 1px solid transparent;
    background-clip: padding-box;
    transition: all 0.2s ease;
}

.scrollbar-modern::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #3B82F6, #2563EB);
    transform: scale(1.05);
}

.scrollbar-modern::-webkit-scrollbar-corner {
    background: #F9FAFB;
}

.dark .scrollbar-modern::-webkit-scrollbar-corner {
    background: #111827;
}

/* Hide scrollbar but keep scroll functionality */
.scrollbar-none {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.scrollbar-none::-webkit-scrollbar {
    display: none;
}

/* Enhanced Smooth Transitions */
* {
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

/* Enhanced Custom Checkbox Styles */
.custom-checkbox {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.custom-checkbox input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.custom-checkbox .checkbox-box {
    width: 18px;
    height: 18px;
    border: 2px solid #D1D5DB;
    border-radius: 4px;
    background: #FFFFFF;
    margin-right: 10px;
    transition: all 0.2s ease;
    position: relative;
}

.dark .custom-checkbox .checkbox-box {
    border-color: #6B7280;
    background: #111827;
}

.custom-checkbox input:checked + .checkbox-box {
    background: #3B82F6;
    border-color: #3B82F6;
    transform: scale(1.05);
}

.custom-checkbox input:checked + .checkbox-box::after {
    content: '✓';
    position: absolute;
    color: white;
    font-size: 12px;
    font-weight: 700;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: checkmark 0.2s ease-in-out;
}

@keyframes checkmark {
    0% { 
        opacity: 0; 
        transform: scale(0.8); 
    }
    100% { 
        opacity: 1; 
        transform: scale(1); 
    }
}

/* Enhanced Animations */
.fade-in {
    animation: fadeIn 0.4s ease-out;
}

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

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

.slide-in-left {
    animation: slideInLeft 0.4s ease-out;
}

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

.scale-in {
    animation: scaleIn 0.3s ease-out;
}

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

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

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

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

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

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

/* Enhanced Dashboard Grid Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr;
    gap: 24px;
    height: calc(100vh - 80px);
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
        height: auto;
    }
}

/* Enhanced Toast Notification Styles */
.toast {
    position: fixed;
    top: 1rem;
    right: 1rem;
    padding: 1rem 1.25rem;
    border-radius: 0.75rem;
    color: white;
    font-weight: 500;
    z-index: 50;
    transform: translateX(100%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.toast.show {
    transform: translateX(0);
}

.toast.success {
    background: linear-gradient(135deg, #10B981, #059669);
}

.toast.error {
    background: linear-gradient(135deg, #EF4444, #DC2626);
}

.toast.warning {
    background: linear-gradient(135deg, #F59E0B, #D97706);
}

.toast.info {
    background: linear-gradient(135deg, #3B82F6, #2563EB);
}

/* Enhanced Focus Styles for Accessibility */
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #3B82F6;
    outline-offset: 2px;
    ring: 2px;
    ring-color: #DBEAFE;
}

.dark button:focus,
.dark input:focus,
.dark select:focus,
.dark textarea:focus {
    ring-color: #1E3A8A;
}

/* Enhanced Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #E5E7EB;
    border-top: 2px solid #3B82F6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Enhanced Table Hover Effects */
.table-row {
    transition: all 0.2s ease;
}

.table-row:hover {
    background-color: rgba(59, 130, 246, 0.05);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.dark .table-row:hover {
    background-color: rgba(96, 165, 250, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Enhanced Button Variants */
.btn-primary {
    @apply bg-blue-600 hover:bg-blue-700 focus:ring-4 focus:ring-blue-300 dark:focus:ring-blue-800 text-white px-6 py-3 rounded-lg transition-all duration-200 transform hover:scale-105 active:scale-95 shadow-lg hover:shadow-xl font-medium;
}

.btn-secondary {
    @apply bg-gray-600 hover:bg-gray-700 focus:ring-4 focus:ring-gray-300 dark:focus:ring-gray-800 text-white px-6 py-3 rounded-lg transition-all duration-200 transform hover:scale-105 active:scale-95 shadow-md hover:shadow-lg font-medium;
}

.btn-success {
    @apply bg-green-600 hover:bg-green-700 focus:ring-4 focus:ring-green-300 dark:focus:ring-green-800 text-white px-6 py-3 rounded-lg transition-all duration-200 transform hover:scale-105 active:scale-95 shadow-lg hover:shadow-xl font-medium;
}

.btn-danger {
    @apply bg-red-600 hover:bg-red-700 focus:ring-4 focus:ring-red-300 dark:focus:ring-red-800 text-white px-6 py-3 rounded-lg transition-all duration-200 transform hover:scale-105 active:scale-95 shadow-lg hover:shadow-xl font-medium;
}

.btn-outline {
    @apply bg-transparent border-2 border-blue-600 text-blue-600 hover:bg-blue-600 hover:text-white px-6 py-3 rounded-lg transition-all duration-200 transform hover:scale-105 active:scale-95 font-medium;
}

.dark .btn-outline {
    @apply border-blue-400 text-blue-400 hover:bg-blue-400 hover:text-gray-900;
}

/* Enhanced Form Input Styles */
.form-input {
    @apply w-full px-4 py-3 border-2 border-gray-300 rounded-lg focus:ring-4 focus:ring-blue-500 focus:border-blue-500 transition-all duration-200 bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400;
}

.dark .form-input {
    @apply border-gray-600 focus:border-blue-400 focus:ring-blue-400;
}

.form-input:focus {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

/* Enhanced Card Styles */
.card {
    @apply bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 transition-all duration-200 hover:shadow-lg hover:border-gray-300 dark:hover:border-gray-600;
}

.card-hover {
    @apply transform hover:scale-[1.02] hover:-translate-y-1;
}

.card-interactive {
    @apply cursor-pointer hover:shadow-xl active:scale-[0.98];
}

/* Enhanced Glassmorphism Effects */
.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.dark .glass {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Enhanced Gradient Backgrounds */
.gradient-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.gradient-secondary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.gradient-success {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.gradient-warning {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

/* Enhanced Responsive Utilities */
@media (max-width: 640px) {
    .mobile-hidden {
        display: none;
    }
    
    .mobile-full {
        width: 100%;
    }
    
    .mobile-stack {
        flex-direction: column;
    }
    
    .mobile-center {
        text-align: center;
    }
}

@media (max-width: 768px) {
    .tablet-hidden {
        display: none;
    }
    
    .tablet-full {
        width: 100%;
    }
}

/* Enhanced Print Styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    .print-break {
        page-break-before: always;
    }
    
    .print-avoid-break {
        page-break-inside: avoid;
    }
}

/* Enhanced Selection Styles */
::selection {
    background: rgba(59, 130, 246, 0.3);
    color: inherit;
}

::-moz-selection {
    background: rgba(59, 130, 246, 0.3);
    color: inherit;
}

/* Enhanced Placeholder Styles */
::placeholder {
    color: #9CA3AF;
    opacity: 1;
}

.dark ::placeholder {
    color: #6B7280;
}

/* Enhanced Focus Visible for Better Accessibility */
.focus-visible:focus {
    outline: 2px solid #3B82F6;
    outline-offset: 2px;
}

/* Enhanced Disabled States */
.disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

/* Enhanced Loading Skeletons */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

.dark .skeleton {
    background: linear-gradient(90deg, #374151 25%, #4B5563 50%, #374151 75%);
}

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

/* Enhanced Tooltip Styles */
.tooltip {
    position: relative;
}

.tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem;
    background: #1F2937;
    color: white;
    font-size: 0.875rem;
    border-radius: 0.5rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1000;
}

.tooltip:hover::before {
    opacity: 1;
}

.dark .tooltip::before {
    background: #F9FAFB;
    color: #1F2937;
}