/* ui.css — the shared look of panels, buttons, badges, fields and tabs.
 *
 * Each element kind is styled once here from the tokens in base.css. New
 * markup uses the generic classes (.ui-panel, .btn-primary, .badge, .field,
 * .ui-tab, ...); the existing page elements are listed next to them so every
 * page gets the same look without changing its markup.
 *
 * Only paint is set here: colours, backgrounds, borders' colours, radii,
 * shadows and blur. Sizes, padding, margins and border widths stay with the
 * page stylesheets, so the layout does not move. This file is linked last so
 * it wins over the page stylesheets at equal specificity.
 */

/* ===== Glass panels ===== */

/* Floating panels sit over content, so they are nearly opaque and blur it. */
.ui-panel-floating,
.modal,
.agent-popover,
.ws-dropdown-panel,
.msg-actions-menu,
.mem-modal,
.md-table-modal-content {
  background: var(--glass-bg-strong);
  border-color: var(--glass-border);
  box-shadow: var(--shadow-lg), var(--glass-highlight);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}
.modal, .mem-modal { border-radius: var(--radius-lg); }
.agent-popover, .ws-dropdown-panel, .md-table-modal-content { border-radius: var(--radius-md); }

/* In-page panels sit over the page background and let its glow through. */
.ui-panel,
.ws-card,
.ws-skill-card,
.ws-mcp-add-form,
.tools-card,
.member-card,
.schedule-result {
  background: var(--glass-bg);
  border-color: var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm), var(--glass-highlight);
}
/* Cards a user picks from show a highlighted border under the pointer. */
.home-tile,
.home-starter,
.conversation-row,
.schedule-card,
.schedule-example,
.schedule-result,
.ws-item,
.settings-card,
.member-card {
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.home-tile:hover,
.home-starter.btn-secondary:hover:not(:disabled),
.conversation-row:hover,
.schedule-card:hover,
.schedule-example:hover,
.schedule-result:hover,
.ws-item:hover,
.settings-card:hover,
.member-card:hover { border-color: var(--card-border-hover); }
.msg.welcome { background: var(--glass-bg); box-shadow: var(--shadow-md), var(--glass-highlight); }

/* App chrome: sidebar, top bar and composer. */
#sidebar,
#top-bar,
.input-area {
  background: var(--surface-chrome);
  border-color: var(--glass-border);
}
.input-area { box-shadow: 0 -1px 0 var(--glass-border); }
@media (max-width: 700px) {
  /* The sidebar slides over the page here, so it must hide it. */
  #sidebar {
    background: var(--glass-bg-strong);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
  }
}

/* ===== Buttons ===== */

.btn,
.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-danger,
.btn-success {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.btn:disabled,
.btn-primary:disabled,
.btn-secondary:disabled,
.btn-ghost:disabled,
.btn-danger:disabled,
.btn-success:disabled { opacity: 0.5; cursor: not-allowed; }

/* Primary: red */
.btn-primary,
.modal button,
.confirm-btn.primary,
.input-row button.send,
.ws-btn-primary,
.archive-banner button,
.pty-modal .pty-modal-close,
.update-banner,
.scroll-pill.done,
#sidebar .new-chat-btn {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border-color: transparent;
  box-shadow: var(--btn-primary-shadow);
}
.btn-primary:hover:not(:disabled),
.modal button:hover,
.confirm-btn.primary:hover,
.input-row button.send:hover:not(:disabled),
.ws-btn-primary:hover,
.archive-banner button:hover,
.pty-modal .pty-modal-close:hover,
.update-banner:hover,
#sidebar .new-chat-btn:hover {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border-color: transparent;
  box-shadow: var(--btn-primary-shadow-hover);
  filter: brightness(1.08);
}
.ws-btn-primary, .archive-banner button,
.confirm-btn, .modal button { border-radius: var(--radius-sm); }
.pty-modal-icon { background: var(--btn-primary-bg); color: var(--btn-primary-text); box-shadow: var(--btn-primary-shadow); }

