/* SPDX-License-Identifier: MIT */
/* Copyright (c) 2026 Obsydia contributors */
:root { --bg: #131722; --fg: #d1d4dc; --muted: #787b86; --accent: #2196f3; --danger: #ef5350; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 13px system-ui, sans-serif; }

#terminal { position: absolute; inset: 0; }
.conn-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  padding: 10px; text-align: center; font-weight: 700; font-size: 15px;
  background: var(--danger); color: #fff;
}
.login { max-width: 320px; margin: 15vh auto; display: flex; flex-direction: column; gap: 10px; }
.login input, .login button { padding: 9px; border-radius: 4px; border: 1px solid #2a2e39; background: #1e222d; color: var(--fg); }
.login button { background: var(--accent); border: 0; color: #fff; cursor: pointer; }
.login .error { color: var(--danger); min-height: 1em; }

/* --- Layout menu (TradingView-style) ------------------------------------- */
.obs-layout-btn { display: inline-flex; align-items: center; gap: 6px; max-width: 240px; }
.obs-layout-btn__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.obs-layout-btn--dirty svg:first-child { color: #f0b90b; }   /* unsaved changes */
.obs-layout-btn--saved svg:first-child { color: #26a69a; }

.obs-menu {
  position: fixed; z-index: 2000; min-width: 240px; padding: 6px 0;
  background: #1e2027; border: 1px solid #2f323c; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); font: 13px system-ui, sans-serif;
}
.obs-menu__item {
  display: grid; grid-template-columns: 18px 1fr auto; align-items: center; gap: 6px;
  width: 100%; padding: 7px 14px 7px 8px; border: 0; background: none; color: #d1d4dc;
  text-align: left; cursor: pointer; font: inherit;
}
.obs-menu__item:hover:not(:disabled) { background: #2a2e39; }
.obs-menu__item:disabled { color: #5d606b; cursor: default; }
.obs-menu__check { color: #2962ff; text-align: center; }
.obs-menu__hint { color: #787b86; font-size: 12px; }
.obs-menu__sep { height: 1px; margin: 5px 0; background: #2f323c; }

.obs-dialog-backdrop {
  position: fixed; inset: 0; z-index: 3000; display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.5);
}
.obs-dialog {
  width: min(420px, calc(100vw - 32px)); background: #1e2027; color: #d1d4dc;
  border: 1px solid #2f323c; border-radius: 10px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  font: 13px system-ui, sans-serif;
}
.obs-dialog--wide { width: min(640px, calc(100vw - 32px)); }
.obs-dialog__title {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; font-size: 16px; font-weight: 600;
}
.obs-dialog__close { border: 0; background: none; color: #787b86; cursor: pointer; font-size: 14px; }
.obs-dialog__body { padding: 0 20px 20px; display: flex; flex-direction: column; gap: 14px; }
.obs-dialog__actions { display: flex; justify-content: flex-end; gap: 8px; }
.obs-input {
  width: 100%; padding: 8px 10px; border: 1px solid #363a45; border-radius: 6px;
  background: #131722; color: #d1d4dc; font: inherit;
}
.obs-input:focus { outline: none; border-color: #2962ff; }
.obs-btn { padding: 7px 16px; border-radius: 6px; border: 1px solid #363a45; font: inherit; cursor: pointer; }
.obs-btn--ghost { background: none; color: #d1d4dc; }
.obs-btn--primary { background: #2962ff; border-color: #2962ff; color: #fff; }

.obs-layout-list { max-height: 50vh; overflow-y: auto; display: flex; flex-direction: column; }
.obs-layout-row {
  display: grid; grid-template-columns: 1fr auto auto 28px; gap: 16px; align-items: center;
  padding: 9px 10px; border-radius: 6px; cursor: pointer;
}
.obs-layout-row:hover { background: #2a2e39; }
.obs-layout-row--current .obs-layout-row__name { color: #2962ff; font-weight: 600; }
.obs-layout-row__meta { color: #787b86; font-size: 12px; white-space: nowrap; }
.obs-icon-btn { border: 0; background: none; color: #787b86; cursor: pointer; padding: 4px; border-radius: 4px; }
.obs-icon-btn:hover { color: #d1d4dc; background: #363a45; }
.obs-icon-btn--danger, .obs-icon-btn--danger:hover { color: #fff; background: #ef5350; }
.obs-layout-empty { padding: 16px 10px; color: #787b86; }
@media (max-width: 640px) {
  .obs-layout-row { grid-template-columns: 1fr 28px; }
  .obs-layout-row__meta { display: none; }
}

/* --- Settings page ------------------------------------------------------- */
.settings-page { height: auto; min-height: 100%; }
.settings { max-width: 460px; margin: 6vh auto; padding: 0 16px; }
.settings h1 { font-size: 22px; margin: 12px 0 20px; }
.settings h2 { font-size: 15px; margin: 0 0 12px; color: var(--fg); }
.settings section { background: #1e2027; border: 1px solid #2f323c; border-radius: 10px; padding: 18px 20px; margin-bottom: 16px; }
.settings dl { display: grid; grid-template-columns: 110px 1fr; gap: 8px; margin: 0; }
.settings dt { color: var(--muted); }
.settings dd { margin: 0; }
.settings form { display: flex; flex-direction: column; gap: 12px; }
.settings label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); }
.settings input { padding: 9px 10px; border: 1px solid #363a45; border-radius: 6px; background: #131722; color: var(--fg); font: inherit; }
.settings input:focus { outline: none; border-color: #2962ff; }
.settings button { padding: 9px; border: 0; border-radius: 6px; background: #2962ff; color: #fff; cursor: pointer; font: inherit; }
.settings button.link { background: none; color: var(--muted); padding: 0; text-align: left; }
.settings .hint { margin: 0; color: var(--muted); font-size: 12px; }
.settings .notice { background: rgba(240, 185, 11, 0.12); border: 1px solid rgba(240, 185, 11, 0.5); color: #f0b90b; padding: 10px 12px; border-radius: 8px; margin-bottom: 16px; }
.settings .error { color: var(--danger); margin-bottom: 10px; }
.settings .ok { color: #26a69a; margin-bottom: 10px; }
.settings .back { color: var(--muted); text-decoration: none; }

/* --- Account (avatar) menu ------------------------------------------------ */
.obs-avatar {
  width: 28px; min-width: 28px; padding: 0; justify-content: center; border-radius: 50%;
  background: #2962ff; color: #fff; font-weight: 600; margin-left: 4px;
}
.obs-menu__user { display: flex; flex-direction: column; gap: 2px; padding: 6px 14px 8px; }
.obs-menu__user span { color: #787b86; font-size: 12px; }
a.obs-menu__item { text-decoration: none; }
.obs-menu__form { margin: 0; }

/* --- Data freshness pill (delayed free source / market closed) ----------- */
.data-pill {
  position: fixed; z-index: 900; right: 96px; bottom: 34px; padding: 4px 10px;
  border-radius: 999px; font: 12px system-ui, sans-serif;
  background: rgba(240, 185, 11, 0.14); color: #f0b90b; border: 1px solid rgba(240, 185, 11, 0.45);
}
.data-pill[data-state="market_closed"] { background: rgba(120, 123, 134, 0.18); color: #b2b5be; border-color: #434651; }
