/* Procedures — the agency's shared SOP library.
   List + reading pane, like the Voicemail inbox, but deliberately WITHOUT that
   tool's 100dvh height chain (see the incident note in css/call-hub.css): the
   page scrolls naturally and the list column is sticky with its own scroll.
   A procedure library is dozens of short items, not a live inbox, so the
   fragile `:has()` overrides on .app-main buy nothing here.

   No @keyframes in this file — those live in css/animations.css.
   Colors come from the tokens in css/variables.css, which already flip under
   body.dark-mode, so most rules need no per-theme variant. */

.proc-container {
    padding: 12px 0 40px;
}

.proc-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ── Status row ───────────────────────────────────────────────────────── */

.proc-status-row {
    margin: 0 0 12px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 13px;
}
.proc-status-error {
    border-color: var(--danger);
    color: var(--danger);
}
.proc-status-warn {
    border-color: var(--warning);
    color: var(--warning-text);
}
.proc-link-btn {
    background: none;
    border: none;
    padding: 0 0 0 6px;
    color: var(--apple-blue);
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
}

/* ── Layout ───────────────────────────────────────────────────────────── */

.proc-layout {
    display: grid;
    grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.proc-list-col {
    position: sticky;
    top: 12px;
    display: flex;
    flex-direction: column;
    /* Definite, so the list scrolls on its own without needing a height on any
       ancestor. calc() against the viewport keeps it correct at every width. */
    max-height: calc(100dvh - 140px);
    min-height: 0;
}

.proc-filters {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.proc-search,
.proc-category-filter {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    font-size: 14px;
}
.proc-search:focus,
.proc-category-filter:focus {
    outline: none;
    border-color: var(--apple-blue);
}

.proc-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    min-height: 0;
    padding-right: 4px;
}

.proc-row {
    display: grid;
    gap: 5px;
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text);
    text-align: left;
    cursor: pointer;
    transition: var(--transition-smooth);
}
.proc-row:hover {
    background: var(--bg-widget-hover);
    border-color: var(--border-strong);
}
.proc-row.is-selected {
    border-color: var(--apple-blue);
    background: var(--sidebar-active);
}
.proc-row-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
}
.proc-row-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.proc-row-meta {
    font-size: 11.5px;
    color: var(--text-secondary);
}

/* ── Chips ────────────────────────────────────────────────────────────── */

.proc-chip {
    display: inline-block;
    padding: 2px 7px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}
.proc-chip-cat     { color: var(--apple-blue);   border-color: var(--apple-blue); }
.proc-chip-freq    { color: var(--text-secondary); }
.proc-chip-draft   { color: var(--warning-text); border-color: var(--warning); }
.proc-chip-archived{ color: var(--text-tertiary); }
.proc-chip-review  { color: var(--danger);       border-color: var(--danger); }
.proc-chip-tag     { font-weight: 500; }

/* ── Reading pane ─────────────────────────────────────────────────────── */

.proc-pane {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    padding: 22px 24px 18px;
    min-height: 320px;
}

.proc-pane-head {
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 14px;
    margin-bottom: 18px;
}
.proc-pane-title {
    margin: 0 0 6px;
    font-size: 21px;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text);
}
.proc-pane-meta {
    font-size: 12.5px;
    color: var(--text-secondary);
}
.proc-pane-summary {
    margin: 10px 0 0;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}
