/* Orion UI — the component layer.
   Loaded AFTER management.css so it is the final word on shared components.

   Why this file exists: the admin surface had grown three parallel button
   systems (mgmt-btn*, bootstrap-style .btn*, and the device pages' dv-tab),
   nine hand-rolled section-nav rows, 31 per-page <style> blocks and ~1300
   inline style attributes. Pages therefore looked subtly different from each
   other for no reason. Everything below is defined ONCE here; the legacy class
   names are aliased onto the same components so existing pages inherit the
   unified look without being rewritten. New pages should use the ori-* classes.

   Palette note: --ori-ns (violet) is reserved exclusively for scope namespaces
   (@handle/) so ownership reads at a glance and never collides with the accent
   or with the semantic state colours. */

:root {
    --ori-ns: #b493ff;               /* scope namespace — reserved */
    --ori-ns-soft: rgba(180,147,255,.14);
    --ori-accent-soft: rgba(74,142,255,.14);
    --ori-success-soft: rgba(102,187,106,.14);
    --ori-warning-soft: rgba(255,183,77,.14);
    --ori-danger-soft: rgba(231,76,60,.14);
    --ori-space: 1rem;
}

/* ==========================================================================
   1. Buttons — ONE definition, three legacy aliases
   ========================================================================== */
.ori-btn,
.btn,
.dv-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .55rem 1.15rem;
    font-family: inherit;
    font-size: .85rem;
    font-weight: 600;
    line-height: 1.2;
    color: #fff;
    background: var(--ori-accent);
    border: 1px solid transparent;
    border-radius: var(--ori-radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.ori-btn:hover,
.btn:hover,
.dv-tab:hover { background: var(--ori-accent-hover); color: #fff; text-decoration: none; }

.ori-btn:active,
.btn:active { transform: translateY(1px); }

.ori-btn:focus-visible,
.btn:focus-visible,
.dv-tab:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ori-accent-soft); }

/* Secondary / quiet */
.ori-btn-secondary,
.btn-secondary,
.btn-disabled,
.dv-tab:not(.active) {
    background: transparent;
    border-color: #3a3a3a;
    color: var(--ori-text-2);
}
.ori-btn-secondary:hover,
.btn-secondary:hover,
.btn-disabled:hover,
.dv-tab:not(.active):hover {
    background: rgba(255,255,255,.04);
    border-color: #4a4a4a;
    color: var(--ori-text);
}

/* Destructive */
.ori-btn-danger,
.btn-danger,
.btn-deny {
    background: var(--ori-danger);
    border-color: transparent;
    color: #fff;
}
.ori-btn-danger:hover,
.btn-danger:hover,
.btn-deny:hover { background: var(--ori-danger-hover); color: #fff; }

/* Affirmative (consent "Allow", completion states) */
.btn-allow,
.btn-done { background: var(--ori-success); border-color: transparent; color: #08240f; }
.btn-allow:hover,
.btn-done:hover { background: #7fd083; color: #08240f; }

/* Sizes */
.ori-btn-sm, .btn-sm { padding: .35rem .75rem; font-size: .78rem; }
.ori-btn-lg, .btn-lg { padding: .7rem 1.5rem; font-size: .92rem; }

.ori-btn:disabled, .btn:disabled,
.ori-btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }

/* Icon-only */
.ori-icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; padding: 0;
    background: transparent; border: 1px solid var(--ori-border);
    border-radius: 6px; color: var(--ori-text-3); cursor: pointer;
    transition: all .15s ease;
}
.ori-icon-btn:hover { border-color: var(--ori-danger); color: var(--ori-danger); }

/* ==========================================================================
   2. Section navigation — replaces nine hand-rolled flex rows
   ========================================================================== */
.ori-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    justify-content: center;
    margin: 0 auto 1.75rem;
    padding: 4px;
    background: var(--ori-surface);
    border: 1px solid var(--ori-border-soft);
    border-radius: 10px;
    width: fit-content;
    max-width: 100%;
}
.ori-nav a {
    padding: .45rem .9rem;
    border-radius: 7px;
    font-size: .82rem;
    font-weight: 500;
    color: var(--ori-text-3);
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s ease, color .15s ease;
}
.ori-nav a:hover { background: rgba(255,255,255,.04); color: var(--ori-text); }
.ori-nav a.active,
.ori-nav a[aria-current="page"] {
    background: var(--ori-accent);
    color: #fff;
    font-weight: 600;
}

/* ==========================================================================
   3. Page header
   ========================================================================== */
.ori-page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--ori-space);
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.ori-page-head h1 { margin: 0 0 .2rem; font-size: 1.45rem; font-weight: 650; color: var(--ori-text); letter-spacing: -.02em; text-wrap: balance; }
.ori-page-head p  { margin: 0; font-size: .87rem; color: var(--ori-text-3); }
.ori-page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ==========================================================================
   4. Tables
   ========================================================================== */
