/* =========================================
   CONTEXT MENU
   ========================================= */
.wox-context-menu {
    position: fixed;
    background: #fff;
    min-width: 180px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    border-radius: 4px;
    z-index: 999999;
    display: none;
    flex-direction: column;
    padding: 5px 0;
    border: 1px solid #ddd;
}

.wox-context-menu.active {
    display: flex;
}

.wox-context-menu-item {
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: background 0.2s;
}

.wox-context-menu-item:hover {
    background: #f5f5f5;
}

.wox-context-menu-item.disabled {
    color: #ccc;
    pointer-events: none;
}

.wox-context-menu-item .material-icons {
    font-size: 18px;
    color: #666;
}

.wox-context-menu-divider {
    height: 1px;
    background: #eee;
    margin: 5px 0;
}

.icon-more {
    margin-left: 5px;
    transition: color 0.2s;
    color: #fff;
    opacity: 0.8;
}

.icon-more:hover {
    color: #2196F3 !important;
    opacity: 1;
}

.canvas-element.context-active {
    outline: 2px solid #2196F3 !important;
}

/* =========================================
   1. RESET & LAYOUT GLOBALE
   ========================================= */
* { box-sizing: border-box; }

body { 
    margin: 0 !important; 
    padding: 0 !important; 
    font-family: 'Roboto', sans-serif; 
    background-color: #f1f3f5;
    display: flex; flex-direction: column; /* Per ospitare la top bar */        
    height: 100vh; width: 100vw; overflow: hidden;           
}

/* =========================================
   0. TOP MENU BAR
   ========================================= */
#top-menu-bar {
    height: 50px;
    background-color: #1a1a1a;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 1000;
    flex-shrink: 0;
}

