/**
 * WP - Power 3D Engine — Professional Frontend UI
 * Viewer container, progress bar, AR button, instructions
 */

:root {
    --a3dv-frontend-bg: #f8fafc;
    --a3dv-frontend-border: #e2e8f0;
    --a3dv-frontend-radius: 12px;
    --a3dv-frontend-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    --a3dv-accent: #0f766e;
    --a3dv-accent-hover: #0d5d57;
    --a3dv-progress-bg: rgba(15, 118, 110, 0.9);
    --a3dv-text-muted: #64748b;
}

/* ---- Main container ---- */
.a3dv-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    border-radius: var(--a3dv-frontend-radius);
    overflow: hidden;
    background: var(--a3dv-frontend-bg);
    border: 1px solid var(--a3dv-frontend-border);
    box-shadow: var(--a3dv-frontend-shadow);
    margin: 24px 0;
}

model-viewer {
    background-color: #f1f5f9;
    --progress-bar-color: transparent;
    --progress-bar-height: 0;
}

/* ---- Progress bar (hidden to avoid horizontal line artifact) ---- */
.a3dv-progress-bar {
    display: none !important;
    width: 33%;
    height: 8px;
    max-height: 8px;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate3d(-50%, -50%, 0);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.15);
    overflow: hidden;
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.a3dv-update-bar {
    background: var(--a3dv-progress-bg);
    width: 0%;
    height: 100%;
    border-radius: 999px;
    float: left;
    transition: width 0.25s ease;
}

/* ---- AR Button ---- */
.a3dv-ar-button {
    background-color: #fff;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%230f766e" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M2 12h20M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/></svg>');
    background-repeat: no-repeat;
    background-size: 20px 20px;
    background-position: 14px 50%;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    bottom: 20px;
    padding: 0 18px 0 42px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: var(--a3dv-accent);
    height: 44px;
    line-height: 44px;
    border-radius: 22px;
    border: 1px solid var(--a3dv-frontend-border);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.a3dv-ar-button:hover {
    background-color: rgba(15, 118, 110, 0.06);
    border-color: var(--a3dv-accent);
    box-shadow: 0 4px 12px rgba(15, 118, 110, 0.15);
}

.a3dv-ar-button:active {
    background-color: rgba(15, 118, 110, 0.12);
}

.a3dv-ar-button:focus {
    outline: none;
}

.a3dv-ar-button:focus-visible {
    outline: 2px solid var(--a3dv-accent);
    outline-offset: 2px;
}

/* ---- Instructions (hidden by default) ---- */
#a3dv-instructions {
    display: none !important;
    position: absolute;
    bottom: 72px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    color: #fff;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.a3dv-container:hover #a3dv-instructions {
    opacity: 1;
}

/* ---- Error message ---- */
.a3dv-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    padding: 16px 20px;
    border-radius: var(--a3dv-frontend-radius);
    margin: 24px 0;
    font-size: 14px;
    font-weight: 500;
}

/* ---- Scene viewer: top-right UI (Instructions, Fullscreen, Exit) ---- */
#a3dv-visitor-ui {
    top: 12px !important;
    right: 12px !important;
    gap: 6px !important;
}
#a3dv-visitor-ui button {
    padding: 6px 12px !important;
    font-size: 12px !important;
}

/* ---- Scene viewer container (Three.js frontend) ---- */
/* Hotspot content modal */
#a3dv-hotspot-modal {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}
#a3dv-hotspot-modal > div {
    background: #fff;
    border-radius: 12px;
    max-width: 90%;
    max-height: 85%;
    overflow: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    position: relative;
}
#a3dv-hotspot-modal button {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #64748b;
    line-height: 1;
}
#a3dv-hotspot-modal img { max-width: 100%; height: auto; }
#a3dv-hotspot-modal iframe { border: none; }

/* Scene viewer: fluid width, responsive height */
.a3dv-scene-frontend-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    min-height: 280px;
    height: 500px;
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    border-radius: var(--a3dv-frontend-radius);
    overflow: hidden;
    border: 1px solid var(--a3dv-frontend-border);
    box-shadow: var(--a3dv-frontend-shadow);
    margin: 24px 0;
    box-sizing: border-box;
}

.a3dv-scene-frontend-container canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* ---- Responsive: tablets and below ---- */
@media (max-width: 1024px) {
    .a3dv-scene-frontend-container {
        height: 420px;
        min-height: 260px;
    }
    .a3dv-container { margin: 16px 0; }
}

/* ---- Responsive: phones ---- */
@media (max-width: 768px) {
    .a3dv-scene-frontend-container {
        height: 320px;
        min-height: 240px;
        margin: 12px 0;
    }
    .a3dv-container {
        margin: 12px 0;
    }
    #a3dv-visitor-ui {
        top: 8px !important;
        right: 8px !important;
        gap: 4px !important;
        flex-wrap: wrap;
    }
    #a3dv-visitor-ui button {
        padding: 8px 10px !important;
        font-size: 11px !important;
        min-height: 36px;
    }
    #a3dv-instructions {
        bottom: 56px;
        padding: 6px 12px;
        font-size: 11px;
    }
    .a3dv-ar-button {
        bottom: 12px;
        height: 40px;
        line-height: 40px;
        padding: 0 14px 0 38px;
        background-size: 18px 18px;
        background-position: 10px 50%;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .a3dv-scene-frontend-container {
        height: 280px;
        min-height: 220px;
    }
}

/* Hotspot modal: full-screen friendly on small screens */
@media (max-width: 768px) {
    #a3dv-hotspot-modal {
        padding: 12px;
    }
    #a3dv-hotspot-modal > div {
        max-width: 100%;
        max-height: 90%;
        border-radius: 10px;
    }
    #a3dv-hotspot-modal button {
        min-width: 44px;
        min-height: 44px;
        top: 4px;
        right: 8px;
    }
}
