/**
 * construtor_layout/MapLayoutComposer.css
 * Construtor de Layout de Mapa (Print Composer)
 * v2.0 — Melhorias: Tema claro/escuro, painel redimensionável, grade, escala, legenda
 */

/* ============================================================
   1. OVERLAY & LAYOUT PRINCIPAL
   ============================================================ */

.mlc-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    background: #0f1117;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    color: #e2e8f0;
    animation: mlc-fadeIn 0.3s ease;
}

@keyframes mlc-fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ============================================================
   2. TOOLBAR SUPERIOR
   ============================================================ */

.mlc-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: linear-gradient(180deg, #1a1e2e 0%, #151822 100%);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    height: 42px;
    min-height: 42px;
    max-height: 42px;
    flex-shrink: 0;
    flex-wrap: nowrap;
    overflow: hidden;
}

.mlc-toolbar-brand {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: 13px;
    color: #60a5fa;
    margin-right: 6px;
    white-space: nowrap;
}

.mlc-toolbar-brand i {
    font-size: 18px;
}

.mlc-toolbar-sep {
    width: 1px;
    height: 28px;
    background: rgba(255,255,255,0.1);
    margin: 0 4px;
}

.mlc-toolbar label {
    font-size: 11px;
    color: #94a3b8;
    margin-right: 4px;
    white-space: nowrap;
}

.mlc-toolbar select,
.mlc-toolbar input[type="number"] {
    background: #1e2235;
    border: 1px solid rgba(255,255,255,0.12);
    color: #e2e8f0;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.mlc-toolbar select:focus,
.mlc-toolbar input[type="number"]:focus {
    border-color: #60a5fa;
}

.mlc-toolbar select {
    min-width: 80px;
}

.mlc-toolbar input[type="number"] {
    width: 60px;
}

.mlc-toolbar-spacer {
    flex: 1;
}

.mlc-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.2s;
    white-space: nowrap;
}

.mlc-btn i {
    font-size: 14px;
}

.mlc-btn-ghost {
    background: transparent;
    color: #94a3b8;
}

.mlc-btn-ghost:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.mlc-btn-active {
    background: rgba(59, 130, 246, 0.25) !important;
    color: #3b82f6 !important;
    border-color: rgba(59, 130, 246, 0.4) !important;
}

/* Guias Magnéticas de Alinhamento (Snapping) */
.mlc-snap-guide-h,
.mlc-snap-guide-v {
    position: absolute;
    pointer-events: none;
    z-index: 999;
}

/* Alinhamento de Bordas (Edges): Azul Royal */
.mlc-snap-guide-h.mlc-snap-guide-edge,
.mlc-snap-guide-h:not(.mlc-snap-guide-center) {
    left: 0;
    right: 0;
    height: 0;
    border-top: 1.5px dashed #3b82f6;
    box-shadow: 0 0 3px rgba(59, 130, 246, 0.5);
}

.mlc-snap-guide-v.mlc-snap-guide-edge,
.mlc-snap-guide-v:not(.mlc-snap-guide-center) {
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 1.5px dashed #3b82f6;
    box-shadow: 0 0 3px rgba(59, 130, 246, 0.5);
}

/* Alinhamento de Centro (Center): Magenta vibrante com brilho */
.mlc-snap-guide-h.mlc-snap-guide-center {
    left: 0;
    right: 0;
    height: 0;
    border-top: 2px dashed #d946ef;
    box-shadow: 0 0 6px rgba(217, 70, 239, 0.7);
}

.mlc-snap-guide-v.mlc-snap-guide-center {
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 2px dashed #d946ef;
    box-shadow: 0 0 6px rgba(217, 70, 239, 0.7);
}

/* Rótulos de medição no mapa embarcado: herdar estilos de style.css, apenas desabilitar interação */
.mlc-embedded-map .ol-tooltip-static,
.mlc-embedded-map .ol-tooltip-measure,
.mlc-embedded-map .segment-measure {
    pointer-events: none !important;
}

.mlc-btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    box-shadow: 0 2px 8px rgba(59,130,246,0.3);
}

.mlc-btn-primary:hover {
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59,130,246,0.4);
}

