/* ================================
   Sidebar 全体
================================ */
.sidebar {
    width: 240px;
    background: #ffffff;
    border-right: 1px solid #dcdcdc;
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    transition: width 0.2s ease;
    z-index: 3000;
    overflow: hidden;
}

/* collapse 時 */
#sidebar.collapsed {
    overflow: visible;
    width: 76px !important;
}

#sidebar {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ナビ部分だけ縦スクロール */
.sidebar-nav {
    flex: 1;                 /* 残りの高さを全部使う */
    overflow-y: auto;        /* 縦スクロール */
    overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}


/* ================================
   Header
================================ */
.sidebar-header {
    display: flex;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #e6e6e6;
}

.sidebar-header.expanded-only {
    display: flex;
}
.sidebar-header.collapsed-only {
    display: none;
    justify-content: center;
}

#sidebar.collapsed .expanded-only {
    display: none !important;
}
#sidebar.collapsed .collapsed-only {
    display: flex !important;
}

.sidebar-logo {
    width: 42px;
    margin-right: 10px;
}

.sidebar-icon-mini {
    width: 40px;
}

/* ================================
   Collapse ボタン
================================ */
.sidebar-toggle-btn {
    position: absolute;
    top: 18px;
    right: -15px;
    width: 34px;
    height: 34px;
    background: #e5f2d9;
    border: 1px solid #c7dfb6;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index:4000;
    transition: all .25s ease;
}

/* collapse → ボタン位置を左へスライド */
#sidebar.collapsed .sidebar-toggle-btn {
    right: -15px; /* 変わらないなら維持でOK */
}

/* collapse → アイコン回転 */
#sidebar.collapsed .sidebar-toggle-btn i {
    transform: rotate(180deg);
}

.sidebar-toggle-btn:hover {
    box-shadow: 0 0 6px rgba(0,0,0,0.2);
}

/* ================================
   メニュー全体
================================ */
.sidebar-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.menu-group,
.menu-item {
    width: 100%;
}

/* 親メニュー */
.menu-parent {
    width: 100%;
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #ffffff;
    border: none;
    outline: none;
    cursor: pointer;
    transition: background 0.15s ease, padding 0.15s ease;
}

.menu-parent:hover {
    background: #f2f7ec;
    color: #558d1d;              /* ← ここで緑 */
    border-left: 4px solid #558d1d;
}

/* collapse → アイコン中央だけ */
#sidebar.collapsed .menu-parent {
    justify-content: center !important;
    padding: 12px 0 !important;
}

/* アイコン */
.menu-icon {
    width: 24px;
    font-size: 18px;
    margin-right: 14px;
    transition: margin 0.2s ease;
}

/* collapse → アイコンの margin を削除 */
#sidebar.collapsed .menu-icon {
    margin-right: 0 !important;
}

/* ラベル（テキスト） */
.menu-label {
    transition: opacity 0.15s ease;
    white-space: nowrap;
}

/* collapse → ラベル非表示 */
#sidebar.collapsed .menu-label {
    display: none !important;
}

/* parent の ▼ 矢印 */
.parent-arrow {
    margin-left: auto;
    transition: transform 0.2s ease;
}

/* 開いている時 ▼ 回転 */
.menu-group.open .parent-arrow {
    transform: rotate(180deg);
}

#sidebar.collapsed .parent-arrow {
    display: none !important;
}


/* ================================
   子メニュー
================================ */
.menu-children {
    display: none;
    padding-left: 40px;
    background: #fafafa;
    border-left: 3px solid #e2e2e2;
}

.menu-group.open .menu-children {
    display: block;
}

.menu-children a {
    display: block;
    padding: 10px 8px;
    color: #333;
    text-decoration: none;
    transition: background 0.15s ease;
    font-weight: 500;
}

.menu-children a:hover {
    background: #e9f3e0;
    color: #558d1d;
}

/* collapse 中は子メニュー常に非表示 */
#sidebar.collapsed .menu-children {
    display: none !important;
}


/* ============================
   親メニュー
============================ */
.menu-parent {
    font-weight: 600;
    color: #2f3a1f; /* 緑寄りダークグレー */
}

.menu-group.open > .menu-parent {
    background: #f2f7ec;
    border-left: 4px solid #90c31f;
}

/* ============================
   子メニュー
============================ */
.menu-children {
    background: #fafafa;
    padding-left: 12px;
}

.menu-children a {
    font-size: 14px;
    padding: 8px 12px 8px 36px;
    color: #555;
    font-weight: 600;
}

