/* Main components */
:root {
  --main-fg: #333;
  --link-color: #2a77ba;
  --darker-link-color: lch(from var(--link-color) calc(l - 10) c h);
}

html {
  font-family: "Helvetica Neue", "Helvetica", "Arial", sans-serif;
  font-size: 14px;
  color: var(--main-fg);
  max-width: 100em;
  margin-left: auto;
  margin-right: auto;
}

body {
  margin-left: auto;
  margin-right: auto;
  padding-left: 2rem;
  padding-right: 2rem;
}

main {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

a {
  color: var(--link-color);
  text-decoration: none;
}
a:hover {
  color: var(--darker-link-color);
  text-decoration: underline;
}

a.button, button, input[type=submit], input[type=search], input[type=text], input[type=password], select {
  border-radius: 0.25rem;
  border: 1px solid #ccc;
  padding: 0.5rem 1rem;
}

select:hover {
  background: #ccc;
}

a.button, button, input[type=submit] {
  background: white;
  cursor: pointer;
}
a.button:hover, button:hover, input[type=submit]:hover {
  background: #eee;
}
a.button:active, button:active, input[type=submit]:active {
  background: #ddd;
}
a.button.disabled, a.button[disabled], button.disabled, button[disabled], input[type=submit].disabled, input[type=submit][disabled] {
  background-color: #eee;
  color: #555;
  cursor: default;
}

a.button {
  text-decoration: none;
  color: var(--main-fg);
  display: inline-block;
  user-select: none;
}

a.tag {
  padding: 0.3rem;
  border-radius: 0.3rem;
  background: var(--link-color);
  color: white;
}
a.tag i {
  margin-left: 0.5rem;
}
a.tag:hover {
  background: #37a;
  text-decoration: none;
}

button i:first-child {
  margin-right: 0.5rem;
}

dialog {
  display: none;
  gap: 1rem;
  padding: 1rem;
  flex-direction: column;
  align-items: stretch;
  border: 1px solid #aaa;
  border-radius: 3px;
  box-shadow: 2px 2px 7px rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
}
dialog:open {
  display: flex;
}
dialog h2 {
  margin: 0;
}
dialog.source-picker.include input + span {
  color: #333;
}
dialog.source-picker.include input:checked + span {
  color: black;
  font-weight: bold;
}
dialog.source-picker.exclude input + span {
  text-decoration: line-through;
}
dialog.source-picker.exclude input:checked + span {
  text-decoration: none;
}
dialog.source-picker button[command=close] {
  padding: 0.5em;
  float: right;
}
dialog.source-picker button[command=close] i {
  margin: 0;
}
dialog ul {
  padding: 0;
  list-style: none;
  margin: 0;
  column-rule: 1px solid lightgray;
}
dialog ul li {
  break-inside: avoid;
  text-indent: 1.5em hanging;
}
dialog ul ul {
  padding-left: 1em;
  margin-bottom: 1em;
}
dialog .buttons {
  display: flex;
  justify-content: space-between;
}
dialog .buttons .delete {
  color: white;
  background: #ce2e2e;
  border-color: #951e1e;
}

/* Header */
.headers {
  display: flex;
  justify-content: space-between;
}

header.login-info {
  text-align: right;
  margin-top: 0.3em;
}

.logout {
  margin-bottom: 1em;
}

/* Log in page */
#login-form {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  max-width: 400px;
  margin: 0 auto;
}
#login-form p {
  text-align: center;
}
#login-form #login-error {
  background: #ffcccc;
  color: #521;
  border-radius: 0.25rem;
  border: 1px solid #ca9;
  padding: 1rem;
}
#login-form input[type=submit] {
  background: var(--link-color);
  color: #fff;
}
#login-form input[type=submit]:hover {
  background: #5ad;
}

