/* ============================================================
   TREEVIEW MANAGER
   Tree-specific CSS
   ============================================================ */


/* ------------------------------------------------------------
   Nested Branch Container
   ------------------------------------------------------------ */

.tree-branch {
    position: relative;
    padding-left: 1.5rem;
    list-style: none;
}


/* ------------------------------------------------------------
   Vertical Guide Continuity Line
   ------------------------------------------------------------ */

.tree-branch::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 1.1rem;
    left: 0.65rem;
    border-left: 2px dashed #cbd5e1;
}


/* ------------------------------------------------------------
   Tree Node Item
   ------------------------------------------------------------ */

.tree-node-item {
    position: relative;
}


/* ------------------------------------------------------------
   Horizontal Connecting Stem
   ------------------------------------------------------------ */

.tree-branch > .tree-node-item::before {
    content: '';
    position: absolute;
    top: 1.1rem;
    left: -0.85rem;
    width: 0.85rem;
    border-top: 2px dashed #cbd5e1;
}


/* ------------------------------------------------------------
   Root Node Override
   ------------------------------------------------------------ */

.root-branch {
    padding-left: 0 !important;
}

.root-branch::before {
    display: none !important;
}

.root-branch > .tree-node-item::before {
    display: none !important;
}


/* ------------------------------------------------------------
   Dragging
   ------------------------------------------------------------ */

.tree-node-card {
    position: relative;
}

.tree-node-card.is-dragging {
    opacity: 0.45;
}


/* ------------------------------------------------------------
   Drop Feedback
   ------------------------------------------------------------ */

.tree-node-card.drop-before {
    box-shadow:
        inset 0 3px 0 #4f46e5;
}

.tree-node-card.drop-after {
    box-shadow:
        inset 0 -3px 0 #4f46e5;
}

.tree-node-card.drop-child {
    background-color: #eef2ff !important;
    border-color: #6366f1 !important;
    box-shadow:
        0 0 0 2px rgba(99, 102, 241, 0.18);
}

.tree-node-card.drop-invalid {
    border-color: #fda4af !important;
    background-color: #fff1f2 !important;
}


/* ------------------------------------------------------------
   Drag Handle Hint
   ------------------------------------------------------------ */

.drag-handle {
    cursor: grab;
}

.drag-handle:active {
    cursor: grabbing;
}


/* ------------------------------------------------------------
   Checkbox
   ------------------------------------------------------------ */

.node-checkbox {
    accent-color: #4f46e5;
}


/* ------------------------------------------------------------
   Checked Node Appearance
   ------------------------------------------------------------ */

.node-checkbox:checked + .node-title {
    color: #64748b;
}


/* ============================================================
   EXPORT DROPDOWN
   ============================================================ */

#export-menu {
    min-width: 13rem;
}


/* ------------------------------------------------------------
   Individual Export Option
   ------------------------------------------------------------ */

.export-menu-item {
    width: 100%;
    display: block;

    padding: 0.7rem 0.85rem;

    background-color: #ffffff;

    border: 0;

    color: #334155;

    font-size: 0.75rem;

    line-height: 1rem;

    font-weight: 500;

    text-align: left;

    white-space: nowrap;

    cursor: pointer;

    transition:
        background-color 0.15s ease,
        color 0.15s ease;
}


/* ------------------------------------------------------------
   Separator Between Options
   ------------------------------------------------------------ */

.export-menu-item + .export-menu-item {
    border-top: 1px solid #e2e8f0;
}


/* ------------------------------------------------------------
   Hover State
   ------------------------------------------------------------ */

.export-menu-item:hover {
    background-color: #eef2ff;
    color: #4338ca;
}


/* ------------------------------------------------------------
   Keyboard Focus
   ------------------------------------------------------------ */

.export-menu-item:focus {
    outline: none;
    background-color: #eef2ff;
    color: #4338ca;
}


/* ------------------------------------------------------------
   Export Button
   ------------------------------------------------------------ */

#export-menu-btn {
    white-space: nowrap;
}


/* ============================================================
   SAVE TREEVIEW BUTTON
   ============================================================ */

#save-tree-btn {
    white-space: nowrap;

    transition:
        background-color 0.35s ease,
        border-color 0.35s ease,
        color 0.35s ease,
        box-shadow 0.35s ease;
}


/* ------------------------------------------------------------
   Normal / Ready State
   ------------------------------------------------------------ */

#save-tree-btn {
    background-color: #4f46e5;
    border-color: #4f46e5;
    color: #ffffff;
}


/* ------------------------------------------------------------
   Autosave In Progress
   ------------------------------------------------------------ */

#save-tree-btn.save-state-saving {
    background-color: #dcfce7 !important;
    border-color: #86efac !important;
    color: #166534 !important;

    box-shadow:
        0 0 0 2px rgba(34, 197, 94, 0.08);
}


/* ------------------------------------------------------------
   Successfully Saved
   ------------------------------------------------------------ */

#save-tree-btn.save-state-saved {
    background-color: #bbf7d0 !important;
    border-color: #86efac !important;
    color: #166534 !important;

    box-shadow:
        0 0 0 2px rgba(34, 197, 94, 0.12);
}


/* ------------------------------------------------------------
   Unsaved Changes
   ------------------------------------------------------------ */

#save-tree-btn.save-state-unsaved {
    background-color: #4f46e5 !important;
    border-color: #4f46e5 !important;
    color: #ffffff !important;
}


/* ------------------------------------------------------------
   Save Error
   ------------------------------------------------------------ */

#save-tree-btn.save-state-error {
    background-color: #dc2626 !important;
    border-color: #dc2626 !important;
    color: #ffffff !important;
}


/* ============================================================
   DESCRIPTION BOX
   ============================================================ */

/*
 * Increase description text from Tailwind text-sm
 * (14px) to approximately 15px for easier reading.
 */

#node-desc {
    font-size: 15px;
}


/* ------------------------------------------------------------
   Small-screen protection
   ------------------------------------------------------------ */

@media (max-width: 1100px) {

    header {
        padding-left: 1rem;
        padding-right: 1rem;
    }

}
