/* CasinoSoft QA portal — themed to match the CasinoSoft app (jack.casinosoftusa.com):
   zinc neutrals, green-600 primary, Open Sans. Light + dark via [data-theme] tokens. */
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;500;600;700&display=swap');

:root {
    /* Brand / accent (matches jack: green-600) */
    --accent: #16a34a;
    --accent-hover: #15803d;
    --accent-soft: rgba(22, 163, 74, .12);

    /* Surfaces & text (light) — bg gradient matches the CasinoSoft app (jack) */
    --bg: #f4f5f7;
    --bg-gradient: linear-gradient(152deg, #eef0fe 0%, #f4f5f7 55%, #f4f4f5 100%);
    --surface: #ffffff;
    --surface-2: #fafafa;
    --border: #e4e4e7;
    --text: #18181b;
    --heading: #18181b;
    --muted: #71717a;
    --muted-2: #a1a1aa;

    /* Sidebar / topbar — transparent so the app gradient shows through (matches jack) */
    --sidebar-bg: transparent;
    --sidebar-border: #e4e4e7;
    --sidebar-text: #3f3f46;
    --sidebar-muted: #a1a1aa;
    --topbar-bg: transparent;

    /* Status colors */
    --green: #16a34a;
    --green-bg: #dcfce7;
    --red: #dc2626;
    --red-bg: #fee2e2;
    --blue: #1d4ed8;
    --blue-bg: #dbeafe;
    --amber: #b45309;
    --amber-bg: #fef3c7;

    /* Code block (kept dark in both themes) */
    --code-bg: #0f172a;
    --code-text: #e2e8f0;

    /* White logo asset -> render black on light surfaces */
    --logo-filter: brightness(0);

    --radius: 12px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
    --font: "Open Sans", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

[data-theme="dark"] {
    --accent: #16a34a;
    --accent-hover: #22c55e;
    --accent-soft: rgba(22, 163, 74, .22);

    --bg: #18181b;
    --bg-gradient: linear-gradient(152deg, #20202b 0%, #18181b 55%, #161618 100%);
    --surface: #27272a;
    --surface-2: #323236;
    --border: #3f3f46;
    --text: #f4f4f5;
    --heading: #fafafa;
    --muted: #a1a1aa;
    --muted-2: #71717a;

    --sidebar-bg: transparent;
    --sidebar-border: #2e2e33;
    --sidebar-text: #d4d4d8;
    --sidebar-muted: #71717a;
    --topbar-bg: transparent;

    --green: #4ade80;
    --green-bg: rgba(22, 163, 74, .20);
    --red: #f87171;
    --red-bg: rgba(220, 38, 38, .22);
    --blue: #93c5fd;
    --blue-bg: rgba(29, 78, 216, .28);
    --amber: #fbbf24;
    --amber-bg: rgba(180, 83, 9, .28);

    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 1px 3px rgba(0, 0, 0, .5);

    /* Logo is already light — show as-is on dark surfaces */
    --logo-filter: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

body {
    font-family: var(--font);
    color: var(--text);
    background-color: var(--bg);
    background-image: var(--bg-gradient);
    background-attachment: fixed;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 248px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
}

/* Break out of the sidebar's 18px/14px padding so the logo spans the full menu-bar width. */
.brand { display: flex; flex-direction: column; gap: 4px; margin: -18px -14px 14px; padding: 16px 8px 14px; }
.brand-logo { width: 100%; max-width: 100%; height: auto; filter: var(--logo-filter); }
.brand-sub { font-size: .7rem; color: var(--sidebar-muted); letter-spacing: .06em; text-transform: uppercase; padding-left: 10px; }

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-section {
    text-transform: uppercase;
    font-size: .68rem;
    letter-spacing: .08em;
    color: var(--sidebar-muted);
    margin: 16px 10px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 10px;
    border-radius: 8px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: .9rem;
    font-weight: 500;
}

.nav-item:hover { background: var(--accent-soft); color: var(--accent); }

.nav-item.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--accent);
}

.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item.disabled { color: var(--muted-2); cursor: default; }
.nav-item.disabled:hover { background: none; color: var(--muted-2); }

.soon {
    margin-left: auto;
    font-size: .6rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 2px 7px;
    border-radius: 20px;
}

.sidebar-foot {
    margin-top: auto;
    padding: 12px 10px 4px;
    font-size: .72rem;
    color: var(--sidebar-muted);
    border-top: 1px solid var(--sidebar-border);
}

/* Theme toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin-top: 10px;
    padding: 9px 10px;
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    background: transparent;
    color: var(--sidebar-text);
    font: inherit;
    font-size: .85rem;
    cursor: pointer;
}

.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle svg { width: 16px; height: 16px; }

/* Main column */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    height: 60px;
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.topbar-title { font-weight: 600; color: var(--heading); }

.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip.muted { color: var(--muted); font-size: .85rem; }

.topbar-user { display: flex; align-items: center; gap: 12px; }
.signout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--muted);
    font-size: .85rem;
    text-decoration: none;
}
.signout:hover { border-color: var(--accent); color: var(--accent); }

.avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    font-size: .85rem;
}

.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-name { font-weight: 600; font-size: .85rem; }
.user-sub { font-size: .7rem; color: var(--muted); }

.content { padding: 28px 24px; max-width: 1080px; width: 100%; }

.page-head h1 { margin: 0 0 4px; font-size: 1.6rem; color: var(--heading); }
.subtitle { margin: 0 0 24px; color: var(--muted); }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 18px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 22px;
}

.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 1rem; color: var(--heading); }
.card-lead { margin: 0 0 14px; color: var(--muted); font-size: .88rem; }
.card-lead strong { color: var(--text); }

.role-grid { display: flex; flex-direction: column; gap: 8px; }

.role-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .88rem;
}

.badge {
    font-size: .72rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.badge-yes { background: var(--green-bg); color: var(--green); }
.badge-no { background: var(--surface-2); color: var(--muted-2); }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: .85rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 20px;
}

.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill-green { background: var(--green-bg); color: var(--green); }
.pill-red { background: var(--red-bg); color: var(--red); }
.pill-muted { background: var(--surface-2); color: var(--muted); }
.pill-blue { background: var(--blue-bg); color: var(--blue); }
.pill-amber { background: var(--amber-bg); color: var(--amber); }

/* Run detail artifacts */
.artifacts { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; }
.artifact { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; }
.artifact-type { font-weight: 600; color: var(--muted); text-transform: uppercase; font-size: .68rem; letter-spacing: .04em; }
.artifact-thumb { max-width: 240px; border: 1px solid var(--border); border-radius: 8px; }
.step-thumb { max-width: 120px; max-height: 68px; object-fit: cover; object-position: top; cursor: zoom-in; transition: transform .08s ease; }
.step-thumb:hover { transform: scale(1.03); border-color: var(--accent); }

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    width: 100%;
    background: var(--amber-bg);
    color: var(--amber);
    padding: .7rem 1.25rem;
    box-shadow: 0 -1px 4px rgba(0, 0, 0, .1);
}

#blazor-error-ui .reload { color: var(--amber); font-weight: 600; }

@media (max-width: 720px) {
    .sidebar { width: 64px; padding: 16px 8px; }
    .brand-sub, .nav-section, .nav-item .label, .soon, .sidebar-foot, .theme-toggle span { display: none; }
    .brand-logo { width: 36px; object-fit: cover; object-position: left; }
    .nav-item { justify-content: center; }
    .theme-toggle { justify-content: center; }
}

/* Generated parameter form */
.param-form { display: flex; flex-direction: column; gap: 16px; max-width: 520px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: .82rem; font-weight: 600; color: var(--text); }
.req { color: var(--red); margin-left: 2px; }

.input {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    width: 100%;
}

.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: .88rem; }
.field-help { margin: 0; font-size: .76rem; color: var(--muted); }

/* Keywords page */
.split { display: grid; grid-template-columns: 260px 1fr; gap: 18px; align-items: start; }
.kw-list { display: flex; flex-direction: column; gap: 4px; }
.kw-group { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted-2); margin: 12px 4px 4px; }

