/* テーマ変数 */
:root {
  --bg-main: #10203e;
  --bg-container: #14284e;
  --bg-scroll: #14284e;
  --bg-palette: #0e1d3a;
  --bg-time-label: #2e5dad;
  --text-calendar: #ddd;
  --text-stat: white;
}

/* 月テーマ（デフォルト） */
body[data-theme="moon"] {
  --bg-main: #10203e;
  --bg-container: #14284e;
  --bg-scroll: #14284e;
  --bg-palette: #0e1d3a;
  --bg-time-label: #2e5dad;
  --text-calendar: #ddd;
  --text-stat: white;
}

/* 太陽テーマ */
body[data-theme="sun"] {
  --bg-main: #fff5e6;
  --bg-container: #ffffff;
  --bg-scroll: #fffaf0;
  --bg-palette: #fff8dc;
  --bg-time-label: #ff9800;
  --text-calendar: #333;
  --text-stat: #333;
}

/* 植物テーマ */
body[data-theme="plant"] {
  --bg-main: #e8f5e9;
  --bg-container: #f1f8f4;
  --bg-scroll: #f1f8f4;
  --bg-palette: #c8e6c9;
  --bg-time-label: #4caf50;
  --text-calendar: #1b5e20;
  --text-stat: #1b5e20;
}
body[data-theme="deceased"] {
  --bg-main: #1a1a1a;
  --bg-container: #2a2a2a;
  --bg-scroll: #2a2a2a;
  --bg-palette: #1a1a1a;
  --bg-time-label: #666666;
  --text-calendar: #999;
  --text-stat: #999;
}
body[data-theme="ocean"] {
  --bg-main: #0f2a3d;
  --bg-container: #143a52;
  --bg-scroll: #143a52;
  --bg-palette: #0c2233;
  --bg-time-label: #1e88e5;
  --text-calendar: #e3f2fd;
  --text-stat: #bbdefb;
}
body[data-theme="paper"] {
  --bg-main: #f7f7f7;
  --bg-container: #ffffff;
  --bg-scroll: #ffffff;
  --bg-palette: #eeeeee;
  --bg-time-label: #555;
  --text-calendar: #222;
  --text-stat: #000;
}
body[data-theme="sakura"] {
  --bg-main: #fff7f9;
  --bg-container: #ffffff;
  --bg-scroll: #fff5f8;
  --bg-palette: #fdecef;
  --bg-time-label: #e85a8c;
  --text-calendar: #4a2c33;
  --text-stat: #4a2c33;
}
body[data-theme="coffee"] {
  --bg-main: #2b1f1a;
  --bg-container: #3a2a23;
  --bg-scroll: #3a2a23;
  --bg-palette: #241914;
  --bg-time-label: #a97142;
  --text-calendar: #f1e4d1;
  --text-stat: #f1e4d1;
}

body[data-theme="wine"] {
  --bg-main: #1b0f14;
  --bg-container: #26131a;
  --bg-scroll: #26131a;
  --bg-palette: #140a0e;
  --bg-time-label: #8e2a3a;
  --text-calendar: #f2d7dc;
  --text-stat: #f2d7dc;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-user-select: none; /* Safari, iOS Safari対応 */
  -moz-user-select: none; /* Firefox */
  -ms-user-select: none; /* Edge(旧) */
  user-select: none; /* 標準仕様 */
  touch-action: manipulation;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
    sans-serif;
  background: var(--bg-main);
  min-height: 100vh;
  padding: 20px;
  overflow: hidden; /* 全体はスクロール不可 */
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  background: var(--bg-container);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  position: relative;
  height: calc(100vh - 40px); /* 画面いっぱいに調整 */
  display: flex;
  flex-direction: column;
}

.header {
  background: var(--bg-container);
  color: var(--text-calendar);
  padding: 10px;
  text-align: center;
  flex-shrink: 0;
  /* 以下追加分 */
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: fixed;
  top: 15px;
  left: 20px;
  right: 20px;
  z-index: 1000;
  border-top-left-radius: 15px;
  border-top-right-radius: 15px;
}

