/* ============================================================
   Components: buttons, tables, cards, tabs, forms, menus, etc.
   ============================================================ */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px;
  padding: 0 16px;
  border-radius: 4px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .25px;
  white-space: nowrap;
  transition: background .15s, box-shadow .15s;
  user-select: none;
}
.btn-primary {
  background: var(--g-blue); color: #fff;
  text-transform: uppercase; font-size: 13px; letter-spacing: .75px;
}
.btn-primary:hover { background: var(--g-blue-hover); box-shadow: var(--shadow-1); }
.btn-primary:active { background: var(--g-blue-active); }
.btn-primary:disabled { background: #f1f3f4; color: #9aa0a6; box-shadow: none; }
.btn-outline {
  border: 1px solid var(--g-border); color: var(--g-blue);
  text-transform: uppercase; font-size: 13px; letter-spacing: .75px;
  background: #fff;
}
.btn-outline:hover { background: #f6fafe; border-color: var(--g-border); }
.btn-outline:disabled { color: #9aa0a6; border-color: #e8eaed; }
.btn-text {
  color: var(--g-blue);
  text-transform: uppercase; font-size: 13px; letter-spacing: .75px;
  padding: 0 12px;
}
.btn-text:hover { background: #f6fafe; }
.btn-text:disabled { color: #9aa0a6; }
.btn-text.gray { color: var(--g-text-2); }
.btn-text.gray:hover { background: var(--g-bg-hover); }
.btn .ms { font-size: 18px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--g-text-2);
  flex: none;
}
.icon-btn:hover { background: var(--g-bg-hover); color: var(--g-text); }
.icon-btn:disabled { color: #bdc1c6; background: none; }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.sm .ms { font-size: 20px; }

/* ---------- Page scaffolding ---------- */
.page-pad { padding: 24px 40px 48px; max-width: 1600px; }
.page-head { display: flex; align-items: center; gap: 16px; margin-bottom: 4px; flex-wrap: wrap; }
.page-title { font-size: 20px; font-weight: 400; font-family: var(--font-display); }
.page-sub { color: var(--g-text-2); font-size: 14px; margin: 4px 0 0; }
.crumbs { display: flex; align-items: center; gap: 4px; color: var(--g-text-2); font-size: 14px; flex-wrap: wrap; }
.crumbs a { color: var(--g-text-2); }
.crumbs a:hover { color: var(--g-text); text-decoration: none; }
.crumbs .ms { font-size: 18px; color: var(--g-text-3); }
.crumbs .cur { color: var(--g-text); font-weight: 500; }

/* ---------- Cards ---------- */
.card {
  background: #fff;
  border: 1px solid var(--g-border-light);
  border-radius: 8px;
  transition: box-shadow .15s;
}
.card.hoverable:hover { box-shadow: var(--shadow-1); }
.card .card-head {
  padding: 16px 20px 8px;
  display: flex; align-items: center; gap: 8px;
}
.card .card-title { font-family: var(--font-display); font-size: 16px; font-weight: 500; flex: 1; }
.card .card-body { padding: 8px 20px 20px; }
.card .card-foot { padding: 8px 20px 16px; border-top: 1px solid var(--g-border-light); }

/* ---------- Tables ---------- */
.table-card {
  border: 1px solid var(--g-border-light);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.gtable-wrap { overflow-x: auto; }
table.gtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.gtable th {
  text-align: left;
  font-weight: 500;
  color: var(--g-text-2);
  height: 44px;
  padding: 0 16px 0 0;
  border-bottom: 1px solid var(--g-border-light);
  white-space: nowrap;
  user-select: none;
}
.gtable th:first-child, .gtable td:first-child { padding-left: 16px; }
.gtable th:last-child, .gtable td:last-child { padding-right: 16px; }
.gtable th.sortable { cursor: pointer; }
.gtable th.sortable:hover { color: var(--g-text); }
.gtable th .sort-arrow { font-size: 16px; vertical-align: -3px; margin-left: 2px; }
.gtable td {
  height: 52px;
  padding: 6px 16px 6px 0;
  border-bottom: 1px solid var(--g-border-light);
  vertical-align: middle;
  max-width: 320px;
}
.gtable tbody tr { transition: background .1s; }
.gtable tbody tr:hover { background: var(--g-bg-subtle); }
.gtable tbody tr.selected { background: var(--g-blue-light); }
.gtable tbody tr:last-child td { border-bottom: none; }
.gtable .cell-main { font-weight: 500; color: var(--g-blue); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gtable .cell-main:hover { text-decoration: underline; }
.gtable .cell-sub { color: var(--g-text-2); font-size: 12px; margin-top: 2px; }
.gtable .muted { color: var(--g-text-2); }
.gtable .nowrap { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gtable .rowmenu { opacity: 0; }
.gtable tr:hover .rowmenu { opacity: 1; }
.gtable .copy-btn { opacity: 0; transition: opacity .1s; }
.gtable tr:hover .copy-btn, .gtable .copy-btn:focus-visible { opacity: 1; }

/* filter bar above tables */
.table-toolbar {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 12px;
  flex-wrap: wrap;
}
.table-toolbar .spacer { flex: 1; }
.filter-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--g-border-light);
  flex-wrap: wrap;
}
.filter-input {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--g-border);
  border-radius: 4px;
  height: 36px;
  padding: 0 10px;
  flex: 1; max-width: 560px; min-width: 200px;
}
.filter-input:focus-within { border-color: var(--g-blue); box-shadow: 0 0 0 1px var(--g-blue); }
.filter-input input { border: none; outline: none; width: 100%; font-size: 13px; }
.filter-input .ms { color: var(--g-text-3); font-size: 20px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--g-blue-light);
  color: var(--g-blue);
  border-radius: 4px;
  height: 28px;
  padding: 0 6px 0 10px;
  font-size: 12px;
  font-weight: 500;
}
.filter-chip .x { display: inline-flex; border-radius: 50%; padding: 2px; }
.filter-chip .x:hover { background: rgba(26,115,232,.15); }
.filter-chip .x .ms { font-size: 14px; }

/* pagination */
.table-foot {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 8px;
  padding: 6px 8px;
  color: var(--g-text-2);
  font-size: 12px;
  border-top: 1px solid var(--g-border-light);
}

/* status icons */
.status-ic { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; }
.status-ic .ms { font-size: 18px; }
.status-ic.green { color: var(--g-green); }
.status-ic.gray { color: #9aa0a6; }
.status-ic.red { color: var(--g-red); }
.status-ic.yellow { color: var(--g-yellow); }
.status-ic.blue { color: var(--g-blue); }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--g-blue-light);
  border-top-color: var(--g-blue);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.spinner.green { border-color: var(--g-green-light); border-top-color: var(--g-green); }
@keyframes spin { to { transform: rotate(360deg); } }
.badge-pill {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 12px; padding: 2px 10px;
  font-size: 12px; font-weight: 500;
  background: var(--g-bg-hover); color: var(--g-text-2);
}
.badge-pill.green { background: var(--g-green-light); color: var(--g-green); }
.badge-pill.red { background: var(--g-red-light); color: var(--g-red); }
.badge-pill.blue { background: var(--g-blue-light); color: var(--g-blue); }
.badge-pill.yellow { background: var(--g-yellow-light); color: #b06000; }

/* checkboxes / radios / toggle */
.gcheck { display: inline-flex; align-items: center; cursor: pointer; user-select: none; }
.gcheck input { display: none; }
.gcheck .box {
  width: 18px; height: 18px;
  border: 2px solid var(--g-text-2);
  border-radius: 2px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .12s;
  background: #fff;
}
.gcheck .box .ms { font-size: 14px; color: #fff; opacity: 0; font-weight: 700; }
.gcheck input:checked + .box { background: var(--g-blue); border-color: var(--g-blue); }
.gcheck input:checked + .box .ms { opacity: 1; }
.gcheck input:focus-visible + .box { outline: 2px solid var(--g-blue); outline-offset: 2px; }
.gcheck .lbl { margin-left: 10px; font-size: 14px; }

.gradio { display: inline-flex; align-items: center; cursor: pointer; }
.gradio input { display: none; }
.gradio .dot {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--g-text-2);
  display: inline-flex; align-items: center; justify-content: center;
}
.gradio .dot::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: transparent; }
.gradio input:checked + .dot { border-color: var(--g-blue); }
.gradio input:checked + .dot::after { background: var(--g-blue); }
.gradio .lbl { margin-left: 10px; }

.gtoggle { display: inline-flex; align-items: center; cursor: pointer; }
.gtoggle input { display: none; }
.gtoggle .track {
  width: 34px; height: 14px; border-radius: 7px; background: #bdc1c6;
  position: relative; transition: background .15s;
  flex: none;
}
.gtoggle .lbl { overflow: visible; }
.gtoggle .track::after {
  content: ''; position: absolute; top: -3px; left: -2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-1);
  transition: left .15s, background .15s;
}
.gtoggle input:checked + .track { background: #a8c7fa; }
.gtoggle input:checked + .track::after { left: 16px; background: var(--g-blue); }
.gtoggle .lbl { margin-left: 10px; }

/* ---------- Inputs ---------- */
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--g-text); }
.field .hint { font-size: 12px; color: var(--g-text-2); margin-top: 4px; line-height: 1.4; }
.field .err { font-size: 12px; color: var(--g-red); margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.field .err .ms { font-size: 16px; }
.ginput, .gselect, textarea.ginput {
  width: 100%;
  height: 40px;
  border: 1px solid var(--g-border);
  border-radius: 4px;
  padding: 0 12px;
  font-size: 14px;
  outline: none;
  background: #fff;
}
textarea.ginput { height: auto; padding: 10px 12px; resize: vertical; }
.ginput:focus, .gselect:focus { border-color: var(--g-blue); box-shadow: 0 0 0 1px var(--g-blue); }
.ginput.error { border-color: var(--g-red); box-shadow: 0 0 0 1px var(--g-red); }
.ginput::placeholder { color: var(--g-text-3); }
.ginput:disabled { background: var(--g-bg-subtle); color: var(--g-text-3); }

/* ---------- Tabs ---------- */
.gtabs {
  display: flex; align-items: center;
  border-bottom: 1px solid var(--g-border-light);
  gap: 0;
  overflow-x: auto;
}
.gtab {
  height: 48px;
  padding: 0 20px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  color: var(--g-text-2);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .3px;
  display: inline-flex; align-items: center;
}
.gtab:hover { color: var(--g-blue); background: #f6fafe; }
.gtab.active { color: var(--g-blue); border-bottom-color: var(--g-blue); }

/* ---------- Menus (dropdown) ---------- */
.menu {
  position: fixed;
  background: #fff;
  border-radius: 4px;
  box-shadow: var(--shadow-2);
  min-width: 176px;
  padding: 6px 0;
  z-index: 560;
  animation: menu-in .12s ease-out;
}
@keyframes menu-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.menu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  color: var(--g-text);
  white-space: nowrap;
}
.menu-item:hover { background: var(--g-bg-subtle); }
.menu-item.danger { color: var(--g-red); }
.menu-item.disabled { color: var(--g-text-3); cursor: default; }
.menu-item.disabled:hover { background: none; }
.menu-item .ms { font-size: 20px; color: var(--g-text-2); }
.menu-item.danger .ms { color: var(--g-red); }
.menu-item .sub { margin-left: auto; color: var(--g-text-3); font-size: 12px; }
.menu-divider { height: 1px; background: var(--g-border-light); margin: 6px 0; }
.menu-head { padding: 8px 16px 4px; font-size: 12px; color: var(--g-text-2); font-weight: 500; }

/* ---------- Banners ---------- */
.banner {
  display: flex; align-items: flex-start; gap: 12px;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 16px;
}
.banner .ms { font-size: 20px; flex: none; margin-top: 1px; }
.banner.error { background: var(--g-red-light); color: var(--g-red); }
.banner.info { background: var(--g-blue-light); color: #174ea6; }
.banner.warn { background: var(--g-yellow-light); color: #b06000; }
.banner .banner-act { margin-left: auto; flex: none; font-weight: 500; text-transform: uppercase; font-size: 12px; letter-spacing: .5px; padding: 4px 8px; border-radius: 4px; }
.banner.error .banner-act { color: var(--g-red); }
.banner .banner-act:hover { background: rgba(0,0,0,.06); }

/* ---------- Skeletons ---------- */
@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
.skel {
  background: linear-gradient(90deg, #f1f3f4 25%, #e8eaed 37%, #f1f3f4 63%);
  background-size: 800px 100%;
  animation: shimmer 1.3s infinite linear;
  border-radius: 4px;
}
.skel-row { display: flex; align-items: center; gap: 16px; height: 52px; padding: 0 16px; border-bottom: 1px solid var(--g-border-light); }
.skel-row .skel { height: 14px; }

/* ---------- Progress ---------- */
.linear-progress {
  height: 4px; background: var(--g-blue-light); border-radius: 2px; overflow: hidden; position: relative;
}
.linear-progress .lp-bar {
  position: absolute; top: 0; bottom: 0; background: var(--g-blue); border-radius: 2px;
  transition: width .3s ease;
}
.linear-progress.indeterminate .lp-bar {
  width: 40%;
  animation: lp-ind 1.4s infinite ease-in-out;
}
@keyframes lp-ind {
  0% { left: -40%; } 100% { left: 110%; }
}

/* ---------- Empty states ---------- */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 64px 24px; text-align: center;
}
.empty-state .es-ic {
  width: 120px; height: 120px; border-radius: 50%;
  background: var(--g-bg-subtle);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}
.empty-state .es-ic .ms { font-size: 56px; color: #bdc1c6; }
.empty-state .es-title { font-family: var(--font-display); font-size: 16px; font-weight: 500; margin-bottom: 6px; }
.empty-state .es-sub { color: var(--g-text-2); font-size: 13px; max-width: 420px; line-height: 1.5; }

/* ---------- Definition lists / detail panels ---------- */
.dl { display: grid; grid-template-columns: 240px 1fr; row-gap: 2px; font-size: 13px; }
.dl dt { color: var(--g-text-2); padding: 6px 0; }
.dl dd { padding: 6px 0; overflow-wrap: break-word; }
.copy-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-mono); font-size: 12px;
}
.copy-chip .icon-btn { width: 28px; height: 28px; }
.copy-chip .icon-btn .ms { font-size: 16px; }

/* ---------- Tooltip ---------- */
.gtip {
  position: fixed;
  background: #202124;
  color: #fff;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 4px;
  z-index: 700;
  pointer-events: none;
  max-width: 280px;
  animation: menu-in .1s;
}

/* ---------- Segmented ---------- */
.seg { display: inline-flex; border: 1px solid var(--g-border); border-radius: 4px; overflow: hidden; }
.seg button {
  height: 32px; padding: 0 14px; font-size: 13px; color: var(--g-text-2); font-weight: 500;
  border-right: 1px solid var(--g-border);
}
.seg button:last-child { border-right: none; }
.seg button.on { background: var(--g-blue-light); color: var(--g-blue); }
.seg button:hover:not(.on) { background: var(--g-bg-subtle); }
