/**
 * Hollow-Craft Admin Dashboard - UI Components Styles v2.0
 * Skeleton Loaders, Toast Notifications, Modals, Animations
 */

/* ==================== SKELETON LOADER ==================== */

.skeleton-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.skeleton {
    background: linear-gradient(
        90deg,
        rgba(139, 92, 246, 0.1) 25%,
        rgba(139, 92, 246, 0.2) 50%,
        rgba(139, 92, 246, 0.1) 75%
    );
    background-size: 200% 100%;
    border-radius: 6px;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

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

.skeleton-text {
    height: 14px;
    border-radius: 4px;
}

.skeleton-circle {
    border-radius: 50%;
}

.skeleton-card {
    background: rgba(30, 30, 50, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 20px;
}

.skeleton-header {
    border-radius: 6px;
}

.skeleton-avatar {
    background: rgba(139, 92, 246, 0.15);
}

.skeleton-table {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.skeleton-row {
    display: flex;
    gap: 16px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
}

.skeleton-header-row {
    background: rgba(139, 92, 246, 0.1);
}

.skeleton-cell {
    height: 16px;
    border-radius: 4px;
}

.skeleton-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.skeleton-stat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: rgba(30, 30, 50, 0.4);
    border-radius: 12px;
}

.skeleton-active {
    pointer-events: none;
}

/* ==================== TOAST NOTIFICATIONS ==================== */

.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 400px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: linear-gradient(135deg, rgba(30, 30, 50, 0.95), rgba(20, 20, 35, 0.98));
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    position: relative;
    overflow: hidden;
}

.toast-visible {
    transform: translateX(0);
    opacity: 1;
}

.toast-hiding {
    transform: translateX(120%);
    opacity: 0;
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-error {
    border-left: 4px solid var(--danger);
}

.toast-warning {
    border-left: 4px solid var(--warning);
}

.toast-info {
    border-left: 4px solid var(--info);
}

.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-success .toast-icon {
    color: var(--success);
}

.toast-error .toast-icon {
    color: var(--danger);
}

.toast-warning .toast-icon {
    color: var(--warning);
}

.toast-info .toast-icon {
    color: var(--info);
}

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.toast-message {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.toast-action {
    margin-top: 8px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--primary-light);
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.toast-action:hover {
    background: rgba(139, 92, 246, 0.25);
}

.toast-close {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    transition: color 0.2s;
    margin-left: 8px;
}

.toast-close:hover {
    color: var(--text-primary);
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
    animation: toast-progress 5s linear forwards;
}

@keyframes toast-progress {
    from { width: 100%; }
    to { width: 0%; }
}

/* ==================== MODAL SYSTEM ==================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-visible {
    opacity: 1;
}

.modal-hiding {
    opacity: 0;
}

.modal {
    background: linear-gradient(135deg, rgba(30, 30, 50, 0.98), rgba(20, 20, 35, 0.99));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
    transform: scale(0.95) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-visible .modal {
    transform: scale(1) translateY(0);
}

.modal-small {
    max-width: 400px;
}

.modal-medium {
    max-width: 600px;
}

.modal-large {
    max-width: 900px;
}

.modal-fullscreen {
    max-width: 95vw;
    max-height: 95vh;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(90vh - 80px);
}

.modal-message {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ==================== KEYBOARD SHORTCUTS ==================== */

.shortcuts-help {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.shortcuts-help h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
}

.shortcut-item kbd {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-light);
    background: rgba(139, 92, 246, 0.15);
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.shortcut-item span {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ==================== LOADING SPINNER ==================== */

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(139, 92, 246, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spinner 0.8s linear infinite;
}

.loading-spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

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

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

.loading-dots {
    display: inline-flex;
    gap: 4px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: loading-dot 1.4s ease-in-out infinite both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes loading-dot {
    0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* ==================== INFINITE SCROLL LOADER ==================== */

.infinite-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    transition: opacity 0.3s;
}

.infinite-loader.loading {
    opacity: 1;
}

.infinite-loader-text {
    font-size: 14px;
    color: var(--text-muted);
    margin-left: 12px;
}

/* ==================== LAZY IMAGE LOADING ==================== */

[data-lazy] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

[data-lazy].loaded {
    opacity: 1;
}

.image-placeholder {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(6, 182, 212, 0.1));
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-placeholder::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 2px solid rgba(139, 92, 246, 0.3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spinner 0.8s linear infinite;
}

/* ==================== ANIMATIONS ==================== */

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

@keyframes slide-in-right {
    from { 
        transform: translateX(100%);
        opacity: 0;
    }
    to { 
        transform: translateX(0);
        opacity: 1;
    }
}

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

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

.animate-fade-in {
    animation: fade-in 0.3s ease;
}

.animate-fade-in-up {
    animation: fade-in-up 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-fade-in-scale {
    animation: fade-in-scale 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-slide-in-right {
    animation: slide-in-right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.animate-bounce {
    animation: bounce 1s ease-in-out infinite;
}

/* ==================== HOVER EFFECTS ==================== */

.hover-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.hover-glow {
    transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
}

.hover-scale {
    transition: transform 0.2s ease;
}

.hover-scale:hover {
    transform: scale(1.02);
}

/* ==================== STAGGER ANIMATION ==================== */

.stagger-container > * {
    opacity: 0;
    animation: fade-in-up 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.stagger-container > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-container > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-container > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-container > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-container > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-container > *:nth-child(6) { animation-delay: 0.3s; }
.stagger-container > *:nth-child(7) { animation-delay: 0.35s; }
.stagger-container > *:nth-child(8) { animation-delay: 0.4s; }

/* ==================== THEME TOGGLE ==================== */

.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background: var(--primary-glow);
    border-color: var(--primary);
    color: var(--primary);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

/* Light mode specific adjustments */
[data-theme="light"] {
    --primary-glow: rgba(139, 92, 246, 0.2);
    --glass-bg-hover: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .gradient-orb {
    opacity: 0.5;
}

[data-theme="light"] .grid-pattern {
    opacity: 0.03;
}

[data-theme="light"] .card {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .sidebar {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.98) 100%);
    border-right-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .nav-link {
    color: var(--text-secondary);
}

[data-theme="light"] .nav-link:hover {
    background: rgba(139, 92, 246, 0.1);
}

[data-theme="light"] .nav-link.active {
    background: rgba(139, 92, 246, 0.15);
    color: var(--primary);
}

[data-theme="light"] .skeleton {
    background: linear-gradient(
        90deg,
        rgba(139, 92, 246, 0.08) 25%,
        rgba(139, 92, 246, 0.15) 50%,
        rgba(139, 92, 246, 0.08) 75%
    );
}

[data-theme="light"] .toast {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.99));
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .modal {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.99));
    border-color: rgba(0, 0, 0, 0.1);
}


::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.5);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 92, 246, 0.3) rgba(255, 255, 255, 0.02);
}

/* ==================== FOCUS STYLES (Accessibility) ==================== */

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Skip link for accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    z-index: 100000;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 0;
}

/* ==================== REDUCED MOTION ==================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .skeleton {
        animation: none;
        background: rgba(139, 92, 246, 0.15);
    }
}

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

@media (max-width: 768px) {
    .toast-container {
        left: 16px;
        right: 16px;
        top: 16px;
        max-width: none;
    }
    
    .toast {
        padding: 14px;
    }
    
    .modal-overlay {
        padding: 16px;
    }
    
    .modal {
        max-width: 100%;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .shortcut-item {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
}
