/**
 * Gallery Dashboard Styles
 *
 * Styles for gallery management in the frontend dashboard.
 *
 * @package Videohub360_Theme
 * @since 1.2.0
 */

/* ==========================================================================
   Gallery Stats
   ========================================================================== */

.vh360-gallery-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.vh360-gallery-stats .vh360-dashboard-widget {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.vh360-gallery-stats .vh360-dashboard-widget-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
}

.vh360-gallery-stats .vh360-dashboard-widget-label {
    font-size: 0.875rem;
    color: var(--text-light);
}

.vh360-gallery-stats .vh360-dashboard-widget-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
}

/* ==========================================================================
   Gallery Grid
   ========================================================================== */

.vh360-galleries-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.vh360-gallery-card {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: var(--transition);
}

.vh360-gallery-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.vh360-gallery-card-cover {
    position: relative;
    width: 100%;
    padding-bottom: 66.67%;
    background: var(--bg-light);
    overflow: hidden;
}

.vh360-gallery-card-cover img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.vh360-gallery-card:hover .vh360-gallery-card-cover img {
    transform: scale(1.05);
}

.vh360-gallery-card-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
}

.vh360-gallery-card-count {
    position: absolute;
    bottom: 0.75rem;
    right: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.vh360-gallery-card-status {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
}

.vh360-gallery-card-status-draft {
    background: var(--warning-color);
    color: #fff;
}

.vh360-gallery-card-status-pending {
    background: var(--info-color);
    color: #fff;
}

.vh360-gallery-card-actions {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: var(--transition);
}

.vh360-gallery-card:hover .vh360-gallery-card-actions {
    opacity: 1;
}

.vh360-gallery-action {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-color);
    text-decoration: none;
}

.vh360-gallery-action:hover {
    background: #fff;
    transform: scale(1.1);
}

.vh360-gallery-delete:hover {
    background: var(--error-color);
    color: #fff;
}

.vh360-gallery-card-info {
    padding: 1rem;
}

.vh360-gallery-card-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vh360-gallery-card-date {
    font-size: 0.8125rem;
    color: var(--text-light);
}

/* ==========================================================================
   Gallery Modal
   ========================================================================== */

.vh360-gallery-modal {
    z-index: 10000;
}

/* Ensure gallery modal inherits proper visibility behavior */
.vh360-gallery-modal:not(.show) {
    visibility: hidden;
    pointer-events: none;
}

.vh360-gallery-modal.show {
    display: flex;
    visibility: visible;
    pointer-events: auto;
}

.vh360-gallery-modal-content {
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--bg-color);
    border-radius: var(--border-radius);
    position: relative;
}

.vh360-gallery-modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.vh360-gallery-modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.vh360-gallery-form {
    padding: 1.5rem;
}

.vh360-gallery-form-section {
    margin-bottom: 1.25rem;
}

.vh360-gallery-form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.vh360-gallery-form-half {
    flex: 1;
}

.vh360-gallery-form-third {
    flex: 1;
}

.vh360-form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.vh360-form-label .required {
    color: var(--error-color);
}

.vh360-form-input,
.vh360-form-textarea,
.vh360-form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--bg-color);
    color: var(--text-color);
}

.vh360-form-input:focus,
.vh360-form-textarea:focus,
.vh360-form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.vh360-form-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.vh360-form-checkbox input {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.vh360-gallery-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    margin-top: 1rem;
}

/* ==========================================================================
   Dropzone
   ========================================================================== */

.vh360-gallery-dropzone {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    background: var(--bg-light);
    cursor: pointer;
    transition: var(--transition);
}

.vh360-gallery-dropzone:hover,
.vh360-gallery-dropzone.dz-drag-hover {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.vh360-dropzone-message {
    color: var(--text-light);
}

.vh360-dropzone-message svg {
    margin-bottom: 1rem;
    color: var(--text-light);
}

.vh360-dropzone-message p {
    font-size: 1rem;
    margin: 0 0 0.5rem;
    color: var(--text-color);
}

.vh360-dropzone-hint {
    font-size: 0.8125rem;
    color: var(--text-light);
}

/* Form hint text */
.vh360-form-hint {
    font-size: 0.8125rem;
    color: var(--text-light);
    margin: 0.5rem 0;
    font-style: italic;
}

/* ==========================================================================
   Image Preview Grid
   ========================================================================== */

.vh360-gallery-images-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
    min-height: 0;
}

.vh360-preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-light);
    cursor: move;
}

.vh360-preview-item.uploading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    z-index: 1;
}

.vh360-preview-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: vh360-spin 1s linear infinite;
    z-index: 2;
}

.vh360-preview-item:not(.uploading) .vh360-preview-loading {
    display: none;
}

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

.vh360-preview-image {
    width: 100%;
    height: 100%;
}

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

.vh360-preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    opacity: 0;
    transition: var(--transition);
}

.vh360-preview-item:hover .vh360-preview-overlay {
    opacity: 1;
}

