/**
 * SITVI Map Editor - Complete Styles
 *
 * Consolidated styles for the map editor component
 * Dead sitvi-map-* prefixed classes removed in v3.0 cleanup
 *
 * @package SITVI
 * @subpackage MapEditor
 * @version 3.0
 * @date 2026-02-09
 */

/* ========================================== */
/* KEYFRAMES (preserved from removed sections) */
/* ========================================== */

@keyframes sitviTabFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* ========================================== */
/* 19. RESPONSIVE DESIGN */
/* ========================================== */

/* Editor page layout */
.sitvi-editor-row {
    display: flex;
    flex-wrap: wrap;
}

#lista_destra {
    min-height: 300px;
}

#anteprima_mappa {
    width: 100%;
    height: calc(100vh - 300px);
    min-height: 350px;
    max-height: 80vh;
}

/* Layer lists dynamic height to match map preview */
#lista_sinistra,
#lista_destra {
    overflow-y: auto;
}

@media (max-width: 991px) {
    .sitvi-editor-row {
        flex-direction: column;
    }

    .sitvi-editor-col-layers,
    .sitvi-editor-col-current {
        width: 100%;
        max-width: 100%;
    }

    .sitvi-editor-col-layers {
        order: 1;
    }

    .sitvi-editor-col-current {
        order: 2;
    }

    .sitvi-editor-col-preview {
        order: 3;
        width: 100%;
        max-width: 100%;
    }

    #lista_sinistra {
        max-height: 200px;
        overflow-y: auto;
    }

    #lista_destra {
        min-height: 150px;
    }

    #anteprima_mappa {
        height: 350px;
    }
}

@media (min-width: 992px) {
    .sitvi-editor-col-layers {
        flex: 0 0 25%;
        max-width: 25%;
    }

    .sitvi-editor-col-current {
        flex: 0 0 25%;
        max-width: 25%;
    }

    .sitvi-editor-col-preview {
        flex: 0 0 50%;
        max-width: 50%;
    }

    #lista_sinistra {
        max-height: calc(100vh - 340px);
        min-height: 200px;
        overflow-y: auto;
    }

    #lista_destra {
        max-height: calc(100vh - 340px);
        min-height: 200px;
        overflow-y: auto;
    }
}

@media (max-width: 768px) {
    #anteprima_mappa {
        height: 300px;
    }
}

@media (max-width: 576px) {
    #anteprima_mappa {
        height: 250px;
    }

    #lista_sinistra {
        max-height: 150px;
    }

    #lista_destra {
        min-height: 120px;
    }
}

/* ========================================== */
/* COMPATIBILITY - Legacy Selectors */
/* ========================================== */

/*
 * These selectors maintain compatibility with existing HTML
 */

/* Backward compatibility for existing elements */
#anteprima_mappa {
    width: 100%;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #e9ecef;
}

#mappa_preview_simbologie {
    width: 100%;
    height: 400px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: #e9ecef;
}

.elemento_lista {
    padding: 8px 10px;
    margin: 4px 0;
    background: #ffffff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: move;
    user-select: none;
    position: relative;
    transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    font-size: 13px;
}

.elemento_lista:hover {
    background: #e8e8e8;
}

.elemento_lista[tipo="livello_geoserver"] {
    background: #ffffff;
    border-left: 3px solid #28a745;
}

.elemento_lista[tipo="livello_geoserver"]:hover {
    background: #e8f5e9;
    border-left-color: #1e7e34;
}

.elemento_lista[tipo="livello_geoserver"]::before {
    margin-right: 4px;
    font-size: 14px;
    flex-shrink: 0;
    content: '\25CF';
    color: #6c757d;
}

.elemento_lista[tipo="livello_geoserver"][data-geometry="point"]::before {
    content: '\25CF'; /* ● */
    color: #e74c3c;
}

.elemento_lista[tipo="livello_geoserver"][data-geometry="line"]::before {
    content: '\2501'; /* ━ */
    color: #e67e22;
}

.elemento_lista[tipo="livello_geoserver"][data-geometry="polygon"]::before {
    content: '\2B21'; /* ⬡ */
    color: #27ae60;
}

.elemento_lista[tipo="livello_geoserver"][data-geometry="raster"]::before {
    content: '\25A6'; /* ▦ */
    color: #8e44ad;
}

/* Editable text: occupa lo spazio disponibile */
.elemento_lista .editable-text {
    flex: 1 1 auto;
    min-width: 50px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.elemento_lista[tipo="gruppo_di_livelli"] {
    background: #fffdf3;
    border: 1px solid #e8c84a;
    font-weight: 600;
    flex-wrap: wrap;
}

.elemento_lista[tipo="gruppo_di_livelli"]::before {
    content: '\1F4C1';
    margin-right: 4px;
    font-size: 14px;
    flex-shrink: 0;
}

/* La nested-list occupa tutta la larghezza sotto gli elementi del gruppo */
.elemento_lista[tipo="gruppo_di_livelli"] > .nested-list {
    flex-basis: 100%;
    order: 99;
}

.elemento_lista[tipo="gruppo_di_livelli"]:hover {
    background: #fffbe6;
    border-color: #d4a800;
}

.elemento_lista.sortable-ghost {
    opacity: 0.4;
    background: #f0f0f0;
}

.elemento_lista.sortable-drag {
    opacity: 0.8;
    transform: rotate(2deg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: grabbing;
    z-index: 9999;
}

.nested-list {
    display: block;
    min-height: 36px;
    padding: 6px 8px;
    margin-top: 0;
    margin-left: 0;
    background: #fafaf5;
    border: none;
    border-top: 1px dashed #e0d080;
    border-radius: 0 0 4px 4px;
    transition: all 0.2s;
}

.nested-list:empty::before {
    content: 'Trascina qui i layer...';
    display: block;
    text-align: center;
    color: #adb5bd;
    font-size: 12px;
    font-style: italic;
    line-height: 24px;
}

.nested-list.sortable-drag-over,
.nested-list:hover {
    background: #e3f2fd;
}

.nested-list:not(:empty) {
    min-height: 40px;
    padding-bottom: 8px;
}

.nested-list > .elemento_lista {
    margin-left: 0;
    margin-bottom: 4px;
    font-size: 13px;
    background: #ffffff;
    border-left: 3px solid #dee2e6;
}

.nested-list > .elemento_lista:hover {
    border-left-color: #4a90e2;
}

/* =============================================
   NESTED GROUPS - Multi-level indentation
   ============================================= */

/* Depth 2: nested-list dentro nested-list */
.nested-list .nested-list {
    margin-left: 12px;
    background: #f1f3f5;
    border-color: #ced4da;
}

/* Depth 3: terzo livello */
.nested-list .nested-list .nested-list {
    margin-left: 10px;
    background: #e9ecef;
    border-color: #adb5bd;
}

/* Depth 4: quarto livello */
.nested-list .nested-list .nested-list .nested-list {
    margin-left: 8px;
    background: #dee2e6;
}

/* Bordi colorati per profondita - sottogruppi */
.nested-list > .elemento_lista[tipo="gruppo_di_livelli"] {
    border-left: 4px solid #fd7e14;
    background: linear-gradient(to right, #fff3e0 0%, #ffffff 10%);
}

.nested-list .nested-list > .elemento_lista[tipo="gruppo_di_livelli"] {
    border-left: 4px solid #e83e8c;
    background: linear-gradient(to right, #fce4ec 0%, #ffffff 10%);
}

.nested-list .nested-list .nested-list > .elemento_lista[tipo="gruppo_di_livelli"] {
    border-left: 4px solid #6f42c1;
    background: linear-gradient(to right, #ede7f6 0%, #ffffff 10%);
}

/* Testo placeholder per sottogruppi */
.nested-list .nested-list:empty::before {
    content: 'Trascina qui layer o sotto-gruppi...';
}

.nested-list .nested-list .nested-list:empty::before {
    content: 'Trascina qui layer...';
}

/* Gruppo nascosto - stile attenuato */
.elemento_lista[tipo="gruppo_di_livelli"].layer-hidden-item {
    opacity: 0.5;
}

.elemento_lista[tipo="gruppo_di_livelli"].layer-hidden-item > .nested-list {
    opacity: 0.6;
}

/* Responsive: profondita ridotta su schermi piccoli */
@media (max-width: 768px) {
    .nested-list .nested-list {
        margin-left: 6px;
    }
    .nested-list .nested-list .nested-list {
        margin-left: 4px;
    }
}

#lista_sinistra {
    background: #fafafa;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px;
}

#lista_destra {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    padding: 12px;
}

#lista_destra:empty::before {
    content: 'Trascina qui layer e gruppi dalla lista a sinistra';
    display: block;
    text-align: center;
    color: #adb5bd;
    font-size: 14px;
    font-style: italic;
    padding: 60px 20px;
}

#lista_destra > .elemento_lista {
    margin-bottom: 8px;
}

.elemento_lista[tipo="gruppo_di_livelli"] .editable-text {
    cursor: text;
    padding: 8px 0 8px 12px;
    border-radius: 0;
    transition: background 0.2s;
    flex: 1;
    font-weight: 600;
}

.elemento_lista[tipo="gruppo_di_livelli"] .editable-text:hover {
    background: rgba(255, 193, 7, 0.1);
}

.elemento_lista[tipo="gruppo_di_livelli"] input[type="text"] {
    font-weight: 600;
    border: 2px solid #ffc107;
    border-radius: 4px;
    padding: 4px 8px;
    background: #fffbea;
}

.delete-icon {
    cursor: pointer;
    color: #dc3545;
    transition: color 0.2s;
    flex-shrink: 0;
    margin-left: auto;
}

.delete-icon:hover {
    color: #a71d2a;
}

#finestra_editor_simbologie {
    resize: both;
    overflow: auto;
    min-width: 800px;
    max-width: 95vw;
    min-height: 600px;
    max-height: 90vh;
}

