/* Ghost Mode - Modalità visitatore (solo lettura) */

/* Banner in cima - NON sticky per evitare overlap con header sticky */
.ghost-banner {
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    color: white;
    text-align: center;
    padding: 10px 16px;
    font-weight: 600;
    font-size: 14px;
    position: relative;
    z-index: 10000;
    letter-spacing: 0.3px;
}

/* ============================================
   NASCONDI TUTTI I BOTTONI DI AZIONE
   ============================================ */
.ghost-mode button[onclick*="create"],
.ghost-mode button[onclick*="Create"],
.ghost-mode button[onclick*="delete"],
.ghost-mode button[onclick*="Delete"],
.ghost-mode button[onclick*="edit"],
.ghost-mode button[onclick*="Edit"],
.ghost-mode button[onclick*="save"],
.ghost-mode button[onclick*="Save"],
.ghost-mode button[onclick*="upload"],
.ghost-mode button[onclick*="Upload"],
.ghost-mode button[onclick*="generate"],
.ghost-mode button[onclick*="Generate"],
.ghost-mode button[onclick*="send"],
.ghost-mode button[onclick*="Send"],
.ghost-mode button[onclick*="download"],
.ghost-mode button[onclick*="Download"],
.ghost-mode button[onclick*="approve"],
.ghost-mode button[onclick*="cancel"],
.ghost-mode button[onclick*="assign"],
.ghost-mode button[onclick*="execute"],
.ghost-mode .btn-primary[onclick],
.ghost-mode .btn-danger,
.ghost-mode .doc-actions button,
.ghost-mode .action-btn,
.ghost-mode [data-action="create"],
.ghost-mode [data-action="delete"],
.ghost-mode [data-action="edit"],
.ghost-mode [data-action="download"],
.ghost-mode button[type="submit"],
.ghost-mode input[type="submit"],
.ghost-mode .save-btn,
.ghost-mode .delete-btn,
.ghost-mode .edit-btn {
    display: none !important;
}

/* Dashboard action buttons - visibili ma disabilitati per visitatori */
/* Piu specifico di .ghost-mode .action-btn, quindi vince */
.ghost-mode .actions-grid .action-btn {
    display: flex !important;
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
    filter: grayscale(30%);
}

/* Nascondi form di creazione e modal */
.ghost-mode .modal-overlay,
.ghost-mode .create-form,
.ghost-mode .upload-form,
.ghost-mode .new-item-form {
    display: none !important;
}

/* Nascondi bottoni header di azione */
.ghost-mode .page-actions button,
.ghost-mode .header-actions button:not(.nav-item) {
    display: none !important;
}

/* ============================================
   NASCONDI PROMPT AGENTI (CUORE DEL SISTEMA)
   ============================================ */
.ghost-mode .agent-prompt,
.ghost-mode .prompt-section,
.ghost-mode .prompt-content,
.ghost-mode .agent-system-prompt,
.ghost-mode [data-field="prompt"],
.ghost-mode [data-field="system_prompt"],
.ghost-mode .prompt-textarea,
.ghost-mode .prompt-editor,
.ghost-mode textarea[name="prompt"],
.ghost-mode textarea[name="system_prompt"],
.ghost-mode .tab-content[data-tab="prompt"],
.ghost-mode #prompt-tab,
.ghost-mode #agent-prompt,
.ghost-mode .prompt-display,
.ghost-mode #tab-prompt,
.ghost-mode #new-prompt,
.ghost-mode #edit-prompt,
.ghost-mode textarea[id*="prompt"] {
    display: none !important;
}

/* Nascondi tab "Prompt" nella pagina agenti */
.ghost-mode .tab-btn[data-tab="prompt"],
.ghost-mode [data-tab="prompt"],
.ghost-mode button[onclick*="prompt"],
.ghost-mode button[onclick*="Prompt"] {
    display: none !important;
}

