@use '@taiga-ui/styles/utils' as taiga;

:root {
  color-scheme: light dark;
}

* {
  box-sizing: border-box;
}

h2 {
  line-height: unset;
}

ul {
  padding-left: 40px;
  list-style-type: disc;
}

:root {
  --bumper: 0.375rem;
}

.g-page {
  @include taiga.scrollbar-hidden();

  display: block;
  height: calc(100dvh - 3.875rem);
  padding: 1px 2rem 1rem;
  box-sizing: border-box;
  overflow: auto;
  isolation: isolate;
  backdrop-filter: blur(2rem);
  border-radius: 0.375rem;
  background-size: 1px 100%;
  background-repeat: no-repeat;
  background-position:
    top left,
    top right;

  // @TODO Theme
  background-color: color-mix(
    in hsl,
    var(--tui-background-base) 90%,
    transparent
  );
  background-image:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.1), transparent),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.1), transparent);
  box-shadow:
    0 0.25rem 0.125rem rgba(0, 0, 0, 0.25),
    0 0 0.5rem rgba(0, 0, 0, 0.3),
    inset 0 -1px rgba(0, 0, 0, 0.5),
    inset 0 1px rgba(255, 255, 255, 0.1);

  tui-root._mobile & {
    // For tui-tab-bar
    height: calc(100dvh - 3.875rem - var(--tui-height-l));
  }
}

.g-subpage {
  height: 100%;
  min-height: fit-content;
  flex: 1;
  padding: 1rem;

  &::after {
    content: '';
    display: block;
    height: 1rem;
  }
}

.g-aside {
  @include taiga.scrollbar-hidden();

  position: sticky;
  top: 1px;
  left: 1px;
  margin: 1px;
  width: 18rem;
  flex-shrink: 0;
  padding: 0.5rem;
  text-transform: capitalize;
  box-shadow: 1px 0 var(--tui-border-normal);
  background: var(--tui-background-base);
  overflow: auto;
}

.g-card {
  container: card / inline-size;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 3.25rem 1rem 0.375rem;
  border-radius: 0.5rem;
  overflow: hidden;
  color: var(--tui-text-primary);
  background-color: color-mix(in hsl, var(--start9-base-1) 50%, transparent);
  background-image:
    linear-gradient(to bottom, var(--tui-background-neutral-2), transparent),
    linear-gradient(to bottom, var(--tui-background-neutral-2), transparent);
  background-size: 1px 100%;
  background-repeat: no-repeat;
  background-position:
    top left,
    top right;
  box-sizing: border-box;
  box-shadow:
    0 0.25rem 0.125rem rgba(0, 0, 0, 0.25),
    0 -0.125rem 0.25rem rgba(55, 155, 255, 0.08),
    0 0 0.5rem rgba(0, 0, 0, 0.3),
    inset 0 -0.125rem rgba(255, 255, 255, 0.03),
    inset 0 2px rgba(255, 255, 255, 0.1),
    inset 0 1px rgba(255, 255, 255, 0.15),
    inset 0 0 1rem rgba(0, 0, 0, 0.25);

  &:is(form) {
    padding-top: 4rem;
  }

  tui-root:not(._mobile) &:has(.g-table) {
    padding-block-end: 1rem;

    > header {
      background: none;
    }
  }

  [tuiCell] {
    margin: 0 -0.625rem;
    border-radius: var(--tui-radius-s);

    &:not(:last-child)::after {
      content: '';
      position: absolute;
      top: 100%;
      left: 1rem;
      right: 1rem;
      height: 1px;
      background: var(--tui-background-neutral-1);
    }
  }

  > .g-table-service {
    margin: 0 -0.5rem;
  }

  > header {
    position: absolute;
    inset: 0 0 auto 0;
    height: 3rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0 1rem;
    font: var(--tui-typography-body-l);
    font-weight: bold;
    background: var(--tui-background-neutral-1);
  }

  > footer {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding: 1rem 0 0.5rem;
  }
}

.g-table {
  width: stretch;
  border: 1px solid var(--tui-background-neutral-1);
  border-collapse: collapse !important;
  border-radius: var(--tui-radius-s);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--tui-background-neutral-1);
  clip-path: inset(0 round var(--tui-radius-s));

  td,
  th {
    position: relative;
    font: var(--tui-typography-body-s);
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--tui-background-neutral-1);
    border-left: 0;
    border-right: 0;
    text-overflow: ellipsis;
  }

  th {
    background: var(--tui-background-neutral-1);
    font-weight: bold;
    text-align: left;
  }

  tr:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 0.125rem var(--tui-border-focus);
  }

  tui-root._mobile & {
    min-width: 0;
    border: none;
    box-shadow: none;
    border-radius: 0;
    color: var(--tui-text-secondary);

    thead {
      display: none;
    }

    tr {
      position: relative;
      display: grid;
      padding: 0.5rem 0;
      box-shadow: inset 0 -1px var(--tui-background-neutral-1);

      &:last-child {
        box-shadow: none;
      }
    }

    td,
    th {
      position: static;
      border: none;
      padding: 0;

      &:first-child {
        font: var(--tui-typography-body-m);
        font-weight: bold;
        color: var(--tui-text-primary);
      }

      &:not([tuiFade]) {
        overflow: hidden;
      }
    }
  }
}

.g-table-service {
  width: stretch;

  &:not(:has(tbody tr)) {
    display: none;
  }

  tr:not(:last-child) {
    box-shadow: inset 0 -1px var(--tui-background-neutral-1);
  }

  th {
    text-transform: uppercase;
    color: var(--tui-text-secondary);
    background: none;
    border: none;
    font: var(--tui-font-text-s);
    font-weight: bold;
    text-align: left;
    padding: 0 0.5rem;
  }

  td {
    padding: 0.5rem;
  }

  td:only-child {
    text-align: center;
    padding: 1rem;
  }

  tui-root._mobile & thead,
  &:has(app-placeholder) thead {
    display: none;
  }
}

.g-title {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-transform: uppercase;
  font-weight: bold;
  font-size: 1rem;
  line-height: 1.5rem;
  margin: 2rem 0 1rem;
  color: var(--tui-text-secondary);
}

.g-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 1.5rem;
}

.g-toggle {
  height: var(--tui-height-l);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  box-shadow: inset 0 0 0 1px var(--tui-background-neutral-1-hover);
  font: var(--tui-typography-body-l);
  font-weight: bold;
  border-radius: var(--tui-radius-m);

  input {
    margin-left: auto;
  }
}

.g-positive {
  color: var(--tui-status-positive) !important;
}

.g-warning {
  color: var(--tui-status-warning) !important;
}

.g-negative.g-negative {
  color: var(--tui-status-negative) !important;
}

.g-info {
  color: var(--tui-status-info) !important;
}

.g-primary {
  color: var(--tui-text-primary) !important;
}

.g-secondary {
  color: var(--tui-text-secondary) !important;
}

.g-stretch,
.g-table {
  width: stretch;
}

ng-component {
  display: block;
}

svg:not(:root) {
  overflow: auto;
}

.g-external-link {
  color: #50c8ff;
}

tui-root._mobile tui-action-bar {
  bottom: 4rem;
}
