/**
 * WebWay ERP - Motor Global Fancybox com Visão IA, Labels e Zoom
 * Layout BDialog Windows-Style, Palco Centralizado, Floating Toolbar Glassmorphic
 * e Estúdio Interativo de Anotação Espacial.
 *
 * @author Victor Lacerda Azevedo
 * @since 2026-09-30
 */

/* ==========================================================================
   1. RESET RADICAL DO FANCYBOX CLÁSSICO PARA O ESTÚDIO IA (BDIALOG STYLE)
   ========================================================================== */

.fancybox-overlay {
    background: rgba(4, 7, 14, 0.88) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    z-index: 5000000 !important;
}

.fancybox-wrap.has-ww-ai {
    padding: 0 !important;
    border: 1px solid rgba(255, 255, 255, 0.14) !important;
    border-radius: 12px !important;
    background: #090d16 !important;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.08) !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    z-index: 5000010 !important;
    transition: width 0.2s cubic-bezier(0.2, 0, 0, 1), height 0.2s cubic-bezier(0.2, 0, 0, 1), left 0.2s cubic-bezier(0.2, 0, 0, 1), top 0.2s cubic-bezier(0.2, 0, 0, 1);
}

.fancybox-wrap.has-ww-ai .fancybox-skin {
    padding: 0 !important;
    margin: 0 !important;
    background: #090d16 !important;
    color: #e2e8f0 !important;
    border: none !important;
    border-radius: 12px !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 100% !important;
    min-height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    box-sizing: border-box !important;
    box-shadow: none !important;
    overflow: hidden !important;
}

.fancybox-wrap.has-ww-ai .fancybox-outer,
.fancybox-wrap.has-ww-ai .fancybox-inner {
    position: relative !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 100% !important;
    min-height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    box-sizing: border-box !important;
    background: transparent !important;
    overflow: hidden !important;
}

/* Oculta preemptivamente a imagem nativa não-tratada do Fancybox antes mesmo do JS */
.fancybox-wrap.has-ww-ai img.fancybox-image {
    display: none !important;
}

/* Oculta os botões padrão legados do Fancybox para utilizar os novos */
.fancybox-wrap.has-ww-ai .fancybox-close,
.fancybox-wrap.has-ww-ai .fancybox-nav,
.fancybox-wrap.has-ww-ai .fancybox-title,
.fancybox-wrap.has-ww-ai > a.fancybox-item {
    display: none !important;
}

/* Modo Fullscreen Real */
.fancybox-wrap.has-ww-ai.is-fullscreen {
    left: 0 !important;
    top: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    max-height: none !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
}

.fancybox-wrap.has-ww-ai.is-fullscreen .fancybox-skin {
    border-radius: 0 !important;
}

/* ==========================================================================
   2. CONTAINER PRINCIPAL E PALCO DA IMAGEM
   ========================================================================== */

.fancybox-ai-root {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background: #090d16;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    box-sizing: border-box;
}

.fancybox-ai-stage-container {
    flex: 1 1 auto;
    position: relative;
    min-width: 0;
    min-height: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: radial-gradient(circle at center, #131c2e 0%, #090d16 100%);
    cursor: default;
    box-sizing: border-box;
}

.fancybox-ai-stage-container.mode-pan {
    cursor: grab;
}

.fancybox-ai-stage-container.mode-pan:active,
.fancybox-ai-stage-container.is-panning {
    cursor: grabbing;
}

/* Camada Transformada por Zoom & Pan */
.fancybox-ai-transform-layer {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    display: block !important;
    transform-origin: 0 0 !important;
    will-change: transform;
    transition: transform 0.12s cubic-bezier(0.2, 0, 0, 1);
    box-sizing: border-box !important;
}

.fancybox-ai-transform-layer.no-transition {
    transition: none !important;
}

.fancybox-wrap.has-ww-ai .fancybox-ai-img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    display: block !important;
    max-width: none !important;
    max-height: none !important;
    pointer-events: none !important;
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.55);
    border-radius: 4px;
    margin: 0 !important;
    padding: 0 !important;
}

