/* =========================================================================
   CyberNest Secure — POC theme
   Official brand palette (CyberNest Secure Branding Notes):
     CyberNest Orange #F05A28  · CyberNest Green #19A974
     Near Black #111111 · Dark Slate #1F2933
     Light Gray #F5F7FA · Medium Gray #6B7280
   Preferred font: Aptos (Segoe UI / system fallback on the web).
   ========================================================================= */
:root {
    --cn-orange: #F05A28;
    --cn-orange-dark: #d64a1e;
    --cn-green: #19A974;
    --cn-green-dark: #14895e;
    --cn-black: #111111;
    --cn-slate: #1F2933;
    --cn-light: #F5F7FA;
    --cn-gray: #6B7280;
    --cn-danger: #DC2626;      /* functional status color for the vulnerable/leak state */
    --cn-danger-tint: #fdecec;
    --cn-green-tint: #e7f6ef;
    --cn-orange-tint: #fdeee7;

    --cn-page: #ffffff;
    --cn-surface: #ffffff;
    --cn-border: #e3e8ef;
    --cn-text: #1F2933;
    --cn-text-muted: #6B7280;

    --cn-radius: 10px;
    --cn-shadow: 0 1px 2px rgba(17,17,17,.04), 0 6px 20px rgba(31,41,51,.06);
    --cn-mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
    --cn-sans: "Aptos", "Aptos Display", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--cn-sans);
    background: var(--cn-light);
    color: var(--cn-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--cn-orange); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.cn-header {
    display: flex; align-items: center; gap: 1.25rem;
    padding: .55rem 1.5rem;
    background: var(--cn-page);
    border-bottom: 1px solid var(--cn-border);
    position: sticky; top: 0; z-index: 20;
    box-shadow: 0 1px 0 rgba(31,41,51,.03);
}
.cn-brand { display: flex; align-items: center; gap: .6rem; color: var(--cn-slate); }
.cn-brand:hover { text-decoration: none; }
.cn-logo { height: 34px; width: auto; display: block; }
.cn-brand-text { font-size: 1.15rem; font-weight: 700; letter-spacing: -.2px; color: var(--cn-slate); }
.cn-nav { display: flex; gap: 1.1rem; flex: 1; }
.cn-nav a { color: var(--cn-slate); font-size: .92rem; padding: .35rem 0; font-weight: 500; border-bottom: 2px solid transparent; }
.cn-nav a:hover { color: var(--cn-orange); text-decoration: none; border-bottom-color: var(--cn-orange); }
.cn-header-right { display: flex; align-items: center; gap: .75rem; }