/* Country selection page */
#country-picker {
  align-items: center;
}
#country-picker ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Table and friends */
.main-table-header {
  display: flex;
  justify-content: space-between;
}
.main-table-header input {
  min-width: 30rem;
}
.main-table-header label {
  margin-left: 1rem;
  margin-right: 0.5rem;
}

.second-row {
  width: 100%;
  position: relative;
}
.second-row a {
  padding: 0.4rem 0.6rem;
  font-size: 1rem;
}
.second-row .new-agent-wrapper {
  position: absolute;
  right: 0px;
  top: 0px;
}
.second-row form.search {
  position: absolute;
  left: 0px;
  top: 0px;
}

.pagination, .small-pagination {
  --gap: 0.5rem;
  display: flex;
  gap: var(--gap);
  align-items: center;
  justify-content: center;
}
.pagination a, .small-pagination a {
  padding: 0.4rem 0.8rem;
}

.pagination {
  --numbtn-width: 2.2rem;
  --spacer-width: 1rem;
}
.pagination .spacer {
  display: inline-block;
  width: var(--spacer-width);
  text-align: center;
}
.pagination .left-buttons, .pagination .right-buttons {
  width: calc(var(--numbtn-width) * 2 + 4px + var(--gap) * 2 + var(--spacer-width));
  display: flex;
  align-items: baseline;
  gap: var(--gap);
}
.pagination .left-buttons {
  justify-content: end;
}
.pagination .button.numbtn {
  padding-left: 0;
  padding-right: 0;
  width: var(--numbtn-width);
  text-align: center;
}
.pagination .button.current-page {
  font-weight: bold;
  border-color: var(--darker-link-color);
  cursor: default;
}
.pagination .button.current-page, .pagination .button.current-page:hover {
  color: white;
  background-color: var(--link-color);
}

.small-pagination {
  display: none;
}

table {
  width: 100%;
  border-collapse: collapse;
}
table th {
  text-align: left;
  border-bottom: 2px solid;
  white-space: nowrap;
}
table th i {
  color: #555;
  margin-left: 0.3rem;
}
table th:first-child {
  width: 40%;
}
table th:nth-child(2) {
  width: 25%;
}
table th:nth-child(5) {
  width: 2.5em;
}
table th:last-child {
  width: 1em;
}
table td {
  border-top: 1px solid;
}
table th, table td {
  padding: 0.7rem 0.8rem;
  border-color: #c9c9c9;
}
table th:nth-child(5), table td:nth-child(5) {
  text-align: right;
}
table i.fa-user {
  margin-right: 0.5rem;
  color: var(--main-fg);
}
table i.fa-user.customer-paying {
  color: #0c0;
}
table a {
  cursor: pointer;
}

table#search-table th:first-child {
  width: 30%;
}
table#search-table th:nth-child(2) {
  width: auto;
}
table#search-table th:last-child {
  width: 1em;
}

/* Agents page */
.source-selection-dialog {
  display: none;
}
.source-selection-dialog:open {
  display: unset;
}
.source-selection-dialog ul {
  list-style: none;
}

.icon-button {
  padding: 0.1em 0.3em;
  border: 0;
}
.icon-button i {
  margin: 0 !important;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 0.3em;
}

#save-reminder {
  color: #6a4d24;
  background-color: #fcf8e3;
  border: 1px solid #faebcc;
  padding: 1rem;
  margin-bottom: 1rem;
  margin-top: 1rem;
  border-radius: 0.2rem;
}

