/* Tux AI assistant overlay — fixed widget shown across all pages.
   Colours come from the app's theme tokens (style.css + brand file), so the widget follows
   light/dark mode and the brand. Every var() carries the light PrivateLAN value as fallback,
   so the same file also works on the public website, which has no tokens. */

#tux-launcher {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--brand, #567386);
    color: var(--on-brand, #fff);
    cursor: pointer;
    box-shadow: var(--overlay-shadow, 0 4px 18px rgba(0, 0, 0, 0.3));
    z-index: 10000;
    font-size: 28px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

#tux-launcher:hover {
    background: var(--brand-strong, #436373);
}

#tux-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 500px;
    max-width: calc(100vw - 40px);
    height: 720px;
    max-height: calc(100vh - 40px);
    background: var(--surface, #fff);
    border-radius: var(--radius, 4px);
    box-shadow: var(--overlay-shadow, 0 4px 18px rgba(0, 0, 0, 0.3));
    z-index: 10001;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: Arial, Helvetica, sans-serif;
}

#tux-panel.tux-open {
    display: flex;
}

#tux-header {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--brand, #567386);
    color: var(--on-brand, #fff);
    padding: 10px 12px;
}

#tux-header .tux-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--surface, #fff);
    object-fit: cover;
}

#tux-header .tux-title {
    display: flex;
    flex-direction: column;
    flex: 1;
    line-height: 1.2;
}

#tux-header .tux-name {
    font-weight: bold;
    font-size: 15px;
}

#tux-header .tux-sub {
    font-size: 11px;
    opacity: 0.85;
}

