/* ===================================================================
   Shared AIP page patterns: header bar, dense table, card grid,
   empty state. Used by /workflows, /monitors, /admin and other
   pages that don't need a custom layout shell.
   =================================================================== */

/* ===== Page header ===== */
.aip-page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 0 0 12px;
    margin: 0 0 16px;
    border-bottom: 1px solid var(--aip-border);
}

.aip-page-head .aip-page-title {
    margin: 0 0 2px;
    font-size: 18px;
    font-weight: 600;
    color: var(--aip-text);
    letter-spacing: 0.2px;
}

.aip-page-head .aip-page-sub {
    margin: 0;
    color: var(--aip-text-muted);
    font-size: 13px;
    line-height: 1.4;
    max-width: 64rem;
}

.aip-page-head .aip-page-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* Inline back-breadcrumb often used in detail pages */
.aip-back-link {
    color: var(--aip-text-muted);
    font-size: 12px;
    text-decoration: none;
}

.aip-back-link:hover { color: var(--aip-accent); }

/* ===== Filter bar (chips above a list) ===== */
.aip-filter-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.aip-filter {
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--aip-text-muted);
    background: transparent;
    border: 1px solid var(--aip-border);
    border-radius: var(--aip-radius);
    cursor: pointer;
}

.aip-filter:hover {
    color: var(--aip-text);
    border-color: var(--aip-border-strong);
}

.aip-filter.active {
    color: var(--aip-accent);
    background: var(--aip-accent-bg);
    border-color: var(--aip-accent-border);
}

/* ===== Card grid ===== */
.aip-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 10px;
}

.aip-page-card {
    border: 1px solid var(--aip-border);
    background: var(--aip-bg-panel);
    border-radius: var(--aip-radius);
    padding: 12px 14px;
    color: inherit;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: border-color 0.1s, background 0.1s;
}

.aip-page-card:hover {
    border-color: var(--aip-accent-border);
}

.aip-page-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.aip-page-card-head h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--aip-text);
    line-height: 1.3;
}

.aip-page-card-head h3 a {
    color: inherit;
    text-decoration: none;
}

.aip-page-card-head h3 a:hover { color: var(--aip-accent); }

.aip-page-card-desc {
    color: var(--aip-text-muted);
    font-size: 12px;
    line-height: 1.4;
    margin: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.aip-page-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    font-size: 11px;
    color: var(--aip-text-muted);
    font-variant-numeric: tabular-nums;
}

.aip-page-card-foot {
    display: flex;
    gap: 6px;
    margin-top: auto;
    padding-top: 4px;
}

/* ===== Dense data table ===== */
.aip-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: var(--aip-bg-panel);
    border: 1px solid var(--aip-border);
    border-radius: var(--aip-radius);
    overflow: hidden;
}

.aip-data-table th {
    text-align: left;
    padding: 8px 12px;
    background: var(--aip-bg-elevated);
    color: var(--aip-text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--aip-border);
    white-space: nowrap;
}

.aip-data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--aip-border);
    vertical-align: middle;
    color: var(--aip-text);
}

.aip-data-table tbody tr:last-child td { border-bottom: none; }

.aip-data-table tbody tr:hover td { background: rgba(127, 127, 127, 0.04); }

.aip-data-table a { color: var(--aip-text); text-decoration: none; }
.aip-data-table a:hover { color: var(--aip-accent); text-decoration: underline; }

.aip-data-table code,
.aip-data-table .aip-mono {
    font-family: var(--aip-font-mono);
    font-size: 12px;
    color: var(--aip-text-muted);
    background: var(--aip-bg-elevated);
    padding: 1px 5px;
    border-radius: 2px;
}

.aip-data-table .aip-row-actions {
    white-space: nowrap;
    text-align: right;
}

.aip-data-table .aip-row-actions form { display: inline; margin: 0; }

/* Status pill helpers (in addition to aip-tag from aip-shell.css) */
.aip-status-never { color: var(--aip-text-disabled); font-style: italic; }
.aip-status-old   { color: var(--aip-text-muted); }
.aip-status-warn  { color: var(--bp-orange5); font-weight: 500; }

/* ===== Empty state ===== */
.aip-empty {
    padding: 32px 20px;
    text-align: center;
    color: var(--aip-text-muted);
    border: 1px dashed var(--aip-border);
    border-radius: var(--aip-radius);
    background: var(--aip-bg-panel);
}

.aip-empty h2 {
    margin: 0 0 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--aip-text);
}

.aip-empty p {
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--aip-text-muted);
}

.aip-empty .aip-empty-actions {
    display: flex;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* ===== Sectioned container (admin orgs, settings groups) ===== */
.aip-section-card {
    border: 1px solid var(--aip-border);
    background: var(--aip-bg-panel);
    border-radius: var(--aip-radius);
    margin-bottom: 16px;
    overflow: hidden;
}

.aip-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 14px;
    background: var(--aip-bg-elevated);
    border-bottom: 1px solid var(--aip-border);
    flex-wrap: wrap;
}

