/**
 * SITVI - Info Panel CSS
 *
 * Stili per il pannello informazioni interattivo (SitviInfoPanel).
 * Organizzato in sezioni: container, floating, docked, header, tabs,
 * navigator, content, footer, animazioni, responsive.
 *
 * @package SITVI
 * @version 1.0.0
 */

/* =============================================
   1. PANEL CONTAINER (base)
   ============================================= */

.sitvi-infopanel {
    display: none;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 12px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.12),
        0 2px 8px rgba(0, 0, 0, 0.06);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    color: #1a1a2e;
    overflow: hidden;
    opacity: 0;
    transform: translateX(8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.sitvi-infopanel.show {
    opacity: 1;
    transform: translateX(0);
}

/* =============================================
   2. FLOATING STATE
   ============================================= */

.sitvi-infopanel-floating {
    position: fixed;
    z-index: 1000;
    width: 380px;
    min-width: 320px;
    max-width: 500px;
    max-height: calc(100vh - 120px);
    resize: both;
}

/* =============================================
   3. DOCKED STATE (left / right)
   ============================================= */

.sitvi-infopanel-docked-right,
.sitvi-infopanel-docked-left {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 380px;
    max-height: none;
    border-radius: 0;
    resize: none;
    z-index: 500;
    border: none;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    background: rgba(255, 255, 255, 0.98);
}

.sitvi-infopanel-docked-right {
    right: 0;
    border-left: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.06);
    transform: translateX(8px);
}

.sitvi-infopanel-docked-left {
    left: 0;
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.06);
    transform: translateX(-8px);
}

.sitvi-infopanel-docked-right.show,
.sitvi-infopanel-docked-left.show {
    transform: translateX(0);
}

/* =============================================
   4. HEADER
   ============================================= */

.sitvi-infopanel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    flex-shrink: 0;
    min-height: 42px;
}

.sitvi-infopanel-docked-left .sitvi-infopanel-header,
.sitvi-infopanel-docked-right .sitvi-infopanel-header {
    cursor: default;
}

.sitvi-infopanel-title {
    font-weight: 600;
    font-size: 13px;
    color: #0369a1;
    letter-spacing: -0.01em;
}

.sitvi-infopanel-title i {
    margin-right: 6px;
    color: #0ea5e9;
    font-size: 14px;
}

.sitvi-infopanel-header-actions {
    display: flex;
    gap: 2px;
    align-items: center;
}

.sitvi-infopanel-btn {
    background: none;
    border: none;
    padding: 5px 6px;
    cursor: pointer;
    color: #94a3b8;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}

.sitvi-infopanel-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #475569;
}

.sitvi-infopanel-btn:active {
    background: rgba(0, 0, 0, 0.1);
}

.sitvi-infopanel-btn:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

.sitvi-infopanel-btn-active {
    background: rgba(99, 102, 241, 0.12);
    color: #6366f1;
}

.sitvi-infopanel-btn-active:hover {
    background: rgba(99, 102, 241, 0.2);
    color: #4f46e5;
}

/* =============================================
   5. TABS
   ============================================= */

.sitvi-infopanel-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 12px;
    background: #f8fafc;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

.sitvi-infopanel-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.sitvi-infopanel-tab:hover {
    border-color: #cbd5e1;
    background: #f1f5f9;
}

.sitvi-infopanel-tab.active {
    background: #0ea5e9;
    border-color: #0ea5e9;
    color: white;
}

.sitvi-infopanel-tab-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sitvi-infopanel-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 9px;
    font-size: 11px;
    font-weight: 600;
}

.sitvi-infopanel-tab.active .sitvi-infopanel-tab-badge {
    background: rgba(255, 255, 255, 0.25);
}

/* =============================================
   6. FEATURE NAVIGATOR
   ============================================= */

.sitvi-infopanel-feature-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 8px 12px;
    background: #f1f5f9;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

.sitvi-infopanel-nav-prev,
.sitvi-infopanel-nav-next {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s;
}

.sitvi-infopanel-nav-prev:hover,
.sitvi-infopanel-nav-next:hover {
    background: #0ea5e9;
    border-color: #0ea5e9;
    color: white;
}