.mlc-btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    box-shadow: 0 2px 8px rgba(16,185,129,0.3);
}

.mlc-btn-success:hover {
    background: linear-gradient(135deg, #34d399, #10b981);
    transform: translateY(-1px);
}

.mlc-btn-danger {
    background: rgba(239,68,68,0.15);
    color: #f87171;
}

.mlc-btn-danger:hover {
    background: rgba(239,68,68,0.25);
}

.mlc-btn-sm {
    padding: 3px 8px;
    font-size: 11px;
}

.mlc-btn-sm i {
    font-size: 12px;
}

/* ============================================================
   3. CORPO PRINCIPAL (3 colunas)
   ============================================================ */

.mlc-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ---- Painel Esquerdo: Paleta de Elementos ---- */

.mlc-palette {
    width: 220px;
    min-width: 160px;
    max-width: 450px;
    background: #151822;
    border-right: 1px solid rgba(255,255,255,0.06);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
    position: relative;
    transition: width 0.2s ease, min-width 0.2s ease;
}

.mlc-palette.mlc-collapsed {
    width: 0 !important;
    min-width: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    border: none !important;
}

.mlc-palette-resize-handle {
    position: absolute;
    right: -4px;
    top: 0;
    width: 8px;
    height: 100%;
    cursor: ew-resize;
    z-index: 20;
    background: transparent;
    transition: background 0.2s;
}

.mlc-palette-resize-handle:hover,
.mlc-palette-resize-handle.mlc-resizing {
    background: rgba(59, 130, 246, 0.4);
}

.mlc-palette-title {
    padding: 12px 14px 8px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #64748b;
    font-weight: 700;
}

/* ─── Accordion por tipo de elemento ─── */
.mlc-type-section {
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.mlc-type-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}

.mlc-type-header:hover {
    background: rgba(255,255,255,0.05);
}

.mlc-type-header i.mlc-type-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.mlc-type-header .mlc-type-name {
    flex: 1;
    font-size: 12px;
    font-weight: 600;
    color: #cbd5e0;
}

.mlc-type-header .mlc-type-count {
    font-size: 9px;
    font-weight: 700;
    background: rgba(255,255,255,0.1);
    color: #94a3b8;
    padding: 1px 6px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
}

.mlc-type-header .mlc-type-count.has-items {
    background: rgba(59,130,246,0.25);
    color: #60a5fa;
}

.mlc-type-header .mlc-type-chevron {
    font-size: 10px;
    color: #64748b;
    transition: transform 0.2s;
}

.mlc-type-section.expanded .mlc-type-chevron {
    transform: rotate(90deg);
}

.mlc-type-body {
    display: none;
    padding: 0 8px 8px 8px;
    flex-direction: column;
    gap: 3px;
}

.mlc-type-section.expanded .mlc-type-body {
    display: flex;
}

/* Cada instância de elemento na lista */
.mlc-inst-item {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s;
}

.mlc-inst-item:hover {
    background: rgba(255,255,255,0.07);
    border-color: rgba(255,255,255,0.15);
}

.mlc-inst-item.active {
    background: rgba(59,130,246,0.2);
    border-color: #3b82f6;
}

.mlc-inst-item .mlc-inst-name {
    flex: 1;
    font-size: 11px;
    font-weight: 500;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mlc-inst-item .mlc-inst-sub {
    font-size: 9px;
    color: #64748b;
    white-space: nowrap;
}

.mlc-inst-btn {
    width: 18px;
    height: 18px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 3px;
    color: #94a3b8;
    cursor: pointer;
    font-size: 10px;
    transition: all 0.15s;
    flex-shrink: 0;
}

.mlc-inst-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.mlc-inst-btn.del:hover {
    background: rgba(239,68,68,0.25);
    color: #ef4444;
}

/* Botão Adicionar dentro da seção */
.mlc-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 5px 8px;
    margin-top: 2px;
    background: rgba(59,130,246,0.08);
    border: 1px dashed rgba(59,130,246,0.3);
    border-radius: 5px;
    color: #60a5fa;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    width: 100%;
}

.mlc-add-btn:hover {
    background: rgba(59,130,246,0.15);
    border-color: #3b82f6;
    color: #93bbfc;
}

.mlc-add-btn i {
    font-size: 11px;
}

/* Seletor de mapa para vinculação */
.mlc-map-select {
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 3px;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.08);
    color: #cbd5e0;
    font-family: inherit;
    cursor: pointer;
    max-width: 90px;
}

