/* Import fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* Base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

/* Gradient text */
.gradient-text {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Custom buttons */
.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

/* Card styles */
.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

/* Loading spinner */
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

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

/* Responsive utilities */
@media (max-width: 768px) {
    .mobile-menu {
        display: block;
    }
}

/* ============================================
   HTMX Loading States
   ============================================ */

/* Global loading state */
.htmx-request {
    opacity: 0.6;
    cursor: wait !important;
    position: relative;
}

/* Spinner overlay for loading elements */
.htmx-request::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #6366f1;
    border-radius: 50%;
    animation: htmx-spin 1s linear infinite;
    z-index: 1000;
}

@keyframes htmx-spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Button specific loading states */
button.htmx-request,
a.htmx-request {
    opacity: 0.7;
    cursor: not-allowed !important;
    pointer-events: none;
}

button.htmx-request::after,
a.htmx-request::after {
    width: 16px;
    height: 16px;
    border-width: 2px;
    margin-left: 8px;
}

/* Form loading state */
form.htmx-request {
    opacity: 0.8;
    pointer-events: none;
}

form.htmx-request::after {
    display: none;
}

/* Table row loading state */
tr.htmx-request {
    background-color: rgba(99, 102, 241, 0.05);
}

tr.htmx-request::after {
    width: 16px;
    height: 16px;
}

/* Loading indicator (hidden by default, shown during requests) */
.htmx-indicator {
    display: none;
}

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

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

/* Skeleton loader for content replacement */
.htmx-swapping {
    opacity: 0;
    transition: opacity 200ms ease-in;
}

.htmx-settling {
    opacity: 1;
    transition: opacity 200ms ease-out;
}

/* Loading overlay for containers */
.htmx-request-container {
    position: relative;
}

.htmx-request-container.htmx-request::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    z-index: 999;
}

.dark .htmx-request-container.htmx-request::before {
    background: rgba(0, 0, 0, 0.5);
}

/* Pulse animation for loading states */
@keyframes htmx-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.htmx-request.pulse {
    animation: htmx-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.htmx-request.pulse::after {
    display: none;
}

/* Progress bar at top of page (optional) */
.htmx-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #6366f1 0%, #8b5cf6 100%);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 300ms ease;
    z-index: 9999;
}

.htmx-progress.active {
    transform: scaleX(0.7);
}

/* Disabled state for buttons during AJAX */
button[disabled].htmx-request,
a[disabled].htmx-request {
    background-color: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
}

.dark button[disabled].htmx-request,
.dark a[disabled].htmx-request {
    background-color: #374151;
    color: #6b7280;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 400px;
}

.toast-notification {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    animation: slideIn 0.3s ease-out;
    min-width: 300px;
}

.dark .toast-notification {
    background: #1f2937;
    color: white;
}

.toast-notification .toast-icon {
    flex-shrink: 0;
}

.toast-notification .toast-message {
    flex: 1;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.toast-notification .toast-close {
    flex-shrink: 0;
    padding: 0.25rem;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #6b7280;
    transition: color 0.2s;
}

.toast-notification .toast-close:hover {
    color: #374151;
}

.dark .toast-notification .toast-close {
    color: #9ca3af;
}

.dark .toast-notification .toast-close:hover {
    color: #d1d5db;
}

/* Toast types */
.toast-success {
    border-left: 4px solid #10b981;
}

.toast-success .toast-icon {
    color: #10b981;
}

.toast-error {
    border-left: 4px solid #ef4444;
}

.toast-error .toast-icon {
    color: #ef4444;
}

.toast-warning {
    border-left: 4px solid #f59e0b;
}

.toast-warning .toast-icon {
    color: #f59e0b;
}

.toast-info {
    border-left: 4px solid #3b82f6;
}

.toast-info .toast-icon {
    color: #3b82f6;
}

/* Toast animations */
@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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