/**
 * navigation_editor.css - Editeur de navigation moderne (NAV_EDITOR_V2)
 */

/* ===== LAYOUT GLOBAL ===== */
.nav-editor-v2 {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 20px;
    margin-top: 12px;
}
@media (max-width: 1024px) {
    .nav-editor-v2 { grid-template-columns: 1fr; }
}

/* ===== ARBORESCENCE ===== */
.nav-tree {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    min-height: 400px;
}

.nav-tree-empty {
    padding: 60px 20px;
    text-align: center;
    color: #6b7280;
}
.nav-tree-empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.6; }

/* ===== NODE ===== */
.nav-node {
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s;
}
.nav-node:hover { background: #fafbfc; }
.nav-node.dragging { opacity: 0.4; }

/* DRAG_AND_DROP_V2 : 3 modes visuels distincts pour le drop
   ---------------------------------------------------------- */

/* drop-before : ligne bleue EN HAUT de l'item (drop avant lui) */
.nav-node.drop-before {
    position: relative;
}
.nav-node.drop-before::before {
    content: '';
    position: absolute;
    top: -2px;
    left: 8px;
    right: 8px;
    height: 3px;
    background: #3b82f6;
    border-radius: 2px;
    pointer-events: none;
    z-index: 5;
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.3);
}
.nav-node.drop-before::after {
    content: '';
    position: absolute;
    top: -5px;
    left: 5px;
    width: 9px;
    height: 9px;
    background: #3b82f6;
    border-radius: 50%;
    pointer-events: none;
    z-index: 5;
}

/* drop-after : ligne bleue EN BAS de l'item (drop apres lui) */
.nav-node.drop-after {
    position: relative;
}
.nav-node.drop-after::before {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 8px;
    right: 8px;
    height: 3px;
    background: #3b82f6;
    border-radius: 2px;
    pointer-events: none;
    z-index: 5;
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.3);
}
.nav-node.drop-after::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 5px;
    width: 9px;
    height: 9px;
    background: #3b82f6;
    border-radius: 50%;
    pointer-events: none;
    z-index: 5;
}

/* drop-inside : highlight vert pour deposer dans une section */
.nav-node.drop-inside > .nav-node-row {
    background: #d1fae5;
    outline: 2px dashed #10b981;
    outline-offset: -2px;
    border-radius: 4px;
}