main.agents-page {
  display: flex;
  align-items: start;
  flex-direction: row;
}
main.agents-page #main-column {
  display: flex;
  gap: 0.5rem;
  flex-direction: column;
}
main.agents-page section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 0.5rem;
  padding: 1rem;
}
main.agents-page #editor-box {
  grid-column-start: 1;
  grid-row-start: 1;
}
main.agents-page #editor-box textarea {
  display: block;
  width: 100%;
  height: 8em;
}
main.agents-page #editor-box label {
  font-weight: bold;
  display: block;
}
main.agents-page #source-list {
  grid-row: 1/span 2;
  user-select: none;
}
main.agents-page #source-list summary {
  cursor: pointer;
}
main.agents-page #source-list li {
  margin: 0.3rem;
}
main.agents-page #source-list li label {
  cursor: pointer;
}
main.agents-page #source-list li label.inactive {
  font-style: italic;
  color: gray;
}
main.agents-page #source-list li .select-all, main.agents-page #source-list li .clear-selection {
  cursor: pointer;
}
main.agents-page #result-box .hit + .hit {
  padding-top: 0.5rem;
  border-top: 1px solid #ddd;
}
main.agents-page #result-box p {
  margin: 0.1rem 0;
}
main.agents-page #result-box blockquote {
  white-space: pre-line;
  margin: 0;
}
main.agents-page #result-box .test-verdict {
  margin-bottom: 0.5rem;
}
main.agents-page #result-box .test-verdict i {
  margin-right: 0.5rem;
}
main.agents-page #result-box .test-verdict.ok i {
  color: #2b8a3e;
}
main.agents-page #result-box .test-verdict.failed {
  color: #a12b2b;
}
main.agents-page #result-box .parse-message .position {
  color: #555;
  white-space: nowrap;
}
main.agents-page #result-box .code-frame {
  overflow-x: auto;
  margin: 0.5rem 0 0;
  line-height: 1.3;
}
main.agents-page #result-box .code-frame .gutter {
  display: inline-block;
  width: 3ch;
  margin-right: 1ch;
  padding-right: 1ch;
  border-right: 1px solid #ddd;
  color: #999;
  text-align: right;
}
main.agents-page #result-box .code-frame mark {
  display: inline-block;
  min-width: 1ch;
  background: #ffd9d9;
}
main.agents-page #result-box .code-frame .ghost {
  color: transparent;
}
main.agents-page #result-box .code-frame .carets {
  color: #a12b2b;
  font-weight: bold;
}
main.agents-page #help-column {
  max-width: 22rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
main.agents-page #help-column h4 {
  margin-top: 0.2rem;
  margin-bottom: 0.1rem;
}
main.agents-page #help-column p, main.agents-page #help-column pre {
  margin-top: 0.1rem;
  margin-bottom: 0.1rem;
}
main.agents-page #help-column code, main.agents-page #help-column pre {
  background: #f4f4f8;
  border: 1px solid #e2e2ea;
  border-radius: 0.1rem;
}
main.agents-page #help-column pre {
  white-space: pre-line;
  padding: 0.2rem;
}
main.agents-page #help-column code {
  padding: 0 0.1rem;
}
main.agents-page ul {
  list-style: none;
  padding-left: 1rem;
  margin: 0;
}
main.agents-page h3 {
  padding: 0;
  margin: 0;
}
main.agents-page button.copy-link {
  margin-left: 0.5rem;
  font-size: 90%;
  padding: 0.3em 0.5em;
}
main.agents-page .button-list {
  display: flex;
  gap: 0.3rem;
}
main.agents-page .button-list button {
  text-align: center;
  vertical-align: middle;
}
main.agents-page #source-list ul {
  margin-left: 0;
  padding: 0;
}
main.agents-page #source-list label {
  font-size: 120%;
}
main.agents-page #source-list li, main.agents-page #source-list label {
  white-space: nowrap;
}
main.agents-page #source-list li[data-catid] {
  display: flex;
  align-items: anchor-center;
  justify-content: space-between;
  gap: 1em;
}
main.agents-page #source-list button.edit {
  padding: 0.4em;
}
main.agents-page #source-list button.edit.include i {
  color: green;
}
main.agents-page #source-list button.edit.exclude i {
  color: red;
}

.hidden {
  display: none !important;
}

@media (max-width: 768px) {
  .pagination {
    display: none;
  }
  .small-pagination {
    display: flex;
  }
  table th, table td {
    padding: 0.3rem 0.5rem;
  }
}