.mlc-palette-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 8px 12px;
}

.mlc-badge-count {
    background: #3b82f6;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 8px;
    margin-left: auto;
}

/* ---- Área Central: Workspace/Canvas ---- */

.mlc-workspace {
    flex: 1;
    background: #0b0e14;
    background-image:
        radial-gradient(circle at 1px 1px, rgba(255,255,255,0.03) 1px, transparent 0);
    background-size: 20px 20px;
    overflow: auto;
    padding: 30px;
    position: relative;
    box-sizing: border-box;
}

/* ─── Botões Flutuantes de Borda para Expandir Painéis Recolhidos ─── */
.mlc-edge-toggle {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 99;
    background: #1e293b;
    color: #60a5fa;
    border: 1px solid rgba(59,130,246,0.35);
    padding: 10px 5px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    box-shadow: 0 4px 14px rgba(0,0,0,0.5);
    transition: all 0.2s ease;
    user-select: none;
}

.mlc-edge-toggle-left {
    left: 0;
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    border-left: none;
}

.mlc-edge-toggle-right {
    right: 0;
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
    border-right: none;
}

.mlc-edge-toggle:hover {
    background: #2563eb;
    color: #ffffff;
    border-color: #3b82f6;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 18px rgba(37,99,235,0.5);
}

.mlc-light .mlc-edge-toggle {
    background: #ffffff;
    color: #2563eb;
    border-color: #cbd5e1;
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}

.mlc-light .mlc-edge-toggle:hover {
    background: #2563eb;
    color: #ffffff;
}

.mlc-paper-wrapper {
    margin: 0 auto;
    position: relative;
    flex-shrink: 0;
    transition: width 0.2s ease, height 0.2s ease;
}

.mlc-paper {
    background: #ffffff;
    box-shadow:
        0 4px 20px rgba(0,0,0,0.5),
        0 0 0 1px rgba(0,0,0,0.2);
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: top left;
    transition: transform 0.2s ease;
}

.mlc-paper::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 1px dashed rgba(0,0,0,0.08);
    pointer-events: none;
    margin: 10px;
    z-index: 0;
}

/* ---- Painel Direito: Propriedades (redimensionável) ---- */

.mlc-properties {
    width: 300px;
    min-width: 220px;
    max-width: 500px;
    background: #151822;
    border-left: 1px solid rgba(255,255,255,0.06);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
    position: relative;
    transition: width 0.2s ease, min-width 0.2s ease;
}

.mlc-properties.mlc-collapsed {
    width: 0 !important;
    min-width: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    border: none !important;
}

.mlc-props-resize-handle {
    position: absolute;
    left: -4px;
    top: 0;
    width: 8px;
    height: 100%;
    cursor: ew-resize;
    z-index: 20;
    background: transparent;
    transition: background 0.2s;
}

.mlc-props-resize-handle:hover,
.mlc-props-resize-handle.mlc-resizing {
    background: rgba(59,130,246,0.4);
}

.mlc-props-header {
    padding: 12px 14px;
    font-size: 13px;
    font-weight: 700;
    color: #60a5fa;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 8px;
}

.mlc-props-empty {
    padding: 20px 14px;
    text-align: center;
    color: #475569;
    font-size: 12px;
    line-height: 1.6;
}

.mlc-props-group {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.mlc-props-group-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #64748b;
    font-weight: 700;
    margin-bottom: 8px;
}

.mlc-props-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.mlc-props-row label {
    font-size: 11px;
    color: #94a3b8;
    min-width: 32px;
    flex-shrink: 0;
}

