@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@700;800&family=Work+Sans:wght@400;500;600;700&display=swap');

:root {
    --cg-ink: #1C2033;
    --cg-soft: #5B6178;
    --cg-accent: #2E5CFF;
    --cg-accent-ink: #EAF0FF;
    --cg-line: #E7E6F0;
    --cg-cream: #FBE9C6;
    --cg-cream-dark: #F3D08C;
    --cg-good: #1F8F5F;
    --cg-bad: #8d2b2b;
    --cg-muted: #5c6b7a;
    --cg-page-bg: #f4f6f8;
    --cg-surface: #eef3f8;
    --cg-font-h: 'Baloo 2', 'Segoe UI', sans-serif;
}

/* Admin theme picker (Settings page). Purely a per-browser display preference, stored in
   localStorage by admin.js — it never touches the database or any other admin's session. */
:root[data-theme="mint"] {
    --cg-ink: #13241F;
    --cg-muted: #51665F;
    --cg-accent: #0EA87C;
    --cg-accent-ink: #E3F7EE;
    --cg-cream: #FDE3C8;
    --cg-cream-dark: #F6C48B;
    --cg-page-bg: #F4FBF8;
    --cg-surface: #E3F7EE;
}

:root[data-theme="sunset"] {
    --cg-ink: #201A33;
    --cg-muted: #5C5A78;
    --cg-accent: #FF6B4A;
    --cg-accent-ink: #FFE9E2;
    --cg-cream: #FFE1A8;
    --cg-cream-dark: #FFCB70;
    --cg-page-bg: #FBF8FC;
    --cg-surface: #FFE9E2;
}

:root[data-theme="royal"] {
    --cg-ink: #1B1033;
    --cg-muted: #5B5276;
    --cg-accent: #7C3AED;
    --cg-accent-ink: #F0E8FE;
    --cg-cream: #F7E7B8;
    --cg-cream-dark: #EFCE6E;
    --cg-page-bg: #FAF8FD;
    --cg-surface: #F0E8FE;
}

:root[data-theme="forest"] {
    --cg-ink: #102319;
    --cg-muted: #4C5F52;
    --cg-accent: #2F7A44;
    --cg-accent-ink: #E4F3E7;
    --cg-cream: #F3DBAE;
    --cg-cream-dark: #E8BE72;
    --cg-page-bg: #F5FAF4;
    --cg-surface: #E4F3E7;
}

:root[data-theme="arctic"] {
    --cg-ink: #15202B;
    --cg-muted: #51626F;
    --cg-accent: #0EA5E9;
    --cg-accent-ink: #E2F3FC;
    --cg-cream: #D9ECF5;
    --cg-cream-dark: #AFD9ED;
    --cg-page-bg: #F4F9FC;
    --cg-surface: #E2F3FC;
}

body {
    margin: 0;
    font-family: "Work Sans", "Segoe UI", sans-serif;
    background: var(--cg-page-bg);
    color: #1c2430;
}

h1, h2 {
    font-family: var(--cg-font-h);
}

header {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 16px;
    align-items: center;
    background: var(--cg-ink);
    color: #fff;
    padding: 12px 20px;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--cg-font-h);
    font-weight: 800;
    font-size: 16px;
    color: #fff;
    text-decoration: none;
    margin-right: 8px;
}

.brand-mark {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
}

.nav-groups {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 20px;
    align-items: flex-start;
    flex: 1;
}

.navgroup {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 10px;
    padding: 4px 10px 4px 0;
    border-right: 1px solid rgba(255, 255, 255, 0.12);
}

.navgroup:last-child {
    border-right: none;
}

.group-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #9aa8c4;
    font-weight: 700;
    margin-right: 4px;
}

.nav-groups a {
    color: #fff;
    text-decoration: none;
    font-size: 0.86rem;
}

.nav-groups a:hover {
    color: var(--cg-cream-dark);
}

header .update-alert {
    color: #ffb020;
    font-weight: 700;
}

