/*
 * app.css — application styles on top of Tabler.
 * Diff colors, monitor-card status borders, picker overlay, timeline tweaks.
 * Dark-mode aware via [data-bs-theme="dark"] (Tabler's theme attribute).
 */

/* ---------- Inline diff rendering (classes produced by the Python worker) - */
ins.diff-add,
.diff-add {
    background: #c8f7c5;
    text-decoration: none;
    border-radius: 2px;
    padding: 0 1px;
}

del.diff-del,
.diff-del {
    background: #f7c5c5;
    text-decoration: line-through;
    border-radius: 2px;
    padding: 0 1px;
}

.diff-line {
    display: block;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: var(--tblr-font-monospace, monospace);
    font-size: 0.8125rem;
    line-height: 1.45;
}

/* Omitted-context marker (compact view): worker emits <div class="diff-gap">⋯</div> */
.diff-gap {
    display: block;
    text-align: center;
    color: var(--tblr-secondary-color, var(--tblr-muted));
    font-family: var(--tblr-font-monospace, monospace);
    font-size: 0.8125rem;
    line-height: 1.45;
    user-select: none;
}

/* Container the controller-sanitized diff HTML is echoed into */
.diff-body {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: var(--tblr-font-monospace, monospace);
    font-size: 0.8125rem;
    max-height: 24rem;
    overflow: auto;
    background: var(--tblr-bg-surface-secondary);
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    padding: 0.75rem;
}

[data-bs-theme="dark"] ins.diff-add,
[data-bs-theme="dark"] .diff-add {
    background: #1c4a1c;
    color: #a6e3a1;
}

[data-bs-theme="dark"] del.diff-del,
[data-bs-theme="dark"] .diff-del {
    background: #4a1c1c;
    color: #f5a3a3;
}

/* ---------- Monitor cards (dashboard grid) -------------------------------- */
.monitor-card {
    border-left: 3px solid var(--tblr-border-color);
    transition: box-shadow 0.15s ease;
}

.monitor-card:hover {
    box-shadow: var(--tblr-shadow, 0 0.125rem 0.25rem rgba(0, 0, 0, 0.08));
}

.monitor-card.status-ok      { border-left-color: var(--tblr-success); }
.monitor-card.status-changed { border-left-color: var(--tblr-warning); }
.monitor-card.status-error   { border-left-color: var(--tblr-danger); }
.monitor-card.status-paused  { border-left-color: var(--tblr-secondary); opacity: 0.65; }

.monitor-card .card-title {
    margin-bottom: 0.25rem;
}

.monitor-favicon {
    width: 16px;
    height: 16px;
    object-fit: contain;
    vertical-align: -2px;
}

.monitor-snippet {
    font-size: 0.8125rem;
    color: var(--tblr-secondary-color, var(--tblr-muted));
    max-height: 3.6em;
    overflow: hidden;
    word-break: break-word;
}

/* Bulk-actions bar pinned above the grid when a selection exists */
.bulk-bar {
    position: sticky;
    top: 0.5rem;
    z-index: 5;
}

/* ---------- Visual element picker ----------------------------------------- */
.picker-stage {
    position: relative;
    display: inline-block;
    max-width: 100%;
    line-height: 0;
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    overflow: hidden;
}

.picker-stage img {
    max-width: 100%;
    height: auto;
    display: block;
}

.picker-box {
    position: absolute;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    z-index: 2;
}

.picker-box:hover {
    border-color: #2fb344;
    background: rgba(47, 179, 68, 0.15);
}

.picker-box.selected {
    border: 2px solid #2fb344;
    background: rgba(47, 179, 68, 0.28);
    z-index: 3;
}

/* ---------- Change timeline ----------------------------------------------- */
.timeline-entry {
    border-left: 2px solid var(--tblr-border-color);
    padding-left: 1rem;
    margin-left: 0.5rem;
    padding-bottom: 1rem;
    position: relative;
}

.timeline-entry::before {
    content: "";
    position: absolute;
    left: -6px;
    top: 0.35rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--tblr-secondary);
}

.timeline-entry.status-changed::before { background: var(--tblr-warning); }
.timeline-entry.status-error::before   { background: var(--tblr-danger); }
.timeline-entry.status-ok::before      { background: var(--tblr-success); }

/* ---------- Misc ----------------------------------------------------------- */
.last-value-block {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: var(--tblr-font-monospace, monospace);
    font-size: 0.875rem;
    max-height: 16rem;
    overflow: auto;
}

/* Alert-rule builder rows (Alpine repeatable) */
.alert-rule-row {
    background: var(--tblr-bg-surface-secondary);
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
}

/* htmx request indicator helper */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: inline-block; }

/* Alpine: hide x-cloak'ed elements until Alpine initializes */
[x-cloak] { display: none !important; }