.mlc-props-row input,
.mlc-props-row select {
    flex: 1;
    background: #1e2235;
    border: 1px solid rgba(255,255,255,0.1);
    color: #e2e8f0;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 11px;
    font-family: inherit;
    outline: none;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

.mlc-props-row input:focus,
.mlc-props-row select:focus {
    border-color: #3b82f6;
}

.mlc-props-row select option {
    background: #1e2235;
    color: #e2e8f0;
    font-size: 11px;
    padding: 4px 6px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mlc-props-row input[type="color"] {
    width: 32px;
    height: 26px;
    padding: 2px;
    cursor: pointer;
    flex: none;
}

/* Swatch clicável (preview da cor com input type=color nativo ancorado à esquerda para não cortar na borda) */
.mlc-color-swatch {
    position: relative;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 2px solid rgba(255,255,255,0.15);
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.mlc-color-swatch:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(59,130,246,0.4);
    border-color: #3b82f6;
}

.mlc-color-swatch input[type="color"] {
    position: absolute;
    top: 0;
    right: 0;
    width: 280px;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: none;
    padding: 0;
    margin: 0;
    background: transparent;
}

.mlc-props-row input[type="checkbox"] {
    flex: none;
    width: 16px;
    height: 16px;
    accent-color: #3b82f6;
}

.mlc-props-row input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #2d3348;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.mlc-props-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

/* ---- Legend items list in properties ---- */

.mlc-legend-items-list {
    max-height: 200px;
    overflow-y: auto;
    margin-top: 4px;
}

.mlc-legend-toggle-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    font-size: 11px;
    color: #cbd5e0;
}

.mlc-legend-toggle-item input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: #3b82f6;
    flex-shrink: 0;
}

.mlc-legend-toggle-item img {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 2px;
}

.mlc-legend-toggle-item .mlc-swatch {
    width: 14px;
    height: 14px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 2px;
    flex-shrink: 0;
}

.mlc-legend-toggle-item span {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================
   4. ELEMENTOS NO CANVAS (PAPEL)
   ============================================================ */

.mlc-element {
    position: absolute;
    cursor: move;
    user-select: none;
    outline: 2px solid transparent;
    outline-offset: -1px;
    transition: outline-color 0.15s;
    z-index: 1;
}

.mlc-element:hover {
    outline-color: rgba(59,130,246,0.4);
}

.mlc-element.mlc-selected {
    outline: calc(2px * var(--handle-scale, 1)) solid #3b82f6;
    z-index: 10;
}

.mlc-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #ffffff;
    border: 2.5px solid #2563eb;
    border-radius: 3px;
    display: none;
    z-index: 50;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.8);
    transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
}

.mlc-selected .mlc-handle {
    display: block;
}

.mlc-handle:hover {
    background: #2563eb;
    border-color: #ffffff;
    box-shadow: 0 4px 12px rgba(37,99,235,0.6);
}

.mlc-handle-nw { top: -6px; left: -6px; cursor: nwse-resize; transform: scale(var(--handle-scale, 1)); }
.mlc-handle-n  { top: -6px; left: 50%; cursor: ns-resize; transform: translateX(-50%) scale(var(--handle-scale, 1)); }
.mlc-handle-ne { top: -6px; right: -6px; cursor: nesw-resize; transform: scale(var(--handle-scale, 1)); }
.mlc-handle-e  { top: 50%; right: -6px; cursor: ew-resize; transform: translateY(-50%) scale(var(--handle-scale, 1)); }
.mlc-handle-se { bottom: -6px; right: -6px; cursor: nwse-resize; transform: scale(var(--handle-scale, 1)); }
.mlc-handle-s  { bottom: -6px; left: 50%; cursor: ns-resize; transform: translateX(-50%) scale(var(--handle-scale, 1)); }
.mlc-handle-sw { bottom: -6px; left: -6px; cursor: nesw-resize; transform: scale(var(--handle-scale, 1)); }
.mlc-handle-w  { top: 50%; left: -6px; cursor: ew-resize; transform: translateY(-50%) scale(var(--handle-scale, 1)); }

