/*
 * Media Library Styles
 *
 * Custom styles for the media manager/library interface.
 * Includes modal, image grid, upload zone, and media picker widget styles.
 */

/* Media Browser Modal */
.media-modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.media-modal-container {
    background: white;
    border-radius: 0.5rem;
    max-width: 1200px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.media-modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.media-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.media-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Image Grid */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.image-card {
    cursor: pointer;
}

.image-card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.media-grid-item {
    position: relative;
    aspect-ratio: 1;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
}

.media-grid-item:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
}

.media-grid-item.selected {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.media-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-grid-item-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 0.75rem;
}

.media-grid-item:hover .media-grid-item-overlay {
    opacity: 1;
}

.media-grid-item-info {
    color: white;
    font-size: 0.75rem;
}

/* Media Picker Widget */
.media-picker-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.media-picker-preview {
    width: 150px;
    height: 150px;
    border: 2px dashed #d1d5db;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background-color: #f9fafb;
    overflow: hidden;
}

.media-picker-preview.has-image {
    border-style: solid;
    border-color: #e5e7eb;
    padding: 0;
}

.media-picker-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-picker-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.media-picker-filename {
    font-size: 0.875rem;
    color: #6b7280;
    word-break: break-word;
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed #d1d5db;
    border-radius: 0.5rem;
    padding: 3rem;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
}

.upload-zone:hover {
    border-color: #3b82f6;
    background-color: #eff6ff;
}

.upload-zone.dragover {
    border-color: #3b82f6;
    background-color: #dbeafe;
}

.upload-preview-item {
    position: relative;
    display: inline-block;
    margin: 0.5rem;
}

.upload-preview-item img {
    width: 96px;
    height: 96px;
    object-cover;
    border-radius: 0.5rem;
    border: 2px solid #e5e7eb;
}

.upload-preview-loading {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
}

/* Progress Bar */
.upload-progress {
    width: 100%;
    height: 0.625rem;
    background-color: #e5e7eb;
    border-radius: 9999px;
    overflow: hidden;
}

.upload-progress-bar {
    height: 100%;
    background-color: #3b82f6;
    transition: width 0.3s ease;
}

/* Checkbox Overlay */
.media-checkbox-overlay {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 10;
}

.media-checkbox {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 0.25rem;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* FrankenUI transitions handle hover effects now */

/* Utility classes needed for media cards */
.z-10 {
    z-index: 10;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .media-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.75rem;
    }

    .media-modal-container {
        max-height: 95vh;
    }

    .media-modal-body {
        padding: 1rem;
    }

    .upload-zone {
        padding: 2rem 1rem;
    }
}

/* Animation utilities */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

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

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