/* Profile Flare Management Styles */

/* ==========================================================================
   Sitewide avatar/banner decoration (used by widgets/ProfileFlareImage.php
   and widgets/ProfileFlareBannerImage.php, rendered anywhere a user's
   picture or banner is shown across HumHub, not just this module's own
   management page)
   ========================================================================== */

.profile-image-container {
    display: inline-block;
    position: relative;
}

.profile-flare-wrapper {
    position: relative !important;
    display: inline-block !important;
}

.profile-flare-wrapper .profile-image,
.profile-image-container .profile-image,
.profile-image-container img.img-square,
.img-squared {
    display: block !important;
    object-fit: cover !important;
    position: relative;
    z-index: 1;
}

.profile-flare-banner-wrapper {
    overflow: hidden;
}

/* Defensive: the flare overlay below is position:absolute and needs this as
   its containing block. Core's own ContainerHeaderAsset CSS likely already
   sets this (given the existing image-upload-loader is already positioned
   within it), but redeclaring the same value here is harmless either way. */
.image-upload-container {
    position: relative;
}

.profile-flare-wrapper .flare-overlay,
.profile-flare-banner-wrapper .flare-overlay,
.image-upload-container .flare-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    pointer-events: none !important;
    z-index: 2 !important;
    overflow: hidden;
    object-fit: cover !important;
    display: block !important;
}

.profile-flare-wrapper .flare-overlay img,
.profile-flare-banner-wrapper .flare-overlay img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}

/* Shape (border-radius) for the profile-picture flare overlay is intentionally
   NOT set here. The widget applies the same shape-related classes as the
   underlying avatar image, allowing the active HumHub theme to determine
   whether the avatar is square, rounded, circular, etc. */

/* Online status positioning: intentionally no rule here. The widget
   (widgets/ProfileFlareImage.php::renderOnlineStatus()) sets the appropriate
   position, bottom/right offsets and z-index per avatar size. */

/* Keep profile image upload controls and loader above the flare overlay. */
.image-upload-container .image-upload-buttons,
.image-upload-container .image-upload-loader {
    z-index: 3;
}

.media-object.img-square,
.img-square,
.profile-image-container img {
    object-fit: cover !important;
}

/* GIF/WebP loading state, set by resources/js/profileflare.js */
img.gif-loading {
    opacity: 0.7;
    transition: opacity 0.2s ease;
}


/* ==========================================================================
   Management page (views/manage/index.php + _flareSection.php)
   ========================================================================== */

/*
 * Bootstrap 5.2-compatible semantic colors.
 *
 * Bootstrap 5.2 does not provide the data-bs-theme color-mode variables that
 * Bootstrap 5.3 introduced. These variables therefore provide a small,
 * self-contained compatibility layer while allowing HumHub themes using
 * data-bs-theme="dark" to switch the management interface automatically.
 */

.profile-flare-tab-content {
    padding-top: 15px;
}

.flare-list-row {
    margin-top: 20px;
}


/* ==========================================================================
   Upload area
   ========================================================================== */

.flare-upload {
    margin-bottom: 20px;
}

.flare-upload .flare-file-input {
    display: none;
}