.proc-pane-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 10px;
}
.proc-review-note {
    margin: 12px 0 0;
    padding: 8px 12px;
    border-left: 3px solid var(--warning);
    background: var(--bg-input);
    color: var(--warning-text);
    font-size: 12.5px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.proc-steps {
    margin: 0;
    padding-left: 26px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.proc-step {
    font-size: 14.5px;
    line-height: 1.55;
    color: var(--text);
}
.proc-step-text {
    /* Steps are lifted verbatim from notes people typed; keep their spacing. */
    white-space: pre-wrap;
}
.proc-step-note {
    display: block;
    margin-top: 3px;
    font-size: 12.5px;
    color: var(--text-secondary);
}
.proc-step-link {
    display: inline-block;
    margin-top: 4px;
    font-size: 12.5px;
    color: var(--apple-blue);
}
/* The visual break between groups — this is the blank line from the original
   note, which is how people already signal "one part of the job is done". */
.proc-step-break {
    height: 1px;
    margin: 16px 0;
    background: var(--border-subtle);
}

.proc-pane-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
}

/* ── Buttons ──────────────────────────────────────────────────────────── */

.proc-btn {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}
.proc-btn:hover:not(:disabled) {
    border-color: var(--border-strong);
    background: var(--bg-widget-hover);
}
.proc-btn:disabled {
    opacity: 0.6;
    cursor: default;
}
.proc-btn-primary {
    background: var(--apple-blue);
    border-color: var(--apple-blue);
    color: var(--accent-on-fill);
}
.proc-btn-primary:hover:not(:disabled) {
    background: var(--apple-blue-hover);
    border-color: var(--apple-blue-hover);
}
.proc-btn-danger {
    color: var(--danger);
    border-color: var(--danger);
}

/* ── Empty states ─────────────────────────────────────────────────────── */

.proc-empty {
    padding: 26px 18px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13.5px;
}
.proc-pane-empty {
    padding: 70px 18px;
}
.proc-empty-icon {
    font-size: 30px;
    margin-bottom: 10px;
    opacity: 0.55;
}
.proc-empty-hint {
    margin-top: 8px;
    font-size: 12.5px;
    color: var(--text-tertiary);
}

/* ── Editor modal ─────────────────────────────────────────────────────── */

.proc-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.55);
}
.proc-modal {
    display: flex;
    flex-direction: column;
    width: min(680px, 100%);
    max-height: min(88dvh, 900px);
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-card);
    box-shadow: var(--shadow);
}
.proc-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
}
.proc-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}
.proc-modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}
.proc-modal-body {
    padding: 18px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.proc-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--border-subtle);
}
.proc-modal-hint {
    margin-right: auto;
    font-size: 12.5px;
    color: var(--danger);
}

.proc-share-warning {
    margin: 0;
    padding: 11px 14px;
    border: 1px solid var(--warning);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--warning-text);
    font-size: 12.5px;
    line-height: 1.5;
}

.proc-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}
.proc-field > label {
    font-size: var(--fs-label);
    font-weight: 600;
    color: var(--text-secondary);
}
.proc-field-hint {
    margin: 0;
    font-size: 11.5px;
    font-weight: 400;
    color: var(--text-tertiary);
}
.proc-field input,
.proc-field select,
.proc-field textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}
.proc-field textarea {
    resize: vertical;
    line-height: 1.55;
}
.proc-field input:focus,
.proc-field select:focus,
.proc-field textarea:focus {
    outline: none;
    border-color: var(--apple-blue);
}
.proc-field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
    gap: 14px;
}

.proc-step-preview {
    margin-top: 4px;
    padding: 10px 12px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
}
.proc-step-preview:empty {
    display: none;
}
.proc-preview-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-tertiary);
    margin-bottom: 8px;
}
.proc-preview-list {
    margin: 0;
    padding-left: 22px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
}
.proc-preview-list li {
    white-space: pre-wrap;
}

/* ── Import-from-reminders picker ─────────────────────────────────────── */

.proc-import-lede {
    margin: 0 0 4px;
}
.proc-import-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.proc-import-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
}
.proc-import-main {
    display: grid;
    gap: 5px;
    min-width: 0;
    flex: 1 1 auto;
}
.proc-import-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}
.proc-import-actions {
    display: flex;
    gap: 6px;
    flex: 0 0 auto;
}
.proc-chip-imported {
    color: var(--success);
    border-color: var(--success);
}

/* ── Narrow ───────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
    .proc-layout {
        grid-template-columns: minmax(0, 1fr);
    }
    .proc-list-col {
        position: static;
        max-height: none;
    }
    .proc-list {
        max-height: 320px;
    }
    .proc-pane {
        padding: 18px 16px 16px;
    }
    .proc-import-row {
        flex-direction: column;
        align-items: stretch;
    }
}
