/* Database upgrades: calculations, grouping, timeline, buttons, automations (assets/js/ext/databases.js) */

/* column calculations */
.dbx-calc-row { border-bottom: 0; min-height: 30px; }
.dbx-calc { font-size: 12px; color: var(--fg-muted); text-align: right; border-right-color: transparent; }
.dbx-calc-label { color: var(--fg-faint); text-transform: uppercase; letter-spacing: .02em; font-size: 11px; }
.dbx-calc-val { color: var(--fg); }
.dbx-calc-hint { opacity: 0; transition: opacity .1s; }
.dbx-calc-row:hover .dbx-calc-hint, .dbx-calc:focus-within .dbx-calc-hint { opacity: 1; }

/* grouping */
.dbx-group { margin-bottom: 14px; }
.dbx-group-head { display: flex; align-items: center; gap: 8px; padding: 6px 2px; position: sticky; left: 0; }
.dbx-group-toggle { border: 0; background: none; cursor: pointer; color: var(--fg-muted); width: 20px; height: 20px; border-radius: 4px; padding: 0; }
.dbx-group-toggle:hover, .dbx-group-new:hover { background: var(--bg-hover); color: var(--fg); }
.dbx-group-label { font-weight: 500; font-size: 14px; }
.dbx-group-count { color: var(--fg-faint); font-size: 13px; }
.dbx-group-new { border: 0; background: none; cursor: pointer; color: var(--fg-faint); width: 22px; height: 22px; border-radius: 4px; opacity: 0; }
.dbx-group-head:hover .dbx-group-new, .dbx-group-new:focus { opacity: 1; }
.dbx-group .tbl-foot { display: none; }
.dbx-group.shut .dbx-group-head { color: var(--fg-muted); }

/* timeline */
.dbx-tl { --tl-row: 34px; font-size: 14px; }
.dbx-tl-bar { display: flex; align-items: center; gap: 12px; padding: 4px 0 8px; flex-wrap: wrap; }
.dbx-tl-range { font-weight: 500; flex: 1; min-width: 160px; }
.dbx-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 5px; overflow: hidden; }
.dbx-seg .tbtn { border-radius: 0; }
.dbx-seg .tbtn.on { background: var(--bg-active); color: var(--fg); }
.dbx-tl-main { display: flex; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.dbx-tl-names { flex: none; width: 210px; border-right: 1px solid var(--border); }
.dbx-tl-corner { height: 48px; box-sizing: border-box; border-bottom: 1px solid var(--border); padding: 26px 8px 0; font-size: 12px; color: var(--fg-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dbx-tl-name { height: var(--tl-row); line-height: var(--tl-row); padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.dbx-tl-name:hover { background: var(--bg-hover); }
.dbx-tl-sep { height: 26px; line-height: 26px; padding: 0 8px; font-size: 12px; color: var(--fg-muted); border-top: 1px solid var(--border); background: var(--bg-hover); }
.dbx-tl-new { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--fg-faint); padding: 7px 8px; cursor: pointer; font: inherit; }
.dbx-tl-new:hover { background: var(--bg-hover); color: var(--fg-muted); }
.dbx-tl-scroll { flex: 1; min-width: 0; overflow-x: auto; }
.dbx-tl-canvas { position: relative; min-height: 100%; }
.dbx-tl-scale { position: relative; height: 48px; border-bottom: 1px solid var(--border); }
.dbx-tl-months, .dbx-tl-ticks { position: relative; height: 24px; }
.dbx-tl-month { position: absolute; top: 4px; padding-left: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; border-left: 1px solid var(--border); height: 20px; line-height: 20px; }
.dbx-tl-tick { position: absolute; top: 2px; font-size: 11px; color: var(--fg-muted); text-align: center; white-space: nowrap; line-height: 20px; }
.dbx-tl-tick.weekend { color: var(--fg-faint); }
.dbx-tl-tick.today { color: var(--danger); font-weight: 600; }
.dbx-tl-lanes { position: relative; }
.dbx-tl-lines { position: absolute; inset: 0; pointer-events: none; }
.dbx-tl-line { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--border); opacity: .6; }
.dbx-tl-today { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px solid var(--danger); z-index: 2; pointer-events: none; }
.dbx-tl-today::before { content: ''; position: absolute; top: -4px; left: -5px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.dbx-tl-lane { position: relative; height: var(--tl-row); }
.dbx-tl-lane:hover { background: var(--bg-hover); }
.dbx-tl-lane.empty { cursor: copy; }
.dbx-tl-item { position: absolute; top: 5px; height: calc(var(--tl-row) - 10px); box-sizing: border-box; border-radius: 5px; background: var(--bg-elev);
  box-shadow: 0 0 0 1px var(--border), 0 1px 3px rgba(15, 15, 15, .12); display: flex; align-items: center; cursor: pointer; z-index: 1; min-width: 6px; user-select: none; }
.dbx-tl-item.editable { cursor: grab; }
.dbx-tl-item.dragging { cursor: grabbing; box-shadow: 0 0 0 2px var(--accent), var(--shadow); z-index: 3; }
.dbx-tl-item:focus-visible { box-shadow: 0 0 0 2px var(--accent); outline: none; }
.dbx-tl-label { flex: 1; min-width: 0; padding: 0 8px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dbx-tl-grip { flex: none; width: 7px; align-self: stretch; cursor: ew-resize; }
.dbx-tl-grip.l { border-radius: 5px 0 0 5px; }
.dbx-tl-grip.r { border-radius: 0 5px 5px 0; }
.dbx-tl-item:hover .dbx-tl-grip { background: var(--bg-active); }
.dbx-tl-off { position: absolute; top: 7px; border: 0; background: var(--bg-hover); color: var(--fg-muted); border-radius: 4px; font-size: 12px; padding: 2px 8px; cursor: pointer; }
.dbx-tl-off.left { left: 4px; }
.dbx-tl-off.right { right: 4px; }
.dbx-tl-off:hover { color: var(--fg); background: var(--bg-active); }
.zoom-month .dbx-tl-label { font-size: 12px; padding: 0 4px; }
@media (max-width: 640px) { .dbx-tl-names { width: 120px; } }

/* button property */
.dbx-btn { border: 1px solid var(--border); background: var(--bg-elev); color: var(--fg); border-radius: 4px; padding: 1px 8px; font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; line-height: 20px; }
.dbx-btn:hover:not(:disabled) { background: var(--bg-hover); }
.dbx-btn:disabled { opacity: .55; cursor: default; }

/* relation pairing, actions and automations */
.dbx-pair { display: flex; flex-direction: column; gap: 6px; }
.dbx-actions { display: flex; flex-direction: column; gap: 6px; }
.dbx-action, .dbx-when { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dbx-action .input, .dbx-when .input { width: auto; min-width: 120px; flex: 1; }
.dbx-verb { color: var(--fg-muted); font-size: 13px; white-space: nowrap; }
.dbx-rules { display: flex; flex-direction: column; gap: 12px; max-height: 60vh; overflow-y: auto; }
.dbx-rule { border: 1px solid var(--border); border-radius: 6px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.dbx-rule.off { opacity: .6; }
.dbx-rule-head { display: flex; justify-content: space-between; align-items: center; }
.dbx-auto .row-end { gap: 8px; }