.aip-section-head h2,
.aip-section-head h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--aip-text);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.aip-section-head .aip-section-meta {
    color: var(--aip-text-muted);
    font-size: 12px;
}

.aip-section-body {
    padding: 0;
}

.aip-section-body .aip-data-table {
    border: none;
    border-radius: 0;
}

/* Subsection label inside a section card (e.g. "Members" / "Gateways") */
.aip-sub-label {
    font-weight: 600;
    font-size: 11px;
    color: var(--aip-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 12px 14px 4px;
    display: block;
}

.aip-add-link {
    display: inline-block;
    font-size: 12px;
    color: var(--aip-text-muted);
    text-decoration: none;
    padding: 4px 14px 12px;
}

.aip-add-link:hover { color: var(--aip-accent); }

/* Pending / warning section variants — recolor head bg only */
.aip-section-card.warn { border-color: rgba(200,118,25,0.4); }
.aip-section-card.warn .aip-section-head {
    background: rgba(200,118,25,0.10);
    color: var(--bp-orange5);
    border-bottom-color: rgba(200,118,25,0.30);
}

/* ===== Inline form group (used in admin user-row approve/assign forms) ===== */
.aip-inline-form {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    margin: 0;
}

.aip-inline-form select,
.aip-inline-form input[type="text"],
.aip-inline-form input[type="email"],
.aip-inline-form input[type="password"],
.aip-inline-form input[type="number"] {
    height: 28px;
    padding: 0 8px;
    font-size: 13px;
    background: var(--aip-bg-elevated);
    color: var(--aip-text);
    border: 1px solid var(--aip-border);
    border-radius: var(--aip-radius);
    font-family: inherit;
}

.aip-inline-form select:focus,
.aip-inline-form input[type="text"]:focus,
.aip-inline-form input[type="email"]:focus,
.aip-inline-form input[type="password"]:focus,
.aip-inline-form input[type="number"]:focus {
    outline: 0;
    border-color: var(--aip-accent-border);
    box-shadow: 0 0 0 2px var(--aip-accent-soft);
}

/* ===== Stacked form (vertical fields with labels) ===== */
.aip-form-stack {
    display: grid;
    gap: 12px;
    max-width: 360px;
}

.aip-form-stack > div { display: grid; gap: 4px; }

.aip-form-stack label {
    font-size: 12px;
    color: var(--aip-text-muted);
    font-weight: 500;
}

.aip-form-stack input[type="text"],
.aip-form-stack input[type="email"],
.aip-form-stack input[type="password"],
.aip-form-stack select,
.aip-form-stack textarea {
    height: 32px;
    padding: 0 10px;
    font-size: 13px;
    background: var(--aip-bg-elevated);
    color: var(--aip-text);
    border: 1px solid var(--aip-border);
    border-radius: var(--aip-radius);
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
}

.aip-form-stack textarea {
    height: auto;
    min-height: 72px;
    padding: 8px 10px;
    line-height: 1.4;
    resize: vertical;
}

.aip-form-stack input:focus,
.aip-form-stack select:focus,
.aip-form-stack textarea:focus {
    outline: 0;
    border-color: var(--aip-accent-border);
    box-shadow: 0 0 0 2px var(--aip-accent-soft);
}

/* Section body padding helper - sections often want default padding for forms */
.aip-section-body.padded { padding: 14px; }
.aip-section-body p { margin: 0 0 8px; font-size: 13px; color: var(--aip-text-muted); line-height: 1.5; }
.aip-section-body p:last-child { margin-bottom: 0; }

/* Property list (label/value pairs, e.g. profile fields) */
.aip-prop-list { display: grid; gap: 0; }
.aip-prop-row {
    display: flex;
    gap: 16px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--aip-border);
    font-size: 13px;
    align-items: center;
}
.aip-prop-row:last-child { border-bottom: none; }
.aip-prop-row .aip-prop-label {
    min-width: 96px;
    color: var(--aip-text-muted);
    font-weight: 500;
    font-size: 12px;
}
.aip-prop-row .aip-prop-val {
    color: var(--aip-text);
    word-break: break-word;
}

/* Code block helper for copyable command/url snippets */
.aip-code-row {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--aip-bg-elevated);
    border: 1px solid var(--aip-border);
    border-radius: var(--aip-radius);
    padding: 6px 8px;
    font-family: var(--aip-font-mono);
    font-size: 12px;
    color: var(--aip-text);
}
.aip-code-row code {
    flex: 1;
    background: transparent;
    padding: 0;
    word-break: break-all;
}

/* Danger section variant */
.aip-section-card.danger { border-color: rgba(205,66,70,0.30); }
.aip-section-card.danger .aip-section-head {
    background: rgba(205,66,70,0.08);
    border-bottom-color: rgba(205,66,70,0.20);
}
.aip-section-card.danger .aip-section-head h2 { color: var(--bp-red5); }
.aip-btn.danger {
    background: var(--bp-red5);
    color: white;
    border-color: var(--bp-red5);
}
.aip-btn.danger:hover { background: var(--bp-red3); border-color: var(--bp-red3); }