.mlc-handle-nw:hover { transform: scale(calc(var(--handle-scale, 1) * 1.35)); }
.mlc-handle-n:hover  { transform: translateX(-50%) scale(calc(var(--handle-scale, 1) * 1.35)); }
.mlc-handle-ne:hover { transform: scale(calc(var(--handle-scale, 1) * 1.35)); }
.mlc-handle-e:hover  { transform: translateY(-50%) scale(calc(var(--handle-scale, 1) * 1.35)); }
.mlc-handle-se:hover { transform: scale(calc(var(--handle-scale, 1) * 1.35)); }
.mlc-handle-s:hover  { transform: translateX(-50%) scale(calc(var(--handle-scale, 1) * 1.35)); }
.mlc-handle-sw:hover { transform: scale(calc(var(--handle-scale, 1) * 1.35)); }
.mlc-handle-w:hover  { transform: translateY(-50%) scale(calc(var(--handle-scale, 1) * 1.35)); }

/* Alça de rotação para textos e elementos */
.mlc-handle-rot {
    top: -24px;
    left: 50%;
    width: 14px;
    height: 14px;
    background: #0284c7;
    border: 2px solid #ffffff;
    border-radius: 50%;
    cursor: grab;
    transform: translateX(-50%) scale(var(--handle-scale, 1));
    z-index: 60;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
.mlc-handle-rot::after {
    content: '';
    position: absolute;
    top: 12px;
    left: 4px;
    width: 2px;
    height: 12px;
    background: #0284c7;
    pointer-events: none;
}
.mlc-handle-rot:hover {
    background: #38bdf8;
    transform: translateX(-50%) scale(calc(var(--handle-scale, 1) * 1.3));
    box-shadow: 0 3px 10px rgba(2, 132, 199, 0.6);
}
.mlc-handle-rot:active {
    cursor: grabbing;
    background: #0369a1;
}

/* Alças circulares para elementos vetoriais (Seta e Linha) */
.mlc-point-handle {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(var(--handle-scale, 1));
    cursor: grab;
    z-index: 60;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45), 0 0 0 2px #ffffff;
}

.mlc-selected .mlc-point-handle {
    display: block !important;
}

.mlc-handle-p1 {
    background: #10b981; /* Verde no início */
    border: 2px solid #ffffff;
}

.mlc-handle-p2 {
    background: #ef4444; /* Vermelho na ponta */
    border: 2px solid #ffffff;
}

.mlc-point-handle:hover {
    transform: translate(-50%, -50%) scale(calc(var(--handle-scale, 1) * 1.45)) !important;
    box-shadow: 0 0 12px rgba(37, 99, 235, 0.8), 0 0 0 2px #ffffff !important;
}

.mlc-point-handle:active {
    cursor: grabbing;
}

/* Elementos sem borda de seleção rígida para flechas e linhas */
.mlc-element[data-type="arrow"].mlc-selected,
.mlc-element[data-type="shape_line"].mlc-selected {
    outline: 1px dashed rgba(59, 130, 246, 0.45) !important;
}

/* Banner de modo desenho interativo */
.mlc-draw-banner {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(56, 189, 248, 0.45);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
    color: #f8fafc;
    padding: 7px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    display: none;
    align-items: center;
    gap: 8px;
    z-index: 250;
    user-select: none;
    animation: mlcSlideDown 0.25s ease;
}

.mlc-draw-banner button {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.mlc-draw-banner button:hover {
    background: rgba(239, 68, 68, 0.85);
}

.mlc-draw-banner button.mlc-banner-finish {
    background: rgba(16, 185, 129, 0.85);
    border-color: rgba(16, 185, 129, 1);
}

.mlc-draw-banner button.mlc-banner-finish:hover {
    background: #059669;
}

.mlc-poly-op-preset {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.mlc-poly-op-preset:hover {
    background: rgba(59, 130, 246, 0.25);
    color: #38bdf8;
    border-color: rgba(59, 130, 246, 0.5);
}

.mlc-draw-preview-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
}


/* ---- Tipos de elemento ---- */

.mlc-el-mapframe {
    background: #e8ecf1;
    border: 1px solid #94a3b8;
    overflow: hidden;
}

.mlc-el-mapframe img {
    width: 100%;
    height: 100%;
    object-fit: fill;
    display: block;
}

.mlc-el-mapframe .mlc-map-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 13px;
    gap: 8px;
    background: repeating-linear-gradient(
        45deg, transparent, transparent 10px,
        rgba(0,0,0,0.02) 10px, rgba(0,0,0,0.02) 20px
    );
}

