/* ZebraSeek styles */

* {
  box-sizing: border-box;
  font-family: "IBM Plex Sans JP", "Noto Sans JP", sans-serif;
}

html {
  overscroll-behavior-x: none;
}

body {
  margin: 0;
  height: 100vh;
  height: -webkit-fill-available;
  overflow-y: hidden;
  color: #2A3356;
}

i {
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* sidebar */
.sidebar {
  position: fixed;
  left: 0;
  top: 60px;
  bottom: 0;
  width: 40px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #EBEBEB;
  border-right: 1px solid #DBDBDB;
  padding: 10px 4px;
  z-index: 99;
  overflow: hidden;
  transition: all 0.5s ease;
}

body.is-logged-in {
  --sidebar-open-width: 240px;
  --history-title-fade: 20px;
  --history-title-tooltip-padding: 4px;
  --history-title-tooltip-border-width: 1px;
}

/* 省略テキストの hover 全文ツールチップ（info / quota と同系統） */
.overflow-text-tooltip {
  position: fixed;
  z-index: 1200;
  box-sizing: border-box;
  padding: var(--history-title-tooltip-padding, 4px);
  border-radius: 4px;
  border: var(--history-title-tooltip-border-width, 1px) solid #CECECE;
  background: #FFF;
  box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.25);
  overflow-wrap: anywhere;
  white-space: normal;
}

.sidebar.open {
  width: var(--sidebar-open-width);
  padding: 10px 6px;
}

.sidebar .sidebar-menu {
  height: 30px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  border-radius: 4px;

  &:not(.title) {
    cursor: pointer;

    &:hover {
      background: #F5F5F5;
    }
  }

  &.title {
    cursor: pointer;
  }

  &.details {
    width: 32px;
    margin-left: auto;
  }

  &.history {
    height: 32px;
    min-width: 0;
    padding: 0 6px 0 30px;
  }

  &.history.is-menu-open {
    background: #F5F5F5;
  }

  &.selected {
    font-weight: 700;
  }
}

.sidebar button.sidebar-menu.title {
  width: fit-content;
  max-width: 100%;
  padding-right: 0;
}

.sidebar .sidebar-history-chevron {
  flex-shrink: 0;
  display: block;
  width: 12px;
  height: 7px;
  max-width: 0;
  margin-left: 0;
  opacity: 0;
  color: #707790;
  background-color: currentColor;
  mask: url("/static/zebraseek/images/icon/chevron_down.svg") no-repeat center / contain;
  -webkit-mask: url("/static/zebraseek/images/icon/chevron_down.svg") no-repeat center / contain;
  transition: transform 0.3s ease, color 0.3s ease, max-width 0.4s, margin-left 0.4s, opacity 0.4s;
}

.sidebar.open .sidebar-history-chevron {
  max-width: 12px;
  margin-left: 12px;
  opacity: 1;
}

.sidebar:not(.is-history-open) .sidebar-history-chevron {
  transform: rotate(-90deg);
}

.sidebar .nav-list,
.sidebar .history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 0;
}

.sidebar .nav-list {
  flex-shrink: 0;
}

.sidebar .history-collapse {
  display: grid;
  grid-template-rows: 0fr;
  flex: 1;
  min-height: 0;
  transition: grid-template-rows 0.3s ease;
}

.sidebar.is-history-open .history-collapse {
  grid-template-rows: 1fr;
}

@media (prefers-reduced-motion: reduce) {
  .sidebar .sidebar-history-chevron,
  .sidebar .history-collapse {
    transition: none;
  }
}

.sidebar .history-collapse-inner {
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.sidebar .history-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.sidebar:not(.open) .history-list {
  overflow: hidden;
}

.sidebar .history-list-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  height: 32px;
}

.sidebar .history-list > .history-list-loading.is-initial {
  flex: 1;
  height: auto;
  min-height: 32px;
}

.sidebar .history-list-loading img {
  display: block;
  animation: sidebar-history-loading-spin 0.9s linear infinite;
}

