/* ========================================
   共通CSS - 全ページで使用
   ======================================== */

/* ========================================
   CSS Variables
   ======================================== */
:root {
  --primary-green: #08BF5A;
  --primary-green-dark: #07a84f;
  --line-green: #06c755;
  --category-green: #44CB80;
  --sidebar-bg: #F4FBF3;
  --sidebar-bg-hover: #e8f5e6;
  --main-area-bg: #EFF2F6;
  --text-primary: #222222;
  --text-secondary: #666666;
  --text-muted: #999999;
  --link-color: #5799DB;
  --bg-white: #FFFFFF;
  --bg-gray: #F2F2F2;
  --border-color: #E0E0E0;
  --border-light: #EEEEEE;
  --header-height: 79px;
  --sidebar-width: 271px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Lato', sans-serif;
  background-color: var(--bg-white);
  font-size: 14px;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ========================================
   ヘッダー
   ======================================== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: var(--primary-green);
  z-index: 1000;
  display: flex;
  align-items: center;
  padding: 0 15px;
  gap: 15px;
}

.header-logo {
  color: white;
  font-size: 18px;
  font-weight: bold;
  text-decoration: none;
  white-space: nowrap;
  margin-right: 10px;
}
.header-logo:hover { color: white; }

/* アカウント/グループドロップダウン */
.account-dropdown { position: relative; }
.account-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 230px;
  height: 38px;
  background-color: white;
  border: none;
  border-radius: 4px;
  padding: 0 12px;
  cursor: pointer;
  transition: box-shadow 0.2s;
}
.account-dropdown-toggle:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }

.account-avatar {
  width: 28px;
  height: 28px;
  background-color: #E8E8E8;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.account-avatar i { color: #888; font-size: 14px; }
.account-avatar.small { width: 24px; height: 24px; }
.account-avatar.small i { font-size: 12px; }

.account-name {
  flex: 1;
  text-align: left;
  font-size: 14px;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-arrow {
  color: #666;
  font-size: 12px;
  transition: transform 0.2s;
}
.account-dropdown.open .dropdown-arrow { transform: rotate(180deg); }

.account-dropdown-menu {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  width: 230px;
  background: white;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  display: none;
  overflow: hidden;
  z-index: 1001;
}
.account-dropdown.open .account-dropdown-menu { display: block; }

.account-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  color: #333;
  text-decoration: none;
  transition: background 0.15s;
}
.account-dropdown-item:hover { background-color: #F5F5F5; }
.account-dropdown-item.active { background-color: #F0FBF5; }
.account-item-name { flex: 1; font-size: 14px; }

.account-dropdown-item.add-new { border-top: 1px solid #EEE; }
.add-icon { width: 24px; text-align: center; font-size: 16px; }

/* 友だち追加ボタン */
.header-action-btn {
  width: 38px;
  height: 38px;
  background-color: white;
  border: 2px solid var(--primary-green);
  border-radius: 4px;
  color: var(--primary-green);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s;
}
.header-action-btn:hover {
  background-color: var(--primary-green);
  color: white;
}

/* ユーザーメニュードロップダウン */
.user-menu {
  position: relative;
  margin-left: auto;
}
.user-menu-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 4px;
  transition: background-color 0.2s;
}
.user-menu-toggle:hover {
  background-color: rgba(255, 255, 255, 0.15);
}
.user-menu-avatar {
  width: 32px;
  height: 32px;
  background-color: rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-menu-avatar i {
  font-size: 18px;
  color: white;
}
.user-menu-toggle .user-info-content {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.user-menu-toggle .user-name {
  font-size: 14px;
  font-weight: 600;
}
.user-menu-toggle .user-role {
  font-size: 11px;
  opacity: 0.85;
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 8px;
  border-radius: 10px;
}
.user-menu-arrow {
  font-size: 10px;
  opacity: 0.7;
  transition: transform 0.2s;
}
.user-menu.open .user-menu-arrow {
  transform: rotate(180deg);
}
.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  width: 200px;
  background: white;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  display: none;
  overflow: hidden;
  z-index: 1001;
}
.user-menu.open .user-menu-dropdown {
  display: block;
}
.user-menu-info {
  padding: 12px 15px;
  border-bottom: 1px solid #eee;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.user-menu-name {
  font-size: 14px;
  font-weight: 600;
  color: #333;
}
.user-menu-role {
  font-size: 12px;
  color: #888;
}
.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  color: #333;
  text-decoration: none;
  transition: background 0.15s;
  font-size: 14px;
}
.user-menu-item:hover {
  background-color: #f5f5f5;
}
.user-menu-item i {
  width: 20px;
  text-align: center;
  color: #888;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
}

/* ========================================
   メインコンテナ
   ======================================== */
.main-container {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

/* ========================================
   サイドバー
   ======================================== */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: var(--header-height);
  left: 0;
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  z-index: 100;
}
.sidebar-nav { display: flex; flex-direction: column; height: 100%; }
.nav-menu { list-style: none; flex: 1; padding: 0; margin: 0; }

.nav-category {
  color: var(--category-green);
  font-size: 16px;
  font-weight: 700;
  padding: 10px 15px;
  border-left: 3px solid var(--primary-green);
  margin-top: 5px;
}
.nav-category:first-child { margin-top: 0; }

.nav-subcategory {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: bold;
  padding: 12px 15px 6px 15px;
  list-style: none;
}

.nav-item { list-style: none; }
.nav-item > a {
  display: flex;
  align-items: center;
  padding: 15px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 14px;
  transition: background-color 0.15s;
}
.nav-item > a:hover { background-color: rgba(8, 191, 90, 0.08); }
.nav-item.active > a { color: var(--primary-green); font-weight: bold; }
.nav-item > a > i {
  width: 25px;
  margin-right: 15px;
  color: var(--primary-green);
  font-size: 20px;
  text-align: center;
  flex-shrink: 0;
}

.submenu {
  display: none;
  list-style: none;
  padding: 0;
  margin: 0;
  background-color: rgba(0, 0, 0, 0.02);
}
.nav-item.has-submenu.open > .submenu { display: block; }
.submenu li { list-style: none; }
.submenu li a {
  display: block;
  padding: 10px 15px 10px 55px;
  color: #444;
  text-decoration: none;
  font-size: 13px;
  transition: background-color 0.15s;
}
.submenu li a:hover { background-color: rgba(8, 191, 90, 0.1); }
.submenu li a.active {
  color: var(--line-green);
  font-weight: 500;
  background-color: rgba(8, 191, 90, 0.08);
}

.nav-logout { margin-top: 10px; }

.sidebar-footer {
  border-top: 1px solid var(--border-color);
}
.menu-collapse-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 15px;
  background: none;
  border: none;
  color: #666;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
}
.menu-collapse-btn:hover {
  background-color: rgba(8, 191, 90, 0.08);
  color: var(--primary-green);
}
.menu-collapse-btn i { font-size: 14px; width: 20px; text-align: center; }

/* ========================================
   メインコンテンツ
   ======================================== */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 20px 30px;
  flex: 1;
  background-color: var(--main-area-bg);
  min-height: calc(100vh - var(--header-height));
}

/* ========================================
   オーバーレイ（モバイル用）
   ======================================== */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* サイドバー開時の背景スクロール防止 */
body.sidebar-open {
  overflow: hidden;
}

/* ========================================
   レスポンシブ対応
   ======================================== */

/* --- Tablet (991px以下) --- */
@media (max-width: 991px) {
  /* ヘッダー調整 */
  .header {
    padding: 0 12px;
    gap: 10px;
  }

  /* アカウントドロップダウン縮小 */
  .account-dropdown-toggle {
    width: 180px;
  }

  .account-name {
    font-size: 13px;
  }

  /* ヘッダー検索を非表示 */
  .header-search {
    display: none;
  }

  /* メニュートグル表示 */
  .menu-toggle {
    display: flex;
  }

  /* サイドバー: オーバーレイ表示 */
  .sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 100;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* コンテンツエリア */
  .main-content {
    margin-left: 0;
    padding: 20px 15px;
  }

  /* ユーザーメニュー: テキスト非表示、アイコンのみ */
  .user-menu-toggle .user-info-content {
    display: none;
  }
  .user-menu-arrow {
    display: none;
  }
}

/* --- Phone (767px以下) --- */
@media (max-width: 767px) {
  /* ヘッダー高さ調整 */
  :root {
    --header-height: 60px;
  }

  .header {
    padding: 0 10px;
    gap: 8px;
  }

  /* ロゴ縮小 */
  .header-logo {
    font-size: 16px;
  }

  /* アカウントドロップダウンさらに縮小 */
  .account-dropdown-toggle {
    width: 150px;
    height: 36px;
    padding: 0 10px;
  }

  .account-avatar {
    width: 24px;
    height: 24px;
  }

  .account-name {
    font-size: 12px;
  }

  /* アクションボタン縮小 */
  .header-action-btn {
    width: 36px;
    height: 36px;
  }

  /* サイドバー幅調整 */
  .sidebar {
    width: 260px;
  }

  .main-content {
    padding: 15px 12px;
  }
}

/* --- Small Phone (575px以下) --- */
@media (max-width: 575px) {
  .header {
    padding: 0 8px;
    gap: 6px;
  }

  /* ロゴをアイコンのみに */
  .header-logo {
    font-size: 14px;
  }

  /* アカウントドロップダウン最小化 */
  .account-dropdown-toggle {
    width: 40px;
    padding: 0;
    justify-content: center;
  }

  .account-dropdown-toggle .account-name,
  .account-dropdown-toggle .dropdown-arrow {
    display: none;
  }

  .account-dropdown-menu {
    left: auto;
    right: 0;
  }

  /* アクションボタン非表示（スペース確保） */
  .header-action-btn:not(.menu-toggle) {
    display: none;
  }

  .main-content {
    padding: 10px 8px;
  }
}

/* --- オーバーレイ表示 --- */
@media (max-width: 991px) {
  .sidebar-overlay.active {
    display: block;
  }
}