/* Ancienne classe conservee pour retrocompat */
.nav-node.drop-target {
    background: #dbeafe;
    outline: 2px dashed #3b82f6;
    outline-offset: -2px;
}
.nav-node.disabled { opacity: 0.45; background: #fafafa; }

.nav-node-row {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    gap: 8px;
    cursor: grab;
    user-select: none;
    min-height: 44px;
}
.nav-node-row:active { cursor: grabbing; }

.nav-node-row.depth-0 { background: linear-gradient(90deg, #fef2f2 0%, #fff 100%); font-weight: 600; }
.nav-node-row.depth-0:hover { background: linear-gradient(90deg, #fee2e2 0%, #fff5f5 100%); }

.nav-node-handle {
    color: #d1d5db;
    cursor: grab;
    padding: 4px 2px;
    font-size: 16px;
    line-height: 1;
}
.nav-node:hover .nav-node-handle { color: #6b7280; }

.nav-node-toggle {
    width: 20px;
    text-align: center;
    color: #9ca3af;
    cursor: pointer;
    font-size: 10px;
    transition: transform 0.15s;
    user-select: none;
}
.nav-node-toggle.expanded { transform: rotate(90deg); }

.nav-node-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    line-height: 1;
}

.nav-node-label {
    flex: 1;
    color: #1f2937;
    font-size: 14px;
}
.nav-node-label-input {
    flex: 1;
    border: 2px solid #3b82f6;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 14px;
    background: #fff;
    outline: none;
}

.nav-node-target {
    font-size: 11px;
    color: #9ca3af;
    font-family: ui-monospace, monospace;
    padding: 2px 6px;
    background: #f3f4f6;
    border-radius: 4px;
}

.nav-node-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}
.nav-node-badge.system { background: #fef3c7; color: #92400e; }
.nav-node-badge.disabled-badge { background: #e5e7eb; color: #6b7280; }
.nav-node-badge.role-restricted { background: #ede9fe; color: #6b21a8; }

/* ===== ACTIONS RAPIDES ===== */
.nav-node-actions {
    display: flex;
    gap: 2px;
    align-items: center;
    margin-left: auto;
    opacity: 0;
    transition: opacity 0.15s;
}
.nav-node-row:hover .nav-node-actions { opacity: 1; }

.nav-action-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: #6b7280;
    transition: all 0.1s;
}
.nav-action-btn:hover { background: #fff; border-color: #d1d5db; color: #1f2937; }
.nav-action-btn.danger:hover { background: #fee2e2; border-color: #fca5a5; color: #dc2626; }
.nav-action-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== TOGGLE ENABLED INLINE ===== */
.nav-toggle-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}
.nav-toggle-switch input { opacity: 0; width: 0; height: 0; }
.nav-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #d1d5db;
    border-radius: 20px;
    transition: 0.2s;
}
.nav-toggle-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.2s;
}
.nav-toggle-switch input:checked + .nav-toggle-slider { background-color: #10b981; }
.nav-toggle-switch input:checked + .nav-toggle-slider:before { transform: translateX(16px); }

/* ===== SIDEBAR PREVIEW ===== */
.nav-preview {
    position: sticky;
    top: 12px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    align-self: start;
    max-height: calc(100vh - 100px);
}
.nav-preview-header {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #fff;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.nav-preview-role-select {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
}
.nav-preview-role-select option { color: #1f2937; }

.nav-preview-body {
    padding: 12px;
    background: #f8fafc;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
    min-height: 300px;
    font-size: 13px;
}

.nav-preview-section {
    margin-bottom: 16px;
}
.nav-preview-section-title {
    font-size: 10px;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    padding: 0 8px;
}
.nav-preview-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    color: #1f2937;
    transition: background 0.1s;
    cursor: default;
}
.nav-preview-item:hover { background: #e0e7ff; }
.nav-preview-item-icon { font-size: 16px; }
.nav-preview-item-label { flex: 1; }
.nav-preview-empty {
    padding: 40px 12px;
    text-align: center;
    color: #9ca3af;
    font-style: italic;
    font-size: 12px;
}

/* ===== ICON PICKER ===== */
.icon-picker {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    max-height: 280px;
    overflow-y: auto;
}
.icon-picker-search {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 13px;
}
.icon-picker-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}
.icon-picker-item {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: #f9fafb;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.1s;
}
.icon-picker-item:hover { background: #e0e7ff; transform: scale(1.1); }
.icon-picker-item.selected { background: #dbeafe; border-color: #3b82f6; }
.icon-picker-category {
    font-size: 11px;
    color: #6b7280;
    font-weight: 600;
    text-transform: uppercase;
    margin: 8px 0 4px;
}

/* ===== MODAL EDITOR ===== */
.nav-editor-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: navFadeIn 0.15s ease;
}
.nav-editor-modal-box {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 720px;
    max-height: 92vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
    animation: navSlideUp 0.2s ease;
}
.nav-editor-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #f8fafc 0%, #fff 100%);
}
.nav-editor-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}
.nav-editor-modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}
.nav-editor-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
    background: #fafbfc;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.nav-field { margin-bottom: 16px; }
.nav-field-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}
.nav-field-help {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
    font-style: italic;
}
.nav-field-input, .nav-field-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    transition: border-color 0.1s;
    box-sizing: border-box;
}
.nav-field-input:focus, .nav-field-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.nav-field-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Tabs dans le modal */
.nav-editor-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}
.nav-editor-tab {
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
}
.nav-editor-tab.active {
    color: #1f2937;
    border-bottom-color: #3b82f6;
    font-weight: 600;
}
.nav-editor-tab:hover:not(.active) { background: #f9fafb; color: #1f2937; }

/* Permissions ligne */
.nav-perm-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid #f3f4f6;
    background: #fff;
}
.nav-perm-row:last-child { border-bottom: none; }
.nav-perm-row.disabled { background: #fafafa; }
.nav-perm-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #1f2937;
}

/* Search bar arborescence */
.nav-tree-search {
    padding: 12px;
    border-bottom: 1px solid #f3f4f6;
    background: #fafbfc;
    display: flex;
    gap: 8px;
    align-items: center;
}
.nav-tree-search input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
}
.nav-tree-search input:focus { outline: none; border-color: #3b82f6; }
.nav-tree-search-count {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
}

/* Section header dans l'arbre (pour les "racines") */
.nav-tree-section-header {
    background: linear-gradient(90deg, #fef2f2 0%, #fff 60%);
    padding: 12px 16px;
    font-size: 11px;
    font-weight: 700;
    color: #c53030;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Toast actions */
@keyframes navFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes navSlideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Unsaved indicator */
.nav-unsaved-banner {
    background: linear-gradient(90deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 10px 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: #92400e;
}
.nav-unsaved-banner-icon { font-size: 18px; }

/* Bouton appliquer pulse */
@keyframes pulse-attention {
    0%, 100% { box-shadow: 0 0 0 0 rgba(59,130,246,0.5); }
    50% { box-shadow: 0 0 0 8px rgba(59,130,246,0); }
}
.btn-apply-pulse { animation: pulse-attention 2s infinite; }