/* Camada de Bounding Boxes (Labels) */
.fancybox-ai-boxes-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    display: block !important;
    pointer-events: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* ==========================================================================
   3. BARRA SUPERIOR DE CABEÇALHO (INFO, AÇÕES E FECHAR)
   ========================================================================== */

.fancybox-ai-top-bar {
    position: absolute !important;
    top: 12px !important;
    left: 16px !important;
    right: 16px !important;
    height: 44px !important;
    z-index: 200 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    pointer-events: none !important;
    box-sizing: border-box !important;
}

.fancybox-ai-top-left,
.fancybox-ai-top-center,
.fancybox-ai-top-right {
    pointer-events: auto !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

/* Informações do Arquivo (Canto Superior Esquerdo) */
.fancybox-ai-file-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(15, 23, 42, 0.78);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 5px 12px;
    color: #e2e8f0;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    max-width: 280px;
}

.fancybox-ai-file-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #f8fafc;
}

.fancybox-ai-dataset-tag {
    font-size: 10px;
    font-weight: 700;
    background: rgba(56, 189, 248, 0.16);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.28);
    border-radius: 12px;
    padding: 1px 7px;
    white-space: nowrap;
}

/* ==========================================================================
   4. FLOATING TOOLBAR CENTRALIZADA (GLASSMORPHISM PILL)
   ========================================================================== */

.fancybox-ai-floating-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 30px;
    padding: 4px 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    color: #e2e8f0;
}

.fancybox-ai-tool-btn {
    -webkit-appearance: none;
    appearance: none;
    background: transparent !important;
    border: 1px solid transparent !important;
    color: #cbd5e1 !important;
    border-radius: 20px;
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.fancybox-ai-tool-btn:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

.fancybox-ai-tool-btn.is-active {
    background: rgba(56, 189, 248, 0.22) !important;
    color: #38bdf8 !important;
    border-color: rgba(56, 189, 248, 0.45) !important;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
}

.fancybox-ai-tool-btn:active {
    transform: scale(0.95);
}

.fancybox-ai-sep {
    width: 1px;
    height: 18px;
    background: rgba(255, 255, 255, 0.15);
    margin: 0 4px;
}

.fancybox-ai-zoom-badge {
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    min-width: 44px;
    text-align: center;
    cursor: default;
}

/* ==========================================================================
   5. AÇÕES SUPERIORES DA DIREITA (TREINO IA, LABELS, FECHAR)
   ========================================================================== */

/* Botão Primário de Abertura do Treinamento de Visão IA */
.fancybox-ai-btn-open-treino {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: linear-gradient(135deg, rgba(2, 132, 199, 0.9) 0%, rgba(14, 116, 144, 0.9) 100%) !important;
    border: 1px solid rgba(56, 189, 248, 0.5) !important;
    color: #ffffff !important;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(2, 132, 199, 0.35);
    transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
    white-space: nowrap;
}

.fancybox-ai-btn-open-treino:hover {
    background: linear-gradient(135deg, #0284c7 0%, #0891b2 100%) !important;
    border-color: #38bdf8 !important;
    box-shadow: 0 6px 20px rgba(2, 132, 199, 0.55), 0 0 14px rgba(56, 189, 248, 0.4);
    transform: translateY(-1px);
}

.fancybox-ai-btn-open-treino:active {
    transform: translateY(0) scale(0.97);
}

/* Botão Alternar Painel de Labels */
.fancybox-ai-btn-toggle-sidebar {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(15, 23, 42, 0.82) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #cbd5e1 !important;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    transition: all 0.18s ease;
}

.fancybox-ai-btn-toggle-sidebar:hover,
.fancybox-ai-btn-toggle-sidebar.is-open {
    background: rgba(30, 41, 59, 0.95) !important;
    color: #38bdf8 !important;
    border-color: rgba(56, 189, 248, 0.4) !important;
}

.fancybox-ai-count-pill {
    background: #0284c7;
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 10px;
    padding: 1px 6px;
    line-height: 14px;
}

/* Botão Fechar Redondo Elegante */
.fancybox-ai-close-btn {
    -webkit-appearance: none;
    appearance: none;
    background: rgba(15, 23, 42, 0.82) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #94a3b8 !important;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    transition: all 0.18s ease;
}

.fancybox-ai-close-btn:hover {
    background: #ef4444 !important;
    color: #ffffff !important;
    border-color: #f87171 !important;
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
    transform: rotate(90deg);
}

.fancybox-ai-close-btn:active {
    transform: rotate(90deg) scale(0.92);
}

/* ==========================================================================
   6. NAVEGAÇÃO LATERAL DISCRETA (NEXT / PREV)
   ========================================================================== */

.fancybox-ai-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 150;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.65) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: #cbd5e1 !important;
    font-size: 18px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
    opacity: 0.55;
}

