/* components.css — buttons, tables, badges, forms, modals, logs, toasts */

/* ── Buttons ───────────────────────────────────────────────── */

button {
  font-family: inherit;
  font-size: .78rem;
  padding: 7px 13px;
  border-radius: var(--rad);
  background: var(--bg3);
  color: var(--fg2);
  border: 1px solid var(--bg4);
  cursor: pointer;
  transition: background var(--tr), color var(--tr), border-color var(--tr), transform var(--tr);
}
button:hover:not(:disabled) { background: var(--bg4); color: var(--fg); }
button:active:not(:disabled) { transform: scale(.97); }
button:disabled { opacity: .45; cursor: not-allowed; }

.btn-p {
  background: linear-gradient(135deg, #3730a3, #312e81);
  color: #fff;
  border-color: #4f46e5;
  box-shadow: 0 2px 10px rgba(49, 46, 129, .28);
}
.btn-p:hover:not(:disabled) {
  background: linear-gradient(135deg, #4338ca, #3730a3);
  color: #fff;
  box-shadow: 0 4px 14px rgba(55, 48, 163, .38);
}

.btn-g {
  background: linear-gradient(135deg, var(--g), #059669);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 14px var(--glow-g);
}
.btn-g:hover:not(:disabled) { color: #fff; filter: brightness(1.08); }

.btn-d { background: transparent; color: var(--r); border-color: rgba(244, 63, 94, .38); }
.btn-d:hover:not(:disabled) { background: rgba(244, 63, 94, .12); color: var(--r); }

.btn-s { padding: 4px 9px; font-size: .7rem; }

/* Inline spinner for busy buttons */
button.busy { position: relative; color: transparent !important; }
button.busy::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 13px; height: 13px;
  border: 2px solid rgba(255, 255, 255, .28);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

/* ── Tables ────────────────────────────────────────────────── */

.tbl-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: .82rem; }

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: left;
  padding: 11px 14px;
  font-size: .67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--fg2);
  background: #101422;
  border-bottom: 1px solid var(--bg4);
  white-space: nowrap;
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--bg3);
  color: var(--fg);
  vertical-align: middle;
}

tbody tr { transition: background var(--tr); }
tbody tr:hover { background: rgba(99, 102, 241, .08); }
tbody tr:last-child td { border-bottom: none; }

/* Rows appear with a short stagger; capped so long pages stay snappy */
tbody tr.in { animation: fadeUp 260ms both; }

td.em {
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--acc2);
  font-weight: 500;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chk-col { width: 34px; }

input[type=checkbox] {
  width: 15px; height: 15px;
  accent-color: var(--acc);
  cursor: pointer;
}

.empty {
  text-align: center;
  padding: 42px 16px !important;
  color: var(--fg3);
  font-size: .8rem;
}

.row-acts { display: flex; gap: 5px; }

.pag {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 15px;
  border-top: 1px solid var(--bg3);
  font-size: .72rem;
  color: var(--fg3);
}

/* ── Badges ────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: .63rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  border: 1px solid transparent;
}
.badge.ok      { background: rgba(16, 185, 129, .13); color: var(--g);   border-color: rgba(16, 185, 129, .3); }
.badge.fail    { background: rgba(244, 63, 94, .13);  color: var(--r);   border-color: rgba(244, 63, 94, .3); }
.badge.ban     { background: rgba(244, 63, 94, .2);   color: #fda4af;    border-color: rgba(244, 63, 94, .42); }
.badge.run     { background: rgba(245, 158, 11, .13); color: var(--y);   border-color: rgba(245, 158, 11, .3); }
.badge.pending { background: var(--bg3);              color: var(--fg3); border-color: var(--bg4); }

/* Running badge gets a live shimmer so activity is obvious at a glance */
.badge.run.live {
  background-image: linear-gradient(90deg, transparent, rgba(245, 158, 11, .28), transparent);
  background-size: 180% 100%;
  animation: shimmer 1.7s linear infinite;
}

/* ── Forms ─────────────────────────────────────────────────── */

.f { margin-bottom: 12px; }
.f label {
  display: block;
  font-size: .68rem;
  color: var(--fg3);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .7px;
}
.f-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

