/* ============================================================
   desktop.css — デスクトップ環境（DESIGN.md準拠）
   ============================================================ */
:root {
  --bg-desktop: #c4ccbd;
  --bg-primary: #f1f0ef;
  --bg-secondary: #ffffff;
  --bg-hover: #e6e4e2;
  --bg-input: #f6f5f4;
  --bg-sidebar: #f3f2f0;
  --accent: #5e6ad2;
  --accent-hover: #4f5bc3;
  --accent-light: #828fff;
  --text-primary: rgba(0,0,0,0.9);
  --text-secondary: #4a4845;
  --text-muted: #8a8f98;
  --success: #27a644;
  --danger: #e74c3c;
  --warning: #f39c12;
  --border: rgba(0,0,0,0.12);
  --border-light: rgba(0,0,0,0.07);
  --shadow-card: rgba(0,0,0,0.06) 0px 2px 8px, rgba(0,0,0,0.04) 0px 4px 18px, rgba(0,0,0,0.02) 0px 1px 3px;
  --shadow-window: rgba(0,0,0,0.12) 0px 8px 32px, rgba(0,0,0,0.06) 0px 4px 16px, rgba(0,0,0,0.03) 0px 1px 4px;
  --msg-self: #6ab04c;
  --msg-other: #ffffff;
  --msg-bg: var(--bg-primary);
  --staff-bg: #eaecf8;
  --staff-text: #5e6ad2;
  --tenant-bg: #e5f5e8;
  --tenant-text: #27a644;
}

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

body {
  font-family: Inter, -apple-system, system-ui, 'Segoe UI', Helvetica, 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', Arial, sans-serif;
  background: var(--bg-desktop);
  color: var(--text-primary);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overflow-x: hidden;
  user-select: none;
  font-size: 14px;
  line-height: 1.5;
  max-width: 100%;
}

