:root {
  --default-padding: .5rem;
  --default-color: #444;
  --default-font-family: "メイリオ", sans-serif;
  --default-font-size: 9pt;
  --default-border-color: #ccc;
  --header-height: 3rem;
  --header-background-color: #2050A4;
  --header-color: #fff;
  --header-title-font-family: 'メイリオ';
  --header-title-font-size: 18pt;
  --header-title-font-weight: bold;
  --header-project-font-size: 14pt;
  --tab-font-size: 8pt;
  --menu-width: 10rem;
  --menu-background-color: rgb(235, 244, 253);
  --menu-item-background-color: rgb(250, 254, 255);
  --menu-hover-background-color: rgb(230, 240, 253);
  --menu-item-height: 38px;
  --menu-font-weight: bold;
  --menu-color: var(--default-color);
  --main-background-color: #fff;
  --block-title-background-color: var(--menu-background-color);
  --iframe-tab-background-color: #ECF4FB;
  --iframe-tab-height: 30px;
  --transition-duration: .2s;
  --debug-border-color: transparent;
  --link-color: #169;
  --link-hover-color: #d33;
  transition-behavior: allow-discrete;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/*
 * エラーダイアログ
 */
#error-dlg {
  width: 300px;
  position: absolute;
  top: 150px;
  left: 160px;
  padding: 10px;
  border: 1px solid #888;
  .message {
    color: #800;
  }
  button {
    display: block;
    margin: 20px auto 0 auto;
    padding: 4px 10px;
  }
}

/*
 * テキストボタン
 */
.text-button {
  height: 26px;
  margin: 0 10px;
  padding: 0px 10px;
  border: 1px solid var(--default-border-color);
  border-radius: 13px;
  background-color: #fff;
  line-height: 26px;
  vertical-align: middle;
  white-space: nowrap;
  font-weight: bold;
  color: var(--default-color);
  cursor: pointer;
  &:hover {
    background-color: #eee;
  }
}
.copy-btn {
  translate: 0 4px;
  width: 26px;
  text-align: center;
  cursor: pointer;
}


/*
 * サブミットボタン
 */
.submit-button {
  display: inline-block;
  text-align: center;
  margin: 0 1rem;
  min-width: 9rem;
  line-height: 2rem;
  height: 2rem;
  border: none;
  border-radius: .3rem;
  background-color: rgb(32, 80, 164);
  color: #fff;
  cursor: pointer;
  font-weight: bold;
}

/*
 * グレーボタン
 */
.gray-button {
  display: inline-block;
  text-align: center;
  margin: 0 1rem;
  min-width: 9rem;
  line-height: 2rem;
  height: 2rem;
  border: 1px solid var(--default-border-color);
  border-radius: .3rem;
  background-color: #eee;
  color: #333;
  cursor: pointer;
  font-weight: bold;
}

/*
 * リンク
 */
a, a:link, a:visited {
  color: var(--link-color);
  text-decoration: none;
  cursor: pointer;
}
a:hover {
  color: var(--link-hover-color);
}

/*
 * ボディ
 */
html {
  height: 100%;
}
body {
  height: 100%;
  font-family: var(--default-font-family);
  font-size: var(--default-font-size);
  color: var(--default-color);
}
#container {
  height: 100%;
}
#container-no-menu {
  height: 100vh;
  display: grid;
  grid: "header" var(--header-height)
        "main" auto
       / auto;
  #header { grid-area: header; }
  #main { grid-area: main; }
}

/*
 * エラー画面
 */
.error {
  padding: 1rem;
}

/*
 * ヘッダ
 */