input[type=text], input[type=number], input[type=password], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--rad);
  background: var(--bg);
  border: 1px solid var(--bg4);
  color: var(--fg);
  font-family: inherit;
  font-size: .82rem;
  transition: border-color var(--tr), box-shadow var(--tr);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--acc);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .14);
}
textarea { min-height: 108px; resize: vertical; font-family: var(--mono); font-size: .76rem; }
select { cursor: pointer; }

.chk { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.chk label { font-size: .78rem; color: var(--fg2); cursor: pointer; text-transform: none; letter-spacing: 0; margin: 0; }

/* ── Modals ────────────────────────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 4, 8, .74);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.overlay.show { display: flex; animation: fadeIn 160ms both; }

.modal {
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--bg2);
  border: 1px solid var(--bg4);
  border-radius: var(--rad3);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .6);
  animation: popIn 220ms cubic-bezier(.2, .9, .3, 1) both;
}
.modal.wide { max-width: 780px; }

.modal-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 18px;
  border-bottom: 1px solid var(--bg3);
}
.modal-h h3 { font-size: .95rem; font-weight: 600; }
.modal-h button {
  background: transparent;
  border: none;
  color: var(--fg3);
  font-size: 1.3rem;
  line-height: 1;
  padding: 0 5px;
}
.modal-h button:hover { color: var(--fg); background: transparent; }

.modal-b { padding: 18px; overflow-y: auto; flex: 1; }
.modal-f {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 13px 18px;
  border-top: 1px solid var(--bg3);
}

/* ── Logs ──────────────────────────────────────────────────── */

.logbox {
  font-family: var(--mono);
  font-size: .7rem;
  line-height: 1.65;
  background: var(--bg);
  border: 1px solid var(--bg3);
  border-radius: var(--rad);
  padding: 11px 13px;
  height: 340px;
  overflow-y: auto;
  color: var(--fg2);
}
.logbox div { animation: fadeIn 160ms both; word-break: break-word; }
.logbox .ok   { color: var(--g); }
.logbox .err  { color: var(--r); }
.logbox .warn { color: var(--y); }

.acc-log-row td { padding: 0 !important; background: var(--bg); }
.acc-log {
  font-family: var(--mono);
  font-size: .67rem;
  line-height: 1.6;
  padding: 9px 13px;
  overflow-y: auto;
  color: var(--fg2);
  border-left: 2px solid var(--acc);
}
.acc-log .ok { color: var(--g); }
.acc-log .err { color: var(--r); }
.acc-log .warn { color: var(--y); }

.arrow { display: inline-block; transition: transform var(--tr); }

/* ── Toasts ────────────────────────────────────────────────── */

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  min-width: 210px;
  max-width: 340px;
  padding: 10px 13px;
  border-radius: var(--rad);
  background: var(--bg-glass);
  border: 1px solid var(--bg4);
  border-left: 3px solid var(--acc);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  font-size: .76rem;
  color: var(--fg);
  animation: popIn 220ms both;
}
.toast.ok   { border-left-color: var(--g); }
.toast.err  { border-left-color: var(--r); }
.toast.warn { border-left-color: var(--y); }
.toast.out  { animation: fadeIn 180ms reverse both; }

/* ── Login ─────────────────────────────────────────────────── */

.login-box {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card {
  width: 100%;
  max-width: 330px;
  padding: 26px;
  background: var(--bg2);
  border: 1px solid var(--bg3);
  border-radius: var(--rad3);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
  animation: popIn 260ms both;
}
.login-card h2 { font-size: 1.05rem; margin-bottom: 4px; text-align: center; }
.login-card p { font-size: .74rem; color: var(--fg3); text-align: center; margin-bottom: 18px; }

/* ── Responsive ────────────────────────────────────────────── */

@media (max-width: 720px) {
  .f-row { grid-template-columns: 1fr; }

  .overlay { padding: 8px; align-items: flex-end; }
  .modal {
    max-width: none;
    max-height: 92vh;
    border-radius: var(--rad3) var(--rad3) 0 0;
  }
  .modal-h, .modal-f { padding-inline: 14px; }
  .modal-b { padding: 14px; }

  .pag { padding: 8px 10px; }
}

/* ── Relation icons ────────────────────────────────────────── */

.rel-icon {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  cursor: default;
  position: relative;
}
.rel-icon img {
  width: 14px;
  height: 14px;
  opacity: .7;
  transition: opacity var(--tr), transform var(--tr);
  vertical-align: -2px;
}
.rel-icon:hover img {
  opacity: 1;
  transform: scale(1.15);
}
.rel-icon .rel-tip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  border-radius: 5px;
  background: var(--bg);
  border: 1px solid var(--bg4);
  color: var(--fg2);
  font-size: .64rem;
  white-space: nowrap;
  z-index: 90;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .4);
  pointer-events: none;
}
.rel-icon:hover .rel-tip { display: block; animation: fadeIn 120ms both; }