#finestra_editor_simbologie::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, transparent 50%, #ccc 50%);
    cursor: nwse-resize;
    pointer-events: none;
}

#simbologie-header {
    cursor: move;
    user-select: none;
    background: linear-gradient(to bottom, #f8f9fa, #e9ecef);
    border-bottom: 1px solid #dee2e6;
    padding: 12px 20px;
    border-radius: 8px 8px 0 0;
    margin: -20px -20px 20px -20px;
}

#simbologie-header:hover {
    background: linear-gradient(to bottom, #e9ecef, #dee2e6);
}

.presets-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    padding: 16px 0;
}

.preset-card {
    border: 2px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    transition: all 0.2s;
    cursor: pointer;
}

.preset-card:hover {
    border-color: #4a90e2;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.15);
    transform: translateY(-2px);
}

.preset-thumbnail {
    position: relative;
    width: 100%;
    height: 120px;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #dee2e6;
}

.preset-thumbnail img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.preset-info {
    padding: 12px;
}

.preset-name {
    font-weight: 600;
    font-size: 14px;
    color: #212529;
    margin-bottom: 4px;
}

.preset-description {
    font-size: 12px;
    color: #6c757d;
    line-height: 1.4;
}

.preset-actions {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

.preset-actions .btn {
    flex: 1;
    padding: 4px 8px;
    font-size: 12px;
}

.rendering-mode-section {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 16px;
    margin-top: 16px;
    background: #f8f9fa;
}

.rendering-mode-section.active {
    border-color: #4a90e2;
    background: #e3f2fd;
}

.rendering-mode-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #dee2e6;
}

.rendering-mode-title {
    font-weight: 600;
    font-size: 14px;
    color: #212529;
}

.rendering-mode-content {
    display: none;
}

.rendering-mode-content.active {
    display: block;
    animation: sitviTabFadeIn 0.3s;
}

#general-visibility-preview {
    padding: 12px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-top: 8px;
}

.zoom-range-visual {
    height: 24px;
    background: #e9ecef;
    border-radius: 4px;
    position: relative;
    margin: 8px 0;
}

.zoom-range-active {
    position: absolute;
    height: 100%;
    background: linear-gradient(to right, #4a90e2, #357abd);
    border-radius: 4px;
    transition: all 0.3s;
}

#simbologie-tabs .nav-link {
    font-size: 13px;
    padding: 10px 14px;
    color: #6c757d;
    border: 1px solid transparent;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

#simbologie-tabs .nav-link:hover {
    color: #4a90e2;
    background: #f8f9fa;
}

#simbologie-tabs .nav-link.active {
    color: #4a90e2;
    background: #fff;
    border-color: #dee2e6 #dee2e6 #fff;
    border-bottom-color: #4a90e2;
    font-weight: 600;
}

#simbologie-tabs .nav-link i {
    margin-right: 4px;
}

#material-icons-gallery {
    max-height: 400px;
    overflow-y: auto;
    padding: 15px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: #f8f9fa;
}

/* Material Icons - Bootstrap rows styling */
#material-icons-gallery .row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -4px;
}

#material-icons-gallery .row.g-2 {
    row-gap: 8px;
}

/* Material Icons - Bootstrap columns styling */
#material-icons-gallery .col-3,
#material-icons-gallery .col-md-2 {
    padding: 0 4px;
}

#material-icons-gallery .col-3 {
    flex: 0 0 25%;
    max-width: 25%;
}

@media (min-width: 768px) {
    #material-icons-gallery .col-md-2 {
        flex: 0 0 16.666667%;
        max-width: 16.666667%;
    }
}

/* Material Icons - Button styling */
#material-icons-gallery button.btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    padding: 8px 4px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 80px;
}

#material-icons-gallery button.btn:hover {
    background: #e3f2fd !important;
    transform: scale(1.05) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
}

#material-icons-gallery button.btn svg {
    display: block;
    width: 28px;
    height: 28px;
    margin: 0 auto;
    flex-shrink: 0;
}

#material-icons-gallery button.btn div {
    margin-bottom: 4px;
}

#material-icons-gallery button.btn small {
    display: block;
    font-size: 9px;
    line-height: 1.1;
    color: #495057;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    max-width: 100%;
}

/* Material Icons - Category headers */
#material-icons-gallery .mb-2.mt-3 h6 {
    color: #555;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #dee2e6;
}

#material-icons-gallery .mb-2.mt-3:first-child {
    margin-top: 0 !important;
}

/* Material Icons - Selected state */
#material-icons-gallery button.btn.selected {
    background-color: #c8e6c9 !important;
    border-color: #4caf50 !important;
    transform: scale(1.05) !important;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3) !important;
}