@keyframes sidebar-history-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

.sidebar li a {
  text-decoration: none;
  color: inherit;

  &:hover,
  &:focus,
  &:visited,
  &:active {
    color: inherit;
  }
}

.sidebar li .sidebar-menu.title {
  max-width: 0;
  transition: 0.4s;
}

.sidebar.open li .sidebar-menu.title {
  max-width: 100%;
}

.sidebar li .menu_name {
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  margin-left: 0;
  transition: 0.4s;
}

.sidebar.open li .menu_name {
  max-width: 100%;
  pointer-events: auto;
  font-size: 15px;
  margin-left: 8px;
  display: inline-block;

  &.history {
    flex: 1 1 auto;
    font-size: 14px;
    margin-left: 0;
    min-width: 0;
  }
}

.sidebar .history-more-button {
  display: none;
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  margin-left: 10px;
  padding: 0;
  border: 0;
  border-radius: 0;
  appearance: none;
  background-color: #707790;
  cursor: pointer;
  -webkit-mask: url("/static/zebraseek/images/icon/three_point_leader.svg") no-repeat center / 14px 14px;
  mask: url("/static/zebraseek/images/icon/three_point_leader.svg") no-repeat center / 14px 14px;
}

.sidebar.open .sidebar-menu.history:hover > .history-more-button,
.sidebar.open .sidebar-menu.history.is-menu-open > .history-more-button {
  display: block;
}

.sidebar .history-more-button:hover {
  background-color: #2A3356;
}

.history-action-menu {
  position: fixed;
  z-index: 200;
  border-radius: 4px;
  background: #F5F5F5;
  box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.25);
  padding: 6px;
  visibility: hidden;
}

.history-action-menu.is-ready {
  visibility: visible;
}

.history-action-delete {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: -4px;
  padding: 4px;
  border: 0;
  border-radius: 4px;
  appearance: none;
  background: transparent;
  color: #2A3356;
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
  line-height: 14px;
  white-space: nowrap;
  cursor: pointer;

  &:hover {
    background: #EBEBEB;
  }
}

.history-action-delete img {
  display: block;
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
}

.sidebar .history-title-text {
  display: inline-block;
  white-space: nowrap;
}

/* 見切れている端だけをぼかして切り落とす。マスクは表示枠に合わせ、表示幅自体は変えない。 */
.sidebar.open li .menu_name.history.is-fade-left,
.sidebar.open li .menu_name.history.is-fade-right {
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-position: 0 0;
  mask-position: 0 0;
}

.sidebar.open li .menu_name.history.is-fade-right:not(.is-fade-left) {
  -webkit-mask-image: linear-gradient(
    to right,
    #000 calc(100% - var(--history-title-fade)),
    rgba(0, 0, 0, 0.45) calc(100% - var(--history-title-fade) * 0.35),
    transparent
  );
  mask-image: linear-gradient(
    to right,
    #000 calc(100% - var(--history-title-fade)),
    rgba(0, 0, 0, 0.45) calc(100% - var(--history-title-fade) * 0.35),
    transparent
  );
}

.sidebar.open li .menu_name.history.is-fade-left:not(.is-fade-right) {
  -webkit-mask-image: linear-gradient(
    to right,
    transparent,
    rgba(0, 0, 0, 0.45) calc(var(--history-title-fade) * 0.35),
    #000 var(--history-title-fade)
  );
  mask-image: linear-gradient(
    to right,
    transparent,
    rgba(0, 0, 0, 0.45) calc(var(--history-title-fade) * 0.35),
    #000 var(--history-title-fade)
  );
}

.sidebar.open li .menu_name.history.is-fade-left.is-fade-right {
  -webkit-mask-image: linear-gradient(
    to right,
    transparent,
    rgba(0, 0, 0, 0.45) calc(var(--history-title-fade) * 0.35),
    #000 var(--history-title-fade),
    #000 calc(100% - var(--history-title-fade)),
    rgba(0, 0, 0, 0.45) calc(100% - var(--history-title-fade) * 0.35),
    transparent
  );
  mask-image: linear-gradient(
    to right,
    transparent,
    rgba(0, 0, 0, 0.45) calc(var(--history-title-fade) * 0.35),
    #000 var(--history-title-fade),
    #000 calc(100% - var(--history-title-fade)),
    rgba(0, 0, 0, 0.45) calc(100% - var(--history-title-fade) * 0.35),
    transparent
  );
}

