/**
 * Media Studio Styles
 * Shared by media-studio-offcanvas.php and media-studio-modal.php
 */

/* ==========================================================================
   Media Studio Offcanvas Styles
   ========================================================================== */

/* Offcanvas sizing */
#mediaStudioOffcanvas {
    width: 100%;
}

@media (min-width: 992px) {
    #mediaStudioOffcanvas {
        width: 500px;
        max-width: 500px;
    }
}

/* Adjust for WP admin bar */
.admin-bar #mediaStudioOffcanvas {
    top: 32px;
    height: calc(100% - 32px);
}

@media screen and (max-width: 782px) {
    .admin-bar #mediaStudioOffcanvas {
        top: 46px;
        height: calc(100% - 46px);
    }
}

/* ==========================================================================
   Left Toolbar
   ========================================================================== */

.studio-toolbar {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 60px;
    padding: 1rem 0.5rem;
    background: white;
    border-right: 1px solid var(--color-gray-300);
    gap: 0.5rem;
}

.studio-toolbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--color-rov-green);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.studio-toolbar-btn:hover {
    background: var(--color-gray-100);
    color: var(--color-rov-green);
}

.studio-toolbar-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--color-rov-green);
}

.studio-toolbar-btn.active {
    background: var(--color-rov-green);
    color: white;
}

.studio-toolbar-spacer {
    flex: 1;
}

.studio-toolbar-divider {
    width: 32px;
    height: 1px;
    background: var(--color-gray-300);
    margin: 0.25rem 0;
}

.studio-toolbar-btn--source {
    background: var(--color-gray-100);
}

/* Hide toolbar on mobile - actions move elsewhere */
@media (max-width: 767.98px) {
    .studio-toolbar {
        display: none;
    }
}

/* ==========================================================================
   Quick Actions
   ========================================================================== */

.studio-quick-actions .r1v-btn {
    transition: all 0.2s ease;
}

.studio-quick-actions .r1v-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--color-rov-green) 30%, transparent);
}

/* ==========================================================================
   Tool Selector
   ========================================================================== */

/* Tool Cards - Image Design */
.studio-tool-card {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 2px solid transparent;
    text-align: left;
}

.studio-tool-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    border-color: var(--color-rov-green);
}

.studio-tool-card:focus {
    outline: none;
    border-color: var(--color-rov-green);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-rov-green) 25%, transparent);
}

/* Tool card image */
.studio-tool-card-image {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    overflow: hidden;
}

.studio-tool-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.studio-tool-card-badge {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border-radius: 4px;
}

.studio-tool-card:hover .studio-tool-card-image img {
    transform: scale(1.05);
}

.studio-tool-card-body {
    padding: 0.75rem 1rem 1rem;
}

.studio-tool-card-body h6 {
    margin-bottom: 0.25rem;
    font-weight: 600;
    font-size: 0.95rem;
}

.studio-tool-card-body p {
    color: var(--color-text-secondary);
    font-size: 0.8rem;
    margin-bottom: 0;
    line-height: 1.3;
}

/* ==========================================================================
   Editing-context preview
   ========================================================================== */

.studio-context-preview {
    border-bottom: 1px solid var(--color-gray-300);
    background: white;
}

.studio-context-preview-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-gray-500);
    padding: 0.5rem 1rem 0;
}

/*
 * The photo being edited, at a size worth looking at.
 *
 * This was 110px tall — small enough that you could not actually see the
 * thing you were about to spend an AI credit changing, which is the one
 * decision this panel exists to support. It now takes a share of the viewport
 * and is capped so it never crowds the tool grid off the screen on a laptop.
 */