.header h1 {
  font-size: 25px;
}
.version {
  font-size: 10px;
}
.login-screen {
  margin-top: 50px;
  padding: 10px 30px;
  text-align: center;
  color: var(--text-calendar);
  background: var(--bg-container);
}

.login-screen input {
  width: 100%;
  max-width: 400px;
  padding: 15px 20px;
  font-size: 16px;
  border: 2px solid #667eea;
  border-radius: 10px;
  margin: 10px 0;
  text-align: center;
}

.login-screen button {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 15px 40px;
  font-size: 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.2s;
}

.login-screen button:hover {
  transform: translateY(-2px);
}
#loginError {
  color: red;
  margin-top: 10px;
}
.terms {
  margin: 0 auto;
  text-align: left;
  height: 33vh;
  overscroll-behavior: contain;
  overflow-y: auto;
  position: relative;
  z-index: 1;
}
.main-content {
  display: none;
  flex: 1;
  position: relative;
}

.user-info {
  background: #f8f9fa;
  padding: 15px 20px;
  border-radius: 10px;
  display: none;
  /*よくよく考えれば不要*/
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.logout-btn {
  background: #dc3545;
  color: white;
  border: none;
  padding: 8px 20px;
  border-radius: 5px;
  cursor: pointer;
}

/* bandPaletteを完全固定 */
.band-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 20px;
  background: var(--bg-palette);
  position: fixed;
  top: 70px;
  left: 20px;
  right: 20px;
  width: auto;
  max-width: 1400px;
  margin: 0;
  z-index: 999;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* 下のスクロール領域 */
.scroll-area {
  background: var(--bg-scroll);
  position: absolute;
  top: 140px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  padding-top: 160px;
  padding-left: 10px;
  padding-right: 10px;
  box-sizing: border-box;
  -ms-overflow-style: none;
  scrollbar-width: none;
  display: flex;
}
#calendarsContainer {
  color: var(--text-calendar);
}
.calendar {
  margin-bottom: 40px;
}

.calendar h3 {
  text-align: center;
  margin-bottom: 20px;
  color: var(--text-calendar);
}

.calendar-grid {
  display: grid;
  grid-template-columns: 100px repeat(7, 1fr);
  gap: 5px;
}

.time-label {
  background: var(--bg-time-label);
  color: white;
  text-align: center;
  font-size: 12px;
  font-weight: bold;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.day-header {
  background: var(--bg-time-label);
  color: white;
  padding: 10px;
  text-align: center;
  font-weight: bold;
  border-radius: 5px;
}

.slot {
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  min-height: 60px;
  /* ※長期休暇仕様の時は変更※ */
  padding: 8px;
  font-size: 10px;
  transition: all 0.3s;
  background: #aaaaaa;
}

.slot-info {
  margin: 0 !important;
  font-size: 10px !important;
  /* ※長期休暇仕様の時は変更※ */
}

.slot.current-time {
  border: 3px solid #ffc107;
  box-shadow: 0 0 10px rgba(255, 193, 7, 0.5);
}

.slot.drag-over {
  background: #e3f2fd;
  border-color: #2196f3;
}

.slot.reserved {
  color: white;
  font-weight: bold;
  font-size: 12px !important;
  /* 長期休暇 */
}

.slot-info {
  font-size: 11px;
  margin-top: 5px;
  opacity: 0.9;
}

.stats {
  margin-top: 40px;
  padding: 20px;
  background: var(--bg-scroll);
  border-radius: 10px;
}

.stats h3 {
  margin-bottom: 15px;
  color: var(--text-stat);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px 20px; /* 行間と列間 */
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
  color: #fff;
  font-family: "Segoe UI", sans-serif;
  min-width: 50px;
}

.band-name {
  flex: 1;
  text-align: left;
  padding-right: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.band-count {
  text-align: right;
  min-width: 3em;
}

.band-block {
  padding: 6px 10px;
  border-radius: 8px;
  color: white;
  font-weight: bold;
  cursor: move;
  user-select: none;
  touch-action: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}
@media (max-width: 1024px) {
  .calendar-grid {
    font-size: 11px;
  }
  .band-block {
    padding: 10px 6px;
    font-size: 10px;
  }
  .stats {
    display: none;
  }
}

.loadingText {
  text-align: center;
}

.dragging-clone {
  position: fixed;
  pointer-events: none;
  display: block;
  z-index: 1000000;
  opacity: 0.8;
  padding: 10px 6px;
  border-radius: 8px;
  color: white;
  font-weight: bold;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  transition: none;
  font-size: 10px;
  white-space: nowrap;
  text-align: center;
}
#loadingOverlay {
  position: fixed;
  padding: 0;
  margin: 0;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(255, 255, 255, 0.8);
  display: none;
  justify-content: center;
  align-items: center;
  font-size: 2rem;
  color: #333;
  z-index: 999999999999;
  backdrop-filter: blur(5px);
}
#knowledge {
  padding: 100px;
}
.loadingText {
  animation: pulse 1.5s infinite;
  font-weight: bold;
}