/* ---------- Nav dropdown menus ---------- */
.cn-dropdown { position: relative; display: inline-block; }
.cn-dropbtn { background: none; border: 0; color: var(--cn-slate); font: inherit; font-size: .92rem; font-weight: 500; cursor: pointer; padding: .35rem 0; border-bottom: 2px solid transparent; }
.cn-dropdown:hover .cn-dropbtn, .cn-dropdown:focus-within .cn-dropbtn { color: var(--cn-orange); border-bottom-color: var(--cn-orange); }
.cn-dropdown-menu { display: none; position: absolute; top: 100%; left: 0; margin-top: 2px; background: #fff; border: 1px solid var(--cn-border); border-radius: 10px; box-shadow: var(--cn-shadow); min-width: 190px; padding: .35rem; z-index: 30; }
.cn-dropdown:hover .cn-dropdown-menu, .cn-dropdown:focus-within .cn-dropdown-menu { display: block; }
.cn-dropdown-menu a { display: block; padding: .45rem .6rem; border-radius: 6px; color: var(--cn-slate); font-size: .88rem; border-bottom: 0; }
.cn-dropdown-menu a:hover { background: var(--cn-orange-tint); color: var(--cn-orange-dark); text-decoration: none; }
.cn-user { color: var(--cn-text-muted); font-size: .85rem; }
.cn-lang { display: inline-flex; border: 1px solid var(--cn-border); border-radius: 999px; overflow: hidden; }
.cn-lang button { background: #fff; color: var(--cn-text-muted); border: 0; padding: .28rem .65rem; cursor: pointer; font-size: .78rem; font-weight: 600; }
.cn-lang button.active { background: var(--cn-orange); color: #fff; }
.cn-logout button { background: #fff; border: 1px solid var(--cn-border); color: var(--cn-slate); border-radius: var(--cn-radius); padding: .35rem .7rem; cursor: pointer; font-weight: 500; }
.cn-logout button:hover { border-color: var(--cn-orange); color: var(--cn-orange); }

/* ---------- Layout ---------- */
.cn-main { flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; padding: 1.75rem 1.5rem 3rem; }
.cn-footer {
    display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
    padding: 1rem 1.5rem; border-top: 1px solid var(--cn-border); background: var(--cn-page);
    color: var(--cn-text-muted); font-size: .8rem;
}

/* ---------- Buttons / cards / badges ---------- */
.cn-btn { display: inline-block; background: var(--cn-orange); color: #fff; font-weight: 600;
    border: 0; border-radius: var(--cn-radius); padding: .6rem 1.05rem; cursor: pointer; transition: background .15s; }
.cn-btn:hover { background: var(--cn-orange-dark); text-decoration: none; }
.cn-btn-sm { padding: .35rem .7rem; font-size: .85rem; }
.cn-btn-ghost { background: #fff; border: 1px solid var(--cn-border); color: var(--cn-slate); }
.cn-btn-ghost:hover { background: var(--cn-light); border-color: var(--cn-gray); }
.cn-btn-danger { background: var(--cn-danger); color: #fff; }

.cn-card { background: var(--cn-surface); border: 1px solid var(--cn-border); border-radius: var(--cn-radius);
    padding: 1.1rem 1.25rem; box-shadow: var(--cn-shadow); }
.cn-grid { display: grid; gap: 1rem; }
.cn-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cn-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cn-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

.badge { display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.badge-owasp { background: #efe9fb; color: #6b46c1; }
.badge-atlas { background: #e6f0fb; color: #1d68b0; }
.badge-sev-Critical { background: var(--cn-danger-tint); color: #b42318; }
.badge-sev-High { background: var(--cn-orange-tint); color: var(--cn-orange-dark); }
.badge-sev-Medium { background: #e6f0fb; color: #1d68b0; }
.badge-sev-Low { background: var(--cn-green-tint); color: var(--cn-green-dark); }

/* ---------- Chat lab (dual pane) ---------- */
.lab-controls { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; margin-bottom: 1rem; }
.lab-controls label { display: block; font-size: .75rem; color: var(--cn-text-muted); margin-bottom: .25rem; font-weight: 600; }
.lab-controls select, .lab-controls input { background: #fff; color: var(--cn-text);
    border: 1px solid var(--cn-border); border-radius: var(--cn-radius); padding: .5rem .6rem; min-width: 200px; }

.attack-bar { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.attack-chip { background: #fff; border: 1px solid var(--cn-border); color: var(--cn-slate);
    border-radius: 999px; padding: .3rem .75rem; font-size: .8rem; cursor: pointer; transition: .15s; }
.attack-chip:hover { border-color: var(--cn-danger); color: var(--cn-danger); background: var(--cn-danger-tint); }

.doc-example-chip { background: #fff; border: 1px solid var(--cn-border); color: var(--cn-slate);
    border-radius: 999px; padding: .25rem .65rem; font-size: .75rem; cursor: pointer; transition: .15s;
    display: inline-block; margin: .2rem .2rem 0 0; }
.doc-example-chip:hover { border-color: var(--cn-danger); color: var(--cn-danger); background: var(--cn-danger-tint); }

.panes { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.pane { display: flex; flex-direction: column; background: var(--cn-surface); border: 1px solid var(--cn-border);
    border-radius: var(--cn-radius); min-height: 380px; overflow: hidden; box-shadow: var(--cn-shadow); }
.pane-head { padding: .65rem .95rem; font-weight: 700; display: flex; align-items: center; gap: .5rem; }
.pane-vulnerable .pane-head { background: var(--cn-danger-tint); color: #b42318; border-bottom: 1px solid #f6cfce; }
.pane-hardened .pane-head { background: var(--cn-green-tint); color: var(--cn-green-dark); border-bottom: 1px solid #c3e9d6; }
.pane-body { flex: 1; padding: .9rem; overflow-y: auto; display: flex; flex-direction: column; gap: .7rem; }
.msg { padding: .6rem .8rem; border-radius: var(--cn-radius); max-width: 92%; white-space: pre-wrap; line-height: 1.45; font-size: .92rem; }
.msg-user { align-self: flex-end; background: var(--cn-slate); color: #fff; }
.msg-assistant { align-self: flex-start; background: var(--cn-light); border: 1px solid var(--cn-border); }
.msg-blocked { border-color: var(--cn-green); }
.msg-leak { border-color: var(--cn-danger); box-shadow: 0 0 0 1px var(--cn-danger) inset; }
.msg-error { background: var(--cn-danger-tint); color: #b42318; }

.guardrails { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .2rem; }
.grd { font-size: .7rem; padding: .12rem .5rem; border-radius: 6px; border: 1px solid var(--cn-border); font-weight: 600; }
.grd-Block { background: var(--cn-green-tint); color: var(--cn-green-dark); border-color: #c3e9d6; }
.grd-Redact { background: var(--cn-orange-tint); color: var(--cn-orange-dark); border-color: #f7d6c6; }
.grd-Warn { background: #e6f0fb; color: #1d68b0; }
.grd-Allow { background: var(--cn-light); color: var(--cn-text-muted); }

.verdict { font-size: .78rem; padding: .3rem .6rem; border-radius: 6px; margin-top: .3rem; font-weight: 600; }
.verdict-leak { background: var(--cn-danger-tint); color: #b42318; }
.verdict-safe { background: var(--cn-green-tint); color: var(--cn-green-dark); }

.unmask-box { margin-top: .3rem; }
.unmask-revealed { background: var(--cn-orange-tint); border: 1px solid #f7d6c6; border-radius: 6px; padding: .5rem .6rem; }
.unmask-row { font-size: .82rem; display: flex; align-items: center; gap: .4rem; padding: .1rem 0; }
.unmask-row code { font-family: var(--cn-mono); font-size: .8rem; }

.composer { display: flex; gap: .6rem; margin-top: 1rem; }
.composer textarea { flex: 1; background: #fff; color: var(--cn-text); border: 1px solid var(--cn-border);
    border-radius: var(--cn-radius); padding: .7rem; min-height: 64px; resize: vertical; font-family: inherit; font-size: .92rem; }
.composer textarea:focus { outline: none; border-color: var(--cn-orange); box-shadow: 0 0 0 3px var(--cn-orange-tint); }

/* ---------- Tables ---------- */
table.cn-table { width: 100%; border-collapse: collapse; }
.cn-table th, .cn-table td { text-align: left; padding: .65rem .75rem; border-bottom: 1px solid var(--cn-border); vertical-align: top; }
.cn-table thead th { background: var(--cn-slate); color: #fff; font-size: .74rem; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.cn-table thead th:first-child { border-top-left-radius: var(--cn-radius); }
.cn-table thead th:last-child { border-top-right-radius: var(--cn-radius); }
.cn-table tbody tr:nth-child(even) td { background: var(--cn-light); }
.cn-table tbody tr:hover td { background: var(--cn-orange-tint); }
.mono { font-family: var(--cn-mono); font-size: .82rem; }

/* ---------- Provider management ---------- */
.cn-input { width: 100%; padding: .5rem; background: #fff; border: 1px solid var(--cn-border); border-radius: 8px; color: var(--cn-text); }
.cn-input:focus { outline: none; border-color: var(--cn-orange); box-shadow: 0 0 0 3px var(--cn-orange-tint); }
.prov-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.prov-actions form { display: inline; }
.test-box { margin-top: .6rem; font-size: .85rem; padding: .55rem .75rem; border-radius: 8px; background: var(--cn-light); border: 1px solid var(--cn-border); }
.test-ok { color: var(--cn-green-dark); font-weight: 600; }
.test-fail { color: var(--cn-danger); font-weight: 600; }
.model-pills { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .5rem; }
.model-pill { font-size: .75rem; padding: .18rem .55rem; border: 1px solid var(--cn-border); border-radius: 999px; background: #fff; cursor: pointer; }
.model-pill:hover { border-color: var(--cn-orange); color: var(--cn-orange); }
.row-test { font-size: .78rem; margin-top: .3rem; }
textarea.config { width: 100%; background: #fff; color: var(--cn-text); border: 1px solid var(--cn-border);
    border-radius: 6px; font-family: var(--cn-mono); font-size: .8rem; padding: .4rem; }

/* ---------- Toggle switch ---------- */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; }
.switch input { display: none; }
.slider { position: absolute; inset: 0; cursor: pointer; background: #cbd2dc; border-radius: 999px; transition: .2s; }
.slider::before { content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
input:checked + .slider { background: var(--cn-green); }
input:checked + .slider::before { transform: translateX(20px); }

/* ---------- Auth / hero ---------- */
.auth-wrap { max-width: 420px; margin: 3.5rem auto; }
.auth-logo { display: block; height: 92px; margin: 0 auto 1.25rem; }
.auth-wrap input[type=email], .auth-wrap input[type=password] { width: 100%; padding: .65rem; margin-bottom: .8rem;
    background: #fff; border: 1px solid var(--cn-border); border-radius: var(--cn-radius); color: var(--cn-text); }
.auth-wrap input:focus { outline: none; border-color: var(--cn-orange); box-shadow: 0 0 0 3px var(--cn-orange-tint); }
.field-validation-error, .validation-summary-errors { color: var(--cn-danger); font-size: .85rem; }

.hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1.75rem; align-items: center; margin-bottom: 1.5rem; }
.hero h1 { font-size: 2.1rem; margin: 0 0 .5rem; color: var(--cn-slate); letter-spacing: -.5px; }
.hero p { color: var(--cn-text-muted); line-height: 1.6; }
.hero-logo { max-width: 240px; width: 100%; height: auto; display: block; margin: 0 auto; }
.stat { text-align: center; }
.stat .n { font-size: 1.9rem; font-weight: 800; color: var(--cn-orange); }
.stat .l { font-size: .78rem; color: var(--cn-text-muted); }
.pill-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .6rem; }

h1, h2, h3 { color: var(--cn-slate); }
h2.section { font-size: 1.2rem; margin: 1.75rem 0 .8rem; padding-bottom: .4rem; border-bottom: 2px solid var(--cn-orange); display: inline-block; }
.muted { color: var(--cn-text-muted); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Mobile nav (hamburger) ---------- */
.cn-nav-toggle { display: none; }
.cn-hamburger { display: none; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--cn-slate); padding: .2rem .5rem; border: 1px solid var(--cn-border); border-radius: 8px; user-select: none; }

@media (max-width: 900px) {
    .panes, .hero, .cn-grid.cols-4, .cn-grid.cols-3, .cn-grid.cols-2 { grid-template-columns: 1fr; }

    .cn-header { flex-wrap: wrap; gap: .6rem; padding: .55rem .9rem; }
    .cn-brand { flex: 1; }
    .cn-hamburger { display: inline-block; order: 3; }
    .cn-header-right { order: 2; gap: .5rem; }
    .cn-user { display: none; }

    /* Nav becomes a full-width dropdown panel toggled by the hamburger checkbox. */
    .cn-nav { order: 5; display: none; flex-basis: 100%; flex-direction: column; gap: .1rem;
        background: #fff; border: 1px solid var(--cn-border); border-radius: 10px; padding: .5rem; box-shadow: var(--cn-shadow); }
    .cn-nav-toggle:checked ~ .cn-nav { display: flex; }
    .cn-nav > a { padding: .6rem .5rem; border-bottom: 1px solid var(--cn-border); }
    .cn-nav > a:last-child { border-bottom: 0; }

    /* Flatten the Assess/Admin dropdowns into inline sections on touch. */
    .cn-dropdown { width: 100%; }
    .cn-dropbtn { width: 100%; text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--cn-border); }
    .cn-dropdown-menu { display: block; position: static; border: 0; box-shadow: none; padding: 0 0 .3rem .8rem; min-width: 0; margin: 0; }
    .cn-dropdown-menu a { padding: .5rem .5rem; }

    /* Lab controls + composer stack full width. */
    .lab-controls { flex-direction: column; align-items: stretch; }
    .lab-controls select, .lab-controls input { min-width: 0; width: 100%; }
    .composer { flex-direction: column; }
    .composer > div { flex-direction: row !important; }
    .cn-main { padding: 1rem .8rem 2.5rem; }
    .cn-header-right .cn-user { display: none; }
    .hero h1 { font-size: 1.6rem; }
    table.cn-table { font-size: .82rem; }
}

@media (max-width: 520px) {
    .cn-brand-text { font-size: 1rem; }
    .cn-btn { padding: .55rem .8rem; }
    .msg { max-width: 100%; }
    .attack-bar { gap: .35rem; }
    .attack-chip { font-size: .75rem; }
}