.mlc-el-mapframe .mlc-map-placeholder i {
    font-size: 32px;
    color: #94a3b8;
}

.mlc-el-title {
    color: #1a1a2e;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
}

.mlc-el-title [contenteditable] {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    padding: 4px;
}

.mlc-el-legend {
    border: 1px solid #cbd5e0;
    background: #ffffff;
    padding: 6px;
    overflow: hidden;
}

.mlc-el-legend .mlc-legend-title {
    font-size: 11px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 4px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 3px;
}

.mlc-el-legend .mlc-legend-body {
    width: 100%;
}

.mlc-el-legend .mlc-legend-block {
    break-inside: avoid-column;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
    display: inline-block;
    width: 100%;
}

.mlc-el-legend .mlc-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    font-size: 10px;
    color: #334155;
}

.mlc-el-legend .mlc-legend-swatch {
    width: 14px;
    height: 14px;
    border: 1px solid #94a3b8;
    border-radius: 2px;
    flex-shrink: 0;
}

.mlc-el-legend .mlc-legend-img {
    max-width: 100%;
    display: block;
    margin: 2px 0;
}

.mlc-el-chart {
    border: 1px solid #cbd5e0;
    background: #ffffff;
    padding: 2px;
    overflow: hidden;
}

.mlc-el-scalebar {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    color: #1a1a2e;
}

.mlc-scalebar-bar {
    display: flex;
    height: 8px;
    border: 1px solid #1a1a2e;
}

.mlc-scalebar-bar span {
    height: 100%;
    display: block;
}

.mlc-scalebar-bar span:nth-child(odd) {
    background: #1a1a2e;
}

.mlc-scalebar-bar span:nth-child(even) {
    background: #fff;
}

.mlc-scalebar-labels {
    display: flex;
    justify-content: space-between;
    width: 100%;
    font-size: 8px;
    color: #334155;
    margin-top: 1px;
}

.mlc-scalebar-text {
    font-size: 8px;
    color: #555;
    margin-top: 1px;
    text-align: center;
    width: 100%;
}

.mlc-el-north {
    display: flex;
    align-items: center;
    justify-content: center;
}

.mlc-el-north svg {
    width: 100%;
    height: 100%;
}

.mlc-el-datebox {
    color: #334155;
    font-size: 10px;
    padding: 2px 4px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-sizing: border-box;
}

.mlc-el-datebox [contenteditable] {
    outline: none;
    line-height: 1.35;
}

.mlc-el-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.mlc-el-logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.mlc-el-logo .mlc-logo-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 10px;
    gap: 4px;
    width: 100%;
    height: 100%;
    border: 1px dashed #cbd5e0;
    cursor: pointer;
}

.mlc-el-logo .mlc-logo-placeholder i {
    font-size: 20px;
}

.mlc-el-textbox {
    color: #334155;
    font-size: 11px;
    padding: 4px;
}

.mlc-el-textbox [contenteditable] {
    width: 100%;
    height: 100%;
    outline: none;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.mlc-el-locationmap {
    border: 1px solid #94a3b8;
    background: #e8ecf1;
    overflow: hidden;
}

.mlc-el-locationmap .mlc-locmap-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 10px;
    gap: 4px;
}

.mlc-el-locationmap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Grade de coordenadas overlay */
.mlc-el-grid {
    pointer-events: none !important;
}

.mlc-grid-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    overflow: visible;
}

.mlc-grid-overlay .mlc-grid-line-h,
.mlc-grid-overlay .mlc-grid-line-v {
    position: absolute;
}

.mlc-grid-overlay .mlc-grid-line-h {
    width: 100%;
    height: 1px;
}

.mlc-grid-overlay .mlc-grid-line-v {
    width: 1px;
    height: 100%;
}

