@import url('src/framework/styles.css');
@import url('src/framework/anim.css');

:root {
  --background: #EEE;
  --color: #121212;
  --primary: #2F2F2F;
  --primary-dark: #1A1A1A;
  --primary-text: #EEE;
  --ripple: rgba(0, 0, 0, 0.5);
  --accent: #AC8F55;
  --middle: rgba(0, 0, 0, .5);
  --middle-light: rgba(255, 255, 255, .5);
  --low: rgba(0, 0, 0, .25);
  --low-light: rgba(255, 255, 255, .25);

  --font-size: 16px;
  --font: Inter;
  --round: 0em;
  --transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
  --margin: 8px;
  --item-height: 3.3rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  font-family: var(--font);
  background-color: var(--background);
  color: var(--color);
  font-size: var(--font-size);
}

#app {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

#app-content {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
}

#sidenav-callarea {
  position: absolute;
  top: 0;
  left: 0;
  width: 24px;
  height: 100%;
  z-index: 10;
  background: transparent;
  touch-action: none;
}

#sidenav-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

#sidenav-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

#sidenav {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 80%;
  background-color: var(--primary-dark);
  position: absolute;
  top: 0;
  left: 0;
  z-index: 100;

  transform: translateX(-100%);
  transition: var(--transition);
  will-change: transform;
}

#sidenav.open {
  transform: translateX(0);
  box-shadow: 10px 0 20px var(--middle);
}

#sidenav-content {
  display: flex;
  flex-direction: column;
  flex: 1 1;
  width: 100%;
  overflow-y: auto;
  color: var(--background);

  .item {
    display: flex;
    width: 100%;
    height: var(--item-height);
    align-items: center;
    transition: 200ms;

    img {
      width: 1.5em;
      margin: 0 var(--margin);
    }

    span {
      display: inline-block;
    }
  }

  .item:active {
    background-color: var(--low-light);
    transition: 0ms;
  }

  .item.selected {
    font-weight: bold;
    border-left: 4px solid var(--accent);
    background-color: var(--low);
  }
}

#sidenav-profilecard {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: auto;
  width: 100%;
  padding: 14px 0;
  color: var(--background);

  #sidenav-profilecard-name {
    font-weight: 400;
    font-size: 1.5rem;
  }

  #sidenav-profilecard-role {
    color: var(--accent);
    font-size: 0.9rem;
  }
}

#sidenav-profilecard-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100px;
  height: 100px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: #d69;
  color: #fff;
  font-size: 3rem;
  margin-bottom: .5rem;
}

/* =========================================================================
   СОСТОЯНИЯ БЛОКА СТАТУСА (#sidenav-status)
   ========================================================================= */
#sidenav-status {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 50;
  background-color: var(--primary-dark);
  color: var(--background);
  padding: 20px;
  text-align: center;
}

/* 1. Класс .hidden — полностью прячет перекрытие */
#sidenav-status.ready {
  display: none;
}

/* По умолчанию прячем внутренние элементы */
#sidenav-status-spinner,
#sidenav-status-error {
  display: none;
}

/* 2. Класс .loading — показываем спиннер */
#sidenav-status.loading #sidenav-status-spinner {
  display: block;
}

/* 3. Класс .error — показываем сообщение об ошибке */
#sidenav-status.error #sidenav-status-error {
  display: block;
  color: #ff6b6b;
}

.loading-spinner {
  --size: 60px;
  --stroke-width: calc(var(--size) / 8);
  --stroke-color: var(--background);

  display: block;
  width: var(--size);
  height: var(--size);
  border: var(--stroke-width) solid var(--stroke-color);
  border-top: var(--stroke-width) solid transparent;
  border-radius: 50%;
  animation: rotateR 1s linear infinite;
}

/* =========================================================================
   TOPNAV И РАБОЧАЯ ОБЛАСТЬ
   ========================================================================= */
.panel {
  display: flex;
  flex-direction: row;
  align-items: center;
  height: var(--item-height);
  width: 100%;
  background-color: var(--primary-dark);
  color: var(--background);

  button {
    appearance: none;
    outline: none;
    border: none;
    background-color: transparent;

    display: grid;
    place-items: center;
    width: var(--item-height);
    height: var(--item-height);
    transition: 200ms;

    &:active {
      background-color: var(--low-light);
      transition: 0ms;
    }

    img {
      width: 60%;
    }
  }
}

#activity-title {
  margin-left: var(--margin);
}

#activity-viewer {
  display: grid;
  place-items: center;
  width: 100%;
  flex: 1 1;
}

.disabled {
  pointer-events: none;
  opacity: .5;
  filter: brightness(.5);
}

#outside-overlay {
  display: grid;
  place-items: center;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 150;
}

#outside-overlay>* {
  pointer-events: auto;
}

.dialog {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 80%;
  height: auto;
  background-color: var(--primary);
  color: var(--primary-text);
  box-shadow: 4px 6px 20px var(--middle);

  .title {
    display: inline-block;
    padding: var(--margin);
    font-weight: bold;
    color: var(--accent);
  }

  .content {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    padding: var(--margin);
    min-height: var(--item-height);

    input {
      padding: 4px;
      border: 1px solid var(--middle-light);
      font-size: var(--font-size);
      color: var(--primary-text);

      &:focus {
        border-color: var(--primary-text);
      }
    }
  }

  .footer {
    display: flex;
    flex-direction: row;
    border-top: 1px solid #000;

    button {
      appearance: none;
      outline: none;
      border: none;
      background-color: transparent;
      border: .5px solid var(--low-light);

      color: var(--primary-text);
      font-family: var(--font);
      font-size: var(--font-size);

      display: grid;
      place-items: center;
      flex: 1 0;
      height: var(--item-height);
      transition: 200ms;

      &:active {
        background-color: var(--low-light);
        transition: 0ms;
      }
    }
  }

  .input-field {
    display: flex;
    align-items: center;
    height: var(--item-height);
    border-bottom: 1px solid var(--middle-light);

    .icon {
      opacity: 0.5;
      height: 50%;
      transition: opacity 0.2s;
    }

    input {
      appearance: none;
      outline: none;
      background: transparent;
      font-family: var(--font);
      font-size: var(--font-size);
      color: var(--middle-light);
      border: none;
      padding: var(--margin);
      flex: 1 1;
      width: 100%;
      box-sizing: border-box;

      &:focus {
        color: var(--primary-text);
        border-color: var(--primary-text)l;
      }
    }

    &:focus-within .icon {
      opacity: 1;
    }
  }

  .input-field:focus-within {
    border-color: var(--primary-text);
  }
}

.cover-overlay {
  display: grid;
  place-items: center;
  position: absolute;
  inset: 0;
  background-color: var(--low);
  transition: 200ms;
}

#login-form {
  z-index: 125;
}

#login-overlay {
  display: none;
  z-index: 120;
}

#dialog {
  z-index: 155;
}

#dialog-overlay {
  z-index: 150;
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 80%;
  height: auto;
  background-color: var(--primary);
  color: var(--primary-text);
  box-shadow: 4px 6px 20px var(--middle);
  padding: var(--margin);

  .title {
    display: inline-block;
    padding: var(--margin);
    font-weight: bold;
    color: var(--accent);
  }

  .loading-spinner {
    --size: 50px;
    margin-right: calc(var(--margin) * 2);
  }

  .content {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: var(--margin);
    min-height: var(--item-height);
  }
}