/* =====================================================================
 * styles.css — GitHub Issues mini-app. Mobile-first, dark default.
 * Colors are CSS variables; app.js maps Telegram themeParams onto them.
 * =================================================================== */
:root {
  --bg: #0d1117;
  --bg-2: #161b22;
  --bg-3: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #2f81f7;
  --accent-text: #ffffff;
  --green: #238636;
  --green-2: #2ea043;
  --purple: #8957e5;
  --danger: #da3633;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }

.app { min-height: 100vh; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + var(--safe-top)) 10px 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar__title {
  flex: 1; font-weight: 700; font-size: 16px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar__right { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px; padding: 0 8px;
  border: 1px solid var(--border); background: var(--bg-2);
  border-radius: 10px; font-size: 17px; cursor: pointer; color: var(--text);
}
.icon-btn:active { background: var(--bg-3); }
.icon-btn--accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.icon-btn--danger { color: #ff7b72; }

.repo-pill {
  display: inline-flex; align-items: center; gap: 5px; max-width: 46vw;
  height: 36px; padding: 0 10px; border: 1px solid var(--border);
  background: var(--bg-2); border-radius: 10px; cursor: pointer;
}
.repo-pill__name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }

/* ---- layout ---- */
.screen { min-height: 100vh; display: flex; flex-direction: column; }
.body { padding: 12px 12px calc(24px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 12px; }
.toolbar { display: flex; flex-direction: column; gap: 8px; }

.center { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; }
.center--pad { min-height: 120px; }
.muted { color: var(--muted); }
.hint { font-size: 12.5px; margin: 0; }

/* ---- spinner ---- */
.spinner { width: 28px; height: 28px; border: 3px solid var(--bg-3); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- empty ---- */
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 16px; text-align: center; }
.empty__icon { font-size: 44px; }
.empty__title { font-weight: 700; font-size: 17px; }
.empty__sub { color: var(--muted); max-width: 460px; }

/* ---- inputs ---- */
.input {
  width: 100%; padding: 10px 12px; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: 10px; outline: none; color: var(--text);
}
.input:focus { border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 40px; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 17px, calc(100% - 13px) 17px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.title-input { font-weight: 700; font-size: 16px; overflow: hidden; }
.search-wrap { display: flex; gap: 6px; }
.search-wrap .input { flex: 1; }

/* ---- tabs ---- */
.tabs { display: flex; gap: 6px; background: var(--bg-2); padding: 4px; border-radius: 12px; border: 1px solid var(--border); }
.tab { flex: 1; padding: 8px 6px; border: 0; background: transparent; color: var(--muted); border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 13.5px; }
.tab--active { background: var(--bg-3); color: var(--text); }

/* ---- chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chips--select { padding: 4px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border: 1px solid var(--border); background: var(--bg-2);
  color: var(--text); border-radius: 999px; cursor: pointer; font-size: 13px;
}
.chip--active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 22%, var(--bg-2)); }
.chip__dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* ---- lists / rows ---- */
.list { display: flex; flex-direction: column; gap: 8px; }
.issue-row, .repo-row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 12px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; color: var(--text);
}
.issue-row:active, .repo-row:active { background: var(--bg-3); }
.issue-row__main, .repo-row__main { flex: 1; min-width: 0; }
.issue-row__title { font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; margin-top: 6px; align-self: flex-start; }
.dot--open { background: var(--green-2); }
.dot--closed { background: var(--purple); }
.row-meta { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.lbls { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.lbl { font-size: 11px; padding: 1px 8px; border: 1px solid; border-radius: 999px; color: var(--text); opacity: 0.95; }
.chev { color: var(--muted); font-size: 20px; }

.repo-row__name { font-weight: 600; display: flex; gap: 2px; }
.repo-row__desc { color: var(--muted); font-size: 12.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 64vw; }
.repo-row--active { border-color: var(--accent); }
.repo-row__meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.badge { font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 8px; padding: 1px 7px; }
.badge--ok { color: var(--green-2); border-color: var(--green-2); }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 16px; border: 1px solid var(--border); background: var(--bg-2); color: var(--text); border-radius: 10px; cursor: pointer; font-weight: 600; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn--ghost { background: var(--bg-2); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--block { width: 100%; }
.btn:disabled, .btn.is-busy { opacity: 0.6; pointer-events: none; }
.btn.is-busy::after { content: ""; width: 14px; height: 14px; margin-left: 8px; border: 2px solid #fff; border-top-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }

/* ---- fields / detail ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.issue-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.state-badge { font-weight: 700; font-size: 13px; padding: 3px 10px; border-radius: 999px; }
.state-badge--open { background: color-mix(in srgb, var(--green-2) 22%, var(--bg-2)); color: var(--green-2); }
.state-badge--closed { background: color-mix(in srgb, var(--purple) 22%, var(--bg-2)); color: #d2a8ff; }

.section { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 4px; display: flex; flex-direction: column; gap: 8px; }
.section__title { font-weight: 700; }
.comment { background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.comment__head { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.comment__body { white-space: pre-wrap; word-break: break-word; }
.add-row { display: flex; flex-direction: column; gap: 8px; }
.sub-row { display: flex; align-items: center; gap: 8px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 4px 4px 4px 10px; }
.sub-row__open { flex: 1; text-align: left; background: transparent; border: 0; color: var(--text); cursor: pointer; padding: 8px 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sub-actions .btn { flex: 1; }

/* ---- users / switch ---- */
.user-row { display: flex; align-items: center; gap: 10px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.user-row__main { flex: 1; min-width: 0; }
.user-row__name { font-weight: 600; }
.user-row__sub { color: var(--muted); font-size: 12.5px; }
.user-row__actions { display: flex; gap: 6px; }
.switch { display: flex; align-items: center; gap: 10px; }
.switch input { width: 20px; height: 20px; accent-color: var(--green-2); }

/* ---- toast ---- */
.toast-layer { position: fixed; left: 0; right: 0; bottom: calc(16px + var(--safe-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 60; pointer-events: none; }
.toast { max-width: 86vw; padding: 11px 16px; background: var(--bg-3); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,0.45); transform: translateY(16px); opacity: 0; transition: all 0.25s; font-size: 14px; }
.toast--in { transform: translateY(0); opacity: 1; }
.toast--error { border-color: var(--danger); }
.toast--success { border-color: var(--green-2); }

/* ---- modal / sheet ---- */
.modal-layer:empty { display: none; }
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.sheet { width: 100%; max-width: 560px; background: var(--bg); border: 1px solid var(--border); border-radius: 18px 18px 0 0; max-height: 88vh; display: flex; flex-direction: column; animation: slideUp 0.22s ease; }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0.6; } to { transform: translateY(0); opacity: 1; } }
.sheet__head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.sheet__title { font-weight: 700; font-size: 16px; }
.sheet__body { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.sheet__actions { display: flex; gap: 8px; padding: 12px 16px calc(16px + var(--safe-bottom)); border-top: 1px solid var(--border); }
.sheet__actions .btn { flex: 1; }

/* ---- menu / workspaces ---- */
.menu-who { padding: 4px 2px 12px; border-bottom: 1px solid var(--border); }
.menu-who__name { font-weight: 700; }
.menu-who__sub { color: var(--muted); font-size: 12.5px; }
.menu-list { display: flex; flex-direction: column; gap: 4px; padding-top: 8px; }
.menu-item { display: flex; align-items: center; gap: 12px; padding: 12px 8px; background: transparent; border: 0; color: var(--text); cursor: pointer; text-align: left; border-radius: 10px; font-size: 15px; }
.menu-item:active { background: var(--bg-2); }
.menu-item__ic { width: 22px; text-align: center; }
.ws-row { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 12px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; color: var(--text); }
.ws-row--active { border-color: var(--accent); }
.ws-row__name { font-weight: 600; }
.ws-row__role { color: var(--muted); font-size: 12.5px; }