/* Crosses */
.mlc-grid-overlay .mlc-grid-cross {
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.mlc-grid-overlay .mlc-grid-cross::before,
.mlc-grid-overlay .mlc-grid-cross::after {
    display: none;
}

.mlc-grid-overlay .mlc-grid-label {
    position: absolute;
    font-size: 7px;
    color: #1a1a2e;
    font-family: 'Inter', monospace;
    background: rgba(255,255,255,0.85);
    padding: 0 2px;
    white-space: nowrap;
}

/* ============================================================
   5. STATUSBAR
   ============================================================ */

.mlc-statusbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 4px 14px;
    background: #111420;
    border-top: 1px solid rgba(255,255,255,0.06);
    font-size: 10px;
    color: #64748b;
    flex-shrink: 0;
}

.mlc-statusbar span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ============================================================
   6. TEMPLATE MODAL
   ============================================================ */

.mlc-template-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #1a1e2e;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 24px;
    z-index: 100;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    min-width: 400px;
}

.mlc-template-modal h3 {
    color: #60a5fa;
    margin-bottom: 16px;
    font-size: 16px;
}

.mlc-template-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.mlc-template-card {
    background: #222840;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.mlc-template-card:hover {
    border-color: #3b82f6;
    background: #283050;
    transform: translateY(-2px);
}

.mlc-template-card i {
    font-size: 24px;
    color: #60a5fa;
    margin-bottom: 8px;
    display: block;
}

.mlc-template-card .mlc-template-name {
    font-size: 12px;
    font-weight: 600;
    color: #e2e8f0;
}

.mlc-template-card .mlc-template-desc {
    font-size: 10px;
    color: #64748b;
    margin-top: 4px;
}

/* ============================================================
   7. ZOOM CONTROLS
   ============================================================ */

.mlc-zoom-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.mlc-zoom-controls input[type="range"] {
    width: 100px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #2d3348;
    border-radius: 2px;
    outline: none;
}

.mlc-zoom-controls input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: 2px solid #fff;
}

.mlc-zoom-label {
    font-size: 11px;
    color: #94a3b8;
    width: 36px;
    text-align: center;
}

/* ============================================================
   8. EXPORTING OVERLAY
   ============================================================ */

.mlc-exporting {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    gap: 16px;
}

.mlc-exporting-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(96,165,250,0.2);
    border-top-color: #60a5fa;
    border-radius: 50%;
    animation: mlc-spin 0.8s linear infinite;
}

@keyframes mlc-spin {
    to { transform: rotate(360deg); }
}

.mlc-exporting-text {
    color: #e2e8f0;
    font-size: 14px;
    font-weight: 600;
}

/* ============================================================
   9. SCROLLBAR
   ============================================================ */

.mlc-overlay ::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.mlc-overlay ::-webkit-scrollbar-track {
    background: transparent;
}

.mlc-overlay ::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.12);
    border-radius: 3px;
}

.mlc-overlay ::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.2);
}

/* ============================================================
   10. TEMA CLARO
   ============================================================ */

.mlc-overlay.mlc-light {
    background: #f0f2f5;
    color: #1a1a2e;
}