.form-range {
    height: 6px;
}

.form-range::-webkit-slider-thumb {
    width: 16px;
    height: 16px;
    background: #4a90e2;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.form-range::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #4a90e2;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.form-range:focus::-webkit-slider-thumb {
    box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.2);
}

.form-control-color {
    width: 50px;
    height: 38px;
    padding: 4px;
    border: 2px solid #dee2e6;
    border-radius: 4px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.form-control-color:hover {
    border-color: #4a90e2;
}

/* ========================================== */
/* 23. SYMBOLOGY EDITOR - Legacy Styles */
/* ========================================== */
/* These styles maintain compatibility with existing HTML in editor */
/* Migrated from inline styles in page-editor-mappa2.php */

/* Finestra modale editor */
#finestra_editor_simbologie {
    max-height: 90vh;
    overflow-y: auto;
}

/* Tab styling */
#simbologie-tabs .nav-link {
    font-size: 13px;
    padding: 8px 12px;
}

/* Mini-mappa preview */
#simbologie-preview-map {
    width: 100%;
    height: 250px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-top: 15px;
}

/* Pickr containers */
.pickr-container {
    display: inline-block;
}

.pickr {
    width: 40px;
    height: 32px;
    border-radius: 4px;
}

/* Graduated classes */
.graduated-class-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-bottom: 1px solid #e0e0e0;
}

.class-color-box, .value-color-box {
    width: 30px;
    height: 30px;
    border: 1px solid #999;
    border-radius: 4px;
}

.class-range {
    flex: 1;
    font-size: 13px;
}

/* Categorized values */
.categorized-value-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-bottom: 1px solid #e0e0e0;
}

.value-label {
    flex: 1;
    font-size: 13px;
}

/* Rules */
.rule-item {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 10px;
    background: #f9f9f9;
}

.rule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.rule-delete-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
}

.rule-delete-btn:hover {
    background: #c82333;
}

/* Loading spinner */
.simbologie-loading {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #333;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Utility class per icone in rotazione (riusabile) */
.spin {
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

/* Presets gallery */
.preset-card {
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-card:hover {
    border-color: #4a90e2;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.preset-preview {
    width: 100%;
    height: 60px;
    border-radius: 4px;
    margin-bottom: 8px;
}

/* SLD editor */
#sld-xml-editor {
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

#sld-validation-feedback, #sld-upload-feedback {
    margin-top: 10px;
}

/* Animazione per attirare attenzione sul bottone upgrade */
@keyframes pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(13, 202, 240, 0.7); }
    50% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(13, 202, 240, 0); }
}

.btn-pulse {
    animation: pulse 1s ease-in-out 2;
}

/* ========================================== */
/* MODULAR SYMBOLOGY EDITOR - New Styles */
/* ========================================== */

/* Pattern Gallery */
#pattern-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 8px;
}

#pattern-gallery button {
    width: 100%;
    height: 60px;
    padding: 4px;
    border: 2px solid #ddd;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s;
}

#pattern-gallery button:hover {
    border-color: #4a90e2;
    transform: scale(1.05);
}

#pattern-gallery button.selected {
    border-color: #4a90e2;
    background: #e3f2fd;
    box-shadow: 0 0 8px rgba(74, 144, 226, 0.3);
}

#pattern-gallery svg {
    width: 100%;
    height: 100%;
}

/* Curve Editor */
.curve-editor canvas {
    width: 100%;
    height: 80px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.stop-item {
    background: #f8f9fa;
}

/* Gradient Stops */
.gradient-stop-item {
    background: #f8f9fa;
}

/* Material Icons Gallery Grid - styles defined above in section 12 */

/* Rendering Mode Content */
.rendering-mode-content {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Layer/Group list items - flex layout */
.elemento_lista {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    padding: 6px 10px !important;
    cursor: move !important;
    border-radius: 4px !important;
    margin-bottom: 3px !important;
    font-size: 13px !important;
    flex-wrap: wrap !important;
}

/* Ordine elementi: testo, icone azioni */
.elemento_lista .editable-text {
    flex: 1 1 auto !important;
    min-width: 40px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

/* Second row: layer action icons */
.elemento_lista .layer-actions {
    flex-basis: 100%;
    display: flex;
    align-items: center;
    gap: 2px;
    padding-top: 4px;
    margin-top: 2px;
    border-top: 1px solid rgba(0,0,0,0.06);
}

.elemento_lista .layer-actions > i,
.elemento_lista .layer-actions > span {
    flex-shrink: 0;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
}

.elemento_lista .layer-actions > i:hover,
.elemento_lista .layer-actions > span:not(.delete-icon):hover {
    background: rgba(0,0,0,0.06);
}

.elemento_lista .layer-actions .delete-icon {
    margin-left: auto !important;
    flex-shrink: 0 !important;
    font-size: 14px !important;
}

.elemento_lista .palette-icon {
    flex-shrink: 0 !important;
    font-size: 14px !important;
}

/* ========================================== */
/* 24. BASEMAP GROUP */
/* ========================================== */

.elemento_lista.basemap-group {
    border-left: 3px solid #0d6efd;
    background: rgba(13, 110, 253, 0.04);
}

/* ========================================== */
/* 25. BOOTSTRAP FORM CONTROLS */
/* ========================================== */
/* Essential Bootstrap form styles for editor functionality */

.form-control, .form-select {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    color: #212529;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus, .form-select:focus {
    color: #212529;
    background-color: #fff;
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.form-control-sm, .form-select-sm {
    min-height: calc(1.5em + 0.5rem + 2px);
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    border-radius: 0.2rem;
}

.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    padding-right: 2.25rem;
}

.form-range {
    width: 100%;
    height: 1.5rem;
    padding: 0;
    background-color: transparent;
    appearance: none;
}

.form-range::-webkit-slider-thumb {
    width: 1rem;
    height: 1rem;
    background-color: #0d6efd;
    border: 0;
    border-radius: 1rem;
    cursor: pointer;
    appearance: none;
}

.form-range::-moz-range-thumb {
    width: 1rem;
    height: 1rem;
    background-color: #0d6efd;
    border: 0;
    border-radius: 1rem;
    cursor: pointer;
}

.form-range::-webkit-slider-runnable-track {
    width: 100%;
    height: 0.5rem;
    color: transparent;
    cursor: pointer;
    background-color: #dee2e6;
    border-color: transparent;
    border-radius: 1rem;
}

.form-range::-moz-range-track {
    width: 100%;
    height: 0.5rem;
    color: transparent;
    cursor: pointer;
    background-color: #dee2e6;
    border-color: transparent;
    border-radius: 1rem;
}

.form-label {
    margin-bottom: 0.5rem;
    display: inline-block;
}

/* Bootstrap utility classes needed by editor */
.d-flex {
    display: flex !important;
}

.gap-2 {
    gap: 0.5rem !important;
}

.justify-content-between {
    justify-content: space-between !important;
}

.align-items-center {
    align-items: center !important;
}

.mb-0 {
    margin-bottom: 0 !important;
}

.mb-1 {
    margin-bottom: 0.25rem !important;
}

.mb-2 {
    margin-bottom: 0.5rem !important;
}

.mb-3 {
    margin-bottom: 1rem !important;
}

.mt-2 {
    margin-top: 0.5rem !important;
}

.small {
    font-size: 0.875em;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -0.75rem;
    margin-left: -0.75rem;
}

.col-md-6 {
    flex: 0 0 auto;
    width: 50%;
    padding-right: 0.75rem;
    padding-left: 0.75rem;
}

/* Alert styles for editor notifications */
.alert {
    padding: 0.75rem 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: 0.25rem;
}

.alert-info {
    color: #055160;
    background-color: #cff4fc;
    border-color: #b6effb;
}

.alert-success {
    color: #0f5132;
    background-color: #d1e7dd;
    border-color: #badbcc;
}

/* ========================================== */
/* 25. SIMPLE TAB SECTIONS VISIBILITY */
/* ========================================== */
/* Ensure Simple tab sections are visible when activated by JavaScript */

/* Simple tab main sections (shown/hidden by toggleSimpleSections) */
#simple-polygon-section,
#simple-line-section,
#simple-point-section {
    padding: 1rem 0;
}

/* Rendering mode content containers (shown/hidden by mode selector) */
#polygon-mode-simple,
#polygon-mode-pattern,
#polygon-mode-extrusion,
#line-mode-simple,
#line-mode-dashed,
#line-mode-gradient,
#point-mode-simple,
#point-mode-heatmap {
    display: block;
    margin-top: 1rem;
}

/* Rendering mode sections (wrapper for mode content) */
.rendering-mode-content {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

/* ========================================== */
/* 26. PICKR COLOR PICKER OVERRIDES */
/* ========================================== */
/* Ensure Pickr popup is visible and above other elements */

.pickr-container {
    display: inline-block;
    vertical-align: middle;
}

.pickr {
    width: 40px;
    height: 32px;
    border-radius: 4px;
    border: 1px solid #ced4da;
    cursor: pointer;
    transition: border-color 0.15s;
}

.pickr:hover {
    border-color: #86b7fe;
}

/* Pickr popup (ensure it's visible above everything) */
.pcr-app {
    z-index: 9999 !important;
    position: fixed !important;
}

.pcr-app .pcr-selection {
    display: flex;
    justify-content: space-between;
    flex-grow: 1;
}

.pcr-app .pcr-selection .pcr-color-preview {
    position: relative;
    z-index: 1;
    width: 2em;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    margin-right: 0.75em;
}

.pcr-app .pcr-interaction {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin: 0 -0.2em;
}

.pcr-app .pcr-interaction input {
    margin: 0.2em;
    padding: 0.4em 0.5em;
    flex: 1 1 auto;
    border: 1px solid #ced4da;
    border-radius: 0.25em;
}

/* ============================================
   MAP SETTINGS - Accordion, Dropzone, Scale, Allegati
   ============================================ */

/* Accordion compatto */
#accordionImpostazioniMappa .accordion-button {
    font-size: 14px;
    padding: 8px 12px;
}

#accordionImpostazioniMappa .accordion-body {
    padding: 10px 12px;
}