.studio-context-preview-canvas {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: clamp(180px, 34vh, 380px);
    margin: 0.5rem 1rem 1rem;
    border-radius: 6px;
    overflow: hidden;
    /* Transparency-grid (checkered) background */
    background-color: #f3f4f6;
    background-image:
        linear-gradient(45deg, #d1d5db 25%, transparent 25%, transparent 75%, #d1d5db 75%, #d1d5db),
        linear-gradient(45deg, #d1d5db 25%, transparent 25%, transparent 75%, #d1d5db 75%, #d1d5db);
    background-size: 14px 14px;
    background-position: 0 0, 7px 7px;
}

.studio-context-preview-canvas img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

/* ==========================================================================
   Floating Bottom Bar
   ========================================================================== */

.studio-bottom-bar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: white;
    border-top: 1px solid var(--color-gray-300);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
}

.studio-bottom-bar.hidden {
    display: none;
}

/* ==========================================================================
   Overlays (Processing, Results, Error)
   ========================================================================== */

.studio-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.studio-overlay.hidden {
    display: none;
}

/* Result preview sizing */
#mediaStudioResultPreview img,
#mediaStudioResultPreview video {
    max-width: 100%;
    max-height: 70vh;
    width: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}


/* ==========================================================================
   Photo Grid Selector
   ========================================================================== */

/* ==========================================================================
   Canvas — graph-paper backdrop, evokes a Photoshop / drafting workspace
   ========================================================================== */

.studio-canvas {
    background-color: #fbfbfa;
    background-image:
        linear-gradient(to right, rgba(15, 23, 42, 0.06) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(15, 23, 42, 0.06) 1px, transparent 1px);
    background-size: 24px 24px;
    background-position: -1px -1px;
}