/* hover */
.menu-children a:hover {
    background: #e9f3e0;
}

/* ============================
   サイドバー タイトル
============================ */
.sidebar-title {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    color: #558d1d;
}

/* Partner∞ */
.sidebar-title .system-name {
    font-size: 18px;
    font-weight: 800;
    color: #558d1d; 
    white-space: nowrap;
    font-family: "Noto Sans JP", "Rounded Mplus 1c", sans-serif;
}

/* 空き社宅 点検システム */
.sidebar-title .system-sub {
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

/* ================================
   User info
================================ */

/* PC サイドバー：ユーザー操作 */
.sidebar-user-box {
    padding: 12px;
  text-align: center;
  border-bottom: 1px solid #e0ebd3;
}

.sidebar-user-division {
  font-size: 13px;
  font-weight: 600;
  color: #558d1d;
}

.sidebar-user-role {
  display: inline-block;
  margin: 4px 0;
  padding: 2px 8px;
  font-size: 12px;
  color: #fff;
  background: #558d1d;
  border-radius: 12px;
}

.role-badge {
  font-size: 11px;
  margin-left: 6px;
  color: #fff;
  background: #558d1d;
  padding: 2px 6px;
  border-radius: 10px;
}

.sidebar-user-name {
    font-weight: 700;
    color: #333;
    margin-bottom: 12px;
    font-size: 14px;
}

.sidebar-user-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-user-username {
  font-size: 12px;
  color: #777;
}

.sidebar-user-email {
    margin-top: 8px;
    font-size: 12px;
    color: #666;
    word-break: break-all;
}

/* ボタン共通 */
.sidebar-btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 10px 0;
    border-radius: 999px;
    font-weight: 700;
    width: 100%;
}

/* パスワード変更 */
.sidebar-btn-primary {
    background: #558d1d;
    color: #fff;
    text-decoration: none;
}

/* ログアウト */
.sidebar-btn-outline {
    background: #fff;
    color: #558d1d;
    border: 2px solid #558d1d;
}


/* アカウント操作（下部） */

.sidebar-account-box {
  margin-top: auto;        /* ← これが重要 */
  padding: 16px 12px;
  border-top: 1px solid #e0ebd3;
  background: #f6f9f1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}


/* ============================
   SPでは sidebar を使わない
============================ */
@media (max-width: 991.98px) {
    #sidebar {
        display: none !important;
    }

    .main-header {
        left: 0 !important;
        width: 100% !important;
        min-height: 56px;
        padding: 8px 12px;
        align-items: center;
        border-bottom: none;
        position: fixed;
        border-bottom: 1px solid #e0ebd3;
    }

    /* ロゴリンクをヘッダー中央に配置 */
  .header-brand.d-lg-none {
      position: absolute;
      left: 50%;
      transform: translateX(-50%);
      text-decoration: none;   /* ← 下線消す */
  }

    .content-wrapper {
        margin-left: 0 !important;
    }

    .global-footer {
        margin-left: 0 !important;
    }
}

/* SP トグルボタン */
.hamburger {
    width: 36px;
    height: 36px;
    border: 2px solid #558d1d;
    border-radius: 6px;
    background: #fff;
    color: #558d1d;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hamburger i {
    font-size: 18px;
}


/* ============================
   SP nav ベースリセット
============================ */
@media (max-width: 991.98px) {

    #sp-nav ul {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    #sp-nav li {
        list-style: none;
    }
}

@media (max-width: 991.98px) {

    .sp-brand {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 12px 16px;
        border-bottom: 1px solid #e0ebd3;
        background: #fff;
    }

    .sp-brand img {
        width: 36px;
        height: auto;
    }

    .sp-brand-main {
        font-size: 16px;
        font-weight: 800;
        color: #558d1d;
        display: block;
        line-height: 1.1;
    }


@media (max-width: 991.98px) {

    .sp-user-block {
        padding: 12px 16px;
        background: #f7f9f3;
        border-bottom: 1px solid #e0ebd3;
    }

    .sp-user-name {
        font-weight: 600;
        margin-bottom: 4px;
        color: #2f3a1f;
    }

    .sp-user-link {
        font-size: 14px;
        color: #558d1d;
        text-decoration: none;
    }
}


/* ============================
   SP メニュー全体
============================ */
#sp-nav {
    background: #ffffff;
    border-top: 1px solid #e0e0e0;
    /* padding: 8px 0; */
}
/* 親メニュー */
#sp-nav .menu-parent {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    font-weight: 600;
    color: #2f3a1f;
}