.flare-upload .upload-area {
    display: block;
    text-align: center;
    padding: 20px;
    border: 2px dashed var(--profileflare-border-color, #ccc);
    border-radius: 8px;
    background-color: var(--profileflare-upload-bg, #f9f9f9);
    color: var(--profileflare-text-color, #212529);
    cursor: pointer;
    transition:
        border-color 0.3s ease,
        background-color 0.3s ease,
        color 0.3s ease;
}

.flare-upload .upload-area:hover {
    border-color: var(--profileflare-primary-color, #337ab7);
    background-color: var(--profileflare-upload-hover-bg, #e3f2fd);
}

.flare-upload .upload-area.dragover {
    border-color: var(--profileflare-success-color, #5cb85c);
    background-color: var(--profileflare-upload-drag-bg, #f0fff0);
}

.flare-upload .upload-instructions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.flare-upload .upload-icon {
    font-size: 24px;
    color: var(--profileflare-primary-color, #337ab7);
    margin-bottom: 10px;
}

.flare-upload .upload-select-btn {
    margin-bottom: 10px;
}

.flare-upload .upload-help {
    margin-top: 5px;
    text-align: center;
}

.flare-upload .upload-preview {
    margin-top: 10px;
    text-align: center;
}

.flare-upload .upload-preview img {
    max-width: 100px;
    max-height: 100px;
    border-radius: 4px;
    border: 1px solid var(--profileflare-border-color, #ddd);
}

.flare-upload .upload-message {
    margin-top: 10px;
}

.flare-upload-submit {
    margin-top: 10px;
}


/* ==========================================================================
   Active flare preview
   ========================================================================== */

.flare-active-preview {
    margin-top: 15px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.active-flare-container {
    position: relative;
    display: inline-block;
}

.active-flare-container img {
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--profileflare-shadow-color, rgba(0, 0, 0, 0.1));
}

.flare-thumbnail.animated-flare,
.active-flare-image.animated-flare {
    outline: 2px solid var(--profileflare-primary-rgb, rgba(0, 123, 255, 0.4));
    outline-offset: 2px;
}

.animated-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--profileflare-badge-bg, rgba(0, 123, 255, 0.9));
    color: #fff;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
}

.no-flare-message,
.no-flares-message {
    text-align: center;
    padding: 30px;
    color: var(--profileflare-muted-color, #999);
}

.no-flare-message i,
.no-flares-message i {
    font-size: 48px;
    color: var(--profileflare-icon-muted-color, #ccc);
    display: block;
    margin-bottom: 10px;
}

.no-flares-message i {
    font-size: 20px;
    display: inline;
    margin-right: 5px;
    margin-bottom: 0;
}


/* ==========================================================================
   Flare list
   ========================================================================== */

.flare-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.flare-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    border: 1px solid var(--profileflare-border-color, #ddd);
    border-radius: 8px;
    background-color: var(--profileflare-item-bg, #fff);
    color: var(--profileflare-text-color, #212529);
    transition:
        box-shadow 0.3s ease,
        border-color 0.3s ease,
        background-color 0.3s ease,
        color 0.3s ease;
    animation: profileflare-fade-in 0.3s ease;
}

.flare-item:hover {
    box-shadow: 0 2px 8px var(--profileflare-shadow-hover-color, rgba(0, 0, 0, 0.1));
    border-color: var(--profileflare-primary-color, #007bff);
}

.flare-item .flare-preview {
    flex: 0 0 80px;
    text-align: center;
}

.flare-image-container {
    position: relative;
    display: inline-block;
}

.flare-item .flare-thumbnail {
    border-radius: 4px;
}

.flare-item .no-image {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--profileflare-no-image-bg, #f8f9fa);
    border: 1px solid var(--profileflare-no-image-border, #dee2e6);
    border-radius: 4px;
}

.flare-item .no-image i {
    font-size: 24px;
    color: var(--profileflare-icon-muted-color, #ccc);
}

.format-badge {
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 3px;
    color: #fff;
}

.format-badge.animated-format {
    background: var(--profileflare-badge-bg, rgba(0, 123, 255, 0.9));
}

.format-badge.static-format {
    background: var(--profileflare-static-badge-bg, rgba(108, 117, 125, 0.9));
}

.flare-item .flare-info {
    flex: 1;
    min-width: 0;
}

.flare-item .flare-filename {
    margin-bottom: 5px;
    word-wrap: break-word;
}

.flare-item .flare-type,
.flare-item .flare-status {
    margin-bottom: 5px;
}

.flare-item .flare-date {
    margin-bottom: 0;
}

.animated-indicator {
    margin-left: 5px;
    color: var(--profileflare-primary-color, #337ab7);
}

.flare-item .flare-actions {
    flex: 0 0 auto;
    display: flex;
    gap: 5px;
    flex-direction: column;
}

.flare-action-form {
    display: inline-block;
}

.flare-action-form-delete {
    margin-left: 0;
}

.flare-item .flare-actions .btn {
    white-space: nowrap;
    min-width: 80px;
}


/* ==========================================================================
   Responsive adjustments
   ========================================================================== */

@media (max-width: 768px) {
    .flare-item {
        flex-direction: column;
        text-align: center;
    }

    .flare-item .flare-preview {
        flex: none;
        margin-bottom: 10px;
    }

    .flare-item .flare-info {
        margin-bottom: 10px;
    }

    .flare-item .flare-actions {
        flex-direction: row;
        justify-content: center;
    }

    .flare-upload .upload-area {
        padding: 15px;
    }
}

@media (max-width: 576px) {
    .flare-item .flare-actions .btn {
        min-width: 60px;
        padding: 5px 10px;
        font-size: 12px;
    }
}


/* ==========================================================================
   Light theme
   ========================================================================== */

:root,
[data-bs-theme="light"] {
    --profileflare-text-color: #212529;

    --profileflare-primary-color: #337ab7;
    --profileflare-primary-rgb: rgba(0, 123, 255, 0.4);

    --profileflare-success-color: #5cb85c;

    --profileflare-border-color: #ddd;

    --profileflare-upload-bg: #f9f9f9;
    --profileflare-upload-hover-bg: #e3f2fd;
    --profileflare-upload-drag-bg: #f0fff0;

    --profileflare-item-bg: #fff;

    --profileflare-no-image-bg: #f8f9fa;
    --profileflare-no-image-border: #dee2e6;

    --profileflare-muted-color: #999;
    --profileflare-icon-muted-color: #ccc;

    --profileflare-badge-bg: rgba(0, 123, 255, 0.9);
    --profileflare-static-badge-bg: rgba(108, 117, 125, 0.9);

    --profileflare-shadow-color: rgba(0, 0, 0, 0.1);
    --profileflare-shadow-hover-color: rgba(0, 0, 0, 0.1);
}


/* ==========================================================================
   Dark theme
   ========================================================================== */

[data-bs-theme="dark"] {
    --profileflare-text-color: #dee2e6;

    --profileflare-primary-color: #6ea8fe;
    --profileflare-primary-rgb: rgba(110, 168, 254, 0.45);

    --profileflare-success-color: #75b798;

    --profileflare-border-color: #495057;

    --profileflare-upload-bg: #212529;
    --profileflare-upload-hover-bg: #1f3347;
    --profileflare-upload-drag-bg: #1d3325;

    --profileflare-item-bg: #212529;

    --profileflare-no-image-bg: #343a40;
    --profileflare-no-image-border: #495057;

    --profileflare-muted-color: #adb5bd;
    --profileflare-icon-muted-color: #6c757d;

    --profileflare-badge-bg: rgba(13, 110, 253, 0.9);
    --profileflare-static-badge-bg: rgba(108, 117, 125, 0.9);

    --profileflare-shadow-color: rgba(0, 0, 0, 0.35);
    --profileflare-shadow-hover-color: rgba(0, 0, 0, 0.5);
}


/* ==========================================================================
   Dark theme fallback
   ========================================================================== */

/*
 * Some HumHub/theme configurations may expose dark mode through a parent
 * element rather than directly on <html>. Keeping this selector allows the
 * module to follow the same Bootstrap-style attribute when it is inherited
 * from a higher-level theme container.
 */
.dark [data-bs-theme="dark"] .flare-item,
.dark [data-bs-theme="dark"] .flare-upload .upload-area,
.dark [data-bs-theme="dark"] .flare-item .no-image {
    color: var(--profileflare-text-color);
    background-color: var(--profileflare-item-bg);
}


/* ==========================================================================
   Animation
   ========================================================================== */

@keyframes profileflare-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}