/**
 * Community Uploads Styles
 *
 * Styles for photo and video uploads in community posts.
 * Follows WordPress coding standards and CodeCanyon quality requirements.
 *
 * @package Videohub360_Theme
 * @since 1.0.0
 */

/* ==========================================================================
   CSS Custom Properties (Design System Variables)
   ========================================================================== */

:root {
    --vh360-upload-border-radius: 8px;
    --vh360-upload-transition: all 0.2s ease-in-out;
    --vh360-upload-bg: #f8f9fa;
    --vh360-upload-border: #e1e4e8;
    --vh360-upload-text: #24292e;
    --vh360-upload-muted: #6a737d;
    --vh360-upload-error: #d73a49;
    --vh360-upload-success: #22863a;
    --vh360-upload-primary: #0366d6;
}

/* ==========================================================================
   Upload Preview Container
   ========================================================================== */

.vh360-upload-preview {
    position: relative;
    margin: 12px 0;
    padding: 12px;
    background-color: var(--vh360-upload-bg);
    border: 1px solid var(--vh360-upload-border);
    border-radius: var(--vh360-upload-border-radius);
    display: flex;
    align-items: center;
    gap: 12px;
}

.vh360-upload-preview[style*="display: none"] {
    display: none;
}

/* ==========================================================================
   Preview Image/Video Icon
   ========================================================================== */

.vh360-preview-image {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    overflow: hidden;
    border-radius: 4px;
    background-color: var(--vh360-upload-border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.vh360-preview-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.vh360-video-icon {
    font-size: 32px;
    color: var(--vh360-upload-muted);
    line-height: 1;
}

/* ==========================================================================
   File Name Display
   ========================================================================== */

.vh360-file-name {
    flex: 1;
    font-size: 14px;
    color: var(--vh360-upload-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* ==========================================================================
   Remove Upload Button
   ========================================================================== */

.vh360-remove-upload {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background-color: var(--vh360-upload-border);
    color: var(--vh360-upload-text);
    font-size: 18px;
    line-height: 26px;
    text-align: center;
    cursor: pointer;
    transition: var(--vh360-upload-transition);
}

.vh360-remove-upload:hover,
.vh360-remove-upload:focus {
    background-color: var(--vh360-upload-error);
    color: #fff;
    outline: none;
}

.vh360-remove-upload:focus {
    box-shadow: 0 0 0 2px rgba(215, 58, 73, 0.3);
}

/* ==========================================================================
   Media Label Styling
   ========================================================================== */

.vh360-post-media-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--vh360-upload-border-radius);
    transition: var(--vh360-upload-transition);
    color: var(--vh360-upload-text);
    font-size: 14px;
}

.vh360-post-media-label:hover {
    background-color: var(--vh360-upload-bg);
}

.vh360-post-media-label input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.vh360-post-media-label input[type="file"]:focus + span {
    outline: 2px solid var(--vh360-upload-primary);
    outline-offset: 2px;
}

/* ==========================================================================
   Video Container and Player
   ========================================================================== */

.vh360-community-video {
    margin-top: 12px;
    border-radius: var(--vh360-upload-border-radius);
    overflow: hidden;
    background-color: #000;
}

.vh360-video-player {
    display: block;
    width: 100%;
    max-height: 500px;
    background-color: #000;
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.vh360-form-submitting {
    pointer-events: none;
    opacity: 0.7;
}

.vh360-btn-loading {
    position: relative;
    color: transparent;
}

.vh360-btn-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    margin-left: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: vh360-spin 0.6s linear infinite;
}

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

/* ==========================================================================
   Error Message Styling
   ========================================================================== */

.vh360-upload-error {
    padding: 12px 16px;
    margin: 12px 0;
    background-color: rgba(215, 58, 73, 0.1);
    border: 1px solid var(--vh360-upload-error);
    border-radius: var(--vh360-upload-border-radius);
    color: var(--vh360-upload-error);
    font-size: 14px;
}

/* ==========================================================================
   Admin Checkbox Styling (inline)
   ========================================================================== */

.vh360-checkbox-inline {
    display: inline-block;
    margin-right: 16px;
    margin-bottom: 8px;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media screen and (max-width: 600px) {
    .vh360-upload-preview {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
    }

    .vh360-preview-image {
        width: 100%;
        height: auto;
        aspect-ratio: 16 / 9;
    }

    .vh360-file-name {
        width: 100%;
    }

    .vh360-remove-upload {
        position: absolute;
        top: 8px;
        right: 8px;
    }

    .vh360-video-player {
        max-height: 280px;
    }
}

@media screen and (max-width: 480px) {
    .vh360-post-media-label span {
        display: none;
    }

    .vh360-post-media-label::before {
        content: "📷";
        font-size: 18px;
    }
}

/* ==========================================================================
   Dark Mode Support (if theme supports it)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    :root {
        --vh360-upload-bg: #21262d;
        --vh360-upload-border: #30363d;
        --vh360-upload-text: #c9d1d9;
        --vh360-upload-muted: #8b949e;
    }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

/* Ensure focus states are visible */
.vh360-media-upload:focus-visible + span,
.vh360-remove-upload:focus-visible {
    outline: 2px solid var(--vh360-upload-primary);
    outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .vh360-btn-loading::after {
        animation: none;
    }

    .vh360-remove-upload,
    .vh360-post-media-label {
        transition: none;
    }
}

/* ==========================================================================
   Image Lightbox
   ========================================================================== */

.vh360-image-lightbox {
    display: block;
    cursor: pointer;
}

.vh360-image-lightbox img {
    transition: opacity 0.2s ease-in-out;
}

.vh360-image-lightbox:hover img {
    opacity: 0.9;
}

.vh360-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.vh360-lightbox-overlay.vh360-lightbox-active {
    display: flex;
}

.vh360-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 28px;
    line-height: 40px;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
    z-index: 1000000;
}

.vh360-lightbox-close:hover,
.vh360-lightbox-close:focus {
    background-color: rgba(255, 255, 255, 0.2);
    outline: none;
}

.vh360-lightbox-close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.vh360-lightbox-content {
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vh360-lightbox-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
}

/* Prevent body scroll when lightbox is open */
body.vh360-lightbox-open {
    overflow: hidden;
}

/* Responsive lightbox */
@media screen and (max-width: 600px) {
    .vh360-lightbox-overlay {
        padding: 10px;
    }

    .vh360-lightbox-close {
        top: 10px;
        right: 10px;
        width: 36px;
        height: 36px;
        font-size: 24px;
        line-height: 32px;
    }
}