#header {
  display: flex;
  position: sticky;
  top: 0;
  height: var(--header-height);
  background-color: var(--header-background-color);
  color: var(--header-color);
  z-index: 90;
  #header-logo {
    margin: 7px 8px 0 8px;
  }
  #header-title {
    line-height: var(--header-height);
    font-family: var(--header-title-font-family);
    font-size: var(--header-title-font-size);
    font-weight: var(--header-title-font-weight);
    margin: 5px 36px 0 0;
    a {
      color: var(--header-color);
    }
  }
  #header-project {
    flex: 1 0 auto;
    line-height: var(--header-height);
    font-family: var(--header-title-font-family);
    font-size: var(--header-project-font-size);
    font-weight: var(--header-title-font-weight);
    margin: 3px 16px 0 0;
  }
  #header-user-name {
    position: relative;
    line-height: var(--header-height);
    padding: 0 .5rem;
    cursor: pointer;
    font-weight: bold;
    #change-password {
      position: absolute;
      top: 0;
      width: 150px;
      line-height: 30px;
      padding: 8px 16px;
      background-color: var(--header-background-color);
      background-color: #EAF4FC;
      border-radius: 4px;
      color: var(--default-color);
      font-weight: bold;
      transform: translateY(40px);
      transform: scaleY(0) translateY(40px);
      transition: .3s ease;
      a {
        color: #fff;
      }
    }
    #change-password::before {
      position: absolute;
      top: -5px;
      left: 20px;
      display: block;
      width: 10px;
      height: 10px;
      background-color: #EAF4FC;
      transform: rotate(45deg);
      content: "";
    }
    #change-password:hover {
      transform: scaleY(1) translateY(40px);
    }
  }
  #header-user-name:hover {
    #change-password {
      transform: scaleY(1) translateY(40px);
    }
  }
  #header-logout {
    line-height: var(--header-height);
    flex: 0 1 auto;
    padding: 0 .5rem;
    font-weight: bold;
    a {
      color: var(--header-color);
    }
  }
}

/*
 * メニュー＆メイン
 */
#menu-and-main {
  display: flex;
  min-height: calc(100% - var(--header-height));
}

#main {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
}
.main-header {
  display: flex;
  font-weight: bold;
  .main-title {
    position: sticky;
    left: 0;
    font-size: 20px;
    white-space: nowrap;
    margin-right: 10px;
  }
}

/*
 * フォーム
 */
.delete-button {
  width: 9rem;
  line-height: 2rem;
  border: none;
  border-radius: .3rem;
  cursor: pointer;
  font-weight: bold;
  background-color: #cc3333;
  color: #fff;
}
.form-box {
  background-color: #fff;
  width: 610px;
  padding: 1.5rem .2rem;
  margin-bottom: 1rem;
  .form-item {
    display: flex;
    gap: 4px;
    margin-bottom: 6px;
    width: 600px;
    label {
      display: inline-block;
      width: 90px;
      text-align: right;
      padding: 0 .10rem 0 0;
      vertical-align: top;
      height: 2.5rem;
      line-height: 2.5rem;
      font-weight: bold;
    }
    input[type="text"],
    input[type="date"],
    textarea,
    select {
      display: inline-block;
      color: #444;
      width: 480px;
      height: 2.2rem;
      line-height: 2.2rem;
      padding: 0 .5rem;
      border: 1px solid var(--default-border-color);
      border-radius: .3rem;
      &:focus {
        outline: 1.5px solid #ccf;
      }
      &:disabled {
        background-color: #ececec;
      }
      &.disable {
        background-color: #ececec;
      }
    }
    textarea {
      height: 8rem;
      line-height: 1rem;
    }
    &.comment-list {
      display: flex;
      margin-bottom: 0;
    }
    .comments {
      display: inline;
      .comment {
        display: block;
        width: 478px;
        margin-bottom: .5rem;
        padding: 0 .2rem;
        border: 1px solid var(--default-border-color);
        border-radius: 8px;
        background-color: #ececec;
        padding: 4px 8px;
        .date-and-name {
          font-weight: bold;
        }
        .notes {
          white-space: pre-wrap;
          word-break: break-all;
        }
      }
      textarea {
        width: 480px;
        min-height: 60px;
        height: calc-size(auto, size);
        line-height: 1.3rem;
      }
    }
  }
  .col-2 {
    display: flex;
    .form-item {
      width: 300px;
      input {
        width: 180px;
      }
      select {
        width: 180px;
      }
    }
  }
  .edit-button {
    position: absolute;
    transform: translate(4px, 4px);
    background: url(/static/icon/pencil_g_12x12.svg) no-repeat;
    color: #fff;
    cursor: pointer;
    height: 16px !important;
  }
  .edit-button:hover {
    background: url(/static/icon/pencil_b_12x12.svg) no-repeat;
  }
  .button-container {
    text-align: center;
    margin-bottom: 8px;
    button {
      width: 9rem;
      line-height: 2rem;
      border: 1px solid var(--default-border-color);
      border-radius: .3rem;
      margin: 0 1rem;
      cursor: pointer;
      font-weight: bold;
      &[type="submit"] {
        border: none;
        background-color: rgb(32, 80, 164);
        color: #fff;
      }
      &.delete-btn {
        border: none;
        background-color: #cc3333;
        color: #fff;
      }
    }
  }
  .form-error {
    color: #f66;
    font-size: 90%;
    padding-top: 2px;
  }
  .form-error.show {
    height: auto;
  }
  #lnk-ai,
  #lnk-shared-folder,
  #lnk-ai-agent {
    color: var(--link-color);
    font-weight: bold;
    cursor: pointer;
    &:hover {
      color: var(--link-hover-color);
    }
  }
  .link-container {
    display: flex;
    margin: -8px 0 8px 0;
    #lnk-folder,
    #lnk-shared-folder,
    #lnk-relation-id {
      display: inline-block;
      color: var(--link-color);
      font-weight: bold;
      cursor: pointer;
      &:hover {
        color: var(--link-hover-color);
      }
    }
    #lnk-ai {
      transform: translateX(161px);
    }
    #lnk-folder {
      transform: translateX(161px);
    }
    #lnk-shared-folder {
      transform: translateX(363px);
    }
    #lnk-relation-id {
      margin-left: auto;
      transform: translateX(-42px);
    }
  }
}

