/* 共通スタイル */
body, html {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: sans-serif;
}
body.dragging, body.resizing {
  user-select: none;
}
#container {
  position: relative;
  display: flex;
  width: 100%;
  height: 100%;
}
.info-popup {
  position: absolute;
  z-index: 10000;
  pointer-events: none;
  transition: opacity 0.2s;
}

/* 左サイドバー */
#twitch-sidebar {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 45px;
  background-color: #222;
  color: white;
  padding: 10px 0;
  z-index: 10;
  box-sizing: border-box;
  overflow-y: scroll;
  overflow-x: hidden;
  scrollbar-width: none;
}
#twitch-sidebar::-webkit-scrollbar { width: 0px; background: transparent; }
#twitch-sidebar:not(.expanded):hover {
  scrollbar-width: thin;
  scrollbar-color: #555 #333;
}
#twitch-sidebar:not(.expanded):hover::-webkit-scrollbar { width: 8px; }
#twitch-sidebar:not(.expanded) #sort-buttons { display: none; }
#twitch-sidebar.expanded {
  width: 250px;
  padding: 10px 5px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #555 #333;
}
#twitch-sidebar.expanded::-webkit-scrollbar { width: 8px; background: #333; }
#twitch-sidebar.expanded::-webkit-scrollbar-track { background: #333; border-radius: 8px; }
#twitch-sidebar.expanded::-webkit-scrollbar-thumb { background: #555; border-radius: 8px; }

/* ヘッダー・ソートボタン */
#sidebar-header {
  position: relative;
  height: 30px;
  width: 100%;
  margin-bottom: 10px;
  overflow: hidden;
  padding: 0;
  box-sizing: border-box;
  display: flex;
  align-items: center;
}
#sort-buttons {
  display: flex;
  gap: 5px;
  margin-right: auto;
}
#sort-buttons button {
  background: none;
  border: none;
  color: white;
  font-size: 14px;
  cursor: pointer;
  padding: 2px 5px;
}
#sort-buttons button.active {
  font-weight: bold;
  text-decoration: underline;
}
#twitch-sidebar:not(.expanded) #sidebar-header button {
  width: 35px;
  height: 30px;
  line-height: 30px;
  padding: 0;
  border: none;
  background: none;
  color: white;
  font-size: 16px;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
}
#twitch-sidebar.expanded #sidebar-header { padding: 0 5px; }
#collapse-button {
  position: absolute;
  right: 5px;
  top: 0;
  width: 35px;
  height: 30px;
  line-height: 30px;
  border: none;
  background: none;
  color: white;
  font-size: 16px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-block;
}

/* 内部リスト */
#live-list { width: 100%; }
.channel-entry {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 2px;
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  transition: background-color 0.2s;
  text-align: left;
}
.channel-entry:hover { background-color: #333; }
.channel-entry img {
  border-radius: 50%;
  width: 35px;
  height: 35px;
  flex-shrink: 0;
}
#twitch-sidebar.expanded .channel-entry { padding: 5px; }
#twitch-sidebar.expanded .channel-info {
  flex-grow: 1;
  margin-left: 5px;
  overflow: hidden;
}
#twitch-sidebar.expanded .channel-info .channel-name {
  font-size: 14px;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#twitch-sidebar.expanded .channel-info .channel-category {
  font-size: 12px;
  color: #ccc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#twitch-sidebar.expanded .viewer-count {
  font-size: 12px;
  margin-left: 5px;
  white-space: nowrap;
}

/* 左側配信ウィンドウ領域 */
#left-container {
  position: relative;
  flex: 1;
  background-color: #000;
  overflow: visible;
  z-index: 1;
}

/* 最小化領域 */
#minimized-streams {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: #808080;
  padding: 5px;
  display: flex;
  gap: 5px;
  box-sizing: border-box;
}
.minimized-item {
  background-color: #696969;
  color: white;
  padding: 3px 6px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
}

/* 空状態表示エリア */
#empty-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
#empty-message {
  color: white;
  white-space: pre;
  max-width: 90vw;
  margin-bottom: 20px;
}
#ad-banner, #ad-banner-large {
  position: static;
  margin: 10px auto;
  display: block;
}
/* 広告バナーコンテナ */
#ad-banner-large { width: 336px; height: 280px; background-color: #000; }
#ad-banner { width: 728px; height: 90px; background-color: #000; }

/* divider */
#divider {
  width: 5px;
  background-color: #666;
  cursor: col-resize;
  z-index: 10000;
}