/* Titolo mappa */
#titolo_mappa {
    font-weight: 600;
    border: 1px solid transparent;
    background: transparent;
    transition: border-color 0.2s, background 0.2s;
}

#titolo_mappa:focus,
#titolo_mappa:hover {
    border-color: #dee2e6;
    background: #fff;
}

/* Dropzone allegati */
.sitvi-dropzone {
    border: 2px dashed #ced4da;
    border-radius: 6px;
    padding: 20px;
    text-align: center;
    color: #6c757d;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
}

.sitvi-dropzone:hover {
    border-color: #0d6efd;
    background-color: #f8f9ff;
}

.sitvi-dropzone.dragover {
    border-color: #0d6efd;
    background-color: #e8f0fe;
    color: #0d6efd;
}

/* Allegato item */
.sitvi-attachment-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    margin-bottom: 4px;
    font-size: 13px;
    background: #fff;
}

.sitvi-attachment-item:hover {
    background: #f8f9fa;
}

.sitvi-attachment-uploading {
    opacity: 0.6;
    font-style: italic;
}

.sitvi-attachment-icon {
    font-size: 16px;
    color: #6c757d;
    flex-shrink: 0;
}

.sitvi-attachment-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sitvi-attachment-size {
    flex-shrink: 0;
    font-size: 12px;
}

.sitvi-attachment-action {
    flex-shrink: 0;
    padding: 2px 6px !important;
    font-size: 12px !important;
    line-height: 1 !important;
}

/* Scale preset tag */
.sitvi-scale-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: #e9ecef;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    color: #495057;
}

.sitvi-scale-tag-remove {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
}

.sitvi-scale-tag-remove:hover {
    color: #dc3545;
}

/* =============================================
   27. LAYER VISIBILITY & OPACITY CONTROLS
   ============================================= */

/* Visibility toggle icon */
.visibility-toggle {
    cursor: pointer;
    color: #495057;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 4px;
    flex-shrink: 0;
    transition: all 0.2s;
    flex-shrink: 0;
    order: -2;
    margin-right: 4px;
}

.visibility-toggle:hover {
    color: #0d6efd;
    background: rgba(13, 110, 253, 0.1);
}

.visibility-toggle.layer-hidden {
    color: #adb5bd;
}

.visibility-toggle.layer-hidden:hover {
    color: #dc3545;
    background: rgba(220, 53, 69, 0.1);
}

/* Layer dimmed when hidden */
.layer-hidden-item {
    opacity: 0.5;
}

.layer-hidden-item .editable-text {
    text-decoration: line-through;
    color: #adb5bd !important;
}

/* Opacity slider control */
.opacity-control {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    order: -1;
    margin-right: 6px;
}

.opacity-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 50px;
    height: 4px;
    background: #dee2e6;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    transition: background 0.2s;
}

.opacity-slider:hover {
    background: #adb5bd;
}

.opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #0d6efd;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 0 2px rgba(0,0,0,0.3);
}

.opacity-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #0d6efd;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 0 2px rgba(0,0,0,0.3);
}

/* Sezione 28 (Basemap Selector) rimossa: lo stile e' ora condiviso da tutte
   le mappe del sito tramite .sitvi-basemap-switcher in sitvi-header.css,
   con altezza FISSA degli item per evitare salti verticali all'hover. */

/* =============================================
   29. BOOKMARKS (SEGNALIBRI)
   ============================================= */

.sitvi-bookmark-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-bottom: 1px solid #eee;
}

.sitvi-bookmark-item:last-child {
    border-bottom: none;
}

.sitvi-bookmark-item:hover {
    background: #f8f9fa;
}

.sitvi-bookmark-icon {
    color: #ffc107;
    font-size: 14px;
    flex-shrink: 0;
}

.sitvi-bookmark-name {
    flex: 1;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sitvi-bookmark-zoom {
    flex-shrink: 0;
    font-size: 11px;
    min-width: 24px;
    text-align: center;
}

.sitvi-bookmark-action {
    flex-shrink: 0;
    padding: 2px 5px !important;
    font-size: 11px !important;
    line-height: 1 !important;
}

/* =============================================
   30. TAG / CATEGORIES
   ============================================= */

.sitvi-tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    color: #fff;
}

.sitvi-tag-pill-remove {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
}

.sitvi-tag-pill-remove:hover {
    color: #fff;
}

.sitvi-tag-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
    min-width: 200px;
}

