/* Custom animations and utilities for 3D Coaster Generator */

/* Loading spinner animation */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Pulse ring animation for processing */
@keyframes pulse-ring {
    0% { 
        transform: scale(0.95); 
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7); 
    }
    70% { 
        transform: scale(1); 
        box-shadow: 0 0 0 20px rgba(59, 130, 246, 0); 
    }
    100% { 
        transform: scale(0.95); 
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); 
    }
}

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

/* Fade in animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

/* Slide up animation */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-slide-up {
    animation: slideUp 0.4s ease-out forwards;
}

/* Bounce animation for buttons */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

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

/* Smooth dark mode transitions */
.transition-theme {
    transition: background-color 0.3s ease, 
                color 0.3s ease, 
                border-color 0.3s ease,
                box-shadow 0.3s ease;
}

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

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Dark mode scrollbar */
.dark ::-webkit-scrollbar-track {
    background: #1e293b;
}

.dark ::-webkit-scrollbar-thumb {
    background: #475569;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Drop zone active state */
.drop-zone-active {
    border-color: #3b82f6 !important;
    background-color: rgba(59, 130, 246, 0.1) !important;
}

.dark .drop-zone-active {
    background-color: rgba(59, 130, 246, 0.2) !important;
}

/* Viewer button active state */
.viewer-btn.active {
    background-color: #1d4ed8 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

/* Progress bar gradient animation */
@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.progress-bar-animated {
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #3b82f6);
    background-size: 200% 200%;
    animation: gradient-shift 2s ease infinite;
}

/* Focus visible styles for accessibility */
*:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Hide focus outline for mouse users */
*:focus:not(:focus-visible) {
    outline: none;
}

/* Prevent text selection on UI elements */
.no-select {
    user-select: none;
}

/* Glassmorphism effect */
.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.dark .glass {
    background: rgba(0, 0, 0, 0.2);
}

/* Mobile optimizations */
@media (max-width: 640px) {
    /* Larger touch targets on mobile */
    button, 
    input[type="file"]::-webkit-file-upload-button,
    a {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Prevent zoom on input focus in iOS */
    input[type="text"],
    input[type="number"],
    input[type="password"],
    select {
        font-size: 16px;
    }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print styles (hide interactive elements) */
@media print {
    .no-print {
        display: none !important;
    }
}

/* Layout fixes for viewer and downloads sections */
#viewerSection:not(.hidden),
#downloadsSection:not(.hidden) {
    width: 100%;
    position: relative;
    display: block;
}

#viewerContainer {
    position: relative;
    width: 100% !important;
    height: 320px !important;
    max-height: 320px !important;
    overflow: hidden !important;
    box-sizing: border-box;
}

#viewerContainer canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-height: 320px !important;
}

/* Ensure sections don't overflow */
#viewerSection > div,
#downloadsSection > div {
    width: 100%;
    box-sizing: border-box;
}

/* Hide viewer controls that might cause expansion */
#viewerSection .flex-wrap {
    flex-wrap: wrap;
}