/* ── App circles (Authorized App column) ───────────────────── */

.app-circles {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}
.app-circle {
  position: relative;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--tr), box-shadow var(--tr);
  cursor: default;
}
.app-circle:hover {
  transform: scale(1.18);
  z-index: 2;
}
.app-circle img {
  width: 14px;
  height: 14px;
  filter: brightness(1.2);
}
.app-circle.gh {
  background: linear-gradient(135deg, #e2e4ea, #c9ccd4);
  border: 1px solid #d1d5db;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
}
.app-circle.gh:hover { box-shadow: 0 0 12px rgba(0, 0, 0, .18); }
.app-circle.gh img { filter: none; }

.app-circle.cb {
  background: linear-gradient(135deg, #1a237e, #283593);
  border: 1px solid #3949ab;
  box-shadow: 0 2px 8px rgba(26, 35, 126, .3);
}
.app-circle.cb:hover { box-shadow: 0 0 12px rgba(57, 73, 171, .35); }

.app-circle.gg {
  background: linear-gradient(135deg, #1b1b2e, #252538);
  border: 1px solid #3a3a4e;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
}
.app-circle.gg:hover { box-shadow: 0 0 12px rgba(66, 133, 244, .25); }

.app-circle.none {
  background: var(--bg3);
  border: 1px dashed var(--bg4);
  opacity: .4;
}
.app-circle.none img { opacity: .3; filter: grayscale(1); }

.app-circle .rel-tip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 9px;
  border-radius: 5px;
  background: var(--bg);
  border: 1px solid var(--bg4);
  color: var(--fg2);
  font-size: .64rem;
  white-space: nowrap;
  z-index: 90;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
  pointer-events: none;
}
.app-circle:hover .rel-tip { display: block; animation: fadeIn 120ms both; }

.app-circle.nr {
  background: linear-gradient(135deg, #0d9488, #0f766e);
  border: 1px solid #14b8a6;
  box-shadow: 0 2px 8px rgba(13, 148, 136, .25);
}
.app-circle.nr:hover { box-shadow: 0 0 12px rgba(20, 184, 166, .35); }
.app-circle.nr img { filter: brightness(1.6); }

/* ── Stepper & Cost Summary ────────────────────────────────── */

.stepper-wrap {
  margin-top: 5px;
}
.stepper {
  display: flex;
  align-items: stretch;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--bg3);
  border-radius: var(--rad);
  padding: 3px;
}
.step-btn {
  background: var(--bg2);
  color: var(--fg);
  border: 1px solid var(--bg3);
  padding: 5px 11px;
  border-radius: calc(var(--rad) - 2px);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: background var(--tr), color var(--tr), border-color var(--tr);
}
.step-btn:hover {
  background: var(--bg4);
  color: var(--fg);
}
.step-btn.primary {
  background: var(--acc);
  color: #fff;
  border-color: var(--acc);
  font-weight: 700;
}
.step-btn.primary:hover {
  filter: brightness(1.15);
}
.step-input {
  flex: 1;
  text-align: center;
  font-family: var(--mono);
  font-size: .95rem;
  font-weight: 700;
  background: transparent !important;
  border: none !important;
  color: var(--fg);
  min-width: 48px;
  padding: 0;
  appearance: textfield;
  -moz-appearance: textfield;
}
.step-input::-webkit-outer-spin-button,
.step-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.cost-summary {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--bg3);
  border-radius: var(--rad);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cost-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .73rem;
}
.cost-row .lbl {
  color: var(--fg3);
}
.cost-row .val {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--fg2);
}
.cost-row .val.highlight {
  color: var(--acc);
  font-size: .84rem;
}
.cost-warning {
  margin-top: 4px;
  font-size: .68rem;
  font-weight: 600;
  color: var(--r);
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: calc(var(--rad) - 2px);
  padding: 5px 8px;
  text-align: center;
}
