/**
 * SITEMAP TREE BUILDER - STYLES
 * Design cohérent avec la Charte Graphik Impact 2025
 * Version: 1.0.0
 */

/* ============================================
   CONTAINER PRINCIPAL
   ============================================ */

.sitemap-tree-builder {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 20px;
}

/* ============================================
   HEADER
   ============================================ */

.tree-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e5e7eb;
}

.tree-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: #374151;
}

.btn-add-page {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #009FE3; /* Cyan primaire GI */
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add-page:hover {
    background: #0088c7;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 159, 227, 0.2);
}

.btn-add-page:active {
    transform: translateY(0);
}

/* ============================================
   CONTAINER DE L'ARBRE
   ============================================ */

.tree-container {
    min-height: 200px;
    max-height: 600px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 0;
}

/* Scrollbar personnalisée */
.tree-container::-webkit-scrollbar {
    width: 8px;
}

.tree-container::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 4px;
}

.tree-container::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.tree-container::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ============================================
   ÉTAT VIDE
   ============================================ */

.tree-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #6b7280;
    text-align: center;
}

.tree-empty-state p {
    margin: 10px 0 0 0;
}

/* ============================================
   LISTES (UL)
   ============================================ */

.tree-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tree-list-root {
    padding-left: 0;
}

.tree-list-nested {
    padding-left: 40px;
    margin-top: 8px;
    border-left: 2px solid #e5e7eb;
    margin-left: 20px;
}

/* ============================================
   ITEMS DE L'ARBRE
   ============================================ */

.tree-item {
    margin-bottom: 8px;
    position: relative;
}

.tree-item-content {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    transition: all 0.2s;
    position: relative;
}

.tree-item-content:hover {
    border-color: #009FE3;
    box-shadow: 0 2px 8px rgba(0, 159, 227, 0.1);
}

/* Page masquée */
.tree-item.page-hidden .tree-item-content {
    background: #f9fafb;
    opacity: 0.7;
}

.tree-item.page-hidden .tree-item-name {
    text-decoration: line-through;
    color: #9ca3af;
}

/* ============================================
   HANDLE (Poignée de drag)
   ============================================ */

.tree-item-handle {
    cursor: grab;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.tree-item-handle:hover {
    background: #f3f4f6;
}

.tree-item-handle:active {
    cursor: grabbing;
}

/* ============================================
   CONTENU PRINCIPAL
   ============================================ */

.tree-item-main {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0; /* Pour le truncate */
}

.tree-item-name {
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-item-description {
    font-size: 12px;
    color: #6b7280;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* ============================================
   BADGES
   ============================================ */

.tree-item-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tree-item-badge-hidden {
    background: #fef3c7; /* Jaune pâle */
    color: #92400e; /* Brun */
}

/* ============================================
   ACTIONS
   ============================================ */

.tree-item-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.tree-item-content:hover .tree-item-actions {
    opacity: 1;
}

.tree-action-btn {
    background: transparent;
    border: 1px solid #e5e7eb;
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
}

.tree-action-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #374151;
}

.tree-action-btn-add-child:hover {
    background: #e6f7ff;
    border-color: #009FE3;
    color: #009FE3;
}

.tree-action-btn-delete:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #dc2626;
}

/* ============================================
   ÉTATS DRAG & DROP
   ============================================ */

.tree-item-ghost {
    opacity: 0.4;
}

.tree-item-chosen {
    background: #e6f7ff !important;
    border-color: #009FE3 !important;
}

.tree-item-drag {
    opacity: 0.9;
    transform: rotate(2deg);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

/* Indicateur de drop */
.tree-list-nested.sortable-drag-over {
    border-left-color: #009FE3;
    border-left-width: 3px;
    background: rgba(0, 159, 227, 0.05);
}

/* ============================================
   AIDE
   ============================================ */

.tree-help {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e5e7eb;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.5;
}

.tree-help i {
    flex-shrink: 0;
    margin-top: 2px;
}

/* ============================================
   MODAL D'AJOUT/ÉDITION
   ============================================ */

.tree-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.tree-modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.tree-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tree-modal-title {
    font-size: 18px;
    font-weight: 600;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tree-modal-close {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.tree-modal-close:hover {
    color: #374151;
}

.tree-modal-body {
    padding: 24px;
}

.tree-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ============================================
   FORMULAIRE DE LA MODAL
   ============================================ */

.tree-form-group {
    margin-bottom: 20px;
}

.tree-form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
}

.tree-form-label .required {
    color: #dc2626;
    margin-left: 2px;
}

.tree-form-input,
.tree-form-textarea,
.tree-form-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    color: #374151;
    transition: all 0.2s;
    font-family: inherit;
}

.tree-form-input:focus,
.tree-form-textarea:focus,
.tree-form-select:focus {
    outline: none;
    border-color: #009FE3;
    box-shadow: 0 0 0 3px rgba(0, 159, 227, 0.1);
}

.tree-form-textarea {
    resize: vertical;
    min-height: 80px;
}

/* Quill WYSIWYG dans la modale */
#tree-page-description-editor .ql-editor {
    min-height: 100px;
    max-height: 250px;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.5;
}

#tree-page-description-editor + .ql-toolbar,
.tree-form-group .ql-toolbar.ql-snow {
    border-radius: 8px 8px 0 0;
    border-color: #d1d5db;
}

.tree-form-group .ql-container.ql-snow {
    border-radius: 0 0 8px 8px;
    border-color: #d1d5db;
}

.tree-form-hint {
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
    display: flex;
    align-items: flex-start;
    gap: 4px;
}

.tree-form-hint i {
    flex-shrink: 0;
    margin-top: 2px;
}

/* ============================================
   BOUTONS DE LA MODAL
   ============================================ */

.tree-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tree-btn-primary {
    background: #009FE3;
    color: white;
}

.tree-btn-primary:hover {
    background: #0088c7;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 159, 227, 0.2);
}

.tree-btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.tree-btn-secondary:hover {
    background: #e5e7eb;
}

.tree-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ============================================
   RADIO BUTTONS POUR TYPE
   ============================================ */

.tree-radio-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.tree-radio-item {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.tree-radio-item input[type="radio"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #009FE3;
}

.tree-radio-item label {
    font-size: 14px;
    color: #374151;
    cursor: pointer;
    user-select: none;
}

/* ============================================
   CHECKBOX POUR HIDDEN
   ============================================ */

.tree-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: #f9fafb;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.tree-checkbox-item:hover {
    background: #f3f4f6;
}

.tree-checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #009FE3;
}

.tree-checkbox-item label {
    font-size: 14px;
    color: #374151;
    cursor: pointer;
    user-select: none;
    flex: 1;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .tree-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .btn-add-page {
        justify-content: center;
    }

    .tree-list-nested {
        padding-left: 20px;
        margin-left: 10px;
    }

    .tree-item-description {
        display: none;
    }

    .tree-modal {
        width: 95%;
        margin: 10px;
    }

    .tree-modal-body {
        padding: 16px;
    }
}

/* ============================================
   ANIMATION DE CHARGEMENT
   ============================================ */

.tree-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #6b7280;
}

.tree-loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #e5e7eb;
    border-top-color: #009FE3;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