.kw-item {
    text-align: left;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 8px;
    padding: 8px 12px;
    font: inherit;
    cursor: pointer;
    color: var(--text);
}

.kw-item:hover { border-color: var(--accent); }
.kw-item.selected { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.kw-meta { color: var(--muted); font-size: .85rem; margin: 0 0 16px; }

.preview { margin-top: 20px; }
.preview h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 8px; }
.preview pre { background: var(--code-bg); color: var(--code-text); padding: 14px 16px; border-radius: 10px; overflow: auto; font-size: .8rem; margin: 0; }

@media (max-width: 720px) { .split { grid-template-columns: 1fr; } }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--red); border-color: var(--border); }
.btn.danger:hover { border-color: var(--red); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-icon {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface);
    cursor: pointer;
    font-size: .95rem;
    line-height: 1;
    color: var(--muted);
}

.btn-icon:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-icon:disabled { opacity: .4; cursor: not-allowed; }
.btn-icon.danger:hover:not(:disabled) { border-color: var(--red); color: var(--red); }

/* Case builder */
.toolbar { margin-bottom: 16px; }
.form-card { max-width: 720px; display: flex; flex-direction: column; gap: 14px; }
.section-title { font-size: 1.05rem; color: var(--heading); margin: 26px 0 12px; }
.step-card { max-width: 720px; margin-bottom: 14px; }
.step-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }

.step-order {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: .78rem;
    font-weight: 700;
}

.step-tools { margin-left: auto; display: flex; gap: 6px; }
.add-step { max-width: 720px; }
.add-row { display: flex; gap: 10px; margin-top: 8px; }
.add-row .input { flex: 1; }
.save-row { display: flex; align-items: center; gap: 12px; margin-top: 20px; max-width: 720px; }
.err { color: var(--red); font-size: .85rem; }
.ok { color: var(--green); font-weight: 600; font-size: .85rem; }

/* Guided authoring */
.mode-tabs { display: flex; gap: 8px; }
.notice {
    display: flex;
    gap: 8px;
    align-items: baseline;
    flex-wrap: wrap;
    max-width: 720px;
    margin-bottom: 18px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--amber-bg);
    color: var(--amber);
    font-size: .85rem;
}

/* Grid table */
.grid { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.grid th, .grid td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: .9rem; }
.grid th { background: var(--surface-2); color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; }
.grid tbody tr:last-child td { border-bottom: none; }
.grid tr:hover td { background: var(--surface-2); }

/* Account pages (login / logout / change-password / access-denied) — standalone
   Razor Pages, no sidebar shell, centered over the same background gradient. */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    position: relative;
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 18px 40px -20px rgba(16, 24, 40, .35), var(--shadow);
    padding: 40px 36px 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow: hidden;
    animation: auth-rise .45s cubic-bezier(.16, 1, .3, 1) both;
}

/* Signature: a thin green brand bar pinned to the card's top edge. */
.auth-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
}

.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.auth-brand img { height: 60px; max-width: 100%; filter: var(--logo-filter); }
.auth-eyebrow {
    margin: 0;
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--muted);
}

.auth-title { margin: 0; font-size: 1.5rem; font-weight: 600; color: var(--heading); text-align: center; }
.auth-sub { margin: -10px 0 0; color: var(--muted); font-size: .9rem; text-align: center; }

.auth-error {
    background: var(--red-bg);
    color: var(--red);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: .85rem;
}

/* Auth inputs: comfortable targets + a clear brand focus ring (scoped so the rest of the app is unaffected). */
.auth-card .input { padding: 10px 12px; }
.auth-card .input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.auth-card .btn.primary { width: 100%; padding: 11px 16px; font-size: .95rem; }

@keyframes auth-rise {
    from { opacity: 0; transform: translateY(10px) scale(.98); }
    to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    .auth-card { animation: none; }
}

/* Admin: Users page */
.temp-password {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--green-bg);
    color: var(--green);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 16px;
    font-size: .85rem;
}

.temp-password code {
    background: var(--code-bg);
    color: var(--code-text);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: .85rem;
}

.role-checks { display: flex; flex-wrap: wrap; gap: 10px 16px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