.fancybox-ai-nav-arrow:hover {
    opacity: 1;
    background: rgba(15, 23, 42, 0.95) !important;
    color: #38bdf8 !important;
    border-color: rgba(56, 189, 248, 0.5) !important;
    transform: translateY(-50%) scale(1.08);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.6), 0 0 12px rgba(56, 189, 248, 0.3);
}

.fancybox-ai-nav-arrow:active {
    transform: translateY(-50%) scale(0.95);
}

.fancybox-ai-nav-prev {
    left: 20px;
}

.fancybox-ai-nav-next {
    right: 20px;
}

/* ==========================================================================
   7. GAVETA / SIDEBAR DE LABELS (DESIGN ESTILO CVAT / ROBOFLOW)
   ========================================================================== */

.fancybox-ai-sidebar {
    width: 340px;
    min-width: 340px;
    max-width: 340px;
    height: 100%;
    background: #0f172a;
    border-left: 1px solid #1e293b;
    display: flex;
    flex-direction: column;
    z-index: 100;
    position: relative;
    overflow: hidden;
    min-height: 0;
    box-shadow: -6px 0 25px rgba(0, 0, 0, 0.45);
    transition: margin-right 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
    user-select: text;
    -webkit-user-select: text;
    flex-shrink: 0;
    padding-top: 64px;
}

.fancybox-ai-sidebar.is-collapsed {
    width: 0;
    min-width: 0;
    max-width: 0;
    margin-right: -340px;
    opacity: 0;
    pointer-events: none;
    border-left: none;
}

.fancybox-ai-sidebar-header {
    display: none !important;
}

.fancybox-ai-sidebar-title {
    font-size: 13px;
    font-weight: 700;
    color: #f1f5f9;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.fancybox-ai-sidebar-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 14px;
    padding: 6px;
    border-radius: 4px;
    transition: color 0.15s, background-color 0.15s;
}

.fancybox-ai-sidebar-close:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.fancybox-ai-sidebar-body {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 14px;
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}

.fancybox-ai-sidebar-body::-webkit-scrollbar {
    width: 6px;
}

.fancybox-ai-sidebar-body::-webkit-scrollbar-track {
    background: transparent;
}

.fancybox-ai-sidebar-body::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 3px;
}

.fancybox-ai-sidebar-section {
    margin-bottom: 16px;
}

.fancybox-ai-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #64748b;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Ações Rápidas de Labels no topo da Sidebar */
.fancybox-ai-quick-actions {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid #1e293b;
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.fancybox-ai-switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
    color: #e2e8f0;
    cursor: default;
    margin: 0;
}

.fancybox-ai-switch-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.fancybox-ai-switch-caption {
    margin: 0;
    font-weight: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    min-width: 0;
}