@keyframes pulse {
  0% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.4;
  }
}
.material-symbols-outlined {
  -webkit-tap-highlight-color: transparent;
  outline: none;
  user-select: none;
}
.switchers {
  display: flex;
  align-items: center;
}
.theme-switcher {
  cursor: pointer;
  font-size: 28px;
  padding: 0 15px;
  user-select: none;
  transition: transform 0.2s;
}

.theme-switcher:hover {
  transform: scale(1.1);
}

/* デバイス切り替えアイコン用スタイルを追加 */
.device-switcher {
  cursor: pointer;
  font-size: 28px;
  padding: 0 15px;
  user-select: none;
  transition: transform 0.2s;
  display: none; /* デフォルトは非表示 */
}

.device-switcher:hover {
  transform: scale(1.1);
}

/* iPad縦(768px)未満でデバイス切り替えを表示 */
@media (max-width: 767px) {
  .device-switcher {
    display: block;
  }
  body[data-display-mode="mobile"] .slot {
    min-height: 38px;
  }
}
/* モバイルモード時のスロット表示 */
body[data-display-mode="mobile"] .slot.reserved {
  font-size: 10px;
}

body[data-display-mode="mobile"] .slot-info {
  display: none; /* ユーザー名と日付を非表示 */
}

/* 768px以上の場合は強制的にPC表示 */
@media (min-width: 768px) {
  body[data-display-mode="mobile"] .slot.reserved {
    font-size: 12px;
  }
  body[data-display-mode="mobile"] .slot-info {
    display: block;
  }
}
@media (max-width: 767px) {
  .mobilenone {
    display: none;
  }
}

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  z-index: 10000;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--bg-time-label);
  padding: 30px;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  max-width: 400px;
  width: 90%;
  text-align: center;
  animation: slideUp 0.3s ease;
  color: var(--text-calendar);
}

.modal-content h3 {
  margin: 0 0 15px 0;
  font-size: 24px;
  font-weight: bold;
}

.modal-content p {
  margin: 0 0 25px 0;
  font-size: 16px;
  line-height: 1.6;
}

.modal-button {
  background: white;
  color: #667eea;
  border: none;
  padding: 12px 30px;
  border-radius: 25px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.modal-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.modal-button:active {
  transform: translateY(0);
}

/* 確認モーダルのボタンコンテナ */
.modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* キャンセルボタン */
.modal-button-cancel {
  background: rgba(255, 255, 255, 0.2);
  color: var(--text-calendar);
  border: 2px solid rgba(255, 255, 255, 0.4);
}

.modal-button-cancel:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* 確認（はい）ボタン */
.modal-button-confirm {
  background: white;
  color: #667eea;
}

.modal-button-confirm:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   Chordal v3.5 - 追加スタイル（style.cssに追記してください）
   ============================================================ */

/* スケジュールモードタブ */
.schedule-tabs {
  display: flex;
  gap: 0;
  position: fixed;
  top: 55px;
  left: 20px;
  right: 20px;
  z-index: 1000;
  background: var(--bg-palette);
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.schedule-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  justify-content: center;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  font-family: inherit;
}

.schedule-tab:hover {
  color: rgba(255, 255, 255, 0.7);
}

.schedule-tab.active {
  color: #fff;
  border-bottom-color: #4a9eff;
  background: rgba(74, 158, 255, 0.1);
}

.schedule-tab .material-symbols-outlined {
  font-size: 18px;
}

/* バンドパレットの位置調整（タブの分だけ下げる） */
.band-palette {
  top: 95px !important;
}

/* スクロール領域の位置調整 */
.scroll-area {
  padding-top: 200px !important;
}

/* モード参照セル */
.slot.mode-redirect {
  background: rgba(255, 255, 255, 0.05) !important;
  border: 2px dashed rgba(255, 255, 255, 0.15) !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

.redirect-text {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.3);
  text-align: center;
  line-height: 1.3;
  font-weight: normal;
}

/* 休暇日マーカー（通常モードのヘッダー） */
.day-header.holiday-marked {
  position: relative;
}

.day-header.holiday-marked::after {
  content: "🏖";
  font-size: 10px;
  margin-left: 2px;
}

/* 休暇日アクティブ（長期休暇モードのヘッダー） */
.day-header.holiday-active {
  background: #e65100 !important;
}

/* MSログインボタン */
.ms-login-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 15px 30px;
  font-size: 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.2s;
}