/* The send button's stop and waiting states. */
.input-row button.send.stop,
.input-row button.send.stopping,
.input-row button.send.stop:hover:not(:disabled) {
  background: var(--btn-neutral-bg);
  color: var(--btn-neutral-text);
  box-shadow: none;
  filter: none;
}
#sendBtn.awaiting,
#sendBtn.awaiting:hover:not(:disabled) {
  background: var(--tone-warning-solid);
  color: var(--tone-warning-solid-text);
  box-shadow: none;
}

/* Secondary: glass with a light edge */
.btn-secondary,
.confirm-btn.cancel,
.ws-btn-secondary,
.modal .ws-btn-secondary,
.team-dialog .dialog-actions button.cancel,
#teamDeleteConfirm .dialog-actions button.cancel,
.team-dialog button.add-member,
.team-dialog button.td-empty-add,
.team-dialog button.td-preset-pill,
.team-dialog button.td-flow-member,
.attach-btn,
.md-table-btn,
.md-table-modal-close,
.marp-nav-btn,
.marp-fullscreen-btn,
.msg.assistant .download-all-btn,
.scroll-pill,
.msg-actions-trigger,
.tool-call-body .tool-copy-btn,
.member-card button.transcript,
.mem-pager button,
.ws-dropdown-trigger,
.theme-toggle,
#top-bar button:not(.ws-dropdown-trigger):not(.ws-dropdown-item):not(.pty-badge) {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
  border-color: var(--btn-secondary-border);
  box-shadow: var(--glass-highlight);
  filter: none;
}
.btn-secondary:hover:not(:disabled),
.confirm-btn.cancel:hover,
.ws-btn-secondary:hover,
.modal .ws-btn-secondary:hover,
.team-dialog .dialog-actions button.cancel:hover,
#teamDeleteConfirm .dialog-actions button.cancel:hover,
.team-dialog button.add-member:hover:not(:disabled),
.team-dialog button.td-empty-add:hover:not(:disabled),
.team-dialog button.td-preset-pill:hover:not(:disabled),
.team-dialog button.td-flow-member:hover:not(:disabled),
.attach-btn:hover,
.md-table-modal-close:hover,
.marp-nav-btn:hover:not(:disabled),
.marp-fullscreen-btn:hover,
.msg.assistant .download-all-btn:not(.download-all-btn-expired):hover,
.member-card button.transcript:hover,
.mem-pager button:hover:not(:disabled),
.ws-dropdown-trigger:hover,
.theme-toggle:hover,
#top-bar button:not(.ws-dropdown-trigger):not(.ws-dropdown-item):not(.pty-badge):hover {
  background: var(--btn-secondary-bg-hover);
  color: var(--btn-secondary-text);
  border-color: var(--accent);
  box-shadow: var(--glass-highlight);
  filter: none;
}
.ws-btn-secondary, .confirm-btn.cancel, .ws-dropdown-trigger, .md-table-btn,
.md-table-modal-close, .marp-nav-btn, .marp-fullscreen-btn,
.member-card button.transcript { border-radius: var(--radius-sm); }
.msg.assistant .download-all-btn-expired,
.msg.assistant .download-all-btn-expired:hover { color: var(--text-dim); background: var(--btn-secondary-bg); }