.fancybox-ai-switch-tools {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.fancybox-ai-btn-copy {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 3px 5px;
    font-size: 12px;
    border-radius: 3px;
    line-height: 1;
}

.fancybox-ai-btn-copy:hover {
    color: #38bdf8;
}

.fancybox-ai-tool-btn.is-copy-ok,
.fancybox-ai-btn-copy.is-copy-ok {
    color: #4ade80 !important;
}

.fancybox-ai-tool-btn.is-copy-fail,
.fancybox-ai-btn-copy.is-copy-fail {
    color: #f87171 !important;
}

.fancybox-ai-filter-pill-group {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.fancybox-ai-filter-pill {
    flex: 1;
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    border-radius: 12px;
    padding: 3px 6px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.fancybox-ai-filter-pill:hover,
.fancybox-ai-filter-pill.is-active {
    background: rgba(56, 189, 248, 0.18);
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.4);
}

/* Cards de cada Label */
.fancybox-ai-labels-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.fancybox-ai-label-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-left-width: 4px;
    border-radius: 6px;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.18s cubic-bezier(0.2, 0, 0, 1);
    box-sizing: border-box;
}

.fancybox-ai-label-card:hover,
.fancybox-ai-label-card.is-active {
    background: #27354f;
    border-color: #64748b;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
    transform: translateX(2px);
}

.fancybox-ai-label-card-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.fancybox-ai-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 8px currentColor;
}

.fancybox-ai-label-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.fancybox-ai-label-name {
    font-size: 12px;
    font-weight: 700;
    color: #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fancybox-ai-label-sub {
    font-size: 10px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 1px;
}

.fancybox-ai-label-card-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.fancybox-ai-btn-box-eye {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 3px 5px;
    font-size: 12px;
    border-radius: 3px;
    transition: color 0.15s;
}

.fancybox-ai-btn-box-eye:hover {
    color: #38bdf8;
}

.fancybox-ai-btn-box-eye.is-hidden {
    color: #ef4444;
}

