/* ============================================================
   media-thumbnail.css
   Scoped styles for the Media Thumbnail editor component.
   Placed alongside MediaThumbnail.razor in Tevarai.Base.Presentation
   ============================================================ */

/* --- Root wrapper ------------------------------------------ */
.media-thumbnail-wrapper {
    --thumb-radius: 6px;
    --thumb-border: 1px solid #e0e0e0;
    --thumb-bg: #f7f7f8;
    --thumb-icon-color: #8a8fa8;
    --thumb-text-color: #555;
    --thumb-shadow: 0 1px 4px rgba(0,0,0,0.08);
    --thumb-overlay-bg: rgba(15,15,20,0.55);
    --thumb-transition: 0.18s ease;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--thumb-radius);
    border: var(--thumb-border);
    background: var(--thumb-bg);
    box-shadow: var(--thumb-shadow);
    overflow: hidden;
    position: relative;
    transition: box-shadow var(--thumb-transition);
}

.media-thumbnail-wrapper:hover {
    box-shadow: 0 3px 10px rgba(0,0,0,0.13);
}

/* --- Sizes -------------------------------------------------- */
.media-thumb-sm {
    width: 48px;
    height: 48px;
    min-width: 48px;
}

.media-thumb-md {
    width: 80px;
    height: 80px;
    min-width: 80px;
}

.media-thumb-lg {
    width: 200px;
    height: 160px;
    min-width: 200px;
}

/* --- Skeleton / Loading ------------------------------------- */

.media-thumbnail-wrapper.is-loading {
    align-items: stretch;
    justify-content: stretch;
}

.media-thumbnail-skeleton {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #ececec;
}

.skeleton-shimmer {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255,255,255,0.55) 50%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
}

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

/* --- Image -------------------------------------------------- */
.media-thumbnail-image-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.media-thumbnail-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--thumb-transition);
}

.media-thumbnail-wrapper:hover .media-thumbnail-img {
    transform: scale(1.04);
}

/* Date overlay on images */
.media-thumbnail-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--thumb-overlay-bg);
    padding: 3px 5px;
    opacity: 0;
    transition: opacity var(--thumb-transition);
}

.media-thumbnail-wrapper:hover .media-thumbnail-overlay {
    opacity: 1;
}

.media-filename-overlay {
    font-size: 9px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

/* --- Placeholder (file icon) -------------------------------- */
.media-thumbnail-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 100%;
    height: 100%;
    padding: 8px;
    box-sizing: border-box;
}

.media-type-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--thumb-icon-color);
    transition: color var(--thumb-transition);
}

.media-thumbnail-wrapper:hover .media-type-icon {
    color: #5a6282;
}

/* Scale icon SVG relative to container */
.media-thumb-sm .media-type-icon svg  { width: 24px; height: 24px; }
.media-thumb-md .media-type-icon svg  { width: 36px; height: 36px; }
.media-thumb-lg .media-type-icon svg  { width: 52px; height: 52px; }

/* --- Date label --------------------------------------------- */
.media-filename {
    font-size: 9px;
    color: var(--thumb-text-color);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    display: block;
}

.media-thumb-sm .media-filename {
    display: none; /* too small for label */
}

/* --- Error state -------------------------------------------- */
.media-thumbnail-wrapper.has-error {
    border-color: #f5c2c7;
    background: #fff5f5;
}

.media-thumbnail-wrapper.has-error .media-type-icon {
    color: #c5808a;
}

.media-thumbnail-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 250px;
    aspect-ratio: 1;
    position: relative;
    border: 1px solid #ccc;
    border-radius: 8px;
    overflow: hidden;
    background-color: #f8f8f8;
    cursor: pointer;
}

.thumbnail-skeleton {
    width: 100%;
    height: 100%;
    background-color: #eee;
    position: relative;
    overflow: hidden;
}

.skeleton-shimmer {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

.thumbnail-placeholder,
.thumbnail-file {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #777;
    font-size: 2rem;
}

.thumbnail-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-thumbnail-wrapper {
    position: relative;
    width: 220px;
    height: 220px;
    border-radius: 12px;
    overflow: hidden;
    background: #f5f5f5;
    cursor: pointer;
}

.thumbnail-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    font-size: 28px;
    color: #888;
}

.thumbnail-file {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.file-overlay {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 6px;
    font-size: 12px;
    background: rgba(0,0,0,0.5);
    color: #fff;
}

.upload-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: all;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.progress-bar-container {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 6px;
    width: 100%;
    background: rgba(255,255,255,0.3);
    z-index: 15;
}

.progress-bar-fill {
    height: 100%;
    background: #0d6efd;
    transition: width 0.2s ease;
}

.media-actions {
    position: absolute;
    right: 8px;
    top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 20;
}

.media-gallery-actions {
    position: absolute;
    right: 50px;
    top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 20;
}

.media-thumbnail-actions {
    position: absolute;
    right: 5px;
    top: 5px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 20;
}

.media-btn.active,
.media-small-btn.active {
    background: var(--bs-primary) !important;
}
.media-small-btn {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.9);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
}

.media-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.9);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
}

    .media-btn:hover {
        transform: scale(1.1);
    }

    .media-btn.change {
        color: #0d6efd;
    }

    .media-btn.remove {
        color: #dc3545;
    }

.media-thumbnail-wrapper.is-uploading {
    pointer-events: none;
    opacity: 0.8;
}
.file-overlay,
.file-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    display: block;
    font-size: 0.85rem;
    text-align: center;
    pointer-events: none;
}

.thumbnail-image .file-overlay,
.thumbnail-placeholder .file-name,
.thumbnail-file .file-name {
    background-color: rgba(0, 0, 0, 0.5);
    color: #fff;
    padding: 6px;
    border-radius: 2px;
    margin-top: 4px;
}

.media-upload-btn {
    width: 80px;
    height: 80px;
    border: none;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}


/* --- Dark theme support (XAF Blazor dark mode) -------------- */
@media (prefers-color-scheme: dark) {
    .media-thumbnail-wrapper {
        --thumb-border: 1px solid #3a3a4a;
        --thumb-bg: #1e1e2a;
        --thumb-icon-color: #7a7f9a;
        --thumb-text-color: #aaa;
        --thumb-shadow: 0 1px 4px rgba(0,0,0,0.3);
    }

    .media-thumbnail-skeleton {
        background: #2a2a38;
    }

    .media-thumbnail-wrapper.has-error {
        border-color: #6b3040;
        background: #2a1a1e;
    }
}