.mlc-light .mlc-toolbar {
    background: linear-gradient(180deg, #ffffff 0%, #f8f9fc 100%);
    border-bottom: 1px solid #e2e8f0;
}

.mlc-light .mlc-toolbar-brand { color: #2563eb; }

.mlc-light .mlc-toolbar-sep { background: #e2e8f0; }

.mlc-light .mlc-toolbar label { color: #64748b; }

.mlc-light .mlc-toolbar select,
.mlc-light .mlc-toolbar input[type="number"] {
    background: #fff;
    border: 1px solid #d1d5db;
    color: #1a1a2e;
}

.mlc-light .mlc-btn-ghost { color: #64748b; }
.mlc-light .mlc-btn-ghost:hover { background: rgba(0,0,0,0.06); color: #1a1a2e; }

.mlc-light .mlc-palette {
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
}




.mlc-light .mlc-workspace {
    background: #e5e7eb;
    background-image: radial-gradient(circle at 1px 1px, rgba(0,0,0,0.06) 1px, transparent 0);
    background-size: 20px 20px;
}

.mlc-light .mlc-paper {
    box-shadow: 0 4px 20px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.08);
}

.mlc-light .mlc-properties {
    background: #ffffff;
    border-left: 1px solid #e2e8f0;
}

.mlc-light .mlc-props-header { color: #2563eb; border-bottom-color: #e2e8f0; }
.mlc-light .mlc-props-empty { color: #94a3b8; }
.mlc-light .mlc-props-group { border-bottom-color: #f1f5f9; }
.mlc-light .mlc-props-group-title { color: #94a3b8; }
.mlc-light .mlc-props-row label { color: #64748b; }

.mlc-light .mlc-props-row input,
.mlc-light .mlc-props-row select {
    background: #f8f9fc;
    border: 1px solid #d1d5db;
    color: #1a1a2e;
}

.mlc-light .mlc-props-resize-handle:hover,
.mlc-light .mlc-props-resize-handle.mlc-resizing {
    background: rgba(37,99,235,0.3);
}

.mlc-light .mlc-legend-toggle-item { color: #334155; }
.mlc-light .mlc-legend-toggle-item img { border-color: #d1d5db; }

.mlc-light .mlc-statusbar {
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    color: #94a3b8;
}

.mlc-light .mlc-zoom-controls input[type="range"] { background: #d1d5db; }
.mlc-light .mlc-zoom-label { color: #64748b; }

.mlc-light .mlc-template-modal {
    background: #fff;
    border-color: #e2e8f0;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.mlc-light .mlc-template-modal h3 { color: #2563eb; }
.mlc-light .mlc-template-card { background: #f8f9fc; border-color: #e2e8f0; }
.mlc-light .mlc-template-card:hover { border-color: #3b82f6; background: #eff6ff; }
.mlc-light .mlc-template-card i { color: #2563eb; }
.mlc-light .mlc-template-card .mlc-template-name { color: #1a1a2e; }
.mlc-light .mlc-template-card .mlc-template-desc { color: #94a3b8; }

/* ─── Accordion da Paleta: Tema Claro ─── */
.mlc-light .mlc-palette-title { color: #64748b; }

.mlc-light .mlc-type-section { border-bottom-color: #e2e8f0; }
.mlc-light .mlc-type-header:hover { background: rgba(0,0,0,0.04); }
.mlc-light .mlc-type-header .mlc-type-name { color: #1e293b; }
.mlc-light .mlc-type-header .mlc-type-count { background: #e2e8f0; color: #475569; }
.mlc-light .mlc-type-header .mlc-type-count.has-items { background: rgba(37,99,235,0.12); color: #2563eb; }
.mlc-light .mlc-type-header .mlc-type-chevron { color: #94a3b8; }

.mlc-light .mlc-inst-item {
    background: #f8fafc;
    border-color: #e2e8f0;
}
.mlc-light .mlc-inst-item:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
}
.mlc-light .mlc-inst-item.active {
    background: #dbeafe;
    border-color: #3b82f6;
}
.mlc-light .mlc-inst-item .mlc-inst-name { color: #1e293b; }
.mlc-light .mlc-inst-item .mlc-inst-sub { color: #64748b; }
.mlc-light .mlc-inst-btn { color: #64748b; }
.mlc-light .mlc-inst-btn:hover { background: rgba(0,0,0,0.08); color: #1e293b; }
.mlc-light .mlc-inst-btn.del:hover { background: rgba(239,68,68,0.12); color: #dc2626; }

.mlc-light .mlc-add-btn {
    background: rgba(37,99,235,0.06);
    border-color: rgba(37,99,235,0.25);
    color: #2563eb;
}
.mlc-light .mlc-add-btn:hover {
    background: rgba(37,99,235,0.12);
    border-color: #3b82f6;
    color: #1d4ed8;
}

.mlc-light .mlc-map-select {
    background: #f8fafc;
    border-color: #d1d5db;
    color: #1e293b;
}

.mlc-light ::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); }
.mlc-light ::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.2); }

/* ============================================================
   11. RESPONSIVO
   ============================================================ */

@media (max-width: 1024px) {
    .mlc-palette { width: 180px; }
}

@media (max-width: 768px) {
    .mlc-palette { width: 50px; }
    .mlc-type-header .mlc-type-name,
    .mlc-type-header .mlc-type-count,
    .mlc-type-header .mlc-type-chevron,
    .mlc-palette-title { display: none; }
    .mlc-type-header { justify-content: center; padding: 10px 0; }
    .mlc-type-body { display: none !important; }
}
