/* 
 * File Upload Animations and Effects
 * For TapSavvyCards - Enhances the user experience during file uploads
 */

.file-upload-container {
    position: relative;
    width: 100%;
    margin: 20px 0;
    transition: all 0.3s ease;
}

.custom-file-upload {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 2px dashed #ccc;
    border-radius: 10px;
    background-color: #fafafa;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
    min-height: 120px;
}

.custom-file-upload:hover, .custom-file-upload.dragover {
    border-color: #4CAF50;
    background-color: rgba(76, 175, 80, 0.05);
}

.upload-animation {
    width: 100%;
    padding: 15px;
}

.upload-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 10px;
    isolation: isolate;
}

.upload-icon {
    font-size: 30px;
    margin-bottom: 10px;
    color: #666;
    transition: color 0.3s ease;
}

.upload-text {
    font-size: 14px;
    color: #666;
    transition: color 0.3s ease;
}

.upload-progress-bar {
    width: 100%;
    height: 5px;
    background-color: #e0e0e0;
    border-radius: 10px;
    margin: 10px 0;
    overflow: hidden;
    display: none;
}

.upload-progress {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    border-radius: 10px;
    transition: width 0.3s ease;
}

/* File preview styles */
.file-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.file-preview-item {
    flex: 0 0 calc(33.333% - 10px);
    min-width: 100px;
    max-width: 150px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: relative;
    background-color: #f5f5f5;
}

.image-preview {
    width: 100%;
    height: 120px;
    background-size: cover;
    background-position: center;
    position: relative;
}

.file-name {
    font-size: 11px;
    color: #fff;
    background: rgba(0,0,0,0.5);
    padding: 4px 8px;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-info {
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
}

.file-info i {
    font-size: 24px;
    margin-bottom: 10px;
    color: #555;
}

.file-info span {
    font-size: 12px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Reset button styling */
.file-reset-button {
    position: absolute;
    top: 10px;
    right: 10px;
    border: none;
    background: rgba(255,255,255,0.8);
    color: #f44336;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 5;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.file-reset-button:hover {
    background: rgba(255,255,255,1);
    opacity: 1;
    transform: scale(1.1);
}

/* Change existing image button */
.change-existing-image {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 8px 15px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.change-existing-image i {
    font-size: 14px;
}

.image-preview:hover .change-existing-image {
    opacity: 1;
}

/* Existing image styling */
.existing-image .image-preview::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.1), rgba(0,0,0,0.3));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.existing-image .image-preview:hover::before {
    opacity: 1;
}

/* Animation keyframes */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(76, 175, 80, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .file-preview-item {
        width: calc(50% - 5px);
        height: 100px;
    }
}

/* Status indicator colors for Bootstrap Icons */
.upload-icon.bi-check-circle {
    color: #4CAF50;
}

.upload-icon.bi-x-circle {
    color: #F44336;
}

/* Spinning animation for loading - Fixed animation implementation */
.upload-icon.spinning {
    animation: spin 1.5s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Additional animation for when file is being processed */
.processing .upload-icon {
    animation: spin 1.5s linear infinite;
}

/* Theme-specific adjustments */
body.dark-mode .custom-file-upload {
    background-color: #333;
    border-color: #555;
}

body.dark-mode .upload-text,
body.dark-mode .upload-icon {
    color: #ddd;
}

body.dark-mode .file-info {
    background-color: #333;
}

body.dark-mode .file-info i,
body.dark-mode .file-info span {
    color: #ddd;
}

/* Fix for mobile Safari and other browsers that might have issues with the spinning animation */
@supports (-webkit-touch-callout: none) {
    .upload-icon.spinning,
    .processing .upload-icon {
        animation: webkit-spin 1.5s linear infinite;
    }
    
    @keyframes webkit-spin {
        0% { -webkit-transform: rotate(0deg); }
        100% { -webkit-transform: rotate(360deg); }
    }
}