/* Center the lone photo vertically + horizontally for single-image tools. */
.studio-canvas:has(.photo-grid-items--single) {
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-grid-items {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

/* Single-photo tools: one large centered image */
.photo-grid-items--single {
    grid-template-columns: 1fr;
    max-width: 320px;
    margin: 0 auto;
}

@media (max-width: 575.98px) {
    .photo-grid-items {
        grid-template-columns: repeat(2, 1fr);
    }

    .photo-grid-items--single {
        grid-template-columns: 1fr;
    }
}

/* Inline count badge inside grid */
.photo-grid-count-badge {
    grid-column: 1 / -1;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
}

.photo-grid-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.photo-grid-item:hover {
    transform: scale(1.02);
}

.photo-grid-item:focus {
    outline: none;
    border-color: var(--color-rov-green);
}

.photo-grid-item--selected {
    border-color: var(--color-rov-green);
}

/* Single-photo tools render the photo plain — no selection chrome. */
.photo-grid-item--readonly {
    cursor: default;
    aspect-ratio: auto;
    border: 1px solid var(--color-gray-300);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
}

.photo-grid-item--readonly:hover {
    transform: none;
}

.photo-grid-item--readonly img {
    object-fit: contain;
    max-height: 60vh;
    background: #fff;
}

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

.photo-grid-item-check {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 24px;
    height: 24px;
    background: var(--color-rov-green);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

.photo-grid-item-order {
    position: absolute;
    bottom: 0.5rem;
    left: 0.5rem;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.photo-grid-item-remove {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.photo-grid-item:hover .photo-grid-item-remove {
    opacity: 1;
}

.photo-grid-item--ghost {
    opacity: 0.4;
}

.photo-grid-item--chosen {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.photo-grid-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.photo-grid-empty-icon {
    font-size: 3rem;
    color: var(--color-rov-yellow);
    margin-bottom: 1rem;
}

/* ==========================================================================
   Options Button Groups
   ========================================================================== */

.studio-options-section {
    margin-bottom: 1.25rem;
}

.studio-options-section:last-child {
    margin-bottom: 0;
}

.studio-options-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-rov-yellow);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.studio-options-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* ==========================================================================
   Compact Options Row (Popovers)
   ========================================================================== */

.studio-compact-options {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.studio-compact-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: white;
    border: 1px solid var(--color-gray-300);
    border-radius: 8px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.studio-compact-option:hover {
    border-color: var(--color-rov-green);
    background: var(--color-rov-light-gray);
}

.studio-compact-option:focus {
    outline: none;
    border-color: var(--color-rov-green);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-rov-green) 20%, transparent);
}

.studio-compact-option>i.fa-music,
.studio-compact-option>i.fa-rabbit,
.studio-compact-option>i.fa-turtle {
    font-size: 1rem;
    color: var(--color-rov-green);
}

.studio-compact-option-value {
    font-weight: 500;
    color: #212529;
    font-size: 0.85rem;
}

.studio-compact-chevron {
    font-size: 0.6rem;
    color: #adb5bd;
    margin-left: 0.125rem;
}

/* Aspect ratio icon display */
.aspect-icon-display {
    display: inline-block;
    border: 2px solid var(--color-rov-green);
    border-radius: 2px;
    flex-shrink: 0;
}

.aspect-icon-display.aspect-icon-display--landscape {
    width: 24px !important;
    height: 14px !important;
}

.aspect-icon-display.aspect-icon-display--square {
    width: 18px !important;
    height: 18px !important;
}

.aspect-icon-display.aspect-icon-display--portrait {
    width: 14px !important;
    height: 24px !important;
}

/* Inline Icon Groups (for aspect ratio and pacing) */
.studio-inline-group {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.studio-inline-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: white;
    border: 1px solid var(--color-gray-300);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    color: var(--color-text-secondary);
}

.studio-inline-icon:hover {
    border-color: var(--color-rov-green);
    background: var(--color-rov-light-gray);
    color: var(--color-rov-green);
}

.studio-inline-icon--selected {
    background: var(--color-rov-green);
    border-color: var(--color-rov-green);
    color: white;
}

.studio-inline-icon--selected:hover {
    background: var(--color-rov-green);
    border-color: var(--color-rov-green);
}

.studio-inline-icon .aspect-icon-display {
    border-color: #6c757d;
    border-width: 2px;
}

.studio-inline-icon--selected .aspect-icon-display {
    border-color: white;
}

.studio-inline-icon i {
    font-size: 1rem;
}

@media (max-width: 575.98px) {
    .studio-compact-options {
        flex-wrap: wrap;
        gap: 0.375rem;
    }

    .studio-compact-option {
        padding: 0.375rem 0.5rem;
    }
}

/* Soundtrack Dropdown */
.studio-soundtrack-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 0.25rem;
    max-width: 280px;
    background: white;
    border: 1px solid var(--color-gray-300);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    padding: 0.5rem;
    z-index: 10;
}

.studio-popover-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.studio-popover-grid--aspect {
    flex-wrap: nowrap;
}

.studio-popover-option {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    background: white;
    border: 1px solid var(--color-gray-300);
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.studio-popover-option:hover {
    border-color: var(--color-rov-green);
    background: var(--color-rov-light-gray);
}

.studio-popover-option--selected {
    background: var(--color-rov-green);
    border-color: var(--color-rov-green);
    color: white;
}

.studio-popover-option--selected:hover {
    background: var(--color-rov-green);
    border-color: var(--color-rov-green);
}

.studio-popover-option--aspect {
    flex-direction: column;
    padding: 0.5rem 0.75rem;
    min-width: 70px;
}

.studio-popover-option .aspect-icon-display {
    border-color: currentColor;
}

.studio-popover-option--selected .aspect-icon-display {
    border-color: white;
}

.studio-popover-option i {
    font-size: 0.85rem;
}

/* ==========================================================================
   Library Browser (Nested Offcanvas)
   ========================================================================== */

#mediaStudioLibraryBrowser {
    width: 320px;
    z-index: 1060;
    /* Above main offcanvas */
}

/* Library Browser Grid */
.library-browser-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.library-browser-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: border-color 0.15s ease, transform 0.15s ease;
    background: var(--color-bg-muted);
}

.library-browser-item:hover {
    transform: scale(1.02);
}

.library-browser-item:focus {
    outline: none;
    border-color: var(--color-rov-green);
}

.library-browser-item--selected {
    border-color: var(--color-rov-green);
}

.library-browser-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.library-browser-item-check {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    width: 20px;
    height: 20px;
    background: var(--color-rov-green);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
}

/* Mobile: Full width */
@media (max-width: 575.98px) {
    #mediaStudioLibraryBrowser {
        width: 100%;
    }
}

/* ==========================================================================
   Media Studio Modal Styles
   ========================================================================== */

/* Result preview sizing */
#mediaStudioResultPreview img {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: 8px;
}

#mediaStudioResultPreview video {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
}

/* Version chooser, floated over the foot of the editing preview. */
.studio-context-preview-versions {
    position: absolute;
    bottom: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
}