/* Ghost: text only until hovered */
.btn-ghost,
.mem-close,
.team-dialog .td-close,
.team-dialog .td-toggle-all,
.team-dialog .td-icon-btn {
  background: transparent;
  color: var(--btn-ghost-text);
  border-color: transparent;
  box-shadow: none;
  filter: none;
}
.btn-ghost:hover:not(:disabled),
.mem-close:hover,
.team-dialog .td-close:hover:not(:disabled),
.team-dialog .td-toggle-all:hover:not(:disabled),
.team-dialog .td-icon-btn:hover:not(:disabled) {
  background: var(--btn-ghost-bg-hover);
  color: var(--btn-ghost-text-hover);
  border-color: transparent;
  box-shadow: none;
  filter: none;
}
.team-dialog .td-icon-btn:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}
#sidebar .sidebar-page { color: var(--btn-ghost-text); }
#sidebar .sidebar-page:hover { background: var(--btn-ghost-bg-hover); color: var(--btn-ghost-text-hover); }
#sidebar .sidebar-page.active,
#sidebar .sidebar-page.active:hover {
  background: var(--nav-active-bg);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--nav-active-ring);
}
#sidebar .sidebar-page.active .icon { color: var(--nav-active-icon); }

/* Danger: tinted red, filled on hover */
.btn-danger,
.confirm-btn.danger,
.ws-btn-danger,
.modal .ws-btn-danger,
.team-dialog .dialog-actions button.delete,
#teamDeleteConfirm .dialog-actions button.confirm,
.team-panel-head .stop-members {
  background: var(--btn-danger-bg);
  color: var(--btn-danger-text);
  border-color: var(--btn-danger-border);
  box-shadow: none;
  opacity: 1;
  filter: none;
}
.btn-danger:hover:not(:disabled),
.confirm-btn.danger:hover,
.ws-btn-danger:hover,
.modal .ws-btn-danger:hover,
.team-dialog .dialog-actions button.delete:hover,
#teamDeleteConfirm .dialog-actions button.confirm:hover,
.team-dialog .member-row .remove-member:hover,
.team-panel-head .stop-members:hover {
  background: var(--btn-danger-bg-hover);
  color: var(--btn-danger-text-hover);
  border-color: var(--btn-danger-bg-hover);
  box-shadow: none;
  opacity: 1;
  filter: none;
}
.ws-btn-danger { border-radius: var(--radius-sm); }

/* Success: create / connect with a shared subscription */
.btn-success,
.ws-btn-success,
.modal button.btn-success {
  background: var(--btn-success-bg);
  color: var(--btn-success-text);
  border-color: transparent;
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius-sm);
}
.btn-success:hover:not(:disabled),
.ws-btn-success:hover,
.modal button.btn-success:hover {
  background: var(--btn-success-bg);
  color: var(--btn-success-text);
  filter: brightness(1.1);
}

/* Links styled as buttons keep their link look. */
.team-dialog button.link { box-shadow: none; }
.team-dialog button.link:hover { background: transparent; color: var(--accent); box-shadow: none; filter: none; }

/* Keyboard focus on every button kind. */
.btn:focus-visible, .btn-primary:focus-visible, .btn-secondary:focus-visible,
.btn-ghost:focus-visible, .btn-danger:focus-visible, .btn-success:focus-visible,
button:focus-visible, .ws-upload-label:focus-within {
  outline: 2px solid var(--field-focus-border);
  outline-offset: 2px;
}

