/* Chicane V3 design system — see memory/reference_design_decisions.md */

:root, [data-theme="dark"] {
    --bg: #0f1117;
    --surface-1: #161b22;
    --surface-2: #21262d;
    --border: #30363d;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --text-ghost: #484f58;
    --main: #3b82f6;
    --radius-sm: 6px;

    --c-success: #00c98e;
    --c-warning: #f59e0b;
    --c-error:   #ef4444;
    --c-info:    #3b82f6;
    --c-purple:  #8b5cf6;
    --c-muted:   #8b949e;
}

[data-theme="light"] {
    --bg: #f6f8fa;
    --surface-1: #ffffff;
    --surface-2: #f0f2f5;
    --border: #d0d7de;
    --text: #1f2937;
    --text-muted: #57606a;
    --text-ghost: #8b949e;
    --main: #3b82f6;
}

html, body {
    background: var(--bg);
    color: var(--text);
    font: 13px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
}

a { color: var(--main); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, .mono { font-family: "Cascadia Code", Consolas, "SF Mono", monospace; font-size: 12px; }

h1 { font-size: 20px; font-weight: 600; margin: 0 0 12px; color: var(--text); }
h2 { font-size: 15px; font-weight: 600; margin: 16px 0 8px; color: var(--text); }
h3, h4 { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 14px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }

/* Page chrome */
.page {
    display: flex;
    min-height: 100vh;
    align-items: stretch;
}
.sidebar {
    width: 220px;
    background: var(--surface-1);
    border-right: 1px solid var(--border);
    padding: 0 0 8px;
    flex-shrink: 0;
    z-index: 5;
    position: relative;
}
main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.top-row {
    height: 44px;
    padding: 0 16px;
    background: var(--surface-1);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    z-index: 4;
    position: relative;
}
.content {
    flex: 1;
    padding: 16px 20px;
    overflow-x: hidden;
    overflow-y: auto;
    min-width: 0;
}
html, body { overflow-x: hidden; }
.navbar-brand {
    display: block;
    padding: 12px 16px;
    font-weight: 600;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
    background: var(--surface-1);
}
.sidebar nav { display: flex; flex-direction: column; }
.nav-link {
    display: block;
    padding: 7px 16px;
    color: var(--text-muted);
    border-left: 3px solid transparent;
    text-decoration: none;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--surface-2); color: var(--text); border-left-color: var(--main); }

/* Buttons */
.btn {
    display: inline-block; padding: 6px 14px; font-size: 13px;
    background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: pointer; transition: background 0.15s;
}
.btn:hover { background: color-mix(in srgb, var(--surface-2), var(--text) 8%); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--main); border-color: var(--main); color: white; }
.btn-primary:hover { background: color-mix(in srgb, var(--main), black 15%); }
.btn-danger { background: var(--c-error); border-color: var(--c-error); color: white; }
.btn-danger:hover { background: color-mix(in srgb, var(--c-error), black 15%); }
.btn-success { background: var(--c-success); border-color: var(--c-success); color: white; }
.btn-sm { padding: 3px 10px; font-size: 12px; }

/* Forms */
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
textarea, select, .form-control {
    width: 100%; box-sizing: border-box;
    padding: 6px 10px; font-size: 13px;
    background: var(--surface-1); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--main); }