.app-logo { font-size: 18px; letter-spacing: 1px; color: #fff; }
.app-logo b { color: #39b54a; }

.top-menu-center { position: relative; }
#btn-pages-menu {
    text-transform: none;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 0 15px;
    height: 36px;
    line-height: 36px;
    cursor: pointer;
    transition: background 0.2s;
    background: transparent;
    color: white;
    display: flex;
    align-items: center;
    box-shadow: none !important;
}
#btn-pages-menu:hover { background: #333; }

.dropdown-content-custom {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    min-width: 260px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border-radius: 4px;
    display: none;
    z-index: 99999; /* Valore altissimo per stare sopra a tutto */
    max-height: 450px;
    overflow: visible;
    color: #333;
    flex-direction: column;
    border: 1px solid #444;
}
.dropdown-content-custom.active { display: flex; }

.pages-list-scroll {
    max-height: 350px;
    overflow-y: auto;
}

.page-item-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s;
    color: #333;
    font-size: 14px;
}
.page-item-link:hover { background: #f5f5f5; }
.page-item-link.active { background: #eef7f0; color: #39b54a; font-weight: bold; }
.page-item-link .material-icons { font-size: 18px; }
.page-item-link .btn-delete-page { 
    color: #ccc; 
    transition: color 0.2s; 
}
.page-item-link:hover .btn-delete-page { color: #d32f2f; }

.dropdown-divider { height: 1px; background: #eee; margin: 0; }
.add-page-btn {
    padding: 12px 15px;
    background: #f9f9f9;
    color: #39b54a !important;
    font-weight: bold;
    text-align: center;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    width: 100%;
}
.add-page-btn:hover { background: #eef7f0; }

/* Main Container Flex */
#main-container {
    display: flex;
    flex-direction: row;
    flex: 1;
    overflow: hidden;
    width: 100%;
}

/* Reset aggressivo per evitare spazi bianchi indesiderati */
h1, h2, h3, h4, h5, h6, p, ul, ol, figure {
    margin-top: 0;
    margin-bottom: 1rem;
}

/* =========================================
   2. SIDEBAR SINISTRA
   ========================================= */
#sidebar {
    width: 300px; height: 100%; background: #fff; border-right: 1px solid #e0e0e0;
    display: flex; flex-direction: column; flex-shrink: 0; min-width: 300px; z-index: 20;
}
.sidebar-header { background: #fff; padding: 0; box-shadow: 0 2px 5px rgba(0,0,0,0.05); flex-shrink: 0; }
.sidebar-header h3 { text-align: center; font-size: 14px; font-weight: 700; margin: 15px 0; text-transform: uppercase; }

.sidebar-tabs { display: flex; border-bottom: 1px solid #ddd; }
.tab { flex: 1; text-align: center; padding: 10px; font-size: 13px; cursor: pointer; color: #555; transition: 0.2s; }
.tab:hover { background: #f9f9f9; }
.tab.active { border-bottom: 2px solid #333; font-weight: 500; color: #000; }

.search-box { padding: 15px; position: relative; }
.search-box input { width: 100%; padding: 8px 10px 8px 50px; border: 1px solid #ddd; background: #fafafa; border-radius: 3px; font-size: 13px; height: 35px; margin: 0; text-align: left; }
.search-box i { position: absolute; left: 22px; top: 50%; transform: translateY(-50%); font-size: 18px; color: #999; }

.sidebar-content { flex: 1; overflow-y: auto; padding-bottom: 20px; position: relative; }
.sidebar-pane { display: none; }
.sidebar-pane.active { display: block; }

.category-title { padding: 15px 20px 5px; font-size: 13px; font-weight: 700; color: #333; display: flex; align-items: center; }
.widgets-grid { display: grid !important; grid-template-columns: 1fr 1fr; gap: 0; padding: 0 10px; }
.widget-item { background: #fff; border: 1px solid #e5e5e5; padding: 15px 5px; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: grab; margin: -1px 0 0 -1px; height: 90px; transition: all 0.2s; }
.widget-item:hover { background: #f9f9f9; z-index: 2; position: relative; border-color: #ccc; }
.widget-item i { font-size: 26px; color: #555; margin-bottom: 8px; }
.widget-item span { font-size: 12px; color: #555; text-align: center; }

/* =========================================
   3. CANVAS (AREA DI LAVORO)
   ========================================= */
#canvas-wrapper { 
    flex-grow: 1; 
    background: #e6e6e6; 
    display: flex; 
    justify-content: center; 
    overflow-y: auto; 
    padding: 40px; 
    position: relative; 
    min-width: 0; 
}

body.is-resizing {
    user-select: none !important;
    cursor: col-resize !important;
}

#canvas { 
    width: 100%; 
    max-width: 1140px; 
    min-height: calc(100vh - 80px);
    height: auto;
    background: #fff; 
    box-shadow: 0 5px 20px rgba(0,0,0,0.1); 
    
    /* FIX: Nessun padding default, gestito da JS Globali */
    padding: 0; 
    padding-bottom: 100px; 
    
    /* FIX CRITICO: flow-root impedisce il margin-collapse */
    display: flow-root; 
    position: relative;
    margin: 0 auto;
}

.empty-state { padding: 50px; text-align: center; border: 2px dashed #ddd; margin: 20px; color: #aaa; }

/* Rimuove margini esterni dal primo elemento per evitare spazi in alto */
#canvas > .canvas-element:first-child { margin-top: 0 !important; }

/* =========================================
   4. ELEMENTI CANVAS & TOOLBARS
   ========================================= */

/* --- CONTENITORE --- */
.canvas-element.container-widget { 
    border: 1px solid transparent; 
    margin: 0; 
    padding: 0 !important; /* Nessuno spazio interno */
    position: relative; 
    transition: all 0.2s; 
    min-height: 50px;
    overflow: visible; /* Permette alla toolbar di uscire */
}

/* Feedback Dragging */
.canvas-element.dragging {
    opacity: 0.5;
    border: 2px dashed #39b54a !important;
    background: rgba(57, 181, 74, 0.05);
}

/* Toolbar Rosa (Contenitore) */
.container-toolbar { 
    position: absolute; 
    top: -22px; /* Fuori dal box (sopra) */
    left: 50%; 
    transform: translateX(-50%); 
    background-color: #eda1e7; 
    color: white; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    padding: 2px 10px; 
    border-radius: 4px 4px 0 0; 
    z-index: 100; 
    opacity: 0; 
    transition: opacity 0.2s; 
    height: 22px;
    font-size: 0; 
    cursor: pointer;
}
.canvas-element.container-widget:hover .container-toolbar, 
.canvas-element.container-widget.selected .container-toolbar { opacity: 1; }
.container-toolbar i { font-size: 16px; margin: 0 6px; cursor: pointer; }
.container-toolbar .icon-drag { cursor: move; }

/* Wrapper interno */
.container-content-wrapper { 
    border: 1px dashed #d5d8dc; 
    padding: 0; 
    background: transparent; 
    transition: border 0.2s; 
    width: 100%;
}
.canvas-element.container-widget.selected .container-content-wrapper { border: 1px solid #eda1e7; }

/* Flex Area Interna */
.container-inner-content { 
    display: flex; flex-wrap: wrap; width: 100%; min-height: 60px; 
    padding: 10px; /* Padding interno di default del WIDGET */
    margin: 0 auto; position: relative; 
}
.container-inner-content.drag-over-active { box-shadow: inset 0 0 0 2px #58D0F5, inset 0 0 20px rgba(88, 208, 245, 0.2) !important; }

/* Placeholder */
.empty-container-placeholder { width: 100%; padding: 30px; text-align: center; color: #aaa; background: rgba(255,255,255,0.5); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; pointer-events: none; }
.plus-icon-circle { width: 35px; height: 35px; background: #eee; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #555; font-size: 20px; transition: 0.2s; pointer-events: auto; }
.plus-icon-circle:hover { background: #39b54a; color: white; cursor: pointer; }

/* --- WIDGET GENERICI --- */
.widget-text, .canvas-element:not(.container-widget) { 
    position: relative; border: 1px solid transparent; padding: 2px; background: transparent; margin: 5px;
    min-width: 0; /* Permette la riduzione del box in flexbox */
}
.widget-text:hover, .canvas-element:not(.container-widget):hover { border: 1px solid #58D0F5; }

/* Toolbar Blu (Widget) */
.element-toolbar { 
    position: absolute; 
    top: -20px; 
    right: 0; 
    background: #58D0F5; 
    color: white; 
    font-size: 11px; 
    padding: 2px 8px; 
    border-radius: 3px 3px 0 0; 
    display: none; 
    align-items: center; 
    z-index: 101; 
    cursor: pointer; 
    height: 20px;
}
.canvas-element:hover .element-toolbar, .canvas-element.selected .element-toolbar { display: flex; }

/* RESIZER */
.col-resizer {
    position: absolute;
    right: -5px;
    top: 0;
    bottom: 0;
    width: 10px;
    cursor: col-resize;
    z-index: 1000;
    display: none;
}
.canvas-element.selected > .col-resizer {
    display: block;
}
.col-resizer::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 10%;
    bottom: 10%;
    width: 2px;
    background: #58D0F5;
    border-radius: 2px;
    opacity: 0.5;
}
.col-resizer:hover::after {
    opacity: 1;
}

#canvas a {
    cursor: default;
    text-decoration: none;
}
body.ctrl-pressed #canvas a {
    cursor: pointer;
}

/* =========================================
   5. AREA "AGGIUNGI SEZIONE"
   ========================================= */
#add-section-area {
    padding: 40px 0;
    margin-top: 20px;
    border: 2px dashed #ddd;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    background-color: rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
}
#add-section-area:hover {
    border-color: #eda1e7;
    background-color: rgba(237, 161, 231, 0.05);
}
.add-section-box { display: flex; flex-direction: column; align-items: center; gap: 10px; }
#btn-add-section, #btn-add-block {
    width: 40px; height: 40px; border-radius: 50%;
    background-color: #eda1e7; color: white; border: none;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}
#btn-add-section:hover, #btn-add-block:hover { transform: scale(1.1); background-color: #e08dd9; }
#btn-add-section i, #btn-add-block i { font-size: 24px; }
.add-section-box span { font-size: 12px; color: #999; font-weight: 500; }

/* =========================================
   6. PANNELLO PROPRIETÀ
   ========================================= */
#properties-panel {
    width: 300px; background: #fff; border-left: 1px solid #ddd;
    display: flex; flex-direction: column; z-index: 30;
    flex-shrink: 0;
    height: 100%;
}

#panel-content {
    flex: 1;
    overflow-y: hidden;
    display: flex;
    flex-direction: column;
}

.panel-header { padding: 15px; background: #fff; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.panel-header h4 { margin: 0; font-size: 15px; font-weight: 700; text-transform: uppercase; }
.panel-tabs { display: flex; border-bottom: 1px solid #e0e0e0; background: #fff; flex-shrink: 0; width: 100%; }
.panel-tab { flex: 1; text-align: center; padding: 12px 5px; border: none; background: none; border-bottom: 3px solid transparent; font-weight: 500; color: #666; cursor: pointer; font-size: 13px; }
.panel-tab.active { border-bottom-color: #39b54a; color: #000; }
.panel-tab-content { display: none; padding: 20px; overflow-y: auto; flex: 1; flex-direction: column; }
.panel-tab-content.active { display: flex; }

/* UI Standard */
.control-group { margin-bottom: 20px; width: 100%; }
.control-group label { display: block; font-size: 12px; font-weight: 500; color: #555; margin-bottom: 8px; text-align: left; }
.control-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.section-title { 
    font-weight: 700; 
    font-size: 11px; 
    margin: 20px 0 15px 0; 
    color: #555; 
    display: flex; 
    align-items: center; 
    width: 100%; 
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 8px;
}
.section-title i { font-size: 14px; margin-right: 8px; color: #999; }

.input-with-icon {
    display: flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: #fff;
    height: 35px;
    padding: 0 8px;
}
.input-with-icon i {
    font-size: 16px;
    color: #999;
    margin-right: 8px;
}
.input-with-icon input {
    border: none !important;
    height: 100%;
    width: 100%;
    margin: 0 !important;
    font-size: 13px;
    outline: none;
}

/* Grid 4 Input */
.spacing-control { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr 30px; gap: 0; background: #fff; border-radius: 3px; }
.spacing-input-col { display: flex; flex-direction: column; }
.spacing-input-col input { width: 100%; border: 1px solid #ddd; border-right: none; padding: 6px; font-size: 12px; text-align: center; outline: none; margin: 0 !important; height: 32px; }
.spacing-input-col:first-child input { border-radius: 3px 0 0 3px; }
.spacing-input-col label { font-size: 9px; color: #999; text-align: center; margin-top: 4px; font-weight: normal; }
.spacing-link-btn { width: 30px; height: 32px; background: #e0e0e0; border: 1px solid #ccc; border-radius: 0 3px 3px 0; display: flex; align-items: center; justify-content: center; cursor: pointer; color: #777; transition: 0.2s; }
.spacing-link-btn.active { background: #ccc; color: #333; box-shadow: inset 0 1px 3px rgba(0,0,0,0.1); }
.spacing-link-btn i { font-size: 14px; }

/* Standard Controls */
.panel-select { display: block !important; width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 3px; background: #fff; margin-bottom: 5px; height: 35px; cursor: pointer; font-size: 13px; -webkit-appearance: none; }
.input-with-unit { display: flex !important; flex-direction: row; border: 1px solid #ddd; border-radius: 3px; overflow: hidden; width: 100%; height: 35px; background: #fff; }
.input-with-unit input { flex: 1; border: none !important; padding: 5px 10px; text-align: left; width: auto; font-size: 13px; outline: none; height: 100%; margin: 0 !important; }
.unit-select { display: block !important; width: 60px; border: none; border-left: 1px solid #ddd; background: #f9f9f9; font-size: 11px; padding: 0 5px; height: 100%; cursor: pointer; color: #555; outline: none; }
.range-slider-group { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; }
.range-slider { flex: 1; height: 4px; background: #ddd; -webkit-appearance: none; outline: none; border-radius: 2px; }
.range-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; background: #fff; border: 2px solid #39b54a; border-radius: 50%; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }

/* Slider + Number Row */
.slider-number-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.slider-number-row .range-slider {
    flex: 1;
    margin-bottom: 0;
}

.slider-number-row .number-input-box {
    width: 85px;
    display: flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: #fff;
    height: 28px;
    overflow: hidden;
    flex-shrink: 0;
}

.slider-number-row .number-input-box input {
    width: 100%;
    border: none !important;
    padding: 0 5px !important;
    font-size: 11px !important;
    height: 100% !important;
    outline: none !important;
    margin: 0 !important;
    text-align: center;
}

.slider-number-row .number-input-box .unit-label,
.slider-number-row .number-input-box .unit-select {
    font-size: 9px;
    color: #777;
    padding: 0 4px;
    background: #f9f9f9;
    border-left: 1px solid #ddd;
    height: 100%;
    display: flex;
    align-items: center;
    -webkit-appearance: none;
}

/* Icons & Colors */
.icon-toggle-group, .bg-type-group { display: flex !important; flex-direction: row; border: 1px solid #ddd; border-radius: 3px; overflow: hidden; width: 100%; }
.bg-type-group { padding: 4px; border:none; gap:5px; background: transparent; }
.icon-toggle-btn { flex: 1; background: #fff; border: none; border-right: 1px solid #ddd; padding: 8px 0; cursor: pointer; color: #555; display: flex; justify-content: center; align-items: center; height: 36px; }
.icon-toggle-btn:last-child { border-right: none; }
.icon-toggle-btn.active { background: #eef7f0; color: #39b54a; }
.icon-toggle-btn i, .bg-type-btn i { font-size: 18px !important; line-height: 1; }
.bg-type-btn { width: 32px; height: 32px; flex: none; border: 1px solid transparent; border-radius: 3px; display: flex; justify-content: center; align-items: center; cursor: pointer; background: white; }
.bg-type-btn:hover { background: #f0f0f0; }
.bg-type-btn.active { background: #e0e0e0; color: #333; border-color: #ccc; }
.icon-btn-small { width: 28px; height: 28px; border: 1px solid transparent; background: transparent; border-radius: 3px; display: flex; justify-content: center; align-items: center; cursor: pointer; color: #555; transition: 0.2s; }
.icon-btn-small:hover { background: #e0e0e0; }
.color-picker-row { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-bottom: 10px; }
.color-preview { width: 30px; height: 30px; border-radius: 3px; border: 1px solid #ddd; overflow: hidden; position: relative; cursor: pointer; }
.color-preview input[type="color"] { position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; padding: 0; margin: 0; cursor: pointer; border: none; }
.image-upload-box { background: #e5e5e5; height: 100px !important; width: 100%; border-radius: 3px; display: flex; align-items: center; justify-content: center; cursor: pointer; position: relative; border: 1px solid #d5d5d5; overflow: hidden; margin-top: 5px; }
.image-upload-box:hover { background: #dcdcdc; }
.image-upload-box i.icon-add { color: #fff; font-size: 24px; text-shadow: 0 1px 3px rgba(0,0,0,0.2); position: relative; z-index: 1; pointer-events: none; }
.image-preview-bg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-size: cover; background-position: center; z-index: 0; }
.btn-delete-img { position: absolute; top: 5px; right: 5px; background: rgba(255, 255, 255, 0.9); color: #d32f2f; border-radius: 50%; width: 24px; height: 24px; display: none; align-items: center; justify-content: center; cursor: pointer; z-index: 10; }
.image-upload-box.has-image:hover .btn-delete-img { display: flex; }
.image-upload-box.has-image i.icon-add { display: none; }

.multi-input-grid { display: grid !important; grid-template-columns: 1fr 1fr 1fr 1fr 30px; gap: 5px; align-items: end; width: 100%; }
.input-col { display: flex; flex-direction: column; }
.input-col input { width: 100%; padding: 6px; font-size: 12px; text-align: center; border: 1px solid #ddd; border-radius: 3px; outline: none; margin: 0 !important; }
.input-col label { font-size: 9px; text-align: center; color: #999; margin-top: 3px; font-weight: normal; }
.link-values-btn { height: 28px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: #aaa; background: #eee; border-radius: 3px; margin-bottom: 16px; }
.link-values-btn.active { background: #ccc; color: #333; }

.typography-popover { background: #fff; border: 1px solid #ddd; box-shadow: 0 2px 15px rgba(0,0,0,0.1); padding: 15px; margin-top: 5px; border-radius: 4px; display: none; position: relative; z-index: 100; }
.typography-popover.active { display: block; }

/* Popover specifico per sidebar globali */
#pane-globals .typography-popover {
    position: fixed; /* Cambiato in fixed per posizionamento preciso via JS */
    width: 280px;
    z-index: 9999;
    box-shadow: 5px 5px 20px rgba(0,0,0,0.15);
}
.popover-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; border-bottom: 1px solid #eee; padding-bottom: 10px; }
.popover-header h5 { font-size: 13px; font-weight: 700; margin: 0; color: #333; }

.editor-toolbar { display: flex; background: #f0f0f1; border: 1px solid #ddd; border-bottom: none; padding: 5px; gap: 2px; border-radius: 3px 3px 0 0; }
.ed-btn { background: transparent; border: none; padding: 4px 6px; cursor: pointer; font-weight: bold; color: #555; border-radius: 2px; }
.ed-btn:hover { background: #e0e0e0; color: #000; }
.panel-textarea { width: 100%; border: 1px solid #ddd; border-radius: 0 0 3px 3px; padding: 10px; font-family: monospace; font-size: 12px; resize: vertical; outline: none; min-height: 150px; }
.panel-footer { padding: 15px; border-top: 1px solid #ddd; margin-top: auto; background: #f9f9f9; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.history-controls { display: flex; background: #e0e0e0; border-radius: 3px; overflow: hidden; }
.hist-btn { background: transparent; border: none; padding: 8px 12px; cursor: pointer; color: #555; display: flex; align-items: center; justify-content: center; transition: background 0.2s; }
.hist-btn:hover { background: #d0d0d0; color: #000; }
.hist-btn i { font-size: 18px !important; }
.btn-update { flex: 1; height: 36px; line-height: 36px; padding: 0; font-weight: bold; box-shadow: none !important; }
/* =========================================
   DRAG & DROP TOLERANCE
   ========================================= */
body.is-dragging .canvas-element {
    margin-top: 15px !important;
    margin-bottom: 15px !important;
    transition: margin 0.2s;
}

body.is-dragging .container-inner-content {
    min-height: 100px !important;
    padding-bottom: 60px !important; /* Spazio extra per facilitare il drop in fondo */
    background-color: rgba(57, 181, 74, 0.03);
    border: 1px dashed #ccc;
}

body.is-dragging .empty-container-placeholder {
    pointer-events: none; /* Evita interferenze */
}


/* SWAP TARGET HIGHLIGHT */
.canvas-element.swap-target {
    outline: 3px solid #ff9800 !important;
    box-shadow: 0 0 10px rgba(255, 152, 0, 0.5);
    z-index: 100;
}


/* CRITICAL FIX for Drag Over Detection */
.canvas-element.dragging {
    pointer-events: none !important;
}


/* DRAG PLACEHOLDER */
.drop-placeholder {
    height: 8px;
    background: #39b54a;
    margin: 10px 0;
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(57, 181, 74, 0.4);
    transition: all 0.1s;
    pointer-events: none;
    width: 100%;
}
/* When inside a horizontal flex container (row) */
.container-inner-content[style*='flex-direction: row'] .drop-placeholder,
.container-inner-content[style*='flex-direction:row'] .drop-placeholder {
    width: 8px;
    height: 60px;
    margin: 0 10px;
}

/* Drag Source Style */
.dragging-source {
    opacity: 0.3;
    outline: 2px dashed #39b54a;
    outline-offset: -2px;
}

body.is-dragging .container-inner-content {
    min-height: 120px !important;
    padding-bottom: 80px !important;
    background-color: rgba(57, 181, 74, 0.05);
    border: 2px dashed #39b54a;
}

.container-inner-content.drag-over-active { 
    box-shadow: inset 0 0 0 4px #39b54a, inset 0 0 40px rgba(57, 181, 74, 0.1) !important;
    background-color: rgba(57, 181, 74, 0.08) !important;
}
/* Hidden elements logic */
.wox-hidden { 
    display: none !important; 
}

/* Override for editor: always show hidden elements but with a pattern */
#canvas .wox-hidden {
    display: block !important;
    opacity: 0.5;
    outline: 2px dashed #ff9800 !important;
    background-image: repeating-linear-gradient(45deg, rgba(255, 152, 0, 0.1) 0, rgba(255, 152, 0, 0.1) 10px, transparent 10px, transparent 20px) !important;
}

#canvas .wox-hidden::before {
    content: "HIDDEN";
    position: absolute;
    top: 0;
    right: 0;
    background: #ff9800;
    color: white;
    font-size: 9px;
    padding: 2px 5px;
    z-index: 10;
    font-weight: bold;
}

/* =========================================
   7. MENU & SUBMENU
   ========================================= */
.wox-menu-container { width: 100%; }
.wox-menu-list { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; position: relative; }
.wox-menu-item { position: relative; }
.menu-item-link-container { display: flex; align-items: center; }
.menu-item-link { color: inherit; text-decoration: none; padding: 10px 15px; display: block; transition: 0.3s; white-space: nowrap; }

/* Submenu Styles */
.wox-submenu {
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    list-style: none;
    padding: 10px 0;
    margin: 0;
    min-width: 180px;
    z-index: 1000;
    display: none;
    border-radius: 4px;
    flex-direction: column;
}
.wox-submenu.has-banner {
    flex-direction: row !important;
    padding: 0;
    overflow: hidden;
}
.submenu-banner {
    flex-shrink: 0;
    min-height: 100px;
    background-size: cover;
    background-position: center;
}
.wox-menu-item:hover > .wox-submenu { display: flex; }
.wox-menu-item:hover > .wox-submenu[style*="grid"] { display: grid; }

.wox-submenu .wox-submenu {
    top: 0;
    left: 100%;
    margin-top: -10px;
}

.wox-submenu .menu-item-link {
    padding: 8px 20px;
    font-size: 14px;
}

/* Vertical Menu Adjustment */
.wox-menu-list.vertical { flex-direction: column; align-items: flex-start; }
.wox-menu-list.vertical > .wox-menu-item { width: 100%; }
.wox-menu-list.vertical .wox-submenu { top: 0; left: 100%; margin-top: 0; }

/* Menu Item Editor in Property Panel */
.menu-item-editor {
    border: 1px solid #eee;
    border-radius: 4px;
    margin-bottom: 5px;
    background: #fdfdfd;
    transition: all 0.2s;
}
.menu-item-editor.drag-over { border-top: 2px solid #58D0F5; background: #eefbff; }
.menu-item-editor.nest-target { border-top: 1px solid #eee; border-left: 4px solid #39b54a; padding-left: 10px; }
.menu-item-header {
    padding: 10px;
    display: flex;
    align-items: center;
    cursor: pointer;
}
.menu-item-header:hover { background: #f5f5f5; }
.menu-item-header .handle { font-size: 16px; color: #ccc; cursor: move; margin-right: 8px; }
.menu-item-header .item-label { font-size: 13px; flex-grow: 1; font-weight: 500; }
.menu-item-header .item-actions { display: flex; gap: 8px; }
.menu-item-header .item-actions i { font-size: 18px; color: #aaa; transition: color 0.2s; }
.menu-item-header .item-actions i:hover { color: #58D0F5; }
.menu-item-header .item-actions i.delete-item:hover { color: #f44336; }
.menu-item-header .item-actions i.add-subitem:hover { color: #39b54a; }

.menu-item-details { padding: 15px; border-top: 1px solid #eee; background: #fff; }

/* CodeMirror Site Panel Overrides */
.CodeMirror {
    height: 300px;
    font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
    font-size: 12px;
    border-radius: 4px;
}

#pane-site .CodeMirror {
    margin-bottom: 20px;
}