.home-section {
  position: fixed;
  top: 0;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  transition: all 0.5s ease;
  z-index: 2;
}

.home-section .common-nav-container {
  width: 100%;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  border-bottom: 1px solid #DDD;
}

.home-section .text {
  display: inline-block;
  color: #11101d;
  font-size: 25px;
  font-weight: 500;
  margin: 18px;
}

.main-content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  width: 100%;
  overflow-y: auto;
}

/* ログイン時: サイドバー幅を除いた残り領域にコンテンツを配置（PC） */
body.is-logged-in .main-content {
  padding-left: 40px;
  transition: padding-left 0.5s ease;
}

body.is-logged-in.sidebar-open .main-content {
  padding-left: var(--sidebar-open-width);
}

/* タブレット以下: サイドバーはオーバーレイ（開いてもコンテンツ幅は変えない） */
@media (max-width: 1024px) {
  body.is-logged-in .main-content,
  body.is-logged-in.sidebar-open .main-content {
    padding-left: 40px;
  }

  .sidebar.open {
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.12);
  }

  .sidebar-backdrop {
    position: fixed;
    left: 0;
    right: 0;
    top: 60px;
    bottom: 0;
    z-index: 98;
    background: rgba(0, 0, 0, 0.25);
  }
}

/* landing (未ログイン) */
.landing {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100%;
  padding: 100px 40px;
}

.landing-inner {
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 100%;
  max-width: 600px;
  line-height: 24px;
  text-align: center;
}

.landing-logo {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  margin: 0 auto;
}

.landing-lead {
  font-size: 15px;
  margin: 60px 0 0;
}

.landing-login-actions {
  margin-top: 60px;
}

.landing-login-actions .landing-login-button {
  width: 100%;
  height: 60px;
  border: solid 1px #DDD;
  border-radius: 32px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  background-color: white;
}

.landing-login-actions .landing-login-button img {
  width: 18px;
  height: 18px;
  margin-right: 8px;
  vertical-align: middle;
}

.landing-login-actions .landing-login-or {
  font-family: "Noto Sans JP", sans-serif;
  font-size: 16px;
  line-height: 20px;
  color: #B3B3B3;
  margin: 16px 0;
}

.landing-login-note {
  display: inline-block;
  font-size: 14px;
  margin: 30px 0 0;
}

.landing-maintenance {
  margin-top: 60px;
  text-align: center;
}

.landing-maintenance-title {
  font-size: 36px;
  font-weight: 600;
  line-height: 1.4;
  color: #F8516D;
}

.landing-maintenance-note {
  display: inline-block;
  font-size: 14px;
  margin: 16px 0 0;
}

/* Not Found（ログイン済みシェル内） */
.not-found-page {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 80px 40px;
}

.not-found-inner {
  box-sizing: border-box;
  width: 100%;
  max-width: 480px;
  text-align: center;
}

.not-found-title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.04em;
  color: #11101d;
}

.not-found-message {
  margin: 16px 0 0;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.7;
  color: #666;
  text-align: center;
  white-space: pre-line;
}

.not-found-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 220px;
  height: 36px;
  margin-top: 36px;
  padding: 0 20px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 700;
  line-height: 20px;
  color: #fff;
  background-color: #009FB2;
  cursor: pointer;
}

.not-found-action:hover {
  background-color: #59C6D3;
}

.not-found-action:focus-visible {
  outline: 2px solid #009FB2;
  outline-offset: 2px;
}

@media (max-width: 1024px) {
  .not-found-page {
    padding: 60px 20px;
  }

  .not-found-title {
    font-size: 20px;
  }
}