/**
 * Photo Upload Component Styles
 * Campyon - Generic Photo Manager (Feature 004)
 *
 * This stylesheet provides additional styling for the photo upload component
 * beyond what Tailwind CSS provides inline. It includes styles for:
 * - Drag-drop zones with enhanced visual feedback
 * - Cropper.js integration
 * - Upload progress indicators
 * - Photo preview displays
 * - Error and success messages
 */

/* ============================================================================
   Upload Area - Drag & Drop Zone
   ============================================================================ */

/**
 * Base upload area styling
 * Enhanced border animation on hover
 */
.photo-upload-area {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.photo-upload-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.photo-upload-area:hover::before {
    opacity: 0.05;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

/**
 * Active drag-over state
 * Applied when file is being dragged over the drop zone
 */
.photo-upload-area.drag-over {
    border-color: #3b82f6 !important;
    background-color: #eff6ff !important;
    transform: scale(1.02);
}

.photo-upload-area.drag-over::before {
    opacity: 0.1;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

/**
 * Upload icon pulse animation
 */
@keyframes upload-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

.photo-upload-area.drag-over svg {
    animation: upload-pulse 1.5s ease-in-out infinite;
}

/* ============================================================================
   Cropper Container
   ============================================================================ */

/**
 * Cropper.js wrapper container
 * Ensures proper aspect ratio and responsive behavior
 */
.photo-cropper-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    background-color: #f9fafb;
    border-radius: 0.5rem;
    overflow: hidden;
}

/**
 * Cropper canvas adjustments
 * Improves mobile responsiveness
 */
.photo-cropper-container .cropper-container {
    max-height: 70vh;
    margin: 0 auto;
}

.photo-cropper-container img {
    max-width: 100%;
    display: block;
}

/**
 * Cropper.js custom styling overrides
 */
.cropper-view-box {
    outline: 2px solid rgba(255, 255, 255, 0.75);
    outline-offset: -1px;
}

.cropper-face {
    background-color: transparent !important;
}

.cropper-dashed {
    border-color: rgba(255, 255, 255, 0.5);
}

.cropper-line {
    background-color: rgba(59, 130, 246, 0.5);
}

.cropper-point {
    background-color: #3b82f6;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.cropper-point.point-se {
    width: 12px;
    height: 12px;
    opacity: 1;
}

/* ============================================================================
   Photo Preview
   ============================================================================ */

/**
 * Preview container with fade-in animation
 */
.photo-preview {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/**
 * Current photo display with hover effects
 */
.photo-display-image {
    transition: all 0.3s ease;
    will-change: transform;
}

.photo-display-image:hover {
    transform: scale(1.02);
}

/**
 * Photo overlay gradient (for action buttons)
 */
.photo-overlay-gradient {
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, 0.7) 100%
    );
}

/* ============================================================================
   Upload Progress Indicator
   ============================================================================ */

/**
 * Progress bar container
 */
.upload-progress {
    position: relative;
    height: 4px;
    background-color: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 1rem;
}

/**
 * Progress bar fill with animation
 */
.upload-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/**
 * Indeterminate progress animation
 * Used when upload progress cannot be determined
 */
@keyframes progress-indeterminate {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(400%);
    }
}

.upload-progress-indeterminate {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 25%;
    background: linear-gradient(90deg, transparent, #3b82f6, transparent);
    animation: progress-indeterminate 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

/**
 * Upload spinner
 */
.upload-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: spinner-rotate 0.6s linear infinite;
}

@keyframes spinner-rotate {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================================================
   Error & Success Messages
   ============================================================================ */

/**
 * Error message container
 */
.photo-error-message {
    animation: slideInFromTop 0.3s ease-out;
    border-left: 4px solid #ef4444;
}

@keyframes slideInFromTop {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/**
 * Success message container
 */
.photo-success-message {
    animation: slideInFromTop 0.3s ease-out;
    border-left: 4px solid #10b981;
}

/**
 * Message icon pulse
 */
.message-icon-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* ============================================================================
   Mobile Optimizations
   ============================================================================ */

/**
 * Mobile-specific adjustments for better touch interaction
 */
@media (max-width: 768px) {
    .photo-cropper-container {
        max-width: 100%;
    }

    .photo-cropper-container .cropper-container {
        max-height: 50vh;
    }

    .photo-upload-area {
        padding: 2rem 1rem !important;
    }

    .cropper-point {
        width: 20px !important;
        height: 20px !important;
    }

    .cropper-point.point-se {
        width: 24px !important;
        height: 24px !important;
    }
}

/* ============================================================================
   Accessibility Enhancements
   ============================================================================ */

/**
 * Focus visible styles for keyboard navigation
 */
.photo-upload-area:focus-within {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/**
 * Reduced motion preference
 */
@media (prefers-reduced-motion: reduce) {
    .photo-upload-area,
    .photo-upload-area::before,
    .photo-preview,
    .photo-display-image,
    .upload-progress-bar,
    .photo-error-message,
    .photo-success-message {
        animation: none !important;
        transition: none !important;
    }

    .photo-upload-area.drag-over {
        transform: none;
    }

    .photo-display-image:hover {
        transform: none;
    }
}

/* ============================================================================
   Loading States
   ============================================================================ */

/**
 * Loading overlay for upload operations
 */
.photo-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    border-radius: 0.5rem;
}

.photo-loading-text {
    margin-top: 1rem;
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
}

/* ============================================================================
   File Type Icons
   ============================================================================ */

/**
 * Visual indicators for accepted file types
 */
.file-type-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    background-color: #f3f4f6;
    color: #6b7280;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    margin: 0 0.25rem;
}

.file-type-badge.accepted {
    background-color: #d1fae5;
    color: #065f46;
}

/* ============================================================================
   Utility Classes
   ============================================================================ */

/**
 * Alpine.js x-cloak helper
 * Hides elements until Alpine initializes
 */
[x-cloak] {
    display: none !important;
}

/**
 * Aspect ratio container for photo previews
 */
.photo-aspect-ratio-1-1 {
    aspect-ratio: 1 / 1;
    width: 100%;
}

.photo-aspect-ratio-16-9 {
    aspect-ratio: 16 / 9;
    width: 100%;
}

.photo-aspect-ratio-4-3 {
    aspect-ratio: 4 / 3;
    width: 100%;
}

/**
 * Object-fit utilities for images
 */
.photo-cover {
    object-fit: cover;
    width: 100%;
    height: 100%;
}

.photo-contain {
    object-fit: contain;
    width: 100%;
    height: 100%;
}
