/* =====================================================================
   Plans API — panel theme
   Layered on top of Bootstrap 5.3. Mobile first.
   ===================================================================== */

:root {
    --pa-sidebar-width: 260px;
    --pa-topbar-height: 60px;
    --pa-sidebar-bg: #111827;
    --pa-sidebar-hover: #1f2937;
    --pa-sidebar-active: #2563eb;
    --pa-sidebar-text: #cbd5e1;
    --pa-body-bg: #f4f6fa;
    --pa-card-border: #e7ebf3;
    --pa-radius: 10px;
}

body {
    background: var(--pa-body-bg);
    font-size: 0.9rem;
    -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------ layout */
.pa-wrapper { min-height: 100vh; }

.pa-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--pa-sidebar-width);
    background: var(--pa-sidebar-bg);
    color: var(--pa-sidebar-text);
    overflow-y: auto;
    z-index: 1040;
    transition: transform .25s ease;
}
.pa-sidebar::-webkit-scrollbar { width: 6px; }
.pa-sidebar::-webkit-scrollbar-thumb { background: #374151; border-radius: 3px; }

.pa-sidebar .pa-brand {
    height: var(--pa-topbar-height);
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 0 1rem;
    border-bottom: 1px solid rgba(255,255,255,.07);
    color: #fff;
    font-weight: 600;
    letter-spacing: .2px;
    text-decoration: none;
}
.pa-sidebar .pa-brand img { max-height: 32px; max-width: 130px; }

.pa-sidebar .nav-section {
    padding: 1rem 1rem .35rem;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: #64748b;
    font-weight: 600;
}

.pa-sidebar .nav-link {
    color: var(--pa-sidebar-text);
    padding: .55rem 1rem;
    display: flex;
    align-items: center;
    gap: .65rem;
    border-left: 3px solid transparent;
    font-size: .875rem;
}
.pa-sidebar .nav-link:hover { background: var(--pa-sidebar-hover); color: #fff; }
.pa-sidebar .nav-link.active {
    background: var(--pa-sidebar-hover);
    color: #fff;
    border-left-color: var(--pa-sidebar-active);
    font-weight: 500;
}
.pa-sidebar .nav-link .badge { margin-left: auto; }
.pa-icon { width: 18px; text-align: center; flex: 0 0 18px; opacity: .9; }

.pa-main {
    margin-left: var(--pa-sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.pa-topbar {
    height: var(--pa-topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--pa-card-border);
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: .75rem;
}

.pa-content { padding: 1.25rem; flex: 1; }

.pa-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1035;
}

@media (max-width: 991.98px) {
    .pa-sidebar { transform: translateX(-100%); }
    .pa-sidebar.show { transform: translateX(0); }
    .pa-main { margin-left: 0; }
    .pa-backdrop.show { display: block; }
    .pa-content { padding: .875rem; }
}

/* ------------------------------------------------------------- cards */
.card {
    border: 1px solid var(--pa-card-border);
    border-radius: var(--pa-radius);
    box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.card-header {
    background: #fff;
    border-bottom: 1px solid var(--pa-card-border);
    font-weight: 600;
    padding: .75rem 1rem;
    border-radius: var(--pa-radius) var(--pa-radius) 0 0 !important;
}

/* stat tiles */
.stat-card { position: relative; overflow: hidden; }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.15; }
.stat-card .stat-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: #6b7280; font-weight: 600; }
.stat-card .stat-icon {
    position: absolute;
    right: .85rem; top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
    opacity: .13;
}
.stat-card .stat-sub { font-size: .76rem; color: #6b7280; }

/* ------------------------------------------------------------ tables */
.table { font-size: .845rem; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .6rem .65rem; vertical-align: middle; }
.table thead th {
    background: #f8fafc;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .045em;
    color: #475569;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 1px solid var(--pa-card-border);
}
.table-hover > tbody > tr:hover > * { background-color: #f8fafc; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* --------------------------------------------------------- utilities */
.badge { font-weight: 600; font-size: .7rem; letter-spacing: .02em; }
.text-xs { font-size: .74rem; }
.text-sm { font-size: .82rem; }

.mono {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: .8rem;
}

.code-block {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 8px;
    padding: .9rem 1rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .78rem;
    line-height: 1.55;
    overflow-x: auto;
    white-space: pre;
    margin: 0;
    tab-size: 2;
}
.code-block .tok-key { color: #7dd3fc; }
.code-block .tok-str { color: #86efac; }
.code-block .tok-num { color: #fca5a5; }

.copy-btn { position: absolute; top: .5rem; right: .5rem; z-index: 2; }
.code-wrap { position: relative; }

/* progress meters */
.meter { height: 8px; border-radius: 4px; background: #e5e7eb; overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 4px; transition: width .4s ease; }

/* filter bar */
.filter-bar {
    background: #fff;
    border: 1px solid var(--pa-card-border);
    border-radius: var(--pa-radius);
    padding: .8rem;
    margin-bottom: 1rem;
}
.filter-bar .form-label { font-size: .72rem; font-weight: 600; color: #475569; margin-bottom: .2rem; text-transform: uppercase; letter-spacing: .03em; }

/* forms */
.form-label { font-weight: 500; font-size: .82rem; margin-bottom: .25rem; }
.form-text { font-size: .76rem; }
.required::after { content: " *"; color: #dc3545; }

/* auth screens */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 45%, #3b82f6 100%);
}
.auth-card {
    width: 100%;
    max-width: 420px;
    border-radius: 14px;
    border: none;
    box-shadow: 0 20px 45px rgba(0,0,0,.22);
}
.auth-card .card-body { padding: 2rem 1.9rem; }

/* documentation */
.docs-sidebar { position: sticky; top: calc(var(--pa-topbar-height) + 1rem); max-height: calc(100vh - 100px); overflow-y: auto; }
.param-table td code { font-size: .78rem; }

/* ------------------------------------------------ API reference cards */
.api-card {
    background: #fff;
    border: 1px solid var(--pa-card-border);
    border-radius: 14px;
    margin-bottom: 1.25rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(16,24,40,.06);
}

.api-card-header {
    /* Indigo/slate, matching the admin sidebar so the panel reads as one product. */
    background: linear-gradient(90deg, #1e293b 0%, #2b3a52 55%, #3a4a63 100%);
    color: #fff;
    padding: .8rem 1rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    width: 100%;
    border: 0;
    text-align: left;
    cursor: pointer;
    transition: filter .15s ease;
}
.api-card-header:hover { filter: brightness(1.15); }
.api-card-header:focus-visible { outline: 2px solid #60a5fa; outline-offset: -2px; }

/* An open card gets a brighter accent so it stands out from the collapsed ones. */
.api-card-header[aria-expanded="true"] {
    background: linear-gradient(90deg, #1d4ed8 0%, #2563eb 55%, #3b82f6 100%);
}

.api-num {
    flex: 0 0 26px;
    width: 26px; height: 26px;
    border-radius: 50%;
    background: rgba(255,255,255,.18);
    display: flex; align-items: center; justify-content: center;
    font-size: .78rem; font-weight: 700;
}
.api-title { font-weight: 600; font-size: .95rem; flex-grow: 1; }

.api-verb {
    background: #dbeafe;
    color: #1d4ed8;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-weight: 700;
    font-size: .68rem;
    letter-spacing: .04em;
    padding: .18rem .5rem;
    border-radius: 5px;
}
/* Inside the request box the verb sits on white, so it needs its own weight. */
.api-url .api-verb { background: #2563eb; color: #fff; }
.api-chevron { transition: transform .2s ease; opacity: .85; font-size: .8rem; }
.api-card-header[aria-expanded="false"] .api-chevron { transform: rotate(-90deg); }

.api-card-body { padding: 1.15rem; }

.api-label {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: #8a94a6;
    margin-bottom: .45rem;
}

/* request URL box */
.api-url {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    background: #f6f8fb;
    border: 1px solid #e6eaf1;
    border-radius: 9px;
    padding: .6rem .7rem;
}
.api-url code {
    flex-grow: 1;
    font-size: .78rem;
    color: #1f2937;
    word-break: break-all;
    line-height: 1.5;
}
.api-url .btn { flex: 0 0 auto; }

.api-note { color: #16a34a; font-size: .74rem; margin-top: .4rem; }

/* parameter table */
.api-params { font-size: .82rem; margin-bottom: 0; }
.api-params thead th {
    background: #f6f8fb;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #64748b;
}
.api-params td, .api-params th { padding: .5rem .65rem; }
.api-params td code { color: #0f766e; font-size: .78rem; }

/* response panel */
.api-response-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .45rem; gap: .5rem; }
.api-toggle .btn { font-size: .7rem; padding: .15rem .55rem; }

.api-code {
    position: relative;
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 10px;
    padding: .9rem 1rem;
    max-height: 460px;
    overflow: auto;
}
.api-code pre {
    margin: 0;
    color: #cbd5e1;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .76rem;
    line-height: 1.6;
    white-space: pre;
}
.api-code .copy-btn { position: absolute; top: .5rem; right: .5rem; }

/* ------------------------------------------- reference code listings */
/*
 * Reference panels: an indigo section bar, then one or more bordered
 * tables with an indigo caption and a cyan column header. Everything
 * renders in full — no inner scrollbars — so nothing is hidden behind a
 * scroll the reader has to discover.
 */
:root {
    --ref-indigo: #5c6bc0;
    --ref-indigo-dark: #4a59ae;
    --ref-cyan: #29b6d8;
    --ref-border: #4054b2;
}

.ref-panel {
    background: #fff;
    border: 1px solid var(--pa-card-border);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 1.1rem;
    box-shadow: 0 1px 2px rgba(16,24,40,.04);
}

.ref-panel > .ref-panel-head {
    background: var(--ref-indigo);
    color: #fff;
    font-weight: 600;
    font-size: .95rem;
    padding: .62rem .95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
}
.ref-panel-head .ref-hint { font-weight: 400; font-size: .74rem; opacity: .85; }

.ref-panel-body { padding: 1.1rem; }

/* one bordered lookup table */
.ref-table-box {
    border: 1px solid var(--ref-border);
    border-radius: 6px;
    overflow: hidden;
    height: 100%;
}
.ref-table-title {
    background: var(--ref-indigo);
    color: #fff;
    font-weight: 600;
    font-size: .87rem;
    padding: .55rem .9rem;
}
.ref-table { width: 100%; margin: 0; font-size: .84rem; border-collapse: collapse; }
.ref-table thead th {
    background: var(--ref-cyan);
    color: #fff;
    font-weight: 600;
    font-size: .84rem;
    padding: .5rem .9rem;
    border: 0;
    white-space: nowrap;
}
.ref-table tbody td {
    padding: .44rem .9rem;
    border-top: 1px solid #e6eaf3;
    color: #1f2a44;
    vertical-align: middle;
}
.ref-table tbody tr:first-child td { border-top: 0; }
.ref-table tbody tr:hover td { background: #f6f8fd; }
.ref-table .ref-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 600;
    color: #1d4ed8;
}
.ref-table .ref-meta { color: #94a3b8; font-size: .76rem; }

.tok-key  { color: #7dd3fc; }
.tok-str  { color: #86efac; }
.tok-num  { color: #fca5a5; }
.tok-bool { color: #c4b5fd; }

@media (max-width: 991.98px) {
    .api-card-body { padding: .9rem; }
    .api-code { max-height: 340px; }
}

.method-badge {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-weight: 700;
    font-size: .7rem;
    padding: .2rem .45rem;
    border-radius: 4px;
}
.method-get  { background: #dbeafe; color: #1d4ed8; }
.method-post { background: #dcfce7; color: #15803d; }

/* routing chain */
.chain-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem .7rem;
    border: 1px solid var(--pa-card-border);
    border-radius: 8px;
    background: #fff;
    margin-bottom: .4rem;
}
.chain-item.primary { border-color: #2563eb; background: #eff6ff; }
.chain-priority {
    width: 26px; height: 26px;
    flex: 0 0 26px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #334155;
    display: flex; align-items: center; justify-content: center;
    font-size: .74rem; font-weight: 700;
}
.chain-item.primary .chain-priority { background: #2563eb; color: #fff; }

/* health dot */
.health-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.health-up      { background: #22c55e; }
.health-degraded{ background: #f59e0b; }
.health-down    { background: #ef4444; }
.health-unknown { background: #cbd5e1; }

/* misc */
.empty-state { padding: 2.5rem 1rem; text-align: center; color: #94a3b8; }
.empty-state .icon { font-size: 2.5rem; opacity: .35; display: block; margin-bottom: .5rem; }

.cursor-pointer { cursor: pointer; }
.truncate-cell { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media print {
    .pa-sidebar, .pa-topbar, .no-print, .filter-bar { display: none !important; }
    .pa-main { margin-left: 0; }
    .card { border: 1px solid #ddd; box-shadow: none; }
}