/*
 * コンテナサイズが1100px以下であればタスクリストを下部に移動する
 */
#redmine-body {
  container-type: inline-size;
  container-name: my-container;
  height: 100%;
  padding: 16px;
  color: #444;
  background-color: var(--main-background-color);
}
#ticket-and-ticket-list {
  display: flex;
  .form-box {
    display: block;
  }
  #ticket-list {
    flex: 1;
  }
}
@container my-container (width < 1000px) {
  #ticket-and-ticket-list {
    display: block;
  }
}
@container my-container (width < 1000px) {
  .redmine-tickets {
    .rate-graph {
      display: none;
    }
  }
}
@container my-container (width >= 1000px) {
  .redmine-tickets {
    .rate-number {
      display: none;
    }
  }
}

/*
 * タスクヘッダリンク部
 */
.redmine-tickets-header {
  flex: 1;
  box-sizing: border-box;
  table-layout: auto;
  border-collapse: collapse;
  background-color: #fff;
  border: 1px solid #ddd;
  width: 100%;
  th, td {
    padding: 0 4px;
    line-height: 1.6rem;
  }
  th {
    text-align: left;
    background-color: #e8e8e8;
    height: 2rem;
  }
  td {
    text-align: right;
    background-color: #e8e8e8;
    height: 2rem;
  }

}

/*
 * タスク
 */
.task-search {
  form {
    display: flex;
    margin: 0 0 4px 0;
    input {
      width: 300px;
      height: 1.5rem;
      line-height: 1.5rem;
      padding: 0 6px;
      outline: 0;
      border: 1px solid #ccc;
      border-radius: 6px 0 0 6px;
    }
    button {
      width: 70px;
      height: 1.5rem;
      line-height: 1.5rem;
      outline: 0;
      border: 1px solid #ccc;
      border-left: 0;
      border-radius: 0 6px 6px 0;
      &:hover {
        background-color: #ddd;
      }
    }
    span {
      margin-left: .3rem;
      height: 1.5rem;
      line-height: 1.5rem;
    }
  }
}
.redmine-tickets {
  flex: 1;
  box-sizing: border-box;
  table-layout: auto;
  border-collapse: collapse;
  background-color: #fff;
  border-right: 1px solid #ddd;
  border-left: 1px solid #ddd;
  border-bottom: 1px solid #ddd;
  width: 100%;
  thead {
    position: sticky;
    top: 0;
    z-index: 2;
  }
  th, td {
    padding: 0 4px;
    line-height: 1.6rem;
  }
  th {
    text-align: left;
    background-color: #e0e0e0;
    height: 2rem;
    white-space: nowrap;
    &[data-sort] {
      cursor: pointer;
      &::after {
        content:"▲";
        color: #aaa;
      }
    }
    &[data-dir="asc"] {
      &::after {
        content:"▲";
        color: #333;
      }
    }
    &[data-dir="desc"] {
      &::after {
        content:"▼";
        color: #333;
      }
    }
  }
  tr:nth-child(odd) {
    background-color: #fafafa;
  }
  tr:nth-child(even) {
    background-color: #ececec;
  }
  tr:hover {
    background-color: #ffffd0;
  }
  :is(th, td).checkbox {
    width: 2rem;
    vertical-align: middle;
    input {
      margin: 4px 0 0 0;
    }
  }
  td.subject {
    display: block;
    max-width: 300px;
    white-space: nowrap;
    overflow-x: hidden;
    text-overflow: ellipsis;
  }
  td.assigned_to {
    white-space: nowrap;
  }
  td.id {
    width: 2rem;
    text-align: right;
  }
  td.flag {
    white-space: nowrap;
  }
  td.tracker {
    text-align: center;
  }
  td.ai {
    max-width: 80px;
    white-space: nowrap;
    overflow-x: hidden;
    text-overflow: ellipsis;
  }
  td.fixed_version {
    max-width: 80px;
    white-space: nowrap;
    overflow-x: hidden;
    text-overflow: ellipsis;
  }
  td.active {
    a {
      color: red;
    }
  }
}