.logout-form {
    margin-left: auto;
}

main {
    /* max-width: 1200px; */
    padding: 20px;
}

h1 {
    margin-top: 0;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat, .card, table {
    background: #fff;
}

.stat, .card {
    border-radius: 8px;
    padding: 14px 16px;
}

.stat span {
    display: block;
    color: var(--cg-muted);
    font-size: 0.9rem;
}

.stat strong {
    display: block;
    margin-top: 4px;
    font-size: 1.4rem;
    font-family: var(--cg-font-h);
}

.note {
    color: var(--cg-muted);
}

.periods {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.periods a {
    display: block;
    min-width: 96px;
    background: #fff;
    color: var(--cg-ink);
    border: 1px solid #d5dee8;
    border-radius: 8px;
    padding: 8px 12px;
    text-decoration: none;
}

.periods a.selected {
    background: var(--cg-ink);
    color: #fff;
}

.periods strong,
.periods span,
.periods small {
    display: block;
}

.periods strong {
    font-size: 1.3rem;
}

.chart-wrap {
    position: relative;
}

.line-chart {
    width: 100%;
    height: auto;
    margin-top: 8px;
}

.line-chart .axis {
    stroke: #d5dee8;
}

.line-chart .messages {
    stroke: var(--cg-ink);
    stroke-width: 2;
}

.line-chart .admins {
    stroke: #b86e00;
    stroke-width: 2;
}

.line-chart .bot {
    stroke: #b42318;
    stroke-width: 2;
}

.line-chart .median {
    stroke: #8a97a6;
    stroke-width: 1;
    stroke-dasharray: 4 4;
}

.line-chart .cursor {
    stroke: var(--cg-ink);
    stroke-width: 1;
}

.line-chart .hover circle {
    stroke: #fff;
    stroke-width: 1.5;
}

.line-chart .hover circle.messages {
    fill: var(--cg-ink);
}

.line-chart .hover circle.admins {
    fill: #b86e00;
}

.line-chart .hover circle.bot {
    fill: #b42318;
}

.chart-tip {
    position: absolute;
    z-index: 2;
    min-width: 180px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(22, 50, 79, 0.18);
    border-radius: 6px;
    pointer-events: none;
}

.chart-tip strong,
.chart-tip span {
    display: block;
}

.line-chart text {
    fill: var(--cg-muted);
    font-size: 11px;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    color: var(--cg-muted);
}

.legend .messages::before,
.legend .admins::before,
.legend .bot::before,
.legend .median::before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 3px;
    margin-right: 6px;
    vertical-align: middle;
}

.legend .messages::before {
    background: var(--cg-ink);
}

.legend .admins::before {
    background: #b86e00;
}

.legend .bot::before {
    background: #b42318;
}

.legend .median::before {
    background: repeating-linear-gradient(90deg, #8a97a6 0 4px, transparent 4px 7px);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

.table-scroll {
    overflow-x: auto;
}

.table-scroll table {
    width: max-content;
    min-width: 100%;
}

th, td {
    border-bottom: 1px solid #e3e8ee;
    padding: 8px 10px;
    text-align: left;
    vertical-align: top;
}

th {
    background: var(--cg-surface);
}

.message-text {
    max-width: 420px;
    max-height: 6em;
    overflow: auto;
    white-space: pre-wrap;
}

label {
    display: block;
    margin-top: 12px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
textarea,
select {
    width: 100%;
    max-width: 480px;
    padding: 8px;
    box-sizing: border-box;
}

button, .button {
    display: inline-block;
    background: var(--cg-accent);
    color: #fff;
    border: 0;
    border-radius: 4px;
    padding: 8px 14px;
    text-decoration: none;
    cursor: pointer;
}

button[hidden] {
    display: none !important;
}

.search, .pager, .toolbar, .row-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 12px 0;
}

.row-actions {
    margin: 0;
    white-space: nowrap;
}

.message-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* The Actions column stays on the right while the rest of the Messages table scrolls. */
#messages-table {
    border-collapse: separate;
    border-spacing: 0;
}

#messages-table .sticky-actions {
    position: sticky;
    right: 0;
    z-index: 2;
    background: var(--cg-page-bg);
    border-left: 1px solid #e3e8ee;
    box-shadow: -8px 0 8px -8px rgba(16, 24, 32, 0.45);
}

#messages-table th.sticky-actions {
    z-index: 3;
    background: var(--cg-surface);
}