.ori-table-wrap { overflow-x: auto; border: 1px solid var(--ori-border); border-radius: var(--ori-radius-sm); }
.ori-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.ori-table th {
    text-align: left; padding: .6rem .8rem;
    font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
    color: var(--ori-text-4); background: var(--ori-surface-2);
    border-bottom: 1px solid var(--ori-border);
}
.ori-table td { padding: .7rem .8rem; border-bottom: 1px solid var(--ori-border-soft); color: var(--ori-text-2); }
.ori-table tbody tr:last-child td { border-bottom: 0; }
.ori-table tbody tr:hover { background: rgba(255,255,255,.02); }
.ori-table .num { font-variant-numeric: tabular-nums; text-align: right; }

/* ==========================================================================
   5. Badges — semantic state, deliberately distinct from the accent
   ========================================================================== */
.ori-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: .18rem .55rem; border-radius: 999px;
    font-size: .68rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap;
}
.ori-badge-ok      { background: var(--ori-success-soft); color: var(--ori-success); }
.ori-badge-warn    { background: var(--ori-warning-soft); color: var(--ori-warning); }
.ori-badge-danger  { background: var(--ori-danger-soft);  color: var(--ori-danger); }
.ori-badge-info    { background: var(--ori-accent-soft);  color: var(--ori-accent); }
.ori-badge-neutral { background: rgba(255,255,255,.05);   color: var(--ori-text-3); border: 1px solid var(--ori-border); }
.ori-badge-ns      { background: var(--ori-ns-soft);      color: var(--ori-ns); }

/* Device pages used these names for the same idea */
.dv-badge { display:inline-flex; align-items:center; padding:.18rem .55rem; border-radius:999px; font-size:.68rem; font-weight:700; }
.dv-ok   { background: var(--ori-success-soft); color: var(--ori-success); }
.dv-bad  { background: var(--ori-danger-soft);  color: var(--ori-danger); }
.dv-warn { background: var(--ori-warning-soft); color: var(--ori-warning); }

/* ==========================================================================
   6. Scope names — namespace always reads as owned
   ========================================================================== */
.ori-scope { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .82rem; white-space: nowrap; }
.ori-scope .ns { color: var(--ori-ns); }
.ori-scope .nm { color: var(--ori-text); }
.ori-scope .ac { color: var(--ori-text-3); }

/* ==========================================================================
   7. Forms
   ========================================================================== */
.ori-field { margin-bottom: 1rem; }
.ori-field > label {
    display: block; margin-bottom: .35rem;
    font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em;
    color: var(--ori-text-3);
}
.ori-field input[type=text], .ori-field input[type=number], .ori-field input[type=password],
.ori-field input[type=email], .ori-field input[type=url], .ori-field select, .ori-field textarea {
    width: 100%; padding: .55rem .7rem;
    background: var(--ori-surface-2); border: 1px solid var(--ori-border);
    border-radius: var(--ori-radius-sm); color: var(--ori-text);
    font-family: inherit; font-size: .85rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.ori-field input:focus, .ori-field select:focus, .ori-field textarea:focus {
    outline: none; border-color: var(--ori-accent); box-shadow: 0 0 0 3px var(--ori-accent-soft);
}
.ori-field .hint { margin: .35rem 0 0; font-size: .74rem; color: var(--ori-text-4); }

/* ==========================================================================
   8. Empty state & inline alerts
   ========================================================================== */
.ori-empty { text-align: center; padding: 2.5rem 1.5rem; color: var(--ori-text-3); }
.ori-empty .icon { font-size: 1.75rem; opacity: .5; margin-bottom: .5rem; }
.ori-empty h3 { margin: 0 0 .3rem; font-size: 1rem; color: var(--ori-text); font-weight: 600; }
.ori-empty p  { margin: 0; font-size: .85rem; }

.ori-alert { padding: .75rem 1rem; border-radius: var(--ori-radius-sm); border-left: 3px solid; font-size: .83rem; margin-bottom: 1.25rem; }
.ori-alert-info    { background: var(--ori-accent-soft);  border-color: var(--ori-accent);  color: #8bb8ff; }
.ori-alert-ok      { background: var(--ori-success-soft);  border-color: var(--ori-success); color: #a5d6a7; }
.ori-alert-warn    { background: var(--ori-warning-soft);  border-color: var(--ori-warning); color: #ffcc80; }
.ori-alert-danger  { background: var(--ori-danger-soft);   border-color: var(--ori-danger);  color: #ef9a9a; }

@media (prefers-reduced-motion: reduce) {
    .ori-btn, .btn, .dv-tab, .ori-nav a, .ori-icon-btn,
    .ori-field input, .ori-field select, .ori-field textarea { transition: none; }
}

/* Contextual actions for a drill-down page. Distinct from .ori-nav, which is the section's
   fixed menu — mixing page-specific links into that menu is what made it look like the
   section's entries were disappearing as you navigated. */
.ori-subnav {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin: -0.5rem auto 1.25rem;
    font-size: .8rem;
}
.ori-subnav a { color: #8bb8ff; text-decoration: none; }
.ori-subnav a:hover { text-decoration: underline; }