/* --- ログイン画面 --- */
#login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  transition: opacity 0.5s;
}
#login-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}
.login-box {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 48px 40px;
  width: 380px;
  box-shadow: var(--shadow-window);
  border: 1px solid var(--border);
  text-align: center;
}
.login-logo {
  margin-bottom: 8px;
}
.login-logo-img {
  max-width: 260px;
  height: auto;
}
.login-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 32px;
}
.login-field {
  margin-bottom: 20px;
  text-align: left;
}
.login-field label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}
.login-field input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-input);
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}
.login-field input:focus {
  border-color: var(--accent);
  background: var(--bg-secondary);
}
.login-btn {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  margin-top: 8px;
  font-family: inherit;
  box-shadow: rgba(94,106,210,0.3) 0px 2px 8px;
}
.login-btn:hover {
  background: var(--accent-hover);
  box-shadow: rgba(94,106,210,0.4) 0px 4px 12px;
}
.login-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ログイン中画面 */
.login-loading {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.login-loading.active {
  display: flex;
}
.login-loading .login-box {
  box-shadow: none;
  border: none;
  background: transparent;
}
.login-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(94,106,210,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: login-spin 0.7s linear infinite;
}
.login-loading-text {
  font-size: 13px;
  color: var(--text-secondary);
}
@keyframes login-spin {
  to { transform: rotate(360deg); }
}
.login-version {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 24px;
}
.login-debug {
  margin-top: 16px;
  font-size: 11px;
}
.login-debug summary {
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.login-debug details[open] summary {
  margin-bottom: 6px;
}
.login-debug a {
  display: block;
  color: var(--accent, #4a7fd9);
  text-decoration: none;
  padding: 3px 0;
}
.login-debug a:hover {
  text-decoration: underline;
}

/* --- デスクトップ --- */
#game-screen { display: none; }
#game-screen.active { display: block; }
#desktop {
  position: relative;
  width: 100%;
  height: calc(100vh - 42px);
  height: calc(100dvh - 42px);
  overflow: hidden;
  background: linear-gradient(160deg, #c7d2e0 0%, #b8c9bd 50%, #d0c8d6 100%);
}

/* --- デスクトップアイコン --- */
.desktop-icon {
  position: absolute;
  width: 80px;
  text-align: center;
  cursor: pointer;
  padding: 8px 4px;
  border-radius: 8px;
  transition: background 0.15s;
}
.desktop-icon:hover { background: rgba(0,0,0,0.04); }
.desktop-icon:nth-child(1) { top: 20px; left: 20px; }
.desktop-icon:nth-child(2) { top: 120px; left: 20px; }
.desktop-icon:nth-child(3) { top: 220px; left: 20px; }
.desktop-icon-img {
  font-size: 2rem;
  line-height: 1.2;
  margin-bottom: 4px;
}
.desktop-icon-label {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.3;
  word-break: break-all;
}

/* --- タスクバー --- */
#taskbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 42px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  z-index: 9999;
}
.taskbar-left {
  padding: 0 14px;
  flex-shrink: 0;
}
.taskbar-brand {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}
.taskbar-center {
  flex: 1;
  display: flex;
  gap: 4px;
  padding: 0 8px;
  overflow-x: auto;
}
.taskbar-btn {
  padding: 4px 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  font-family: inherit;
}
.taskbar-btn:hover { background: var(--bg-hover); }
.taskbar-btn.active {
  background: var(--accent);
  color: #fff;
}
.taskbar-right {
  padding: 0 16px;
  flex-shrink: 0;
}
.taskbar-clock {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   モバイル対応
   ============================================================ */
@media (max-width: 768px) {
  .login-box {
    width: calc(100vw - 32px);
    max-width: 380px;
    padding: 36px 24px;
  }

  /* デスクトップアイコン非表示 — タスクバーで切り替え */
  .desktop-icon { display: none; }

  #desktop {
    height: calc(100vh - 48px);
    /* safe area対応 */
    height: calc(100dvh - 48px);
  }

  /* タスクバー */
  #taskbar { height: 48px; }
  .taskbar-left { display: none; }
  .taskbar-center {
    flex: 1;
    justify-content: center;
    gap: 6px;
    padding: 0 12px;
  }
  .taskbar-btn {
    padding: 6px 16px;
    font-size: 13px;
  }
  /* モバイルではタスクバーのウィンドウボタン非表示 */
  .taskbar-center { display: none; }
  .taskbar-right { padding: 0 12px; }

  /* スマホ用メニューボタン — 右上固定 */
  .sp-menu-btn {
    position: fixed;
    top: 6px;
    right: 8px;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255,255,255,0.85);
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
    box-shadow: rgba(0,0,0,0.1) 0 1px 4px;
    backdrop-filter: blur(4px);
  }
  .sp-menu-btn:active { background: var(--bg-hover); }

  /* スマホ用メニューパネル — 上から展開 */
  .sp-menu-panel {
    display: none;
    position: fixed;
    top: 48px;
    right: 8px;
    width: 200px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: rgba(0,0,0,0.12) 0 4px 20px;
    z-index: 10002;
    padding: 6px;
  }
  .sp-menu-panel.open { display: block; }
  .sp-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: none;
    background: none;
    width: 100%;
    font-size: 15px;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 8px;
    font-family: inherit;
    text-align: left;
  }
  .sp-menu-item:active { background: var(--bg-hover); }
  .sp-menu-item-icon { font-size: 18px; }
  .sp-menu-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
  }
  .sp-menu-backdrop.open { display: block; }

}

/* PC ではスマホUI非表示 */
@media (min-width: 769px) {
  .sp-menu-btn,
  .sp-menu-panel,
  .sp-menu-backdrop,
  .chat-sp-header { display: none; }
}

/* --- 新着通知オーバーレイ --- */
.chat-notify-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99998;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: chat-notify-fade-in 0.3s ease;
}
.chat-notify-overlay.hiding {
  opacity: 0;
  transition: opacity 0.2s;
}
.chat-notify-card {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: rgba(0,0,0,0.15) 0 8px 32px;
  max-width: 320px;
  width: calc(100% - 48px);
  animation: chat-notify-pop 0.3s ease;
}
.chat-notify-icon {
  font-size: 40px;
  margin-bottom: 12px;
}
.chat-notify-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.chat-notify-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.chat-notify-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}
.chat-notify-btn {
  padding: 12px 32px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  box-shadow: rgba(94,106,210,0.3) 0px 2px 8px;
  transition: background 0.15s;
}
.chat-notify-btn:hover {
  background: var(--accent-hover);
}
@keyframes chat-notify-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes chat-notify-pop {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