.form-label { display: block; margin-bottom: 4px; font-size: 12px; color: var(--text-muted); }
.mb-3 { margin-bottom: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
/* Default: any col-* without an explicit width fills equally. The
   specific .row > .col-N rules below MUST share the same selector
   shape (.row > .X) as this default, otherwise specificity wins for
   the attribute selector and all cols collapse to flex:1 — which is
   why col-12 looked like it was being ignored. */
.row > [class*="col-"] { flex: 1; min-width: 0; }
.row > .col-12 { flex: 0 0 100%; }
.row > .col-6  { flex: 0 0 calc(50% - 4px); }
.row > .col-4  { flex: 0 0 calc(33.333% - 6px); }
.row > .col-2  { flex: 0 0 calc(16.666% - 7px); }
.row > .col-8  { flex: 0 0 calc(66.666% - 3px); }
/* Bootstrap-style breakpoint variants used in the deploy pages.
   Treat md/lg the same as the unprefixed form for now — the layouts
   we use don't need different mobile behaviour. */
.row > .col-md-12, .row > .col-lg-12 { flex: 0 0 100%; }
.row > .col-md-6,  .row > .col-lg-6  { flex: 0 0 calc(50% - 4px); }
.row > .col-md-4,  .row > .col-lg-4  { flex: 0 0 calc(33.333% - 6px); }
.row > .col-md-3,  .row > .col-lg-3  { flex: 0 0 calc(25% - 6px); }
.row > .col-md-2,  .row > .col-lg-2  { flex: 0 0 calc(16.666% - 7px); }
.row > .col-md-8,  .row > .col-lg-8  { flex: 0 0 calc(66.666% - 3px); }

/* Modal dialogs — Blazor-controlled overlay, no JS interop needed.
   Mounted as a fixed-position element with a translucent backdrop;
   the dialog is centred + capped to viewport so long content scrolls
   internally. Page renders <NmModal Open="..."> components and toggles
   the bound boolean to show/hide. */
.nm-modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
}
.nm-modal {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    max-width: 720px; width: 100%;
    max-height: calc(100vh - 48px);
    display: flex; flex-direction: column;
}
.nm-modal-header {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 8px;
}
.nm-modal-header h4 { margin: 0; }
.nm-modal-body  { padding: 14px 18px; overflow-y: auto; flex: 1; }
.nm-modal-footer {
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    display: flex; gap: 8px; justify-content: flex-end;
}

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { background: var(--surface-2); color: var(--text-muted); font-weight: 500; font-size: 12px; position: sticky; top: 0; }
.table tbody tr:hover { background: var(--surface-2); }

/* Cards */
.card {
    background: var(--surface-1); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 12px 16px;
}

/* Badges */
.badge {
    display: inline-block; padding: 2px 8px; font-size: 11px; font-weight: 500;
    border-radius: 999px; background: color-mix(in srgb, var(--main), transparent 80%); color: var(--main);
}
.badge-success { background: color-mix(in srgb, var(--c-success), transparent 80%); color: var(--c-success); }
.badge-warning { background: color-mix(in srgb, var(--c-warning), transparent 80%); color: var(--c-warning); }
.badge-error,
.badge-danger  { background: color-mix(in srgb, var(--c-error), transparent 80%); color: var(--c-error); }
.badge-muted   { background: color-mix(in srgb, var(--c-muted), transparent 80%); color: var(--c-muted); }

/* Alerts */
.alert {
    padding: 10px 14px; border-radius: var(--radius-sm);
    border-left: 3px solid var(--main); background: var(--surface-1); margin-bottom: 12px; font-size: 13px;
}
.alert-success { border-left-color: var(--c-success); }
.alert-warning { border-left-color: var(--c-warning); }
.alert-danger  { border-left-color: var(--c-error); color: var(--text); }
.alert-secondary { border-left-color: var(--text-muted); color: var(--text-muted); }

/* Utility */
.text-muted { color: var(--text-muted); }
.text-ghost { color: var(--text-ghost); }
.small { font-size: 11px; }
.d-flex { display: flex; }
.gap-2 { gap: 8px; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-5 { margin-top: 20px; }
.me-3 { margin-right: 12px; }
.ms-1 { margin-left: 4px; } .ms-3 { margin-left: 12px; }

/* SSO buttons */
.btn-sso {
    display: inline-flex; align-items: center; gap: 8px; width: 100%;
    padding: 8px 14px; justify-content: center; font-weight: 500;
    background: var(--surface-1); color: var(--text); border: 1px solid var(--border);
    border-radius: var(--radius-sm); cursor: pointer; margin-bottom: 8px;
}
.btn-sso:hover { background: var(--surface-2); }
.btn-sso .ico { width: 18px; height: 18px; }

/* Settings sections */
.settings-section { margin-bottom: 16px; }
.settings-section-title {
    font-size: 13px; font-weight: 600; color: var(--text-muted);
    margin-bottom: 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border);
    text-transform: uppercase; letter-spacing: 0.05em;
}

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-sm); width: 92%; max-width: 720px; max-height: 90vh; overflow: auto; }
.modal-header { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 14px 16px; }
.modal-footer { padding: 10px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.btn-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; }
.btn-close:hover { color: var(--text); }

/* Status dot */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle; }
.dot-online { background: var(--c-success); }
.dot-offline { background: var(--c-muted); }
.dot-warning { background: var(--c-warning); }
.dot-error { background: var(--c-error); }
