/* --- Modo foco PLM (menu horizontal sem header) --- */
html[data-plm-tech-editor="true"],
html[data-plm-tech-editor="true"] body {
    overflow: hidden;
}

html[data-plm-tech-editor="true"] .footer {
    display: none;
}

html[data-plm-tech-editor="true"] .app-header {
    display: none !important;
}

@media (min-width: 992px) {
    html[data-plm-tech-editor="true"][data-nav-layout="horizontal"] .app-sidebar {
        inset-block-start: 0 !important;
        height: 3rem;
    }

    html[data-plm-tech-editor="true"][data-nav-layout="horizontal"] .app-sidebar .main-sidebar-header {
        display: none;
    }

    /* Sem header: menu usa a largura útil inteira (evita slide-left/right à toa com 94%) */
    html[data-plm-tech-editor="true"][data-nav-layout="horizontal"] .main-sidebar,
    html[data-plm-tech-editor="true"][data-nav-layout="horizontal"] .main-header-container {
        width: 100% !important;
        max-width: 100% !important;
        margin-inline: 0 !important;
    }

    html[data-plm-tech-editor="true"][data-nav-layout="horizontal"] .main-menu-container {
        width: 100%;
    }

    html[data-plm-tech-editor="true"][data-nav-layout="horizontal"] .app-content {
        margin-block-start: 3rem !important;
        min-height: calc(100vh - 3rem) !important;
        padding: 0 !important;
        overflow: hidden !important;
    }

    html[data-plm-tech-editor="true"][data-nav-layout="horizontal"] .app-content > .container-fluid {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
}

html[data-plm-tech-editor="true"] .main-content {
    padding: 0 !important;
    overflow: hidden;
    height: calc(100vh - 3rem);
}

/* --- Página do editor --- */
.plm-tech-editor-page {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.plm-tech-editor-page-bar {
    flex: 0 0 auto;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--default-border, #e9edf4);
    background: var(--custom-white, #fff);
}

.plm-tech-editor-page-bar .page-header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

/* --- Área útil do canvas (100% menos barra da página) --- */
.plm-tech-editor-shell {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    background: #e9ecef;
}

.plm-tech-editor-stage {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.plm-tech-editor-canvas-wrap {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.plm-tech-editor-canvas-wrap canvas {
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
}

/* Toolbar fixa na viewport (não rola com o conteúdo) */
.plm-tech-editor-toolbar-dock {
    position: fixed;
    left: 50%;
    bottom: 1.5rem;
    transform: translateX(-50%);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
}

.plm-tech-editor-toolbar-dock > * {
    pointer-events: auto;
}

.plm-tech-editor-toolbar-float {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.5rem;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--default-border, #e9edf4);
    border-radius: 0.75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    backdrop-filter: blur(8px);
}

.plm-tech-editor-toolbar-float .btn-tool i {
    font-size: 1.05rem;
    line-height: 1;
}

.plm-tech-editor-toolbar-float .btn-tool {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    border: none;
    background: transparent;
    color: var(--default-text-color, #536485);
}

.plm-tech-editor-toolbar-float .btn-tool:hover {
    background: rgba(var(--primary-rgb, 132, 90, 223), 0.08);
    color: rgb(var(--primary-rgb, 132, 90, 223));
}

.plm-tech-editor-toolbar-float .btn-tool.active {
    background: rgb(var(--primary-rgb, 132, 90, 223));
    color: #fff;
}

.plm-tech-editor-toolbar-float .toolbar-divider {
    width: 1px;
    height: 1.5rem;
    background: var(--default-border, #e9edf4);
    margin: 0 0.15rem;
}

.plm-tech-editor-props-popover {
    margin-bottom: 0.5rem;
    padding: 0.75rem;
    background: #fff;
    border: 1px solid var(--default-border, #e9edf4);
    border-radius: 0.5rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    min-width: 200px;
}

/* Painel de camadas — flutuante à direita, não bloqueia o canvas */
.plm-tech-layers-dock {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    bottom: 0.5rem;
    width: min(280px, calc(100% - 1rem));
    z-index: 200;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid var(--default-border, #e9edf4);
    border-radius: 0.625rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    backdrop-filter: blur(10px);
    overflow: hidden;
}

.plm-tech-layers-dock-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid var(--default-border, #e9edf4);
}

.plm-tech-layers-dock-title {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted, #7987a1);
}

.plm-tech-layers-dock-close {
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 0.375rem;
    background: transparent;
    color: var(--default-text-color, #536485);
}

.plm-tech-layers-dock-close:hover {
    background: rgba(var(--primary-rgb, 132, 90, 223), 0.08);
}

.plm-tech-layers-dock-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.plm-tech-layers {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.plm-tech-layers-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0.35rem;
}

.plm-tech-layers-empty {
    margin: 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-muted, #7987a1);
}

.plm-tech-layers-row {
    display: flex;
    align-items: stretch;
    gap: 0.15rem;
    margin-bottom: 0.2rem;
    border-radius: 0.375rem;
    border: 1px solid transparent;
}

.plm-tech-layers-row:hover {
    background: rgba(var(--primary-rgb, 132, 90, 223), 0.05);
}

.plm-tech-layers-row.is-selected {
    border-color: rgb(var(--primary-rgb, 132, 90, 223));
    background: rgba(var(--primary-rgb, 132, 90, 223), 0.08);
}

.plm-tech-layers-row.is-hidden .plm-tech-layers-title {
    opacity: 0.45;
    text-decoration: line-through;
}

.plm-tech-layers-row-select {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.4rem;
    border: none;
    border-radius: 0.375rem;
    background: transparent;
    text-align: start;
    color: inherit;
}

.plm-tech-layers-icon {
    flex: 0 0 auto;
    width: 1.65rem;
    height: 1.65rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.3rem;
    background: rgba(var(--primary-rgb, 132, 90, 223), 0.1);
    color: rgb(var(--primary-rgb, 132, 90, 223));
}

.plm-tech-layers-icon i {
    font-size: 1rem;
    line-height: 1;
}

.plm-tech-layers-meta {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.plm-tech-layers-type {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted, #7987a1);
    line-height: 1.2;
}

.plm-tech-layers-title {
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.plm-tech-layers-btn {
    flex: 0 0 auto;
    width: 1.75rem;
    align-self: center;
    padding: 0;
    height: 1.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 0.3rem;
    background: transparent;
    color: var(--default-text-color, #536485);
}

.plm-tech-layers-btn:hover {
    background: rgba(0, 0, 0, 0.06);
}

.plm-tech-layers-btn-danger:hover {
    background: rgba(220, 53, 69, 0.12);
    color: #dc3545;
}

.plm-tech-layers-detail {
    flex: 0 0 auto;
    padding: 0.5rem 0.6rem 0.6rem;
    border-top: 1px solid var(--default-border, #e9edf4);
    background: rgba(var(--primary-rgb, 132, 90, 223), 0.03);
}

/* Barra de estilo de texto (Figma / Excalidraw) — acima da toolbar */
.plm-tech-editor-text-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
    padding: 0.4rem 0.55rem;
    max-width: min(96vw, 36rem);
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid var(--default-border, #e9edf4);
    border-radius: 0.75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
    backdrop-filter: blur(10px);
}

.plm-tech-text-bar-font-wrap {
    flex: 0 0 auto;
}

.plm-tech-text-bar-font-wrap .form-select.plm-tech-text-bar-font {
    display: block;
    width: auto;
    min-width: 9.75rem;
    max-width: min(12.5rem, 42vw);
    height: 2rem;
    padding-block: 0.2rem;
    padding-inline-start: 0.55rem;
    padding-inline-end: 1.85rem;
    font-size: 0.8125rem;
    line-height: 1.35;
    color: var(--default-text-color, #536485);
    background-color: var(--form-control-bg, #fff);
    border: 1px solid var(--input-border, var(--default-border, #e9edf4));
    border-radius: var(--bs-border-radius-sm, 0.375rem);
    background-position: right 0.5rem center;
    background-size: 1rem 1rem;
    box-shadow: none;
    cursor: pointer;
}

.plm-tech-text-bar-font-wrap .form-select.plm-tech-text-bar-font:hover {
    border-color: var(--input-border, #ced4da);
}

.plm-tech-text-bar-font-wrap .form-select.plm-tech-text-bar-font:focus {
    border-color: rgb(var(--primary-rgb, 132, 90, 223));
    box-shadow: 0 0 0 0.15rem rgba(var(--primary-rgb, 132, 90, 223), 0.18);
}

.plm-tech-text-bar-size,
.plm-tech-text-bar-border-w {
    width: 3.25rem;
    padding: 0.2rem 0.35rem;
    font-size: 0.8125rem;
    text-align: center;
    border: 1px solid var(--default-border, #e9edf4);
    border-radius: 0.375rem;
    background: #fff;
    color: var(--default-text-color, #536485);
}

.plm-tech-text-bar-border-w {
    width: 2.75rem;
}

.plm-tech-text-bar-divider {
    width: 1px;
    height: 1.35rem;
    background: var(--default-border, #e9edf4);
    flex-shrink: 0;
}

.plm-tech-text-bar-swatch {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin: 0;
    border: 1px solid var(--default-border, #e9edf4);
    border-radius: 0.375rem;
    overflow: hidden;
    cursor: pointer;
    background: #fff;
}

.plm-tech-text-bar-swatch-sm {
    width: 1.75rem;
    height: 1.75rem;
}

.plm-tech-text-bar-swatch input[type="color"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: none;
    opacity: 0;
    cursor: pointer;
}

.plm-tech-text-bar-swatch-label {
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
    color: var(--default-text-color, #536485);
}

.plm-tech-text-bar-btn {
    width: 2rem;
    height: 2rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--default-border, #e9edf4);
    border-radius: 0.375rem;
    background: #fff;
    color: var(--default-text-color, #536485);
}

.plm-tech-text-bar-btn:hover {
    background: rgba(var(--primary-rgb, 132, 90, 223), 0.08);
    color: rgb(var(--primary-rgb, 132, 90, 223));
}

.plm-tech-text-bar-btn.active {
    background: rgba(var(--primary-rgb, 132, 90, 223), 0.15);
    border-color: rgb(var(--primary-rgb, 132, 90, 223));
    color: rgb(var(--primary-rgb, 132, 90, 223));
}

.plm-tech-text-bar-btn i {
    font-size: 1.1rem;
    line-height: 1;
}

.plm-tech-editor-stage:focus {
    outline: none;
}

@media (max-width: 991.98px) {
    html[data-plm-tech-editor="true"] .main-content {
        height: calc(100vh - 2rem);
    }

    .plm-tech-layers-dock {
        top: 0.35rem;
        right: 0.35rem;
        bottom: 4.5rem;
        width: min(260px, calc(100% - 0.7rem));
    }
}
