/* ===================================
   LOADING STATES & FEEDBACK
   =================================== */

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

.loading-spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

.loading-spinner-primary {
    border: 3px solid rgba(59, 130, 246, 0.3);
    border-top-color: #3B82F6;
}

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

/* Button Loading State */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
    cursor: not-allowed;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.6s linear infinite;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    background: white;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease-out;
    border-left: 4px solid;
}

.toast-success {
    border-left-color: #10B981;
}

.toast-error {
    border-left-color: #EF4444;
}

.toast-warning {
    border-left-color: #F59E0B;
}

.toast-info {
    border-left-color: #3B82F6;
}

.toast-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.toast-success .toast-icon {
    background: #D1FAE5;
    color: #10B981;
}

.toast-error .toast-icon {
    background: #FEE2E2;
    color: #EF4444;
}

.toast-warning .toast-icon {
    background: #FEF3C7;
    color: #F59E0B;
}

.toast-info .toast-icon {
    background: #DBEAFE;
    color: #3B82F6;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
    color: #111827;
}

.toast-message {
    font-size: 13px;
    color: #6B7280;
}

.toast-close {
    background: none;
    border: none;
    color: #9CA3AF;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

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

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

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

.toast-exit {
    animation: slideOut 0.3s ease-out forwards;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 4px;
    background: #E5E7EB;
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3B82F6, #8B5CF6);
    transition: width 0.3s ease;
    border-radius: 2px;
}

.progress-bar-indeterminate {
    width: 100%;
    height: 4px;
    background: #E5E7EB;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.progress-bar-indeterminate::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 40%;
    background: linear-gradient(90deg, #3B82F6, #8B5CF6);
    border-radius: 2px;
    animation: indeterminate 1.5s ease-in-out infinite;
}

@keyframes indeterminate {
    0% {
        left: -40%;
    }
    100% {
        left: 100%;
    }
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #F3F4F6 25%, #E5E7EB 50%, #F3F4F6 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
    border-radius: 4px;
}

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

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: 12px;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

/* ===================================
   MICRO-INTERACTIONS
   =================================== */

/* Smooth Transitions */
.transition-all {
    transition: all 0.2s ease;
}

.transition-fast {
    transition: all 0.15s ease;
}

.transition-slow {
    transition: all 0.3s ease;
}

/* Button Hover Effects */
.btn-hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

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

/* Card Hover Effects */
.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
}

/* Icon Animations */
.icon-spin:hover {
    animation: spin 0.6s ease;
}

.icon-bounce:hover {
    animation: bounce 0.5s ease;
}

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

/* Link Hover */
.link-underline {
    position: relative;
}

.link-underline::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: currentColor;
    transition: width 0.3s ease;
}

.link-underline:hover::after {
    width: 100%;
}

/* Ripple Effect */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    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;
}

.ripple:active::after {
    width: 300px;
    height: 300px;
}

/* Focus States */
.focus-ring:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

/* ===================================
   RESPONSIVE UTILITIES
   =================================== */

/* Mobile Menu */
@media (max-width: 768px) {
    .mobile-menu-hidden {
        display: none;
    }
    
    .mobile-menu-visible {
        display: block;
    }
    
    /* Stack on mobile */
    .mobile-stack > * {
        width: 100% !important;
        margin-bottom: 12px;
    }
    
    /* Full width on mobile */
    .mobile-full {
        width: 100% !important;
    }
    
    /* Hide on mobile */
    .mobile-hidden {
        display: none !important;
    }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .tablet-stack > * {
        width: 100% !important;
        margin-bottom: 12px;
    }
}

/* Touch-friendly buttons */
@media (max-width: 768px) {
    button, a.btn, .btn {
        min-height: 44px;
        padding: 12px 16px;
    }
    
    /* Larger tap targets */
    .tap-target {
        min-width: 44px;
        min-height: 44px;
    }
}

/* ===================================
   FORM IMPROVEMENTS
   =================================== */

/* Better Input States */
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #3B82F6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

input.error, textarea.error, select.error {
    border-color: #EF4444;
}

input.error:focus, textarea.error:focus, select.error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Required Field Indicator */
.required::after {
    content: " *";
    color: #EF4444;
}

/* Inline Error Messages */
.error-message {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #EF4444;
    font-size: 13px;
    margin-top: 6px;
}

.error-message i {
    font-size: 14px;
}

/* Character Counter */
.char-counter {
    font-size: 12px;
    color: #9CA3AF;
    text-align: right;
    margin-top: 4px;
}

.char-counter.warning {
    color: #F59E0B;
}

.char-counter.error {
    color: #EF4444;
}

/* ===================================
   EMPTY STATES
   =================================== */

.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state-icon {
    font-size: 64px;
    color: #D1D5DB;
    margin-bottom: 20px;
}

.empty-state-title {
    font-size: 20px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 8px;
}

.empty-state-description {
    font-size: 14px;
    color: #6B7280;
    margin-bottom: 24px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* ===================================
   ACCESSIBILITY
   =================================== */

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Skip to Main Content */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: #3B82F6;
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 0 0 4px 0;
    z-index: 10000;
}

.skip-to-main:focus {
    top: 0;
}

/* High Contrast Focus */
@media (prefers-contrast: high) {
    *:focus {
        outline: 3px solid currentColor;
        outline-offset: 2px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
