/* ==========================================================================
   Tour Virtual Unifacisa — Frontend CSS
   Isolated styles for the dedicated tour page only.
   ========================================================================== */

/* ---------- Reset & Base (scoped to .ufctour-page) ---------- */
body.ufctour-page {
    margin: 0;
    padding: 0;
    overflow: hidden; /* No page scroll on desktop */
    font-family: 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #1a1a2e;
    background: #ffffff;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.ufctour-page *,
body.ufctour-page *::before,
body.ufctour-page *::after {
    box-sizing: border-box;
}

/* WP admin bar offset */
body.ufctour-page.admin-bar .ufctour-app {
    height: calc(100vh - 32px);
}
@media screen and (max-width: 782px) {
    body.ufctour-page.admin-bar .ufctour-app {
        height: calc(100vh - 46px);
    }
}

/* ---------- App Container ---------- */
.ufctour-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
}

/* ---------- Header ---------- */
.ufctour-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    min-height: 56px;
    padding: 0 20px;
    background: #0153FF;
    color: #fff;
    flex-shrink: 0;
    z-index: 100;
}

.ufctour-header__brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ufctour-header__logo {
    height: 28px;
    width: auto;
    object-fit: contain;
}

.ufctour-header__logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: opacity 0.2s;
}
.ufctour-header__logo-link:hover {
    opacity: 0.8;
}

.ufctour-header__divider {
    width: 1px;
    height: 24px;
    background: rgba(255,255,255,0.3);
}

.ufctour-header__title {
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.ufctour-header__back {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #1a1a2e;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 20px;
    background: #44FF00;
    transition: background 0.2s, transform 0.15s;
    white-space: nowrap;
}
.ufctour-header__back:hover {
    background: #3de600;
    transform: scale(1.03);
}
.ufctour-header__back:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* ---------- Content Layout ---------- */
.ufctour-content {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ---------- Sidebar ---------- */
.ufctour-sidebar {
    width: 300px;
    min-width: 280px;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    background: #f8f9fb;
    border-right: 1px solid #e8eaef;
    padding: 16px;
    gap: 10px;
    overflow: hidden;
}

/* ---------- Filters ---------- */
.ufctour-filter-group {
    flex-shrink: 0;
}

.ufctour-select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #dde0e7;
    border-radius: 10px;
    font-family: inherit;
    font-size: 13px;
    color: #1a1a2e;
    background: #fff;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23666' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
    transition: border-color 0.2s;
}
.ufctour-select:focus {
    outline: none;
    border-color: #0153FF;
    box-shadow: 0 0 0 3px rgba(1,83,255,0.12);
}

.ufctour-search-wrap {
    position: relative;
}
.ufctour-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    pointer-events: none;
}
.ufctour-search-input {
    width: 100%;
    padding: 9px 12px 9px 36px;
    border: 1px solid #dde0e7;
    border-radius: 10px;
    font-family: inherit;
    font-size: 13px;
    color: #1a1a2e;
    background: #fff;
    transition: border-color 0.2s;
}
.ufctour-search-input:focus {
    outline: none;
    border-color: #0153FF;
    box-shadow: 0 0 0 3px rgba(1,83,255,0.12);
}
.ufctour-search-input::placeholder {
    color: #aaa;
}

/* ---------- Environment List ---------- */
.ufctour-list-area {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ufctour-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    overflow: hidden;
}

/* Environment Card */
.ufctour-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    border: 2px solid transparent;
    background: #fff;
    min-height: 0;
}
.ufctour-card:hover {
    background: #eef2ff;
    box-shadow: 0 1px 4px rgba(1,83,255,0.08);
}
.ufctour-card:focus-visible {
    outline: 2px solid #0153FF;
    outline-offset: -2px;
}
.ufctour-card--active {
    border-color: #0153FF;
    background: #eef2ff;
    box-shadow: 0 2px 8px rgba(1,83,255,0.12);
}
.ufctour-card--active::after {
    content: 'Você está aqui';
    position: absolute;
    top: 4px;
    right: 8px;
    font-size: 9px;
    font-weight: 600;
    color: #0153FF;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.ufctour-card {
    position: relative;
}

