/* Editor Specific Styles */

.editor-container {
    max-width: none;
    width: 100%;
    margin: 100px auto 40px;
    padding: 0 20px;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.editor-actions {
    display: flex;
    gap: 10px;
}

.editor-layout {
    display: flex;
    gap: 16px;
    align-items: stretch;
}

.editor-nav {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.editor-nav-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.editor-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.editor-nav-quick {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.tree-container {
    flex: 1;
    overflow: auto;
    max-height: 70vh;
    padding-right: 4px;
}

.editor-nav-actions {
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.editor-detail {
    flex: 1 1 0;
    min-width: 0;
}

.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.detail-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.detail-subtitle {
    margin: 0;
    color: var(--text-light);
    font-size: 0.9rem;
}

.detail-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* Tree */
.tree {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tree-root {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    background: var(--bg-light);
    cursor: pointer;
}

.tree-root.selected {
    border-color: var(--primary-color);
    background: var(--bg-light);
}

.tree-root:hover {
    border-color: var(--primary-color);
}

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

.tree-item {
    margin: 6px 0;
}

.tree-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    cursor: pointer;
    background: var(--bg-card);
}

.tree-row:hover {
    border-color: var(--primary-color);
}

.tree-row.selected {
    border-color: var(--primary-color);
    background: var(--bg-light);
}

.tree-label {
    flex: 1;
    min-width: 0;
    white-space: normal;
    overflow: visible;
    text-overflow: initial;
    word-break: break-word;
}

.tree-meta {
    color: var(--text-light);
    font-size: 0.85rem;
    white-space: nowrap;
}

.tree-children {
    margin-left: 14px;
    padding-left: 10px;
    border-left: 1px dashed var(--border-color);
}

.tree-handle {
    cursor: grab;
    color: var(--text-light);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
}

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

.tree-toggle {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-light);
    border-radius: var(--border-radius-sm);
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.tree-toggle:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: 25px;
    box-shadow: var(--shadow-md);
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.metadata-card {
    border-left: 5px solid var(--primary-color);
}

.section-card {
    border-left: 5px solid var(--accent-color);
    position: relative;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.section-title-group {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.btn-remove {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px;
    margin-left: 10px;
    opacity: 0.7;
    transition: var(--transition-fast);
}

.btn-remove:hover {
    opacity: 1;
    transform: scale(1.1);
}

.list-container {
    background: var(--bg-light);
    border-radius: var(--border-radius-md);
    padding: 15px;
    margin-top: 15px;
    border: 1px solid var(--border-color);
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.item-row {
    display: grid;
    grid-template-columns: 30px 100px 2fr 2fr 1fr 40px; /* Added column for handle */
    gap: 10px;
    align-items: start;
    padding: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    margin-bottom: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.item-row.header-row {
    background: transparent;
    border: none;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-light);
    padding-bottom: 0;
}

.form-group {
    margin-bottom: 15px;
}

.form-group.form-row {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-dark);
}

.form-group.form-row > label {
    flex: 0 0 220px;
    margin-bottom: 0;
    padding-top: 8px;
}

.form-group .form-control {
    flex: 1;
    min-width: 0;
}

.help-text {
    margin-top: 6px;
    color: var(--text-light);
    font-size: 0.85rem;
    line-height: 1.3;
}

/* Make edit-pane option titles stand out */
.editor-detail .form-group > label {
    font-weight: 700;
}

.editor-detail .checkbox-group span {
    font-weight: 700;
}

input[type="text"],
textarea,
select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition-fast);
}

input[type="text"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

.btn-block {
    width: 100%;
    margin-top: 10px;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.85rem;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Checkbox layout in the right-hand detail pane */
.checkbox-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px 16px;
    margin-top: 8px;
}

.checkbox-grid .form-group {
    margin-bottom: 0;
}

/* Prevent global input styles (from styles.css) from stretching checkboxes */
.checkbox-group input[type="checkbox"] {
    width: auto;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.advanced-options {
    grid-column: 1 / -1;
    padding-top: 10px;
    margin-top: 5px;
    border-top: 1px dashed var(--border-color);
    display: none;
}

.item-row.expanded .advanced-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.toggle-advanced {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: underline;
}

/* Drag and Drop Styles */
.drag-handle {
    cursor: grab;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
}

/* Responsive */
@media (max-width: 900px) {
    .editor-layout {
        flex-direction: column;
    }

    .editor-nav {
        width: 100%;
    }

    .tree-container {
        max-height: 40vh;
    }
}

.drag-handle:hover {
    color: var(--primary-color);
}

/* Automation trigger grouping */
.automation-triggers {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 12px;
}

.automation-trigger {
    border: 3px solid var(--primary-color);
    border-radius: var(--border-radius-lg);
    background: var(--bg-card);
    padding: 16px;
    box-shadow: var(--shadow-md);
}

.automation-trigger-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: space-between;
    background: var(--bg-light);
    border: 1px solid var(--primary-color);
    border-radius: var(--border-radius-md);
    padding: 8px 10px;
    margin-bottom: 10px;
}

.automation-trigger-summary {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-right: auto;
}

.automation-trigger-toggle {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-light);
    border-radius: var(--border-radius-sm);
    padding: 4px 8px;
    cursor: pointer;
}

.automation-trigger-toggle:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.automation-trigger-body {
    display: block;
}

.automation-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.automation-action {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 10px;
    background: var(--bg-card);
}

.automation-action-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.automation-action-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.automation-warning {
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px solid var(--accent-color);
    border-radius: var(--border-radius-sm);
    background: var(--bg-light);
    color: var(--text-dark);
    font-weight: 600;
}

.automation-empty {
    color: var(--text-light);
    font-size: 0.9rem;
    padding: 8px 10px;
    border: 1px dashed var(--border-color);
    border-radius: var(--border-radius-sm);
    background: var(--bg-light);
}

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

.section-handle {
    margin-right: 10px;
    font-size: 1.2rem;
}

.list-handle {
    margin-right: 10px;
    font-size: 1.1rem;
}

.item-handle {
    font-size: 1rem;
}

/* Sortable Ghost (Placeholder) */
.sortable-ghost {
    opacity: 0.4;
    background-color: #e2e8f0;
    border: 2px dashed #cbd5e1;
}

/* Sortable Drag (Item being dragged) */
.sortable-drag {
    opacity: 1;
    background: white;
    box-shadow: var(--shadow-xl);
    transform: scale(1.02);
    z-index: 9999;
}

/* Adjust header row to match item row grid */
.item-row.header-row {
    grid-template-columns: 30px 100px 2fr 2fr 1fr 40px;
}