/* Nascondi label e form-group che contengono prompt */
.ghost-mode label:has(+ textarea[id*="prompt"]),
.ghost-mode .form-group:has(textarea[id*="prompt"]),
.ghost-mode .form-group:has(#edit-prompt),
.ghost-mode .form-group:has(#new-prompt) {
    display: none !important;
}

/* Disabilita tutti gli input (visualizzabili ma non modificabili) */
/* NOTA: Esclude Ariel, ricerca, filtri agenti, e mobile nav */
.ghost-mode input:not([type="search"]):not(.help-widget input):not(.ariel-input):not(.ariel-widget input):not(#search-input),
.ghost-mode select:not(.help-widget select):not(.ariel-widget select):not(.filter-select),
.ghost-mode textarea:not(.help-widget textarea):not(.ariel-widget textarea):not([id*="prompt"]) {
    pointer-events: none !important;
    cursor: not-allowed !important;
}

/* ============================================
   TOAST NOTIFICA
   ============================================ */
.ghost-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(239, 68, 68, 0.95);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 99999;
    animation: ghostToastIn 0.3s ease-out;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

@keyframes ghostToastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============================================
   ARIEL WIDGET SEMPRE FUNZIONANTE
   ============================================ */
/* Bottone trigger e widget container */
.ghost-mode .ariel-widget,
.ghost-mode .ariel-trigger,
.ghost-mode .help-widget,
.ghost-mode .help-trigger {
    pointer-events: auto !important;
    opacity: 1 !important;
    cursor: pointer !important;
}

/* Pannello CHIUSO: blocca TUTTI i click (il pannello e' opacity:0 ma nel DOM) */
.ghost-mode .ariel-widget:not(.open) .ariel-panel,
.ghost-mode .ariel-widget:not(.open) .ariel-panel * {
    pointer-events: none !important;
}

/* Pannello APERTO: abilita interazione */
.ghost-mode .ariel-widget.open .ariel-panel .ariel-header,
.ghost-mode .ariel-widget.open .ariel-panel .ariel-messages,
.ghost-mode .ariel-widget.open .ariel-panel .ariel-input-area,
.ghost-mode .ariel-widget.open .ariel-panel .ariel-quick-actions,
.ghost-mode .ariel-widget.open .ariel-panel input,
.ghost-mode .ariel-widget.open .ariel-panel textarea,
.ghost-mode .ariel-widget.open .ariel-panel button,
.ghost-mode .ariel-input,
.ghost-mode .ariel-send,
.ghost-mode .ariel-close,
.ghost-mode .ariel-quick-btn {
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Input chat - cursore testo */
.ghost-mode .ariel-input {
    cursor: text !important;
}

/* Il pannello mantiene le sue transizioni normali (opacity/transform) */
/* NON forzare display o opacity sul pannello stesso */

/* Tutte le pagine sono visibili per visitatori */

/* Tour button - non matchato da nessun selettore sopra,
   ma protetto esplicitamente per sicurezza */
.ghost-mode #tour-floating-btn {
    opacity: 1 !important;
    pointer-events: auto !important;
    cursor: pointer !important;
    visibility: visible !important;
}

/* ============================================
   MOBILE NAV MENU - Sempre funzionante
   ============================================ */
/* Hamburger button always clickable */
.ghost-mode .mobile-hamburger {
    pointer-events: auto !important;
    cursor: pointer !important;
}
/* Menu items clickable only when overlay is open */
.ghost-mode .mobile-nav-overlay.open .mobile-nav-panel,
.ghost-mode .mobile-nav-overlay.open .mobile-nav-item,
.ghost-mode .mobile-nav-overlay.open .mobile-nav-close {
    pointer-events: auto !important;
    cursor: pointer !important;
}
/* Nascondi il logout dal menu mobile per visitatori */
.ghost-mode .mobile-nav-logout {
    display: none !important;
}

/* ============================================
   MOBILE FIX - Visitatori su mobile
   ============================================ */
@media (max-width: 768px) {

    /* === ARIEL: ferma pulse animation e hover su mobile === */
    /* Evita che il bottone "si illumini" con touch casuali */
    .ghost-mode .ariel-trigger::before {
        animation: none !important;
    }
    .ghost-mode .ariel-trigger:hover {
        transform: none !important;
        box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4) !important;
    }
    .ghost-mode .ariel-trigger:active {
        transform: scale(0.95) !important;
    }

    /* === SCROLL === */
    body.ghost-mode {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* Agents page layout */
    .ghost-mode .agents-container {
        height: auto !important;
        display: block !important;
    }

    .ghost-mode .agents-sidebar {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .ghost-mode .agents-list {
        max-height: 50vh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        height: auto !important;
    }

    /* === ELEMENTI INTERATTIVI PER VISITATORI === */
    .ghost-mode .agent-item,
    .ghost-mode .org-agent {
        cursor: pointer !important;
        pointer-events: auto !important;
    }

    /* Tour */
    .ghost-mode .tour-overlay {
        pointer-events: none !important;
    }
    .ghost-mode .tour-tooltip,
    .ghost-mode .tour-tooltip button {
        pointer-events: auto !important;
    }

    /* Mobile nav overlay chiuso = non-interactive */
    .ghost-mode .mobile-nav-overlay:not(.open) {
        pointer-events: none !important;
    }
    .ghost-mode .mobile-nav-overlay:not(.open) * {
        pointer-events: none !important;
    }

    /* Dashboard action buttons disabilitati */
    .ghost-mode .actions-grid .action-btn {
        pointer-events: none !important;
    }

    /* Ghost banner compatto */
    .ghost-banner {
        padding: 6px 12px;
        font-size: 12px;
    }
}
