/* admin.css
 *
 * Admin tab styles, extracted from styles.css as part of the frontend
 * modularization plan (docs/planning/frontend-modularization-and-csp-
 * hardening-plan.md), Stage 5. Admin is being migrated in four sub-stages
 * (5d/5c/5b/5a, safest first) -- this file grows as each lands.
 *
 * Scoped to js/modules/admin/storage-maintenance.js (Stage 5d): Document
 * Storage, Database Backup, Historian Retention, Dashboard Refresh
 * Interval, Stale Device Cleanup; js/modules/admin/notification-
 * channels.js + admin/portal-settings.js (Stage 5c): IFTTT Integration,
 * Default Webhook URL, Chat Integrations, SMTP Email, SMS Delivery, Portal
 * Public Base URL, Subscription Plan, Portal-Wide Notification (admin
 * side), Onboarding Site Defaults; js/modules/admin/outbound-webhooks.js
 * (Stage 5b): the Outbound Webhooks endpoint list, create/edit modal, test
 * ping, delivery log; and js/modules/admin/portal-users.js +
 * admin/api-keys.js + admin/device-credentials.js + admin/activity-log.js
 * (Stage 5a): Portal Access Users, API Key Management, Device Certificate
 * Access, Activity Log. This closes out Stage 5 -- every Admin panel is
 * now its own ES module. The shared .admin-section/.form-row/.form-group/
 * etc. base styles used by every Admin panel stay in styles.css (never
 * migrated on their own -- shared across tabs, not Admin-specific).
 *
 * Load order: linked in index.html after core.css, before styles.css.
 */

.admin-flex-1 {
    flex: 1;
}

.admin-field-220 {
    width: 220px;
    flex: 0 0 220px;
}

.admin-field-140 {
    width: 140px;
}

/* Two separate overrides needed here, both for specificity reasons -- a bare
   `.admin-input-narrow` class alone never wins either fight regardless of file load order:
   1. styles.css's `.form-group input[type="number"] { width: 100% }` (two selectors + a type).
   2. styles.css's `.admin-section .form-group { display: flex }` + `.admin-section .form-group
      input { flex: 1 }` -- every .form-group in Admin Tools is a flex row (label left, input
      growing to fill the rest), which is the desired default for most fields, but a flex item's
      flex-basis governs its main-axis size instead of `width` once it's non-auto, so flex-grow
      silently overrides width:80px above unless flex is also reset here.
   Scoped to the actual input types this class is used on today (all type="number" so far). */
.form-group input[type="number"].admin-input-narrow {
    flex: 0 0 80px;
    width: 80px;
}

.admin-mb-sm {
    margin-bottom: 0.75rem;
}

.admin-mb-md {
    margin-bottom: 1rem;
}

.admin-subheading {
    margin: 0 0 0.75rem;
}

.admin-subheading-tight {
    margin: 0 0 0.5rem;
}

.admin-table-full {
    width: 100%;
}

.admin-hint-block {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0 0 0.75rem;
}

.admin-filesize-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-left: 0.5rem;
}

.admin-table-dash {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.admin-col-date {
    width: 120px;
}

.admin-backup-files-gap {
    margin-top: 1.25rem;
}

/* These three tables sit in .users-list-table-wrap (styles.css), which already has
   overflow-x: auto -- but without a min-width, a table just compresses its columns to fit
   instead of scrolling, same gap .portal-users-table's min-width: 980px already closed.
   Sized per column count/density rather than copying that value outright. */
.admin-table-device-certs {
    min-width: 760px;
}

.admin-table-api-keys {
    min-width: 900px;
}

#webhooks-table {
    min-width: 760px;
}

/* ── Notification & integration settings (Stage 5c) ─────────────────────── */

.form-group.admin-mb-0 {
    margin-bottom: 0;
}

.admin-m-0 {
    margin: 0;
}

.admin-hint-tight-top {
    margin-top: -1rem;
    margin-bottom: 1.25rem;
}

.admin-hint-tight-top-sm {
    margin-top: -0.25rem;
}

.admin-derived-list {
    margin: 0.4rem 0 0 1.2rem;
    padding: 0;
}

.admin-ifttt-events-heading {
    margin: 1.5rem 0 0.5rem;
}