.tux-status {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
    background: var(--gray, #bbb);     /* checking / unknown */
}

.tux-status.tux-online {
    background: var(--green, #36a64f);
}

.tux-status.tux-offline {
    background: var(--red, #8b2b2b);
}

.tux-status.tux-checking {
    background: var(--yellow, #e0b000);   /* amber while checking */
}

#tux-close,
#tux-restart {
    background: none;
    border: none;
    color: var(--on-brand, #fff);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 0 2px;
}

#tux-restart {
    font-size: 18px;
}

#tux-close:hover,
#tux-restart:hover {
    opacity: 0.8;
}

#tux-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: var(--surface-2, #f5f6f7);
}

.tux-msg {
    margin-bottom: 10px;
    max-width: 85%;
    padding: 8px 11px;
    border-radius: var(--radius, 4px);
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    white-space: normal;
}

.tux-msg a {
    color: var(--brand-ink, #436373);
    text-decoration: underline;
}

.tux-msg .tux-h {
    font-weight: bold;
    font-size: 14px;
    margin: 6px 0 2px;
}

.tux-msg .tux-list {
    margin: 4px 0;
    padding-left: 20px;
}

.tux-msg .tux-list li {
    margin: 2px 0;
}

.tux-msg code {
    background: var(--surface-2, #f5f6f7);
    border: 1px solid var(--border, #e0e0e0);
    border-radius: var(--radius-sm, 3px);
    padding: 1px 4px;
    font-family: var(--font-mono, Consolas, monospace);
    font-size: 12px;
}

.tux-msg .tux-table {
    border-collapse: collapse;
    width: 100%;
    margin: 6px 0;
    font-size: 12px;
}

.tux-msg .tux-table th,
.tux-msg .tux-table td {
    border: 1px solid var(--border, #e0e0e0);
    padding: 4px 6px;
    text-align: left;
    vertical-align: top;
}

.tux-msg .tux-table th {
    background: var(--surface-2, #f5f6f7);
    font-weight: bold;
}

.tux-msg .tux-table tr:nth-child(even) td {
    background: var(--row-hover, #f7f9fa);
}

.tux-user {
    background: var(--brand, #567386);
    color: var(--on-brand, #fff);
    margin-left: auto;
    border-bottom-right-radius: var(--radius-sm, 3px);
}

.tux-bot {
    background: var(--surface, #fff);
    color: var(--text, #222);
    border: 1px solid var(--border, #e0e0e0);
    border-bottom-left-radius: var(--radius-sm, 3px);
}

.tux-bot.tux-pending {
    opacity: 0.6;
    font-style: italic;
}

#tux-disclaimer {
    font-size: 10px;
    color: var(--muted, #888);
    text-align: center;
    padding: 4px 8px;
    background: var(--surface-2, #f5f6f7);
}

#tux-form {
    display: flex;
    border-top: 1px solid var(--border, #e0e0e0);
}

#tux-input {
    flex: 1;
    border: none;
    padding: 11px;
    font-size: 14px;
    background: var(--field, #fff);
    color: var(--text, #222);
    outline: none;
}

#tux-input:focus {
    /* Inset ring instead of an outline/border so the focus state does not
       change the input's box model or push neighbouring elements. */
    box-shadow: inset 0 0 0 1px var(--brand-ink, #436373);
}

#tux-send {
    border: none;
    background: var(--brand, #567386);
    color: var(--on-brand, #fff);
    padding: 0 16px;
    cursor: pointer;
    font-size: 14px;
    width: 100px;
}

#tux-send:hover {
    background: var(--brand-strong, #436373);
}

#tux-send:disabled {
    background: var(--border-strong, #d8dde0);
    cursor: default;
}

/* --- Full control -------------------------------------------------------
   Applied by js/chat.js when #tux-panel carries data-ai-mode="full", so the
   assistant that can change this system never looks like the one that cannot.
   The header keeps the brand colour; a red ring around the avatar carries the
   signal, matching the launcher, without flooding the panel in red.
   The public website widget has no such attribute and stays on brand colour. */

#tux-panel.tux-fullcontrol #tux-header .tux-avatar {
    box-shadow: 0 0 0 3px var(--red, #8b2b2b);
}

#tux-launcher.tux-fullcontrol {
    background: var(--red, #8b2b2b);
}

#tux-launcher.tux-fullcontrol:hover {
    /* No separate "red-strong" token exists; derive the hover shade from
       --red the same way the dashboard status tiles do in style.css. */
    background: color-mix(in srgb, var(--red, #8b2b2b) 82%, black);
}

#tux-notice {
    background: color-mix(in srgb, var(--red, #8b2b2b) 12%, var(--surface, #fff));
    border-bottom: 1px solid color-mix(in srgb, var(--red, #8b2b2b) 35%, var(--border, #e0e0e0));
    color: var(--err-text, #7a2020);
    font-size: 12px;
    line-height: 1.35;
    padding: 7px 12px;
}

#tux-notice[hidden] {
    display: none;
}

/* --- Confirmation card --------------------------------------------------
   Shown when Tux asks to change something. The server has not run anything at
   this point; it is waiting for Confirm or Cancel. */

.tux-msg.tux-confirm {
    max-width: 100%;
    background: var(--surface, #fff);
    border: 1px solid color-mix(in srgb, var(--red, #8b2b2b) 40%, var(--border, #e0e0e0));
    border-left: 4px solid var(--red, #8b2b2b);
    border-radius: var(--radius, 4px);
    padding: 10px 12px;
}

.tux-confirm-head {
    font-weight: bold;
    color: var(--err-text, #7a2020);
    margin-bottom: 8px;
}

.tux-confirm-item {
    margin-bottom: 8px;
}

.tux-confirm-title {
    font-weight: bold;
}

.tux-confirm-call {
    font-family: var(--font-mono, Consolas, monospace);
    font-size: 12px;
    color: var(--muted, #888);
    word-break: break-all;
}

.tux-confirm-body {
    margin: 6px 0 0;
    padding: 6px 8px;
    background: var(--surface-2, #f5f6f7);
    border: 1px solid var(--border, #e0e0e0);
    border-radius: var(--radius-sm, 3px);
    font-family: var(--font-mono, Consolas, monospace);
    font-size: 12px;
    max-height: 180px;
    overflow: auto;
    white-space: pre;
}

.tux-confirm-buttons {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.tux-confirm-yes,
.tux-confirm-no {
    border: none;
    border-radius: var(--radius-sm, 3px);
    padding: 7px 14px;
    font-size: 13px;
    cursor: pointer;
}

.tux-confirm-yes {
    background: var(--red, #8b2b2b);
    /* No "on-red" token exists; same convention as .warningbtn/.deletebtn in
       theme.css, which also pair var(--red, #8b2b2b) with plain white text. */
    color: #fff;
}

.tux-confirm-yes:hover {
    background: color-mix(in srgb, var(--red, #8b2b2b) 82%, black);
}

.tux-confirm-no {
    background: var(--surface-2, #f5f6f7);
    color: var(--text, #222);
}

.tux-confirm-no:hover {
    background: var(--border, #e0e0e0);
}

.tux-confirm-done {
    margin-top: 10px;
    font-size: 12px;
    font-style: italic;
    color: var(--muted, #888);
}

/* An answered card, kept in the transcript so the record of what was approved
   survives a page navigation. Muted: it is history, not a pending decision. */

.tux-msg.tux-confirm.tux-confirm-resolved {
    border-color: var(--border, #e0e0e0);
    border-left-color: var(--border-strong, #d8dde0);
}

.tux-confirm-resolved .tux-confirm-head {
    color: var(--muted, #888);
    font-weight: normal;
}

/* What the ids in an action point at, resolved server-side. This is the line a
   human can actually check before approving — the path alone is just a number. */

.tux-confirm-subject {
    font-size: 13px;
    color: var(--text, #222);
    margin-top: 1px;
}

.tux-confirm-title.tux-confirm-destructive {
    color: var(--err-text, #7a2020);
}