/* ===== Badges ===== */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px;
  font-size: 12px; font-weight: 700; line-height: 1.4;
}
.badge,
.status-badge,
.channel-badge,
.ws-mcp-type-badge,
.run-status,
.team-dialog .chip.edited {
  --badge-bg: var(--tone-neutral-bg); --badge-ring: var(--tone-neutral-ring); --badge-text: var(--tone-neutral-text);
  background: var(--badge-bg);
  color: var(--badge-text);
  border-radius: var(--radius-pill);
  box-shadow: inset 0 0 0 1px var(--badge-ring);
}
/* Badges that already draw a 1px border use it as the ring. */
.team-badge,
.pty-badge,
.agent-popover .agent-unavail-tag {
  --badge-bg: var(--tone-neutral-bg); --badge-ring: var(--tone-neutral-ring); --badge-text: var(--tone-neutral-text);
  background: var(--badge-bg);
  color: var(--badge-text);
  border-color: var(--badge-ring);
  border-radius: var(--radius-pill);
}
.badge-accent, .channel-badge.web, .run-status.running, .team-dialog .chip.edited, .team-badge, .pty-badge {
  --badge-bg: var(--tone-accent-bg); --badge-ring: var(--tone-accent-ring); --badge-text: var(--tone-accent-text);
}
.badge-success, .status-badge.active, .run-status.succeeded {
  --badge-bg: var(--tone-success-bg); --badge-ring: var(--tone-success-ring); --badge-text: var(--tone-success-text);
}
.badge-warning, .status-badge.paused {
  --badge-bg: var(--tone-warning-bg); --badge-ring: var(--tone-warning-ring); --badge-text: var(--tone-warning-text);
}
.badge-danger, .run-status.failed, .run-status.abandoned {
  --badge-bg: var(--tone-danger-bg); --badge-ring: var(--tone-danger-ring); --badge-text: var(--tone-danger-text);
}
.badge-info, .channel-badge.telegram {
  --badge-bg: var(--tone-info-bg); --badge-ring: var(--tone-info-ring); --badge-text: var(--tone-info-text);
}
.badge-violet, .channel-badge.intercom {
  --badge-bg: var(--tone-violet-bg); --badge-ring: var(--tone-violet-ring); --badge-text: var(--tone-violet-text);
}
.pty-badge:hover { background: var(--tone-accent-bg); filter: brightness(1.15); }
.pty-badge-dot { background: var(--badge-text); }

/* ===== Fields ===== */

.field {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid;
  font: inherit; font-size: 15px;
}
.field,
.modal input,
.input-row textarea,
#top-bar select,
.ws-form input[type="text"],
.ws-form select,
.ws-claudemd-body textarea,
.env-input,
.ws-mcp-add-form textarea,
.ws-mcp-add-form input[type="text"],
.ws-auth-field input[type="password"],
.mem-search,
.team-dialog label > input,
.team-dialog label > select,
.team-dialog label > textarea,
.team-dialog .member-row select,
.team-dialog .member-row input,
.team-dialog .member-row textarea {
  background-color: var(--field-bg);
  color: var(--field-text);
  border-color: var(--field-border);
  border-radius: var(--radius-sm);
  box-shadow: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.3s ease;
}
.input-row textarea { border-radius: var(--radius-md); }
.field:hover:not(:focus),
.modal input:hover:not(:focus),
.input-row textarea:hover:not(:focus),
#top-bar select:hover:not(:focus),
.ws-form input[type="text"]:hover:not(:focus),
.ws-form select:hover:not(:focus),
.ws-claudemd-body textarea:hover:not(:focus),
.env-input:hover:not(:focus),
.ws-mcp-add-form textarea:hover:not(:focus),
.ws-mcp-add-form input[type="text"]:hover:not(:focus),
.ws-auth-field input[type="password"]:hover:not(:focus),
.mem-search:hover:not(:focus),
.team-dialog label > input:hover:not(:focus),
.team-dialog label > select:hover:not(:focus),
.team-dialog label > textarea:hover:not(:focus),
.team-dialog .member-row select:hover:not(:focus),
.team-dialog .member-row input:hover:not(:focus),
.team-dialog .member-row textarea:hover:not(:focus) {
  border-color: var(--field-border-hover);
}
.field:focus,
.modal input:focus,
.input-row textarea:focus,
#top-bar select:focus,
.ws-form input[type="text"]:focus,
.ws-form select:focus,
.ws-claudemd-body textarea:focus,
.env-input:focus,
.ws-mcp-add-form textarea:focus,
.ws-mcp-add-form input[type="text"]:focus,
.ws-auth-field input[type="password"]:focus,
.mem-search:focus,
.team-dialog label > input:focus,
.team-dialog label > select:focus,
.team-dialog label > textarea:focus,
.team-dialog .member-row select:focus,
.team-dialog .member-row input:focus,
.team-dialog .member-row textarea:focus {
  outline: none;
  border-color: var(--field-focus-border);
  box-shadow: var(--field-focus-ring);
}
input::placeholder,
textarea::placeholder { color: var(--field-placeholder); opacity: 1; }