.admin-ifttt-events-hint {
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.admin-ifttt-add-row {
    margin-top: 0.5rem;
    align-items: flex-end;
}

.admin-integrations-empty {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0 0 0.5rem;
}

.admin-integrations-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.admin-integrations-table thead tr {
    background: var(--bg-secondary, #f3f4f6);
}

.admin-integrations-table th {
    padding: 6px 10px;
    text-align: left;
}

.admin-integrations-table tbody tr {
    border-bottom: 1px solid var(--border-color);
}

.admin-integrations-table td {
    padding: 7px 10px;
}

.admin-integrations-endpoint {
    color: var(--text-secondary);
    font-family: monospace;
    font-size: 0.8rem;
}

.admin-integrations-actions {
    text-align: right;
}

.admin-modal-header-row {
    align-items: center;
    justify-content: space-between;
}

.admin-spacer-12 {
    height: 12px;
}

.admin-row-center {
    align-items: center;
}

.admin-max-280 {
    max-width: 280px;
}

.admin-max-260 {
    max-width: 260px;
}

.admin-max-220 {
    max-width: 220px;
}

.admin-checkbox-align {
    padding-top: 1.15rem;
}

.admin-secret-status-spacing {
    margin-top: 0.35rem;
}

/* ── Outbound Webhooks (Stage 5b) ────────────────────────────────────────── */

.admin-webhook-modal-box {
    min-width: 480px;
}

.admin-field-hint {
    font-weight: 400;
    color: var(--text-secondary);
    font-size: 0.82em;
}

.admin-checkbox-label-sm {
    font-size: 0.85em;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.admin-webhook-events-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem 1rem;
    margin-top: 0.3rem;
    font-size: 0.87em;
}

.admin-modal-actions-mt {
    margin-top: 1rem;
}

.admin-webhook-delivery-modal-box {
    min-width: 680px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.admin-webhook-delivery-subtitle {
    margin-top: -0.35rem;
    margin-bottom: 0.6rem;
}

.admin-webhook-delivery-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 0.15rem;
}

.admin-table-empty {
    text-align: center;
    color: var(--text-secondary);
}

.admin-webhook-url-cell {
    font-size: 0.8em;
    word-break: break-all;
}

.admin-text-xs {
    font-size: 0.8em;
}

.admin-text-sm {
    font-size: 0.85em;
}

.admin-event-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.admin-text-error {
    color: var(--danger-color);
}

.admin-delivery-card {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    margin-bottom: 0.5rem;
    font-size: 0.82em;
}

.admin-delivery-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.3rem;
}

.admin-delivery-icon-success {
    color: var(--success-color);
}

.admin-delivery-icon-error {
    color: var(--danger-color);
}

.admin-text-muted {
    color: var(--text-secondary);
}

.admin-delivery-error-msg {
    color: var(--danger-color);
    margin-bottom: 0.2rem;
}

/* ── Identity & credentials (Stage 5a) ───────────────────────────────────── */

.admin-hint-tight-below {
    margin: 0.4rem 0 0;
}

.admin-key-name-display {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.admin-mb-half {
    margin-bottom: 0.5rem;
}

.admin-mt-sm {
    margin-top: 0.25rem;
}

.admin-modal-hr {
    margin: 1rem 0;
    border-color: var(--border-color);
}

.admin-modal-subheading {
    margin: 0 0 0.25rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.admin-modal-subtext {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0 0 0.75rem 0;
}

.admin-text-secondary-sm {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.api-key-scope-read {
    background: var(--info-bg);
    color: var(--info-text);
}

.api-key-scope-operator {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.api-key-status-disabled {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.api-key-status-expired {
    background: var(--cool-gray-8);
    color: var(--cool-gray-4);
}

.api-key-status-stale {
    background: var(--warning-bg);
    color: var(--warning-text);
}

/* Generic warning status-tag variant -- same tokens as api-key-status-stale above, but under a
   name that doesn't imply "API key" for reuse elsewhere (e.g. device credentials nearing expiry
   in device-credentials.js). */
.status-warning {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.api-key-reveal-box {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.75rem;
    word-break: break-all;
    user-select: all;
    margin-bottom: 0.5rem;
}

.api-key-reveal-code {
    font-size: 0.82rem;
    color: var(--text-primary);
    font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, monospace;
}

.user-active-session-badge {
    display: inline-block;
    margin-left: 0.45rem;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: color-mix(in srgb, var(--success-color) 14%, var(--white));
    color: color-mix(in srgb, var(--success-color) 85%, var(--black));
    border: 1px solid color-mix(in srgb, var(--success-color) 38%, transparent);
    vertical-align: middle;
}

/* ── Notification & integration settings (Stage 5c) -- CSS consolidated
   from styles.css during the Stage 5 close-out review, having been missed
   at the time each stage originally landed ── */

.ob-derived-info {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.65rem 0.9rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.ob-derived-info ul {
    list-style: disc;
}

.ifttt-key-status {
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.ifttt-key-configured {
    color: var(--success-color);
}

.ifttt-key-missing {
    color: var(--text-secondary);
}

.entitlement-key-status {
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.entitlement-key-active {
    color: var(--success-color);
}

.entitlement-key-inactive {
    color: var(--text-secondary);
}

.ifttt-events-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    min-height: 1.5rem;
}

.ifttt-events-empty {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.ifttt-event-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--bg-color);
    border-radius: 999px;
    padding: 0.2rem 0.6rem 0.2rem 0.75rem;
    font-size: 0.85rem;
}

.ifttt-event-chip-remove {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    color: var(--text-secondary);
    padding: 0;
}

.ifttt-event-chip-remove:hover {
    color: var(--danger-color);
}
