/* Shared styles for the Automation Engine dashboard pages (OPP-95/97/110). */

.auto-page {
    display: flex;
    height: calc(100vh - 60px);
    background: #1a1d21;
    color: #e5e7eb;
    font-family: system-ui, sans-serif;
}
.auto-sidebar {
    width: 260px;
    background: #23272e;
    border-right: 1px solid #2f353d;
    padding: 12px;
    overflow-y: auto;
}
.auto-sidebar h3 {
    margin: 0 0 8px 0;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
}
.auto-sidebar ul {
    list-style: none;
    margin: 0;
    padding: 0;
}
.auto-sidebar li {
    padding: 8px 10px;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 2px;
    font-size: 14px;
}
.auto-sidebar li:hover { background: #2d333b; }
.auto-sidebar li.active { background: #3a82f6; color: #fff; }

.auto-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.auto-toolbar {
    padding: 10px 16px;
    border-bottom: 1px solid #2f353d;
    display: flex;
    gap: 8px;
    align-items: center;
    background: #23272e;
}
.auto-toolbar button,
.auto-toolbar input[type="text"] {
    background: #2d333b;
    border: 1px solid #3a4049;
    color: #e5e7eb;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
}
.auto-toolbar button:hover { background: #3a4049; }
.auto-toolbar button.primary {
    background: #3a82f6;
    border-color: #3a82f6;
}
.auto-toolbar button.primary:hover { background: #2563eb; }
.auto-toolbar button.danger {
    background: #9b1e2a;
    border-color: #9b1e2a;
}

.auto-content {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

/* --- Tree editor --- */
.tree-node {
    background: #2d333b;
    border: 1px solid #3a4049;
    border-radius: 6px;
    padding: 10px 12px;
    margin: 6px 0;
}
.tree-node.composite { border-left: 3px solid #3a82f6; }
.tree-node.decorator { border-left: 3px solid #f59e0b; }
.tree-node.leaf      { border-left: 3px solid #10b981; }
.tree-node-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.tree-node-type {
    font-weight: bold;
    color: #60a5fa;
}
.tree-node-name {
    color: #9ca3af;
    font-size: 12px;
}
.tree-node-children {
    margin-left: 18px;
    border-left: 1px dashed #3a4049;
    padding-left: 12px;
}
.tree-node input[type="text"],
.tree-node input[type="number"],
.tree-node select {
    background: #1a1d21;
    border: 1px solid #3a4049;
    color: #e5e7eb;
    padding: 4px 6px;
    border-radius: 3px;
    font-size: 12px;
    min-width: 100px;
    margin-right: 6px;
}
.tree-node .btn-small {
    background: #3a4049;
    border: 0;
    color: #e5e7eb;
    padding: 3px 7px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    margin-left: 4px;
}
.tree-node .btn-small:hover { background: #4a5059; }
.tree-node .btn-small.del { background: #7f1d1d; }

/* --- Visualizer --- */
.viz-log {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    background: #0f1113;
    padding: 10px;
    border-radius: 4px;
    max-height: 500px;
    overflow-y: auto;
}
.viz-row {
    padding: 2px 4px;
    border-left: 2px solid transparent;
}
.viz-row.SUCCESS { border-left-color: #10b981; color: #a7f3d0; }
.viz-row.FAILURE { border-left-color: #ef4444; color: #fca5a5; }
.viz-row.RUNNING { border-left-color: #f59e0b; color: #fcd34d; }

/* --- Rule builder --- */
.rule-card {
    background: #2d333b;
    border: 1px solid #3a4049;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
}
.rule-card h4 {
    margin: 0 0 4px 0;
    color: #60a5fa;
    font-size: 15px;
}
.rule-card .rule-meta {
    font-size: 11px;
    color: #9ca3af;
    margin-bottom: 8px;
}
.rule-card pre {
    background: #1a1d21;
    padding: 8px;
    border-radius: 4px;
    font-size: 11px;
    overflow-x: auto;
    margin: 4px 0;
    color: #d1d5db;
}
.rule-card .rule-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}
.rule-form textarea {
    width: 100%;
    background: #1a1d21;
    border: 1px solid #3a4049;
    color: #e5e7eb;
    padding: 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
    min-height: 100px;
    box-sizing: border-box;
}
.rule-form label {
    display: block;
    margin: 10px 0 4px 0;
    color: #9ca3af;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.rule-form input[type="text"],
.rule-form input[type="number"] {
    width: 100%;
    background: #1a1d21;
    border: 1px solid #3a4049;
    color: #e5e7eb;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 13px;
    box-sizing: border-box;
}

.status-chip {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: bold;
}
.status-chip.enabled { background: #10b981; color: #fff; }
.status-chip.disabled { background: #6b7280; color: #fff; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
}

/* ==================== Mobile (≤768px) ==================== */

@media (max-width: 768px) {
    .auto-page {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 56px);
        min-height: calc(100dvh - 56px);
    }
    .auto-sidebar {
        width: 100%;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid #2f353d;
        padding: 8px;
    }
    /* Match the classic .layout collapse pattern from style.css */
    .auto-sidebar.mobile-collapsible {
        display: none;
    }
    body.mobile-sidebar-open .auto-sidebar.mobile-collapsible {
        display: block;
        max-height: 50vh;
        overflow-y: auto;
    }
    .auto-sidebar li { padding: 12px 14px; min-height: 44px; }
    .auto-toolbar {
        padding: 8px 12px;
        flex-wrap: wrap;
        gap: 6px;
    }
    .auto-toolbar button,
    .auto-toolbar input[type="text"] {
        font-size: 14px;
    }
    .auto-content {
        padding: 12px;
    }
    .tree-node-children {
        margin-left: 8px;
        padding-left: 8px;
    }
    .tree-node input[type="text"],
    .tree-node input[type="number"],
    .tree-node select {
        min-width: 0;
        width: 100%;
        margin-right: 0;
        margin-bottom: 4px;
        font-size: 16px;
    }
    .rule-card pre {
        font-size: 10px;
    }
    .rule-form input[type="text"],
    .rule-form input[type="number"],
    .rule-form textarea {
        font-size: 16px;
    }
}