.sitvi-infopanel-nav-counter {
    font-size: 12px;
    font-weight: 500;
    color: #475569;
    min-width: 50px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* =============================================
   7. CONTENT
   ============================================= */

.sitvi-infopanel-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.sitvi-infopanel-content::-webkit-scrollbar {
    width: 5px;
}

.sitvi-infopanel-content::-webkit-scrollbar-track {
    background: transparent;
}

.sitvi-infopanel-content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.sitvi-infopanel-content::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Empty state */
.sitvi-infopanel-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #94a3b8;
    text-align: center;
}

.sitvi-infopanel-empty i {
    font-size: 36px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.sitvi-infopanel-empty p {
    margin: 0;
    font-size: 13px;
}

/* Feature header */
.sitvi-infopanel-feature-header {
    padding: 12px 16px;
    color: white;
    font-weight: 600;
    font-size: 14px;
    background: #2c3e50;
    letter-spacing: -0.01em;
}

/* Attributes table */
.sitvi-infopanel-attrs {
    width: 100%;
    border-collapse: collapse;
}

.sitvi-infopanel-attrs tr {
    border-bottom: 1px solid #f1f5f9;
}

.sitvi-infopanel-attrs tr:last-child {
    border-bottom: none;
}

.sitvi-infopanel-attrs tr:hover {
    background: #fafbfc;
}

.sitvi-infopanel-attrs td {
    padding: 8px 12px;
    vertical-align: top;
    font-size: 12px;
}

.sitvi-infopanel-attr-label {
    width: 40%;
    color: #64748b;
    font-weight: 500;
    background: #f8fafc;
}

.sitvi-infopanel-attr-value {
    color: #1e293b;
    word-break: break-word;
}

.sitvi-infopanel-attr-value a {
    color: #0ea5e9;
    text-decoration: none;
}

.sitvi-infopanel-attr-value a:hover {
    text-decoration: underline;
}

/* =============================================
   8. FOOTER
   ============================================= */

.sitvi-infopanel-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #f8fafc;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}

.sitvi-infopanel-attrtable-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s;
}

.sitvi-infopanel-attrtable-btn:hover {
    background: #0ea5e9;
    border-color: #0ea5e9;
    color: white;
}

.sitvi-infopanel-attrtable-btn i {
    font-size: 14px;
}

.sitvi-infopanel-zoom-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s;
}