/*
 * 期日カレンダー
 */
.calendar {
  width: 100%;
  border-collapse: collapse;
  background-color: #fff;
  th, td {
    width: calc(100% / 7);
    border: 1px solid var(--default-border-color);
  }
  th {
    height: 3rem;
  }
  td {
    text-align: left;
    vertical-align: top;
    padding-left: 5px;
    .day {
      text-align: center;
      font-weight: bold;
    }
    &:first-of-type,
    &.holiday {
      background-color: #fef4f4;
      .day {
        color: red;
        color: #AB1C23;
      }
      .holiday-title {
        color: red;
        color: #AB1C23;
      }
    }
    &:last-of-type {
      background-color: #eaf4fc;
      .day {
        color: #2050A4;
      }
    }
  }
  /* td の min-height を指定するハック */
  td::before {
    content: "";
    display: block;
    min-height: 4rem;
    float: left;
  }
}
.calendar-header {
  margin-bottom: 4px;
  .arrow-icon {
    display: inline-block;
    border: 1px solid #ddd;
    width: 24px;
    border-radius: 4px;
    padding: 4px 0 0 4px;
    &:hover {
      background-color: #f0f0f0;
    }
  }
}

/*
 * ニュース
 */
#redmine-body {
  .news-box {
    margin-top: 8px;
    border-top: 1px solid var(--default-border-color);
    .news-item {
      margin-bottom: 1rem;
      background-color: #fff;
      padding-top: 10px;
      .title {
        font-size: 130%;
        font-weight: bold;
      }
      .author-and-created-date {
        font-weight: bold;
        margin-bottom: 10px;
      }
      .description {
        white-space: pre;
      }
    }
    &:last-child {
      border-bottom: 1px solid var(--default-border-color);
    }
  }
}


/*
 * 短期目標
 */
.milestone-box {
  margin-top: 10px;
  .milestone-item {
    margin-bottom: 20px;
    background-color: #fff;
    border-radius: .3rem;
    .title {
      font-size: 130%;
      font-weight: bold;
      margin-bottom: .3rem;
    }
    .description {
      white-space: pre;
    }
    .rate-and-select {
      display: flex;
      gap: 1rem;
      select {
        line-height: 26px;
        height: 26px;
        min-width: 180px;
        border: 1px solid var(--default-border-color);
        border-radius: .3rem;
        color: #444;
      }
    }
  }
}
.milestone-tickets {
  .subject {
    .delayed {
      font-weight: bold;
      color: red;
    }
  }
}

/*
 * ガントチャート
 */