#messages-table .message-actions {
    width: 22rem;
}

.message-actions form {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 0;
}

.message-actions input[type="text"] {
    width: 16rem;
    max-width: 16rem;
}

#messages-table .message-actions input[type="text"] {
    width: 12rem;
    max-width: 12rem;
}

.pager a,
.pager .current,
.pager .disabled,
.pager .gap {
    min-width: 2rem;
    text-align: center;
    padding: 4px 8px;
    border-radius: 4px;
    background: #fff;
    color: var(--cg-ink);
    text-decoration: none;
}

.pager .current {
    background: var(--cg-ink);
    color: #fff;
}

.pager .disabled {
    opacity: 0.45;
}

th.check, td.check {
    width: 2rem;
}

.col-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.icon-button {
    display: inline-flex;
    color: inherit;
    line-height: 0;
}

.icon-button .up,
.icon-button .down,
.col-filter summary path {
    fill: #9aa8b5;
}

.icon-button.sorted-asc .up,
.icon-button.sorted-desc .down,
.col-filter.active summary path {
    fill: var(--cg-ink);
}

.col-filter {
    position: relative;
}

.col-filter summary {
    display: inline-flex;
    cursor: pointer;
    list-style: none;
}

.col-filter summary::-webkit-details-marker {
    display: none;
}

.col-filter form {
    flex-basis: 100%;
    display: grid;
    gap: 6px;
    min-width: 160px;
    margin-top: 8px;
}

.col-filter input,
.col-filter select {
    max-width: none;
}

button.danger {
    background: var(--cg-bad);
}

button.secondary {
    background: #5c6b7a;
}

dialog.edit-dialog {
    border: 0;
    border-radius: 8px;
    padding: 16px;
    max-width: 560px;
    width: 92%;
    max-height: 90vh;
    overflow: auto;
}

dialog.edit-dialog::backdrop {
    background: rgba(16, 24, 32, 0.45);
}

.flash, .error, .hint {
    padding: 10px 12px;
    border-radius: 6px;
}

.flash {
    background: #e7f6ec;
}

.error {
    background: #fdecea;
    white-space: pre-wrap;
}

.hint {
    background: var(--cg-surface);
}

.channel-layout {
    display: grid;
    grid-template-columns: minmax(280px, 420px) minmax(320px, 640px);
    gap: 20px;
    align-items: start;
}

.channel-list tr.selected td {
    background: var(--cg-accent-ink);
}

.channel-list a {
    color: inherit;
    text-decoration: none;
}

.chat-settings-form fieldset {
    border: 0;
    margin: 0;
    padding: 0;
}

@media (max-width: 800px) {
    .channel-layout {
        grid-template-columns: 1fr;
    }
}

pre.example {
    white-space: pre-wrap;
    background: #f7f9fb;
    border: 1px solid #d5dee8;
    border-radius: 6px;
    padding: 12px;
    max-width: 640px;
}

.login {
    max-width: 360px;
    margin: 48px auto;
}

.update-page section {
    margin-bottom: 16px;
}

.update-page button:disabled {
    opacity: 0.55;
    cursor: default;
}

.update-page .table-scroll {
    overflow-x: visible;
}

.update-page .table-scroll table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
}

.update-page col.published {
    width: 16%;
}

.update-page col.version {
    width: 12%;
}

.update-page col.commit {
    width: 62%;
}

.update-page col.running {
    width: 10%;
}

.update-page .table-scroll th,
.update-page .table-scroll td {
    white-space: normal;
    overflow-wrap: anywhere;
}