.sitvi-infopanel-zoom-btn:hover {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

.sitvi-infopanel-zoom-btn i {
    font-size: 16px;
}

/* =============================================
   9. ANIMATIONS
   ============================================= */

.sitvi-infopanel-docked-left,
.sitvi-infopanel-docked-right {
    transition: opacity 0.25s ease, transform 0.25s ease;
}

/* =============================================
   10. RESPONSIVE (mobile)
   ============================================= */

@media (max-width: 576px) {
    .sitvi-infopanel.sitvi-infopanel-floating {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        max-height: 70vh;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
        resize: none;
        transform: translateY(8px);
    }

    .sitvi-infopanel.sitvi-infopanel-floating.show {
        transform: translateY(0);
    }

    /* Nascondi bottoni dock su mobile */
    .sitvi-infopanel-dock-left-btn,
    .sitvi-infopanel-dock-right-btn {
        display: none !important;
    }

    .sitvi-infopanel-header {
        cursor: default;
        padding: 12px 16px;
    }

    .sitvi-infopanel-tabs {
        padding: 8px;
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .sitvi-infopanel-tab {
        flex-shrink: 0;
    }

    .sitvi-infopanel-attrs td {
        padding: 10px 12px;
    }

    .sitvi-infopanel-footer {
        padding: 12px;
    }

    .sitvi-infopanel-attrtable-btn {
        padding: 10px 14px;
        font-size: 13px;
    }

    .sitvi-infopanel-zoom-btn {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 768px) {
    .sitvi-infopanel-docked-left,
    .sitvi-infopanel-docked-right {
        width: 320px;
    }
}

/* =============================================
   11. COORDINATION WITH LEGEND PANEL
   Se entrambi i pannelli sono docked sullo stesso lato,
   l'info panel si sposta automaticamente
   ============================================= */

/* Utility per offset quando legenda e' presente */
.sitvi-infopanel-docked-left.sitvi-legend-offset {
    left: var(--sitvi-legend-width, 300px);
}

.sitvi-infopanel-docked-right.sitvi-legend-offset {
    right: var(--sitvi-legend-width, 300px);
}

/* =============================================
   12. SEARCH BAR
   Barra di ricerca testo per filtrare le features
   nel tab corrente.
   ============================================= */

.sitvi-infopanel-search {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f8fafc;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

.sitvi-infopanel-search > i {
    color: #94a3b8;
    font-size: 12px;
    flex-shrink: 0;
}

.sitvi-infopanel-search-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    background: white;
    color: #1e293b;
    outline: none;
    transition: border-color 0.15s;
}

.sitvi-infopanel-search-input:focus {
    border-color: #0ea5e9;
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.15);
}

.sitvi-infopanel-search-input::placeholder {
    color: #cbd5e1;
}

.sitvi-infopanel-search-clear {
    background: none;
    border: none;
    padding: 2px 4px;
    cursor: pointer;
    color: #94a3b8;
    font-size: 12px;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

.sitvi-infopanel-search-clear:hover {
    color: #475569;
    background: rgba(0, 0, 0, 0.06);
}

/* =============================================
   13. HIGHLIGHT TOGGLE BUTTON
   Pulsante nel footer per attivare/disattivare
   l'evidenziazione della feature sulla mappa.
   ============================================= */

.sitvi-infopanel-highlight-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.15s;
}

.sitvi-infopanel-highlight-btn:hover {
    border-color: #f97316;
    color: #f97316;
}

.sitvi-infopanel-highlight-btn.active {
    background: #fff7ed;
    border-color: #f97316;
    color: #f97316;
}

.sitvi-infopanel-highlight-btn i {
    font-size: 15px;
}

/* =============================================
   14. TOOLS BAR (footer secondario)
   Barra con strumenti aggiuntivi: export, stampa,
   grafico e confronto.
   ============================================= */

.sitvi-infopanel-tools {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 12px;
    background: #f1f5f9;
    border-top: 1px solid rgba(0, 0, 0, 0.04);
    flex-shrink: 0;
}

.sitvi-infopanel-tool-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 28px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    color: #64748b;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
}

.sitvi-infopanel-tool-btn:hover {
    background: #0ea5e9;
    border-color: #0ea5e9;
    color: white;
}

.sitvi-infopanel-tool-btn:active {
    transform: scale(0.95);
}

/* =============================================
   15. COMPARE VIEW
   Vista di confronto side-by-side delle features.
   ============================================= */

.sitvi-infopanel-compare {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sitvi-infopanel-compare-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: #fef3c7;
    border-bottom: 1px solid #fcd34d;
    font-size: 13px;
    font-weight: 600;
    color: #92400e;
}

.sitvi-infopanel-compare-header i {
    font-size: 14px;
}

.sitvi-infopanel-compare-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: #92400e;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 14px;
}

.sitvi-infopanel-compare-close:hover {
    background: rgba(0, 0, 0, 0.08);
}

.sitvi-infopanel-compare-info {
    padding: 6px 14px;
    font-size: 11px;
    color: #78716c;
    background: #fffbeb;
    border-bottom: 1px solid #fde68a;
}

.sitvi-infopanel-compare-table-wrap {
    flex: 1;
    overflow: auto;
}