.ms-login-button:hover {
  transform: translateY(-2px);
}

.login-description {
  color: var(--text-calendar);
  opacity: 0.7;
  margin: 10px 0 20px;
  font-size: 14px;
}

/* ログアウトボタン */
.logout-button {
  cursor: pointer;
  font-size: 28px;
  padding: 0 15px;
  user-select: none;
  transition: transform 0.2s;
}

.logout-button:hover {
  transform: scale(1.1);
}

/* 承認待ち画面 */
.pending-screen {
  margin-top: 50px;
  padding: 10px 30px;
  text-align: center;
  color: var(--text-calendar);
}

.pending-user-info {
  margin-top: 15px;
  opacity: 0.6;
  font-size: 14px;
}

/* ============================================================
   Chordal v3.5 - 追加スタイル（style.cssに追記してください）
   ============================================================ */

/* スケジュールモードタブ */
.schedule-tabs {
  display: flex;
  gap: 0;
  position: fixed;
  top: 55px;
  left: 20px;
  right: 20px;
  z-index: 1000;
  background: var(--bg-palette);
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.schedule-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  justify-content: center;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  font-family: inherit;
}

.schedule-tab:hover {
  color: rgba(255, 255, 255, 0.7);
}

.schedule-tab.active {
  color: #fff;
  border-bottom-color: #4a9eff;
  background: rgba(74, 158, 255, 0.1);
}

.schedule-tab .material-symbols-outlined {
  font-size: 18px;
}

/* バンドパレットの位置調整（タブの分だけ下げる） */
.band-palette {
  top: 95px !important;
}

/* スクロール領域の位置調整 */
.scroll-area {
  padding-top: 200px !important;
}

/* モード参照セル（1セルに結合） */
.slot.mode-redirect-merged {
  background: rgba(255, 255, 255, 0.03) !important;
  border: 2px dashed rgba(255, 255, 255, 0.12) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.redirect-text-merged {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.3);
  text-align: center;
  line-height: 1.4;
  font-weight: 600;
}

/* 休暇日マーカー（通常モードのヘッダー） */
.day-header.holiday-marked {
  position: relative;
}

.day-header.holiday-marked::after {
  content: "🏖";
  font-size: 10px;
  margin-left: 2px;
}

/* 休暇日アクティブ（長期休暇モードのヘッダー） */
.day-header.holiday-active {
  background: #e65100 !important;
}

/* MSログインボタン */
.ms-login-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 15px 30px;
  font-size: 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.2s;
}

.ms-login-button:hover {
  transform: translateY(-2px);
}

.login-description {
  color: var(--text-calendar);
  opacity: 0.7;
  margin: 10px 0 20px;
  font-size: 14px;
}

/* ログアウトボタン */
.logout-button {
  cursor: pointer;
  font-size: 28px;
  padding: 0 15px;
  user-select: none;
  transition: transform 0.2s;
}

.logout-button:hover {
  transform: scale(1.1);
}

/* 承認待ち画面 */
.pending-screen {
  margin-top: 50px;
  padding: 10px 30px;
  text-align: center;
  color: var(--text-calendar);
}

.pending-user-info {
  margin-top: 15px;
  opacity: 0.6;
  font-size: 14px;
}