.sitvi-tag-suggestion {
    padding: 6px 10px;
    cursor: pointer;
    transition: background 0.15s;
}

.sitvi-tag-suggestion:hover {
    background: #f8f9fa;
}

/* =============================================
   31. DOCUMENT SELECTOR
   ============================================= */

.sitvi-doc-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
    max-height: 240px;
    overflow-y: auto;
}

.sitvi-doc-suggestion {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 12px;
    gap: 6px;
}

.sitvi-doc-suggestion:hover {
    background: #f8f9fa;
}

.sitvi-doc-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    margin-bottom: 4px;
    font-size: 12px;
    transition: background 0.15s;
}

.sitvi-doc-item:hover {
    background: #f8f9fa;
}

.sitvi-doc-icon {
    font-size: 16px;
    color: #64748b;
    flex-shrink: 0;
}

.sitvi-doc-info {
    flex: 1;
    min-width: 0;
}

.sitvi-doc-title {
    display: block;
    font-weight: 500;
    color: #1e293b;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sitvi-doc-title:hover {
    color: #0d6efd;
    text-decoration: underline;
}

.sitvi-doc-desc {
    font-size: 10px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sitvi-doc-type {
    flex-shrink: 0;
    font-size: 10px;
}

.sitvi-doc-remove {
    flex-shrink: 0;
    font-size: 14px;
    line-height: 1;
    padding: 2px 6px;
}

/* ========================================== */
/* MAP PARAMS TOOLBAR (sopra anteprima)       */
/* ========================================== */
/* Toolbar a riga singola che sostituisce il vecchio tab "Parametri".
   Visibile sempre sopra l'anteprima, divisa in 3 gruppi (Scale/Zoom/Vista)
   separati da divider verticali. Ogni gruppo ha icona + controlli inline,
   senza label di testo (le label sono sostituite da title attributes per
   accessibilita' e brevita'). Stessi id dei controlli per non rompere JS. */
.sitvi-map-params-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12px;
}
.sitvi-mpt-group {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
}
.sitvi-mpt-icon {
    color: #94a3b8;
    font-size: 14px;
    flex-shrink: 0;
}
.sitvi-mpt-sep {
    width: 1px;
    height: 22px;
    background: #cbd5e1;
    flex-shrink: 0;
}
.sitvi-map-params-toolbar .form-control,
.sitvi-map-params-toolbar .input-group-text,
.sitvi-map-params-toolbar .btn {
    font-size: 12px;
}
.sitvi-map-params-toolbar .input-group-sm > .form-control,
.sitvi-map-params-toolbar .input-group-sm > .input-group-text {
    padding: 2px 6px;
    height: 26px;
}
.sitvi-map-params-toolbar .input-group-text {
    background: #ffffff;
    color: #64748b;
    font-weight: 500;
}
.sitvi-map-params-toolbar .btn-sm {
    padding: 3px 8px;
    line-height: 1.3;
}
/* Input width: compatte, focused */
.sitvi-map-params-toolbar .sitvi-scale-input {
    width: 120px;
}
.sitvi-map-params-toolbar .sitvi-scale-input .form-control {
    min-width: 0;
}
.sitvi-map-params-toolbar .sitvi-zoom-input {
    width: 80px;
}
.sitvi-map-params-toolbar .sitvi-zoom-input .form-control {
    min-width: 0;
    text-align: center;
}
/* Chip "scala predefinita" cliccabile (usato da map-settings-manager.js) */
.sitvi-map-params-toolbar .sitvi-scale-tag {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 10px;
    background: #e0e7ff;
    color: #3730a3;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1.4;
}
.sitvi-map-params-toolbar .sitvi-scale-tag-remove {
    background: transparent;
    border: 0;
    padding: 0;
    color: #6366f1;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}
.sitvi-map-params-toolbar .sitvi-scale-tag-remove:hover {
    color: #dc2626;
}
/* vista_info inline a destra del bottone Cattura, troncato con ellipsis */
.sitvi-map-params-toolbar .sitvi-mpt-info {
    font-style: italic;
    font-size: 10.5px;
    color: #94a3b8 !important;
    line-height: 1.3;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Su schermo stretto la toolbar va a capo per gruppo */
@media (max-width: 991.98px) {
    .sitvi-mpt-sep { display: none; }
    .sitvi-mpt-group { flex: 1 1 auto; }
}

/* ========================================== */
/* EDITOR TABS (impostazioni mappa)           */
/* ========================================== */
.sitvi-editor-tabs .nav-link {
    font-size: 12px;
    color: #495057;
    border-color: #dee2e6 #dee2e6 transparent;
}
.sitvi-editor-tabs .nav-link.active {
    font-weight: 600;
    color: #0d6efd;
}
.sitvi-editor-tabs .nav-link .badge {
    font-size: 9px;
    vertical-align: middle;
}
#tabImpostazioniContent {
    max-height: 220px;
    overflow-y: auto;
    font-size: 13px;
}

/* ========================================== */
/* LAYER SEARCH (lista sinistra)              */
/* ========================================== */
#input_ricerca_layer {
    font-size: 12px;
}
.sitvi-layer-hidden {
    display: none !important;
}

/* Layer dal catalogo: bordo verde a sinistra */
.sitvi-catalog-layer {
    border-left: 3px solid #198754;
}
.sitvi-catalog-layer .badge {
    vertical-align: middle;
}

/* Header gruppo nel catalogo layer (editor) */
.sitvi-catalog-group-header {
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    color: #495057;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    gap: 4px;
    user-select: none;
}

/* ========================================== */
/* POPUP EDITOR MODAL                         */
/* ========================================== */
.sitvi-popup-editor-modal {
    position: fixed;
    z-index: 2100;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border: 2px solid #333;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    padding: 20px;
    width: 600px;
    max-width: 95vw;
    max-height: 90vh;
    overflow: auto;
    resize: both;
    min-width: 400px;
    min-height: 300px;
}

.sitvi-popup-editor-modal::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, transparent 50%, #ccc 50%);
    cursor: nwse-resize;
    pointer-events: none;
}

.sitvi-popup-editor-header {
    cursor: move;
    user-select: none;
    background: linear-gradient(to bottom, #fdf2e9, #f5e0cc);
    border-bottom: 1px solid #e8c9a8;
    padding: 12px 20px;
    border-radius: 8px 8px 0 0;
    margin: -20px -20px 20px -20px;
}

.sitvi-popup-editor-header:hover {
    background: linear-gradient(to bottom, #f5e0cc, #edcfaa);
}

.sitvi-popup-editor-modal .table th,
.sitvi-popup-editor-modal .table td {
    vertical-align: middle;
    padding: 4px 8px;
}

.popup-config-icon {
    font-size: 13px;
}

/* ========================================== */
/* MAPLIBRE POPUP STYLING                      */
/* ========================================== */
.sitvi-popup .maplibregl-popup-content {
    padding: 0;
    border-radius: 6px;
    overflow: hidden;
}

.sitvi-popup-header {
    background: #2c3e50;
    color: #fff;
    padding: 8px 12px;
    font-weight: 600;
    font-size: 14px;
}

.sitvi-popup-body {
    padding: 8px 12px;
}

.sitvi-popup-body table {
    width: 100%;
    font-size: 13px;
    border-collapse: collapse;
}

.sitvi-popup-body table td {
    padding: 3px 6px;
    border-bottom: 1px solid #eee;
}

.sitvi-popup-body table td:first-child {
    font-weight: 600;
    color: #555;
    white-space: nowrap;
    width: 40%;
}

.sitvi-popup-body img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 4px;
    margin: 2px 0;
}

.sitvi-popup-body a {
    color: #2980b9;
    text-decoration: underline;
    word-break: break-all;
}

.sitvi-popup-body a:hover {
    color: #1a5276;
}

/* =============================================
   ATTRIBUTE TABLE - EDITOR MODAL
   ============================================= */

.sitvi-attrtable-editor-modal {
    position: fixed;
    left: 50%;
    top: 30px;
    transform: translateX(-50%);
    width: 800px;
    max-width: 90vw;
    max-height: 85vh;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.3);
    z-index: 2000;
    padding: 0;
    overflow: hidden;
    resize: both;
    min-width: 500px;
    min-height: 300px;
    display: flex;
    flex-direction: column;
}