/* 右側領域 */
#right-container {
  width: 340px;
  background-color: #333;
  color: white;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 10000;
}
#stream-controls {
  display: flex;
  flex-direction: column;
  padding: 10px;
  background-color: #444;
}
.row.row1, .row.row2 {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 5px;
}
#stream-input {
  flex: 1;
  min-width: 100px;
  padding: 5px;
  box-sizing: border-box;
}
#fav-select {
  width: 120px;
  padding: 5px;
  border-radius: 3px;
  background: #666;
  color: white;
}
#stream-controls button {
  background-color: #721de0;
  color: #fff;
  border: none;
  padding: 5px 10px;
  border-radius: 3px;
  cursor: pointer;
}
/* チャット切替用ボタン */
#chat-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 5px;
  background: #222;
}
.chat-button img {
  width: 40px;
  height: 40px;
  border-radius: 0;
  display: block;
}
.chat-button.no-thumbnail {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #ccc;
  color: #000;
  font-size: 16px;
  font-weight: bold;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.chat-button {
  position: relative;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 0;
}
.chat-button.selected {
  border-color: #721de0;
}

/* チャットウィンドウ */
#chat-wrapper {
  position: relative;
  flex: 1;
  overflow: hidden;
}
#chat-container {
  width: 100%;
  height: 100%;
  position: relative;
}
#chat-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* 配信ウィンドウ */
.stream-window {
  position: absolute;
  background-color: transparent;
  box-sizing: border-box;
  min-width: 240px;
  min-height: 135px;
}

/* コントロールバー */
.control-bar {
  background-color: rgba(0,0,0,0.6);
  color: white;
  left: 20px;
  right: 20px;
  position: absolute;
  top: 0;
  z-index: 3;
  opacity: 0;
  cursor: move;
  display: flex;
  align-items: center;
}
.stream-window:hover .control-bar { opacity: 1; }
.button-container {
  display: flex;
  flex-direction: row;
  gap: 5px;
  align-items: center;
  margin-left: auto;
}

/* 下部リサイズハンドル（右下） */
.resize-handle {
  width: 20px;
  height: 20px;
  position: absolute;
  right: 0;
  bottom: 0;
  cursor: se-resize;
  z-index: 4;
  background: transparent;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.resize-handle:before {
  content: "";
  position: absolute;
  width: 20px;
  height: 3px;
  left: 0;
  bottom: 0;
  background-color: white;
}
.resize-handle:after {
  content: "";
  position: absolute;
  width: 3px;
  height: 100%;
  right: 0;
  top: 0;
  background-color: white;
}

/* 下部リサイズハンドル（左下） */
.resize-handle-left {
  width: 20px;
  height: 20px;
  position: absolute;
  left: 0;
  bottom: 0;
  cursor: sw-resize;
  z-index: 4;
  background: transparent;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.resize-handle-left:before, .resize-handle-left:after {
  content: "";
  position: absolute;
  background-color: white;
}
.resize-handle-left:before { width: 3px; height: 100%; left: 0; bottom: 0; }
.resize-handle-left:after { width: 100%; height: 3px; left: 0; bottom: 0; }

/* 上部リサイズハンドル（右上） */
.resize-handle-top-right {
  width: 20px;
  height: 20px;
  position: absolute;
  right: 0;
  top: 0;
  cursor: ne-resize;
  z-index: 4;
  background: transparent;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.resize-handle-top-right:before {
  content: "";
  position: absolute;
  width: 20px;
  height: 3px;
  left: 0;
  top: 0;
  background-color: white;
}
.resize-handle-top-right:after {
  content: "";
  position: absolute;
  width: 3px;
  height: 100%;
  right: 0;
  top: 0;
  background-color: white;
}

/* 上部リサイズハンドル（左上） */
.resize-handle-top-left {
  width: 20px;
  height: 20px;
  position: absolute;
  left: 0;
  top: 0;
  cursor: nw-resize;
  z-index: 4;
  background: transparent;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.resize-handle-top-left:before,
.resize-handle-top-left:after {
  content: "";
  position: absolute;
  background-color: white;
}
.resize-handle-top-left:before { width: 3px; height: 100%; left: 0; top: 0; }
.resize-handle-top-left:after { width: 100%; height: 3px; left: 0; top: 0; }
.stream-window:hover .resize-handle,
.stream-window:hover .resize-handle-left,
.stream-window:hover .resize-handle-top-right,
.stream-window:hover .resize-handle-top-left {
  opacity: 1;
  pointer-events: auto;
}

/* ボタン類 */
.fav-button, .update-button, .close-button, .maximize-button, .minimize-button {
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
  padding: 2px;
  width: 16px;
  height: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
}
.close-button, .maximize-button, .minimize-button {
  background-color: gray;
  color: white;
  z-index: 1;
}
.update-button { background-color: green; color: white; }
.tooltip {
  position: fixed;
  background-color: black;
  color: white;
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 100000;
  opacity: 0;
  transition: opacity 0.2s;
}

/* クリックオーバーレイ */
.click-overlay {
  position: absolute;
  top: 24px;
  left: 0;
  width: 100%;
  height: calc(100% - 24px);
  z-index: 2;
  background-color: transparent;
  pointer-events: auto;
}
#close-chat-button {
  position: absolute;
  top: 5px;
  left: 5px;
  background: transparent;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  z-index: 1;
}
#close-chat-button::after { content: "|⮕"; }
#open-chat-button {
  position: fixed;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.8);
  border: none;
  color: white;
  font-size: 18px;
  padding: 5px 8px;
  border-radius: 3px;
  cursor: pointer;
  z-index: 99999;
}