.sitvi-infopanel-compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.sitvi-infopanel-compare-table th {
    position: sticky;
    top: 0;
    background: #f1f5f9;
    padding: 6px 8px;
    font-weight: 600;
    color: #475569;
    border-bottom: 2px solid #e2e8f0;
    text-align: center;
    white-space: nowrap;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sitvi-infopanel-compare-table td {
    padding: 5px 8px;
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
    text-align: center;
    word-break: break-word;
}

.sitvi-compare-label {
    text-align: left !important;
    background: #f8fafc;
    color: #64748b;
    font-weight: 500;
    white-space: nowrap;
    position: sticky;
    left: 0;
}

.sitvi-infopanel-compare-table tr:hover td {
    background: #fafbfc;
}

/* =============================================
   16. CHART VIEW
   Grafico a barre orizzontali per campi numerici.
   Implementato in puro HTML/CSS senza dipendenze.
   ============================================= */

.sitvi-infopanel-chart {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sitvi-infopanel-chart-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: #ede9fe;
    border-bottom: 1px solid #c4b5fd;
    font-size: 13px;
    font-weight: 600;
    color: #5b21b6;
}

.sitvi-infopanel-chart-header i {
    font-size: 14px;
}

.sitvi-infopanel-chart-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: #5b21b6;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 14px;
}

.sitvi-infopanel-chart-close:hover {
    background: rgba(0, 0, 0, 0.08);
}

.sitvi-infopanel-chart-selector {
    padding: 8px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.sitvi-infopanel-chart-field {
    width: 100%;
    padding: 5px 8px;
    font-size: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    background: white;
    color: #1e293b;
    cursor: pointer;
}

.sitvi-infopanel-chart-bars {
    flex: 1;
    overflow-y: auto;
    padding: 8px 14px;
}

.sitvi-chart-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.sitvi-chart-bar-label {
    flex: 0 0 90px;
    font-size: 11px;
    color: #475569;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
}

.sitvi-chart-bar-track {
    flex: 1;
    height: 18px;
    background: #f1f5f9;
    border-radius: 3px;
    overflow: hidden;
}

.sitvi-chart-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
    min-width: 2px;
}

.sitvi-chart-bar-value {
    flex: 0 0 60px;
    font-size: 11px;
    color: #1e293b;
    font-weight: 500;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.sitvi-chart-bar-more {
    text-align: center;
    font-size: 11px;
    color: #94a3b8;
    padding: 8px 0;
    font-style: italic;
}

/* =============================================
   17. GEO INFO BAR
   Barra con coordinate centroide e misura
   area/lunghezza sotto l'header feature.
   ============================================= */

.sitvi-infopanel-geo-info {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f0f9ff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    font-size: 11px;
    color: #475569;
    flex-wrap: wrap;
}

.sitvi-geo-coords {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
    font-variant-numeric: tabular-nums;
}

.sitvi-geo-coords:hover {
    background: #0ea5e9;
    color: white;
}

.sitvi-geo-coords i {
    font-size: 11px;
    color: #0ea5e9;
}

.sitvi-geo-coords:hover i {
    color: white;
}

.sitvi-geo-measure {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    font-weight: 500;
}

.sitvi-geo-measure i {
    font-size: 11px;
    color: #10b981;
}

.sitvi-geo-sep {
    color: #cbd5e1;
    font-size: 10px;
}

/* =============================================
   18. CLICK-TO-COPY (celle valore)
   Feedback visivo quando un valore viene copiato
   negli appunti.
   ============================================= */

.sitvi-copyable {
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    position: relative;
}

.sitvi-copyable:hover {
    background: #e0f2fe !important;
    color: #0369a1;
}

.sitvi-copied {
    background: #d1fae5 !important;
    color: #065f46 !important;
}

.sitvi-copied::after {
    content: '\2713';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #10b981;
    font-weight: 700;
    animation: sitvi-copy-check 0.3s ease;
}

@keyframes sitvi-copy-check {
    0% { opacity: 0; transform: translateY(-50%) scale(0.5); }
    50% { transform: translateY(-50%) scale(1.2); }
    100% { opacity: 1; transform: translateY(-50%) scale(1); }
}

/* =============================================
   19. PIN FEATURE BUTTON
   Pulsante nel footer per pinnare feature
   che sopravvivono a clearAll().
   ============================================= */

.sitvi-infopanel-pin-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}

.sitvi-infopanel-pin-btn:hover {
    border-color: #6366f1;
    color: #6366f1;
}

.sitvi-infopanel-pin-btn.active {
    background: #eef2ff;
    border-color: #6366f1;
    color: #6366f1;
}

.sitvi-infopanel-pin-btn i {
    font-size: 15px;
}

.sitvi-pin-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: #6366f1;
    color: white;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