.sitvi-attrtable-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: linear-gradient(135deg, #e8f4fd 0%, #d0e8f7 100%);
    border-bottom: 1px solid #b0d0e8;
    cursor: move;
    user-select: none;
    flex-shrink: 0;
}

.sitvi-attrtable-editor-header h5 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 6px;
}

#attrtable_editor_body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
}

/* =============================================
   ATTRIBUTE TABLE - BOTTOM PANEL
   ============================================= */

.sitvi-attrtable-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1500;
    background: #fff;
    border-top: 2px solid #333;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.15);
    display: none;
    flex-direction: column;
}

.sitvi-attrtable-panel[style*="display: block"],
.sitvi-attrtable-panel[style*="display:block"] {
    display: flex !important;
}

.sitvi-attrtable-resize {
    height: 6px;
    cursor: ns-resize;
    background: linear-gradient(to bottom, #e0e0e0, #ccc);
    flex-shrink: 0;
}

.sitvi-attrtable-resize:hover {
    background: linear-gradient(to bottom, #4a90e2, #3a7bc8);
}

.sitvi-attrtable-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 12px;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
}

.sitvi-attrtable-tabs {
    display: flex;
    gap: 2px;
    overflow-x: auto;
}

.sitvi-attrtable-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border: 1px solid transparent;
    border-bottom: none;
    background: transparent;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    border-radius: 4px 4px 0 0;
    color: #555;
    transition: all 0.15s;
}

.sitvi-attrtable-tab:hover {
    background: #e8f0fe;
    color: #333;
}

.sitvi-attrtable-tab.active {
    background: #fff;
    border-color: #ddd;
    color: #2c3e50;
    font-weight: 600;
    border-bottom: 2px solid #4a90e2;
}

.sitvi-attrtable-tab-close {
    font-size: 14px;
    color: #999;
    cursor: pointer;
}

.sitvi-attrtable-tab-close:hover {
    color: #e74c3c;
}

.sitvi-attrtable-header-actions {
    display: flex;
    gap: 4px;
}

/* Filters */
.sitvi-attrtable-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 12px;
    background: #fafafa;
    border-bottom: 1px solid #eee;
    align-items: center;
    flex-shrink: 0;
}

.sitvi-attrtable-filter-item {
    flex: 0 0 auto;
}

.sitvi-attrtable-filter-input {
    width: 140px;
    font-size: 11px !important;
}

.sitvi-attrtable-filter-reset {
    font-size: 11px;
}

/* Table body */
.sitvi-attrtable-body {
    flex: 1;
    overflow: auto;
}

.sitvi-attrtable-table {
    width: 100%;
    font-size: 12px;
    border-collapse: collapse;
    table-layout: fixed;
}

.sitvi-attrtable-table tbody {
    content-visibility: auto;
}

.sitvi-attrtable-table th {
    position: sticky;
    top: 0;
    background: #f8f9fa;
    white-space: nowrap;
    padding: 6px 8px;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    color: #555;
    letter-spacing: 0.3px;
}

.sitvi-attrtable-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.sitvi-attrtable-table th.sortable:hover {
    background: #e8f0fe;
    color: #2c3e50;
}

.sitvi-attrtable-table th.sorted {
    background: #dce8f5;
    color: #2c3e50;
}

.sitvi-attrtable-table td {
    padding: 4px 8px;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sitvi-attrtable-table tbody tr:hover {
    background: #e8f4fd;
    cursor: pointer;
}

.sitvi-attrtable-table tbody tr:nth-child(even) {
    background: #fafcfe;
}

.sitvi-attrtable-table tbody tr:nth-child(even):hover {
    background: #e8f4fd;
}

.sitvi-attrtable-rownum {
    color: #999;
    font-size: 10px;
    text-align: center;
    width: 40px;
    min-width: 40px;
}

/* Footer */
.sitvi-attrtable-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 12px;
    background: #f5f5f5;
    border-top: 1px solid #ddd;
    font-size: 12px;
    flex-shrink: 0;
}

.sitvi-attrtable-pagination {
    display: flex;
    gap: 2px;
    align-items: center;
}

.sitvi-attrtable-pagination .btn {
    font-size: 11px;
    padding: 2px 8px;
    min-width: 28px;
}

.sitvi-attrtable-info {
    color: #666;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
}

/* Pulsante tabella attributi nella legenda */
.sitvi-attrtable-btn {
    cursor: pointer;
    color: #4a90e2;
    margin-left: 6px;
    transition: all 0.2s;
    font-size: 14px;
}

.sitvi-attrtable-btn:hover {
    color: #2c6fbb;
    transform: scale(1.15);
}

/* Inline filters in table header */
.sitvi-attrtable-filter-row th {
    padding: 2px 4px !important;
    border-bottom: 2px solid #dee2e6 !important;
    background: #f8f9fa !important;
}

.sitvi-attrtable-filter-cell {
    padding: 2px 4px !important;
}

.sitvi-attrtable-th-filter {
    width: 100%;
    font-size: 11px;
    padding: 2px 6px;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #fff;
    outline: none;
    transition: border-color 0.2s;
}

.sitvi-attrtable-th-filter:focus {
    border-color: #4a90e2;
    box-shadow: 0 0 0 2px rgba(74,144,226,0.15);
}

.sitvi-attrtable-th-label {
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.sitvi-attrtable-header-row th {
    border-bottom: 1px solid #dee2e6 !important;
}

.sitvi-attrtable-header-row th.sorted {
    background: #e8f0fe !important;
}

/* CSV export button */
.sitvi-attrtable-csv-btn {
    font-size: 11px;
    padding: 2px 8px;
}

/* Selection column */
.sitvi-attrtable-sel-col {
    width: 32px;
    min-width: 32px;
    max-width: 32px;
    text-align: center;
    padding: 2px 4px !important;
}

.sitvi-attrtable-sel-col input[type="checkbox"] {
    cursor: pointer;
    width: 14px;
    height: 14px;
    margin: 0;
    vertical-align: middle;
}

/* Selected row highlight */
.sitvi-attrtable-row-selected {
    background-color: rgba(0, 188, 212, 0.15) !important;
}

.sitvi-attrtable-row-selected:hover {
    background-color: rgba(0, 188, 212, 0.25) !important;
}

/* Selection info in footer */
#sitvi_attrtable_sel_info {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

#sitvi_attrtable_sel_info .badge {
    font-size: 11px;
    font-weight: 500;
}