/* 親メニュー：展開中 */
#sp-nav .menu-group.open > .menu-parent {
    background: #f2f7ec;
    color: #558d1d;
    border-left: 4px solid #558d1d;
}

/* 子メニュー */
#sp-nav .menu-children a {
    display: block;
    padding: 10px 16px 10px 40px;
    font-size: 15px;
    font-weight: 500;
    color: #444;
}

/* hover / tap */
#sp-nav .menu-children a:hover {
    background: #e9f3e0;
    color: #558d1d;
}

/* SP ヘッダー内システム名 */
.sp-system-name {
    font-size: 16px;
    font-weight: 800;
    color: #558d1d;
}

.sp-system-sub {
    font-size: 11px;
    font-weight: 500;
    color: #558d1d;
}

#sp-nav .parent-arrow {
    margin-left: auto;
    color: #558d1d;
}

#sp-nav .menu-children {
    border-left: 2px solid #e0ebd3;
}

/* ============================
   SP メニュー 初期状態
============================ */
@media (max-width: 991.98px) {

    #sp-nav {
        display: none;          /* ← 初期は必ず非表示 */
        background: #ffffff;
        border-top: 1px solid #e0ebd3;
    }

    #sp-nav.open {
        display: block;         /* ← トグルで表示 */
    }
}

@media (max-width: 991.98px) {
  #sp-nav {
    position: fixed;
    top: 56px;           /* ヘッダーの高さ */
    left: 0;
    width: 100%;
    z-index: 3000;
    background: #fff;
  }
}

/* ============================
   SP ユーザー領域
============================ */
.sp-user-block {
    padding: 12px 16px;
    background: #f7f9f3;
}

.sp-user-name {
    font-weight: 600;
    color: #2f3a1f;
    margin-bottom: 6px;
}

.sp-user-link {
    font-size: 14px;
    color: #558d1d;
    text-decoration: none;
}

.sp-user-link:hover {
    text-decoration: underline;
}

.sp-divider {
    height: 1px;
    background: #e0ebd3;
    margin: 8px 0;
}

/* ============================
   SP ブランド表示
============================ */
.sp-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
}

.sp-brand img {
    width: 36px;
}

.sp-brand-main {
    font-size: 16px;
    font-weight: 800;
    color: #558d1d;
}

.sp-brand-sub {
    font-size: 11px;
    color: #558d1d;
}
@media (max-width: 991.98px) {

    /* リセット */
    #sp-nav ul {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    /* ===== ユーザー操作 ===== */
    .sp-user-main {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 14px 16px;
        background: #f2f7ec;
        border-bottom: 1px solid #e0ebd3;
    }

    .sp-user-name {
        font-weight: 600;
        color: #2f3a1f;
    }

    .sp-user-action {
        font-size: 13px;
        color: #558d1d;
        text-decoration: underline;
    }

    /* ===== 業務メニュー（2列） ===== */
    .sp-menu-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .sp-menu-grid a {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 14px;
        border-bottom: 1px solid #e0ebd3;
        border-right: 1px solid #e0ebd3;
        font-weight: 600;
        color: #2f3a1f;
        text-decoration: none;
    }

    .sp-menu-grid a i {
        color: #558d1d;
    }

    .sp-menu-grid a:hover {
        background: #f2f7ec;
    }

    /* ===== ログアウト ===== */
    .sp-logout button {
        width: 100%;
        padding: 16px;
        border: none;
        background: #fff;
        font-weight: 600;
        color: #c0392b;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }
}

@media (max-width: 991.98px) {

  /* ユーザー操作エリア */
  .sp-user-main {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 10px;
      padding: 16px;
      background: #f2f7ec;
      border-bottom: 1px solid #e0ebd3;
      text-align: center;
  }

  .sp-user-name {
      font-weight: 600;
      color: #2f3a1f;
  }

  /* パスワード変更ボタン */
  .sp-user-action {
      display: inline-block;
      padding: 10px 24px;
      background: #558d1d;
      color: #fff;
      font-weight: 700;
      border-radius: 999px;
      text-decoration: none;
      min-width: 200px;
      text-align: center;
  }

  .sp-user-action:hover {
      background: #467514;
  }
}

@media (max-width: 991.98px) {

  /* ログアウト枠 */
  .sp-logout {
      border-top: 2px solid #e0ebd3;
      margin-top: 8px;
  }

  .sp-logout button {
      width: 100%;
      padding: 14px;
      background: #f7fbf2;
      border: none;
      font-weight: 700;
      color: #558d1d;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
  }

  .sp-logout button i {
      color: #558d1d;
  }

  .sp-logout button:hover {
      background: #e9f3e0;
  }
}
@media (max-width: 991.98px) {

  /* ヘッダー内ロゴ：横並び */
  .sp-brand-inline {
      display: flex;
      align-items: center;
      gap: 8px;
  }

  .sp-brand-logo {
      width: 56px;
      height: auto;
      flex-shrink: 0;
      margin-top: 2px;
  }

  .sp-brand-text {
      display: flex;
      flex-direction: column;
      line-height: 1.15;
      margin-top: 2px;
  }

  .sp-brand-sub {
      font-size: 12px;
      color: #558d1d;
      font-weight: 800;
  }

  .sp-brand-main {
      font-size: 18px;   /* ← Partner∞ を主役に */
      font-weight: 800;
      color: #558d1d;
      font-family: "Noto Sans JP", "Rounded Mplus 1c", sans-serif;
  }
}


@media (max-width: 991.98px) {

  .sp-user-box {
      padding: 16px;
      background: #f2f7ec;
      border-bottom: 1px solid #e0ebd3;
      text-align: center;
  }

  .sp-user-name {
      font-weight: 600;
      color: #2f3a1f;
      margin-bottom: 12px;
  }

  .sp-user-actions {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 12px;
  }

  /* 共通ボタン */
  .sp-btn {
      padding: 10px 0;
      border-radius: 999px;
      font-weight: 700;
      text-align: center;
      width: 100%;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
  }

  /* パスワード変更（主） */
  .sp-btn-primary {
      background: #558d1d;
      color: #fff;
      text-decoration: none;
  }

  /* ログアウト（同系色・枠） */
  .sp-btn-outline {
      background: #fff;
      color: #558d1d;
      border: 2px solid #558d1d;
  }
}
@media (max-width: 991.98px) {
  #sp-nav {
      margin-top: 0;   /* ← 余白を作らない */
  }
}