/* Rodapé da Sidebar */
.fancybox-ai-sidebar-footer {
    padding: 12px 14px;
    background: #0b1220;
    border-top: 1px solid #1e293b;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.fancybox-ai-sidebar-treino-btn {
    width: 100%;
    background: linear-gradient(135deg, #0284c7 0%, #0891b2 100%);
    border: 1px solid #38bdf8;
    color: #ffffff;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4);
    transition: all 0.2s ease;
}

.fancybox-ai-sidebar-treino-btn:hover {
    background: linear-gradient(135deg, #0369a1 0%, #0e7490 100%);
    box-shadow: 0 6px 18px rgba(2, 132, 199, 0.6);
    transform: translateY(-1px);
}

.fancybox-ai-sidebar-treino-btn:active {
    transform: translateY(0);
}

.fancybox-ai-treino-hint {
    font-size: 11px;
    color: #64748b;
    text-align: center;
    line-height: 1.35;
}

/* ==========================================================================
   8. CAMADA DE BOUNDING BOXES (LABELS ESPACIAIS)
   ========================================================================== */

.fancybox-ai-box {
    position: absolute;
    border: 2px solid;
    border-radius: 3px;
    box-sizing: border-box;
    pointer-events: auto;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.14);
    transition: background-color 0.15s, box-shadow 0.15s, border-color 0.15s, transform 0.15s;
    z-index: 10;
}

.fancybox-ai-box:hover,
.fancybox-ai-box.is-highlighted {
    background: rgba(255, 255, 255, 0.22) !important;
    box-shadow: 0 0 0 2px #ffffff, 0 8px 24px rgba(0, 0, 0, 0.75) !important;
    z-index: 30 !important;
}

.fancybox-ai-box-tag {
    position: absolute;
    top: -24px;
    left: -2px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 700;
    color: #ffffff;
    border-radius: 3px;
    white-space: nowrap;
    line-height: 16px;
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    letter-spacing: 0.2px;
}

/* Ajuste inteligente se a caixa estiver colada no topo */
.fancybox-ai-box.tag-inside .fancybox-ai-box-tag {
    top: 2px;
    left: 2px;
}

/* ==========================================================================
   9. RESPONSIVIDADE E PERSPECTIVA MOBILE (< 768px)
   ========================================================================== */

@media (max-width: 767px), (max-width: 1023px) and (max-height: 499px) {
    .fancybox-wrap.has-ww-ai {
        position: fixed !important;
        border-radius: 0 !important;
        border: none !important;
        margin: 0 !important;
        box-shadow: none !important;
        max-width: 100% !important;
    }

    .fancybox-wrap.has-ww-ai .fancybox-skin {
        border-radius: 0 !important;
    }

    .fancybox-ai-stage-container {
        touch-action: none !important;
    }

    .fancybox-ai-top-bar {
        top: calc(8px + env(safe-area-inset-top)) !important;
        left: calc(8px + env(safe-area-inset-left)) !important;
        right: calc(8px + env(safe-area-inset-right)) !important;
        height: 48px !important;
        padding: 0 !important;
        z-index: 300 !important;
    }

    .fancybox-ai-close-btn,
    .fancybox-ai-btn-toggle-sidebar,
    .fancybox-ai-window-btn {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        border-radius: 8px !important;
        font-size: 16px !important;
        touch-action: manipulation;
        box-sizing: border-box !important;
    }

    .fancybox-ai-btn-toggle-sidebar .btn-txt {
        display: none !important;
    }

    .fancybox-ai-file-pill {
        max-width: 42vw;
        font-size: 12px;
        padding: 4px 8px;
    }

    .fancybox-ai-file-name {
        max-width: 28vw;
    }

    .fancybox-ai-dataset-tag {
        display: none;
    }

    .fancybox-ai-top-center {
        position: fixed !important;
        bottom: calc(12px + env(safe-area-inset-bottom)) !important;
        top: auto !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        z-index: 320 !important;
        max-width: calc(100% - 16px);
    }

    .fancybox-ai-floating-toolbar {
        position: static !important;
        transform: none !important;
        padding: 4px 6px;
        gap: 4px;
        box-shadow: 0 8px 28px rgba(0, 0, 0, 0.85);
        max-width: 100%;
        overflow-x: auto;
    }

    .fancybox-ai-tool-btn {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        font-size: 16px !important;
        border-radius: 8px !important;
        touch-action: manipulation;
        flex: 0 0 auto;
    }

    .fancybox-ai-tool-btn[data-action="zoom-100"],
    .fancybox-ai-tool-btn[data-action="toggle-fullscreen"] {
        display: none !important;
    }

    .fancybox-ai-sidebar {
        position: absolute;
        top: calc(56px + env(safe-area-inset-top));
        right: 0;
        bottom: calc(72px + env(safe-area-inset-bottom));
        width: 86%;
        min-width: 0;
        max-width: 320px;
        height: auto;
        z-index: 280;
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.8);
        padding-top: 0;
    }

    .fancybox-ai-sidebar.is-collapsed {
        margin-right: -100%;
    }

    .fancybox-ai-sidebar-header {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        padding: 8px 10px;
        border-bottom: 1px solid #1e293b;
        flex: 0 0 auto;
    }

    .fancybox-ai-sidebar-close {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        touch-action: manipulation;
    }

    .fancybox-ai-nav-arrow {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        font-size: 18px;
        opacity: 0.9;
        z-index: 360;
        touch-action: manipulation;
    }

    .fancybox-ai-nav-prev {
        left: calc(8px + env(safe-area-inset-left));
    }

    .fancybox-ai-nav-next {
        right: calc(8px + env(safe-area-inset-right));
    }
}

/* Mascara no thumbnail enquanto a imagem grande ainda carrega */
a.is-ww-fb-busy {
    cursor: progress;
}

.ww-fb-thumb-busy {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    pointer-events: auto;
    border-radius: inherit;
}

.ww-fb-thumb-busy__spin {
    width: min(22px, 46%);
    height: min(22px, 46%);
    box-sizing: border-box;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ww-fb-thumb-spin 0.7s linear infinite;
}

.ww-fb-thumb-busy__text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@keyframes ww-fb-thumb-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .ww-fb-thumb-busy__spin {
        animation: none;
        border-color: #fff;
    }
}