#sitvi_attrtable_sel_info .btn {
    font-size: 11px;
    padding: 1px 6px;
}

/* Attribute table panel flex layout */
.sitvi-attrtable-panel {
    display: none;
    flex-direction: column;
}

/* =============================================
   ATTRIBUTE TABLE - FLOATING MODE
   ============================================= */

/* Floating panel overrides */
.sitvi-attrtable-panel.sitvi-attrtable-floating {
    position: fixed;
    bottom: auto;
    left: auto;
    top: auto;
    width: auto;
    min-width: 480px;
    min-height: 280px;
    max-width: 95vw;
    max-height: 90vh;
    border: 2px solid #333;
    border-radius: 6px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    overflow: hidden;
    z-index: 2500;
}

/* Hide docked resize handle in floating mode */
.sitvi-attrtable-panel.sitvi-attrtable-floating > .sitvi-attrtable-resize {
    display: none;
}

/* Header draggable in floating mode */
.sitvi-attrtable-panel.sitvi-attrtable-floating .sitvi-attrtable-header {
    cursor: move;
    user-select: none;
}

/* Floating resize handles (invisible hit areas on edges/corners) */
.sitvi-attrtable-rhandle {
    position: absolute;
    z-index: 10;
    display: none;
}

.sitvi-attrtable-floating .sitvi-attrtable-rhandle {
    display: block;
}

/* Edge handles */
.sitvi-attrtable-rhandle-n  { top: -3px;    left: 12px;    right: 12px;   height: 6px;  cursor: ns-resize; }
.sitvi-attrtable-rhandle-s  { bottom: -3px; left: 12px;    right: 12px;   height: 6px;  cursor: ns-resize; }
.sitvi-attrtable-rhandle-w  { left: -3px;   top: 12px;     bottom: 12px;  width: 6px;   cursor: ew-resize; }
.sitvi-attrtable-rhandle-e  { right: -3px;  top: 12px;     bottom: 12px;  width: 6px;   cursor: ew-resize; }

/* Corner handles */
.sitvi-attrtable-rhandle-nw { top: -3px;    left: -3px;    width: 14px;   height: 14px; cursor: nw-resize; }
.sitvi-attrtable-rhandle-ne { top: -3px;    right: -3px;   width: 14px;   height: 14px; cursor: ne-resize; }
.sitvi-attrtable-rhandle-sw { bottom: -3px; left: -3px;    width: 14px;   height: 14px; cursor: sw-resize; }
.sitvi-attrtable-rhandle-se { bottom: -3px; right: -3px;   width: 14px;   height: 14px; cursor: se-resize; }

/* Undock/dock toggle button */
.sitvi-attrtable-undock-btn {
    font-size: 14px;
    padding: 2px 6px;
    line-height: 1;
    border: 1px solid transparent;
    background: transparent;
    color: #666;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.15s;
    margin-right: 4px;
}

.sitvi-attrtable-undock-btn:hover {
    color: #2c3e50;
    background: #e8f0fe;
}

/* =============================================
   ATTRIBUTE TABLE - EXPRESSION SELECTION BAR
   ============================================= */

.sitvi-attrtable-expr-bar {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 4px 12px;
    background: #f0f4ff;
    border-top: 1px solid #d0d8e8;
    font-size: 12px;
    flex-shrink: 0;
}

.sitvi-attrtable-expr-input {
    flex: 1;
    font-size: 12px;
    padding: 3px 8px;
    border: 1px solid #aab8d0;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    outline: none;
}

.sitvi-attrtable-expr-input:focus {
    border-color: #4a90e2;
    box-shadow: 0 0 0 2px rgba(74,144,226,0.15);
}

#sitvi_attrtable_expr_info {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

/* =============================================
   ATTRIBUTE TABLE - SELECTION STATISTICS POPUP
   ============================================= */

.sitvi-attrtable-stats-panel {
    position: absolute;
    bottom: 40px;
    right: 12px;
    width: 520px;
    max-width: 90%;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    z-index: 20;
    font-size: 12px;
}

.sitvi-attrtable-stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
    border-radius: 6px 6px 0 0;
}

.sitvi-attrtable-stats-body {
    padding: 8px;
    max-height: 250px;
    overflow-y: auto;
}

.sitvi-attrtable-stats-body .table {
    font-size: 11px;
}

.sitvi-attrtable-stats-body .table th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* =============================================
   ATTRIBUTE TABLE - CONDITIONAL FORMATTING PANEL
   ============================================= */

.sitvi-attrtable-cond-panel {
    position: absolute;
    bottom: 40px;
    right: 12px;
    width: 640px;
    max-width: 95%;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    z-index: 20;
    font-size: 12px;
}

.sitvi-attrtable-cond-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
    border-radius: 6px 6px 0 0;
}

.sitvi-attrtable-cond-body {
    padding: 8px 12px;
    max-height: 300px;
    overflow-y: auto;
}

.sitvi-attrtable-cond-rule {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-bottom: 6px;
    flex-wrap: nowrap;
}

.sitvi-attrtable-cond-rule select,
.sitvi-attrtable-cond-rule input[type="text"] {
    font-size: 11px;
    padding: 2px 4px;
}

.sitvi-attrtable-cond-rule .sitvi-cond-field {
    width: 130px;
    min-width: 80px;
    flex-shrink: 0;
}

.sitvi-attrtable-cond-rule .sitvi-cond-op {
    width: 95px;
    min-width: 70px;
    flex-shrink: 0;
}

.sitvi-attrtable-cond-rule .sitvi-cond-val,
.sitvi-attrtable-cond-rule .sitvi-cond-val2 {
    width: 80px;
    min-width: 60px;
    flex-shrink: 1;
}

.sitvi-attrtable-cond-rule .form-control-color {
    width: 32px;
    min-width: 32px;
    height: 28px;
    padding: 2px;
    flex-shrink: 0;
    cursor: pointer;
}

.sitvi-attrtable-cond-rule .sitvi-cond-del {
    flex-shrink: 0;
    padding: 2px 6px;
    font-size: 11px;
}

/* =============================================
   ATTRIBUTE TABLE - COLUMN RESIZE BY DRAG
   ============================================= */

.sitvi-attrtable-th-resizable {
    position: relative;
}

.sitvi-attrtable-col-resize {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    cursor: col-resize;
    background: transparent;
    z-index: 2;
}

.sitvi-attrtable-col-resize:hover {
    background: rgba(74, 144, 226, 0.35);
}

.sitvi-attrtable-col-resize:active {
    background: rgba(74, 144, 226, 0.5);
}

/* Table layout for column resize support */
.sitvi-attrtable-table {
    table-layout: auto;
}

.sitvi-attrtable-table td,
.sitvi-attrtable-table th {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =============================================
   ATTRIBUTE TABLE - NEW SELECTION BUTTONS
   ============================================= */

#sitvi_attrtable_sel_info .btn {
    font-size: 10px;
    padding: 1px 5px;
    line-height: 1.3;
}

.sitvi-attrtable-expr-btn,
.sitvi-attrtable-cond-btn {
    font-size: 11px !important;
    padding: 2px 6px !important;
}