@media (max-width: 991.98px) {

  /* パスワード変更（主ボタン） */
  .sp-btn-primary {
      background: #558d1d;
      color: #fff;
      font-weight: 700;
      border-radius: 999px;
      text-decoration: none;
      transition: all 0.2s ease;
  }

  .sp-btn-primary:hover,
  .sp-btn-primary:active {
      background: #467514;  /* 濃い緑 */
      color: #fff;          /* 白文字維持 */
      text-decoration: none;
  }
}

/* =====================================
   サイドバー collapsed 時の制御
===================================== */

/* 通常（展開時）は表示 */
.sidebar-user-box {
    display: block;
}

#sidebar.collapsed .expanded-only {
    display: none;
}

/* 展開時 */
#sidebar:not(.collapsed) .sidebar-nav {
    overflow-y: auto;
}

/* 折りたたみ時（白いピルを消す） */
#sidebar.collapsed .sidebar-nav {
    overflow-y: hidden;
}

/* collapsed時は sidebar 自体を完全非スクロール */
#sidebar.collapsed {
    overflow: hidden !important;
}

/* 展開時のみ nav をスクロール */
#sidebar:not(.collapsed) .sidebar-nav {
    overflow-y: auto;
}
/* .layout-wrapper {
    overflow-y: auto;
} */
#sidebar.collapsed ~ .layout-wrapper {
    overflow-y: hidden;
}
body {
    overflow-y: auto;
}
body.sidebar-collapsed {
    overflow: hidden;
}
document.body.classList.toggle("sidebar-collapsed");

@media (max-width: 991.98px) {
    .main-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1100;
        background: #fff;
        border-bottom: 1px solid #e5e5e5;
    }

    .content-wrapper {
        padding-top: 64px; /* header高さ分 */
    }
}

/* collapsed 時は toggle 以外を無効化 */
#sidebar.collapsed {
  pointer-events: none;
}
/* トグルボタンだけは有効 */
#sidebar.collapsed #pcSidebarToggle {
  pointer-events: auto;
}

/* ただし toggle 自体は「専用領域」に限定 */
#pcSidebarToggle {
  position: relative;
  z-index: 1100;
}

#sidebar.collapsed {
  pointer-events: none;
}
#sidebar.collapsed #pcSidebarToggle {
  pointer-events: auto;
}
.parent-arrow {
  pointer-events: none;
}
#sidebar.collapsed {
  overflow: hidden;      /* ★ visible をやめる */
}
#sidebar {
  overflow: hidden;
  contain: paint;        /* 対応ブラウザなら効く */
}