/* ===== Tabs ===== */
/* The rounded highlight is drawn by ::before outside the tab's box, so a
   tab keeps the size and position it had with the underline style. */

.ui-tabs { display: flex; gap: 4px; }
.ui-tab { padding: 8px 16px; border: none; background: transparent; font: inherit; font-weight: 600; cursor: pointer; }
.ui-tab,
.ws-tab,
.schedules-tab {
  position: relative;
  isolation: isolate;
  color: var(--tab-text);
  opacity: 1;
  border-bottom-color: transparent;
  transition: color 0.15s ease;
}
.ui-tab::before,
.ws-tab::before,
.schedules-tab::before {
  content: '';
  position: absolute;
  inset: 3px 2px;
  z-index: -1;
  border-radius: var(--radius-pill);
  background: transparent;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.ui-tab:hover,
.ws-tab:hover,
.schedules-tab:hover { color: var(--tab-text-hover); opacity: 1; }
.ui-tab:hover::before,
.ws-tab:hover::before,
.schedules-tab:hover::before { background: var(--btn-ghost-bg-hover); }
.ui-tab.active,
.ui-tab[aria-selected="true"],
.ws-tab.active,
.schedules-tab.active {
  color: var(--tab-active-text);
  border-bottom-color: transparent;
}
.ui-tab.active::before,
.ui-tab[aria-selected="true"]::before,
.ws-tab.active::before,
.schedules-tab.active::before {
  background: var(--tab-active-bg);
  box-shadow: inset 0 0 0 1px var(--tab-active-ring);
}
.ws-tabs, .schedules-tabs { border-bottom-color: var(--glass-border); }

/* ===== forge2 type scale =====
   Golem and forge2 are one brand, so the app chrome uses the sizes of the
   forge2 mockup (Mulish): brand 22/800, caps labels 11px with .12em tracking,
   nav 15/650, primary buttons 15/650 at 45px, page title 40/800, subtitles
   16/400, section titles 19/700, card titles 16/700, badges 12/750, secondary
   text 14/400. Conversation and answer text keep their own reading size. */
#sidebar .sidebar-brand-name { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
#sidebar .sidebar-navlabel,
#sidebar .sidebar-recent-head { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
#sidebar .sidebar-page { font-size: 15px; font-weight: 650; }
#sidebar .new-chat-btn { font-size: 15px; font-weight: 650; padding: 10px 16px; border-radius: 13px; min-height: 45px; }
#sidebar .sidebar-count { font-size: 11px; font-weight: 800; }

.page-title,
.page-title.hero,
.page-head .page-title,
body.section-chat #top-bar .topbar-title { font-size: 40px; font-weight: 800; letter-spacing: -0.035em; line-height: 1.1; }
.page-sub,
.home-description { font-size: 16px; font-weight: 400; }
.section-title,
.home-section-head h2,
.ui-empty-title,
.schedules-empty-state h3 { font-size: 19px; font-weight: 700; letter-spacing: -0.015em; }

.btn, .btn-primary, .btn-secondary, .btn-ghost, .btn-danger, .btn-success { font-size: 15px; font-weight: 650; padding: 10px 16px; border-radius: 13px; }

.investigation-title,
.schedule-name,
.schedule-example-title,
.ws-item-name,
.settings-card-head h3 { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }
.ui-empty-text,
.schedule-meta,
.ws-item-meta { font-size: 14px; font-weight: 400; }
.badge, .status-badge { font-size: 12px; font-weight: 750; }

@media (max-width: 700px) {
  .page-title, .page-title.hero, .page-head .page-title, body.section-chat #top-bar .topbar-title { font-size: 30px; }
}