/* ========================================== */
/* SYMBOLOGY IMPORT/EXPORT BAR               */
/* ========================================== */

.sitvi-symbology-io-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    margin-bottom: 8px;
    background: #f0f4f8;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}

.sitvi-symbology-io-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.sitvi-symbology-io-actions .btn {
    font-size: 12px;
    white-space: nowrap;
}

.sitvi-symbology-io-info {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #64748b;
    min-width: 0;
}

.sitvi-symbology-io-info i {
    color: #94a3b8;
    flex-shrink: 0;
}

.sitvi-symbology-qml-info {
    padding: 10px 14px;
    margin-bottom: 8px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 6px;
    font-size: 12px;
}

.sitvi-symbology-qml-info .badge {
    font-size: 10px;
    font-weight: 500;
    margin-right: 2px;
    margin-bottom: 2px;
}

/* ========================================== */
/* SLD EDITOR MODAL                          */
/* ========================================== */

.sitvi-sld-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 3000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

.sitvi-sld-modal-content {
    width: 85%;
    max-width: 1200px;
    height: 88vh;
    background: #fff;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

/* Header */
.sitvi-sld-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
    flex-shrink: 0;
}

.sitvi-sld-title {
    font-size: 15px;
    font-weight: 600;
    color: #212529;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.sitvi-sld-title i {
    color: #6f42c1;
    font-size: 18px;
}

.sitvi-sld-layer-badge {
    font-size: 12px;
    font-weight: 500;
    background: #e9ecef;
    color: #495057;
    padding: 2px 10px;
    border-radius: 12px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

.sitvi-sld-style-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.sitvi-sld-label {
    font-size: 13px;
    font-weight: 500;
    color: #6c757d;
    white-space: nowrap;
    margin-bottom: 0;
}

.sitvi-sld-style-selector .form-select-sm {
    width: auto;
    min-width: 180px;
    max-width: 280px;
    font-size: 12px;
}

.sitvi-sld-close-btn {
    background: none;
    border: none;
    padding: 4px 8px;
    cursor: pointer;
    color: #6c757d;
    border-radius: 4px;
    transition: all 0.15s;
    margin-left: 8px;
    flex-shrink: 0;
}

.sitvi-sld-close-btn:hover {
    background: #e9ecef;
    color: #dc3545;
}

/* Toolbar */
.sitvi-sld-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background: #fdfdfe;
    border-bottom: 1px solid #e9ecef;
    flex-shrink: 0;
}

.sitvi-sld-toolbar .btn {
    font-size: 12px;
    white-space: nowrap;
}

.sitvi-sld-toolbar-sep {
    width: 1px;
    height: 24px;
    background: #dee2e6;
    margin: 0 6px;
    flex-shrink: 0;
}

/* Editor area */
.sitvi-sld-editor-wrap {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
    min-height: 0;
}

.sitvi-sld-line-numbers {
    width: 48px;
    flex-shrink: 0;
    background: #f1f3f5;
    border-right: 1px solid #dee2e6;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 13px;
    line-height: 1.5;
    padding: 10px 6px;
    text-align: right;
    color: #adb5bd;
    overflow: hidden;
    white-space: pre;
    user-select: none;
}

.sitvi-sld-editor-wrap textarea {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 13px;
    line-height: 1.5;
    padding: 10px 12px;
    tab-size: 2;
    -moz-tab-size: 2;
    color: #212529;
    background: #fff;
    overflow: auto;
    white-space: pre;
}

.sitvi-sld-editor-wrap textarea:focus {
    background: #fffef8;
}

/* Footer */
.sitvi-sld-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
    flex-shrink: 0;
}

/* Status messages */
.sitvi-sld-status {
    display: none;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 4px;
    white-space: nowrap;
    max-width: 45%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sitvi-sld-status-success {
    color: #0f5132;
    background: #d1e7dd;
}

.sitvi-sld-status-error {
    color: #842029;
    background: #f8d7da;
}

.sitvi-sld-status-info {
    color: #055160;
    background: #cff4fc;
}

/* Footer actions */
.sitvi-sld-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.sitvi-sld-new-name {
    width: 180px !important;
    font-size: 12px !important;
}

.sitvi-sld-default-check {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #6c757d;
    white-space: nowrap;
    margin-bottom: 0;
    cursor: pointer;
}

.sitvi-sld-default-check .form-check-input {
    margin-top: 0;
}

/* Responsive: smaller screens */
@media (max-width: 992px) {
    .sitvi-sld-modal-content {
        width: 96%;
        height: 95vh;
    }

    .sitvi-sld-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .sitvi-sld-style-selector {
        margin-left: 0;
        width: 100%;
    }

    .sitvi-sld-style-selector .form-select-sm {
        flex: 1;
    }

    .sitvi-sld-footer {
        flex-wrap: wrap;
    }

    .sitvi-sld-status {
        max-width: 100%;
        width: 100%;
    }

    .sitvi-sld-actions {
        flex-wrap: wrap;
        width: 100%;
        justify-content: flex-end;
    }

    .sitvi-sld-new-name {
        flex: 1;
        min-width: 120px !important;
    }
}

/* ========================================== */
/* SYMBOLOGY PICKER MODAL (v4.2.0)          */
/* ========================================== */

.sitvi-symb-modal {
    border-radius: 12px;
    border: none;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.sitvi-symb-modal .modal-header {
    border-bottom: 1px solid #e2e8f0;
    padding: 14px 20px;
}

.sitvi-symb-modal .modal-title {
    font-weight: 700;
    font-size: 14px;
    color: #1e293b;
}

.sitvi-symb-modal .modal-title i {
    color: #8b5cf6;
}

.sitvi-symb-modal .modal-body {
    padding: 0;
    max-height: 50vh;
    overflow-y: auto;
}

.sitvi-symb-modal .modal-footer {
    border-top: 1px solid #e2e8f0;
    padding: 10px 20px;
}

.sitvi-symb-modal-search-wrap {
    padding: 12px 20px;
    border-bottom: 1px solid #f1f5f9;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}

.sitvi-symb-modal-search-wrap input {
    border-radius: 8px;
    font-size: 13px;
}

.sitvi-symb-modal-section {
    padding: 8px 0;
}

.sitvi-symb-modal-section + .sitvi-symb-modal-section {
    border-top: 1px solid #f1f5f9;
}

.sitvi-symb-modal-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
    font-weight: 600;
    padding: 4px 20px;
}

.sitvi-symb-modal-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 13px;
}

.sitvi-symb-modal-item:hover {
    background: #f0f4ff;
}

.sitvi-symb-modal-item.active {
    background: #e8f0fe;
    border-left: 3px solid #3b82f6;
    padding-left: 17px;
}

.sitvi-symb-modal-item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sitvi-symb-modal-item-gs {
    opacity: 0.7;
}

.sitvi-symb-modal-item-gs:hover {
    opacity: 1;
}

.sitvi-symb-modal-empty {
    padding: 24px 20px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
}

.sitvi-symb-modal-loading {
    padding: 24px 20px;
    text-align: center;
    color: #64748b;
    font-size: 13px;
}

.sitvi-symb-modal-no-results {
    padding: 16px 20px;
    text-align: center;
    color: #94a3b8;
    font-size: 12px;
    display: none;
}

/* END OF SITVI MAP EDITOR STYLES */