.ufctour-card__thumb {
    width: 80px;
    height: 54px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: #e8eaef;
}
.ufctour-card__thumb--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
    font-size: 20px;
    width: 80px;
    height: 54px;
    border-radius: 8px;
    background: #e8eaef;
    flex-shrink: 0;
}

.ufctour-card__info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.ufctour-card__title {
    font-size: 13px;
    font-weight: 600;
    color: #1a1a2e;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ufctour-card__unit {
    font-size: 11px;
    color: #666;
    margin: 2px 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Pagination ---------- */
.ufctour-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 0 2px;
    flex-shrink: 0;
    border-top: 1px solid #e8eaef;
}

.ufctour-page-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid #dde0e7;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    color: #1a1a2e;
    transition: all 0.15s;
}
.ufctour-page-btn:hover:not(:disabled) {
    background: #eef2ff;
    border-color: #0153FF;
    color: #0153FF;
}
.ufctour-page-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.ufctour-page-btn:focus-visible {
    outline: 2px solid #0153FF;
    outline-offset: 2px;
}

.ufctour-page-info {
    font-size: 12px;
    color: #666;
    font-weight: 500;
    min-width: 40px;
    text-align: center;
}

/* ---------- Empty State ---------- */
.ufctour-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 8px;
    color: #999;
    text-align: center;
    padding: 20px;
}
.ufctour-empty p { margin: 0; font-size: 13px; }

.ufctour-btn {
    padding: 8px 20px;
    border-radius: 8px;
    border: none;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.ufctour-btn--text {
    background: none;
    color: #0153FF;
    padding: 6px 12px;
}
.ufctour-btn--text:hover { background: #eef2ff; }

/* ---------- Main Area ---------- */
.ufctour-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
    background: #1a1a2e;
}

/* ---------- Welcome State ---------- */
.ufctour-welcome {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 32px;
    background: linear-gradient(135deg, #0153FF 0%, #0040cc 100%);
    position: relative;
    overflow: hidden;
}

.ufctour-welcome__hero {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center center;
    opacity: 0.15;
    pointer-events: none;
    padding: 24px;
}

.ufctour-welcome__text {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 600px;
}

.ufctour-welcome__text h1 {
    font-size: 52px;
    font-weight: 300;
    color: #fff;
    margin: 0 0 16px;
    line-height: 1.15;
    letter-spacing: -0.01em;
}
.ufctour-welcome__text h1 strong {
    font-weight: 700;
    display: block;
}
.ufctour-welcome__text p {
    font-size: 17px;
    color: rgba(255,255,255,0.75);
    margin: 0;
    font-weight: 400;
}

/* ---------- Viewer ---------- */
.ufctour-viewer {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 0;
}

.ufctour-viewer__pano {
    flex: 1;
    min-height: 0;
    border-radius: 0 16px 16px 0;
    overflow: hidden;
    border: 6px solid #fff;
    border-left: none;
    box-shadow: 0 4px 24px rgba(0,0,0,0.10);
}

/* Scene Navigation Arrows */
.ufctour-scene-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(4px);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    opacity: 0.7;
}
.ufctour-scene-nav:hover {
    background: rgba(255,255,255,0.35);
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
}
.ufctour-scene-nav:active {
    transform: translateY(-50%) scale(0.95);
}
.ufctour-scene-nav:disabled {
    opacity: 0.2;
    cursor: default;
    pointer-events: none;
}
.ufctour-scene-nav--prev {
    left: 20px;
}
.ufctour-scene-nav--next {
    right: 20px;
}
.ufctour-viewer__pano .pnlm-container {
    border-radius: 0 !important;
}

/* Scene Overlay Label */
.ufctour-scene-overlay {
    position: absolute;
    bottom: 36px;
    left: 24px;
    z-index: 15;
    pointer-events: none;
    max-width: 70%;
}
.ufctour-scene-overlay h2 {
    font-size: 52px;
    font-weight: 700;
    color: #fff;
    margin: 0 0 4px;
    text-decoration: underline;
    text-decoration-thickness: 3px;
    text-underline-offset: 8px;
    text-decoration-color: #fff;
    line-height: 1.15;
    text-shadow: 0 2px 12px rgba(0,0,0,0.5);
}
.ufctour-scene-overlay__unit {
    font-size: 26px;
    color: rgba(255,255,255,0.9);
    font-weight: 400;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

/* ---------- Loading ---------- */
.ufctour-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(26,26,46,0.85);
    z-index: 20;
    color: #fff;
    gap: 16px;
}
.ufctour-loading p { font-size: 14px; margin: 0; }

.ufctour-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: #0153FF;
    border-radius: 50%;
    animation: ufctour-spin 0.8s linear infinite;
}
@keyframes ufctour-spin { to { transform: rotate(360deg); } }

