/* ==========================================================================
   MIVB — Public Share Page
   Full-viewport, no-scroll layout that mirrors the builder's immersive mode
   but driven by body.mivb-share-page instead of body.mivb-immersive so it
   never conflicts with the builder.
   ========================================================================== */

/* Full-viewport, no-scroll body
   — reset WP admin bar margin-top and wp-responsive-menu padding-top (42px on mobile) */
html:has(body.mivb-share-page) {
    margin-top: 0 !important;
    padding-top: 0 !important;
    height: 100%;
    overflow: hidden;
}
body.mivb-share-page {
    height: 100%;
    min-height: 100vh;
    overflow: hidden;
    margin: 0;
    padding: 0;
    background: #f8f8fa;
}

/* Hide everything injected by theme/plugins (wp_footer, sticky headers, mobile menus, etc.)
   Only our .mivb-share-wrapper should be visible on share pages */
body.mivb-share-page > *:not(.mivb-share-wrapper) {
    display: none !important;
}

/* Outer wrapper: the absolute-positioning root — immune to theme transforms */
body.mivb-share-page .mivb-share-wrapper {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100svh; /* shrinks with browser chrome on mobile */
    overflow: hidden;
}

/* Middle container fills the wrapper */
body.mivb-share-page .mivb-share-mode {
    width: 100%;
    height: 100%;
}

/* Preview step: absolute-positioning context — fills share-mode */
body.mivb-share-page .mivb-preview-step {
    position: absolute !important;
    inset: 0;
    background: #f8f8fa;
    overflow: hidden;
}

/* ==========================================================================
   Header: absolute, pinned to top of .mivb-preview-step
   ========================================================================== */

body.mivb-share-page .mivb-preview-header-bar {
    display: flex !important;
    position: absolute !important;
    top: 0;
    left: 0;
    right: 0;
    height: 49px;
    box-sizing: border-box;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: #fff;
    border-bottom: 1px solid #eee;
    z-index: 10;
}

/* Clickable logo wrapper */
.mivb-header-logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.mivb-header-logo-link:hover {
    opacity: 0.85;
}

/* Left spacer matches .mivb-header-back width so logo stays centered */
.mivb-header-back-placeholder {
    width: 36px;
    flex-shrink: 0;
}

/* Ensure logo renders at consistent 24px regardless of theme CSS */
.mivb-header-logo-link img {
    height: 24px !important;
    width: auto !important;
    display: block;
}

/* ==========================================================================
   Canvas zone: fills exact space between header (49px) and footer (54px).
   Using absolute (not fixed) so theme body/html transforms don't displace it.
   ========================================================================== */

body.mivb-share-page .mivb-preview-center {
    position: absolute !important;
    top: 49px;
    bottom: 54px;
    left: 0;
    right: 0;
    display: flex !important;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 6px 12px;
}

/* ==========================================================================
   Footer: absolute, pinned to bottom — always visible
   ========================================================================== */

body.mivb-share-page .mivb-preview-bottom {
    position: absolute !important;
    bottom: 0;
    left: 0;
    right: 0;
    height: 54px;
    box-sizing: border-box;
    z-index: 10;
    background: #fff;
    border-top: 1px solid #eee;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
}

body.mivb-share-page .mivb-share-controls .mivb-bottom-row {
    justify-content: center !important;
}

body.mivb-share-page .mivb-share-controls .mivb-preview-controls {
    justify-content: center;
}

/* ==========================================================================
   Share Video button — builder header variant
   ========================================================================== */

/* Base style for the header version */
.mivb-header-share {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: transparent;
    color: #ff7396;
    border: 1.5px solid #ff7396;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    white-space: nowrap;
    font-family: inherit;
    flex-shrink: 0;
}

.mivb-header-share:hover {
    background: #ff7396;
    color: #fff;
}

.mivb-header-share:active {
    transform: scale(0.96);
}

.mivb-header-share:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

/* ==========================================================================
   Share panel — shown in the builder after a link is generated
   ========================================================================== */

#mivb-share-panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 99998;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0 0 env(safe-area-inset-bottom, 0);
}

#mivb-share-panel {
    background: #fff;
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-width: 520px;
    padding: 20px 20px 28px;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
}

.mivb-share-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    font-weight: 600;
    font-size: 0.95rem;
    color: #1a1a1a;
}

.mivb-share-panel-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #888;
    font-size: 1.1rem;
    padding: 4px;
    line-height: 1;
}

.mivb-share-panel-close:hover { color: #333; }

.mivb-share-panel-url-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.mivb-share-panel-url {
    flex: 1;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 0.85rem;
    color: #333;
    background: #f9f9f9;
    outline: none;
    min-width: 0;
}

.mivb-share-panel-url:focus { border-color: #ff7396; }

.mivb-share-panel-copy {
    flex-shrink: 0;
    background: #ff7396;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.mivb-share-panel-copy:hover { background: #e85c80; }

.mivb-share-panel-actions {
    display: flex;
    gap: 10px;
}

.mivb-share-panel-actions button {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid #ff7396;
    transition: background 0.2s, color 0.2s;
}

.mivb-share-panel-native {
    background: #ff7396;
    color: #fff;
}

.mivb-share-panel-native:hover { background: #e85c80; }

.mivb-share-panel-open {
    background: #fff;
    color: #ff7396;
}

.mivb-share-panel-open:hover {
    background: #ff7396;
    color: #fff;
}

/* ==========================================================================
   Toast notification (Share Video copy feedback)
   ========================================================================== */

.mivb-share-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e1e1e;
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    z-index: 99999;
    white-space: nowrap;
    pointer-events: none;
    border: 1px solid #333;
}

.mivb-share-toast--error {
    border-color: #ff7396;
    color: #ff7396;
}

/* ==========================================================================
   Error pages (404 / expired) — same layout shell as preview page
   ========================================================================== */

/* Error pages: fill between header and bottom of the step */
body.mivb-share-page .mivb-share-error-center {
    position: absolute !important;
    top: 49px;
    bottom: 0;
    left: 0;
    right: 0;
}

.mivb-share-error-center {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    min-height: 0;
}

.mivb-share-error-inner {
    max-width: 380px;
}

.mivb-share-error-icon {
    font-size: 3rem;
    color: #ff7396;
    margin-bottom: 1.25rem;
}

.mivb-share-error h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 0.6rem;
    line-height: 1.4;
}

.mivb-share-error p {
    font-size: 0.9rem;
    color: #888;
    margin: 0;
    line-height: 1.5;
}