.gantt-chart {
  display: flex;
  gap: 8px;
  width: 2900px;
  .list {
    position: sticky;
    top: 0;
    left: 0;
    z-index: 2;
    transform: translateY(-1px);
    table {
      border-collapse: separate;
      border-spacing: 0;
      background-color: #fff;
      border-left: 1px solid #ddd;
      border-bottom: 1px solid #ddd;
      margin-bottom: 10px;
      thead {
        background-color: #ececec;
        position: sticky;
        top: 0;
      }
      tbody {
        tr:nth-child(odd) {
          background-color: #f6f7f8;
        }
        tr:nth-child(even) {
          background-color: #ececec;
        }
      }
      th, td {
        line-height: 1.6rem;
        text-align: left;
        padding: 0 .5rem;
        border-top: 1px solid #ddd;
        border-right: 1px solid #ddd;
        white-space: nowrap;
      }
      td.subject {
        max-width: 16rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }
  }
  .date {
    z-index: 1;
    transform: translateY(-1px);
    table {
      border-collapse: separate;
      border-spacing: 0;
      border-left: 1px solid #ddd;
      border-bottom: 1px solid #ddd;
      thead {
        position: sticky;
        top: 0;
        .row-year-month {
          th {
            padding-left: 6px;
            background-color: #ececec;
          }
        }
        .row-day {
          th {
            text-align: center;
            background-color: #ececec;
            &.saturday {
              color: #00b;
              background-color: #e0f7fa;
            }
            &.sunday,
            &.holiday {
              color: #c00;
              background-color: #ffebee;
            }
          }
        }
      }
      tbody {
        tr:nth-child(odd) {
          background-color: #f6f7f8;
        }
        tr:nth-child(even) {
          background-color: #ececec;
        }
      }
      th, td {
        line-height: 1.6rem;
        text-align: left;
        min-width: 28px;
        border-top: 1px solid #ddd;
        border-right: 1px solid #ddd;
      }
      td.red-border {
        border-right: 3px solid red;
      }
      tr.delayed {
        td.running {
          background-image: linear-gradient(to bottom, #ffffff00 0% 15%, #F0B8BA 15% 87%, #ffffff00 87% 100%);
        }
        td.running.done {
          background-image: linear-gradient(to bottom, #ffffff00 0% 15%, #D94E55 15% 87%, #ffffff00 87% 100%);
        }
      }
      tr.nodelay {
        td.running {
          background-image: linear-gradient(to bottom, #ffffff00 0% 15%, #83CEEF 15% 87%, #ffffff00 87% 100%);
        }
        td.running.done {
          background-image: linear-gradient(to bottom, #ffffff00 0% 15%, #2AABE2 15% 87%, #ffffff00 87% 100%);
        }
      }
      td.holiday {
        background-color: #e6e6e6;
      }
      tr.milestone {
        td.running,
        td.overdue {
          background-image: linear-gradient(to bottom, #ffffff00 0% 30%, #1E50A2 30% 70%, #ffffff00 70% 100%);
        }
      }
    }
  }
}

/*
 * ツール画面
 */
#tools {
  height: 100%;
  overflow-y: hidden;
  background-color: var(--main-background-color);
  iframe {
    width: 100%;
    height: calc(100vh - var(--header-height) - 55px);
    border-width: 0;
  }
}

/*
 * パスワード変更ダイアログ
 */
#passwd-dlg {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid var(--default-border-color);
  .dlg-content {
    display: flex;
    flex-direction: column;
    padding: 20px 30px 30px 30px;
    .message {
      margin-bottom: 10px;
      color: red;
      visibility: hidden;
    }
    .change-password-form-item {
      margin-bottom: 8px;
      label {
        display: inline-block;
        width: 150px;
        line-height: 2.2rem;
      }
      input {
        display: inline-block;
        line-height: 2.2rem;
        border: 1px solid var(--default-border-color);
        border-radius: .3rem;
        width: 300px;
        padding-left: 4px;
        &:focus {
          outline: 1px solid #88f;
        }
      }
    }
    .button-group {
      margin: 10px auto 0 auto;
      button {
        width: 120px;
        line-height: 2.2rem;
        border: none;
        border-radius: .3rem;
        cursor: pointer;
        &#change-pw-ok {
          background-color: rgb(32, 80, 164);
          color: #fff;
          margin-right: 20px;
          &:disabled {
            background-color: #ddd;
            color: #888;
          }
        }
        &#change-pw-cancel {
          background-color: #e0e0e0;
        }
      }
    }
  }
}

/*
 * ページャー
 */
.pager {
  display: inline-block;
  margin-left: auto;
  white-space: nowrap;
  .pager-button {
    width: 24px;
    height: 24px;
    line-height: 24px;
    border: 1px solid var(--default-border-color);
    border-radius: 4px;
    cursor: pointer;
    &:hover:not(:disabled) {
      background-color: #ccc;
    }
    &:disabled {
      color: #ccc;
      cursor: default;
    }
    img {
      transform: translateY(2px);
    }
  }
}

/*
 * 通常テーブル
 */
table.normal-table {
  border-collapse: collapse;
  margin: 1rem 0;
  th {
    background-color: #e8e8e8;
  }
  th, td {
    border: 1px solid #ccc;
    padding: 4px 8px;
  }
}

/*
 * 注意書き
 */
.caution {
  color: #c33;
}


/*
 * スピナー
 */
@keyframes spinner {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
#spinner {
  position: absolute;
  top: 300px;
  margin: 0 auto;
  border: none;
  background-color: transparent;
  visibility: hidden;
  svg {
    animation: spinner .5s linear infinite;
  }
}