/* ---------- Error ---------- */
.ufctour-error {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(26,26,46,0.92);
    z-index: 20;
    color: #fff;
}
.ufctour-error__content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.ufctour-error__content p { margin: 0; font-size: 14px; }
.ufctour-error__thumb img {
    max-width: 240px;
    border-radius: 8px;
    opacity: 0.7;
}

#ufctour-retry {
    background: #0153FF;
    color: #fff;
}
#ufctour-retry:hover { background: #003fd6; }

/* ---------- Mobile Bottom Sheet ---------- */
.ufctour-bottomsheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 200;
    max-height: 65vh;
    display: flex;
    flex-direction: column;
}
.ufctour-bottomsheet--open {
    transform: translateY(0);
}
.ufctour-bottomsheet__handle {
    display: flex;
    justify-content: center;
    padding: 12px 0 8px;
    cursor: grab;
    flex-shrink: 0;
    width: 100%;
    border: none;
    background: transparent;
    outline: none;
}
.ufctour-bottomsheet__handle:focus-visible {
    outline: 2px solid #0153FF;
    outline-offset: -2px;
    border-radius: 20px 20px 0 0;
}
.ufctour-bottomsheet__bar {
    width: 40px;
    height: 4px;
    background: #ddd;
    border-radius: 2px;
}
.ufctour-bottomsheet__content {
    padding: 0 16px 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ufctour-bs-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

/* FAB */
.ufctour-fab {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #0153FF;
    color: #fff;
    border: none;
    border-radius: 28px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(1,83,255,0.35);
    z-index: 150;
    transition: transform 0.2s, box-shadow 0.2s;
}
.ufctour-fab:hover { transform: translateX(-50%) scale(1.04); box-shadow: 0 6px 24px rgba(1,83,255,0.45); }
.ufctour-fab:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

/* Safe area padding for mobile */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .ufctour-bottomsheet__content { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
    .ufctour-fab { bottom: calc(20px + env(safe-area-inset-bottom)); }
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .ufctour-spinner { animation-duration: 2s; }
    .ufctour-bottomsheet { transition-duration: 0.01s; }
    .ufctour-card { transition-duration: 0.01s; }
}

/* ---------- RESPONSIVE: Mobile / Compact Mode ---------- */
@media screen and (max-width: 768px) {
    body.ufctour-page {
        overflow: auto; /* Allow scroll on mobile */
    }

    .ufctour-content {
        flex-direction: column;
    }

    .ufctour-sidebar {
        width: 100%;
        max-width: none;
        min-width: 0;
        border-right: none;
        border-bottom: 1px solid #e8eaef;
    }

    /* In mobile with a scene active, hide sidebar and show FAB */
    .ufctour-app--scene-active .ufctour-sidebar {
        display: none;
    }
    .ufctour-app--scene-active .ufctour-main {
        flex: 1;
    }

    .ufctour-list {
        overflow: visible;
    }

    /* Fix #2: allow the entire list area to scroll on mobile */
    .ufctour-list-area {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        flex: 1;
    }

    .ufctour-welcome__hero {
        padding: 16px;
        opacity: 0.12;
    }
    .ufctour-welcome__text h1 {
        font-size: 32px;
    }

    .ufctour-scene-info {
        padding: 8px 14px;
    }
    .ufctour-scene-info__text h2 {
        font-size: 14px;
    }

    .ufctour-header__back span {
        display: none; /* Show only icon on very small screens */
    }
}

/* Very small screens */
@media screen and (max-width: 380px) {
    .ufctour-header {
        padding: 0 12px;
    }
    .ufctour-header__logo {
        height: 22px;
    }
    .ufctour-header__title {
        font-size: 13px;
    }
}