.vh360-preview-cover,
.vh360-preview-remove {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.vh360-preview-cover {
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-color);
}

.vh360-preview-cover:hover {
    background: #fff;
    color: var(--warning-color);
}

.vh360-preview-remove {
    background: rgba(239, 68, 68, 0.9);
    color: #fff;
}

.vh360-preview-remove:hover {
    background: var(--error-color);
}

.vh360-preview-item.is-cover {
    box-shadow: 0 0 0 3px var(--warning-color);
}

.vh360-preview-item.is-cover::before {
    content: 'Cover';
    position: absolute;
    top: 4px;
    left: 4px;
    background: var(--warning-color);
    color: #fff;
    font-size: 0.625rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    z-index: 2;
    text-transform: uppercase;
}

.vh360-preview-item.is-cover .vh360-preview-cover {
    color: var(--warning-color);
}

/* Sortable states */
.vh360-preview-ghost {
    opacity: 0.4;
}

.vh360-preview-chosen {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.vh360-preview-drag {
    opacity: 0.9;
}

/* ==========================================================================
   Gallery Grid Display Columns
   ========================================================================== */

.vh360-gallery-cols-1 .vh360-gallery-grid {
    grid-template-columns: 1fr;
}

.vh360-gallery-cols-2 .vh360-gallery-grid {
    grid-template-columns: repeat(2, 1fr);
}

.vh360-gallery-cols-3 .vh360-gallery-grid {
    grid-template-columns: repeat(3, 1fr);
}

.vh360-gallery-cols-4 .vh360-gallery-grid {
    grid-template-columns: repeat(4, 1fr);
}

.vh360-gallery-cols-5 .vh360-gallery-grid {
    grid-template-columns: repeat(5, 1fr);
}

.vh360-gallery-cols-6 .vh360-gallery-grid {
    grid-template-columns: repeat(6, 1fr);
}

/* ==========================================================================
   Gallery Card (Shortcode Grid)
   ========================================================================== */

.vh360-gallery-grid-shortcode {
    display: grid;
    gap: 1.5rem;
}

.vh360-gallery-grid-shortcode.vh360-gallery-cols-1 {
    grid-template-columns: 1fr;
}

.vh360-gallery-grid-shortcode.vh360-gallery-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.vh360-gallery-grid-shortcode.vh360-gallery-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.vh360-gallery-grid-shortcode.vh360-gallery-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

.vh360-gallery-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.vh360-gallery-card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, transparent 50%, rgba(0, 0, 0, 0.3) 100%);
    opacity: 0;
    transition: var(--transition);
}

.vh360-gallery-card:hover .vh360-gallery-card-overlay {
    opacity: 1;
}

.vh360-gallery-card-author {
    font-size: 0.8125rem;
    color: var(--text-light);
}

/* ==========================================================================
   Simple Lightbox Fallback
   ========================================================================== */

.vh360-simple-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vh360-simple-lightbox-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
}

.vh360-simple-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.vh360-simple-lightbox-image {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
}

.vh360-simple-lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 1.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

.vh360-simple-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.vh360-simple-lightbox-prev,
.vh360-simple-lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 1.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

.vh360-simple-lightbox-prev {
    left: -60px;
}

.vh360-simple-lightbox-next {
    right: -60px;
}

.vh360-simple-lightbox-prev:hover,
.vh360-simple-lightbox-next:hover {
    background: rgba(255, 255, 255, 0.3);
}

.vh360-simple-lightbox-caption {
    color: #fff;
    padding: 1rem;
    text-align: center;
    max-width: 600px;
}

/* ==========================================================================
   Modal Open State
   ========================================================================== */

body.vh360-modal-open {
    overflow: hidden;
}

/* ==========================================================================
   Responsive Styles
   ========================================================================== */

@media (max-width: 768px) {
    .vh360-gallery-stats {
        grid-template-columns: 1fr 1fr;
    }

    .vh360-galleries-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 1rem;
    }

    .vh360-gallery-form-row {
        flex-direction: column;
    }

    .vh360-gallery-modal-content {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
    }

    .vh360-gallery-images-preview {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }

    .vh360-gallery-grid-shortcode.vh360-gallery-cols-4,
    .vh360-gallery-grid-shortcode.vh360-gallery-cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .vh360-simple-lightbox-prev,
    .vh360-simple-lightbox-next {
        display: none;
    }
}

@media (max-width: 480px) {
    .vh360-gallery-stats {
        grid-template-columns: 1fr;
    }

    .vh360-galleries-grid {
        grid-template-columns: 1fr;
    }

    .vh360-gallery-grid-shortcode.vh360-gallery-cols-2,
    .vh360-gallery-grid-shortcode.vh360-gallery-cols-3,
    .vh360-gallery-grid-shortcode.vh360-gallery-cols-4 {
        grid-template-columns: 1fr;
    }

    .vh360-gallery-dropzone {
        padding: 1.5rem;
    }
}
