/* ============================================
   イベントハブ基幹システム - コンポーネント
   ============================================ */

/* ── モーダル ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-modal);
  animation: scaleIn 0.25s cubic-bezier(.4,0,.2,1);
}

.modal-lg  { max-width: 820px; }
.modal-sm  { max-width: 440px; }
.modal-xl  { max-width: 1000px; }

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

  .modal-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
  gap: 8px;
}

.modal-title .title-icon { color: var(--accent-cyan); }

.modal-close {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1;
}
.modal-close:hover {
  background: rgba(255,255,255,0.07);
  color: var(--text-primary);
}

.modal-body {
  padding: 22px 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* ── 確認ダイアログ ── */
.confirm-dialog .modal { max-width: 400px; }
.confirm-icon {
  font-size: 40px;
  text-align: center;
  margin-bottom: 12px;
}
.confirm-message {
  font-size: 14px;
  text-align: center;
  color: var(--text-secondary);
  line-height: 1.6;
}
.confirm-sub {
  font-size: 11.5px;
  text-align: center;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ── イベント選択リスト（ポップアップ用） ── */
.event-select-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 380px;
  overflow-y: auto;
}

.event-select-item {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 14px;
}
.event-select-item:hover {
  border-color: var(--accent-cyan);
  background: rgba(0,212,255,0.05);
}

.event-select-item .item-date {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  min-width: 80px;
}

.event-select-item .item-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
}

/* ── ステップインジケーター ── */
.step-indicator {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 24px;
}

.step-item {
  display: flex;
  align-items: center;
  flex: 1;
}

.step-circle {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border-mid);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all var(--transition);
}

.step-circle.active {
  border-color: var(--accent-cyan);
  background: rgba(0,212,255,0.1);
  color: var(--accent-cyan);
}

.step-circle.done {
  border-color: var(--accent-green);
  background: rgba(0,255,157,0.1);
  color: var(--accent-green);
}

.step-line {
  flex: 1;
  height: 2px;
  background: var(--border-subtle);
  margin: 0 -1px;
}

/* ── サイドドロワー風詳細パネル ── */
.detail-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  padding: 22px;
}

.detail-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.detail-row:last-child { border-bottom: none; }

.detail-label {
  min-width: 140px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  text-transform: uppercase;
  flex-shrink: 0;
}

.detail-value {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
}

/* ── タグ入力 ── */
.tag-input-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  min-height: 40px;
  align-items: center;
  transition: border-color var(--transition);
}
.tag-input-wrap:focus-within {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(0,212,255,0.1);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(0,212,255,0.1);
  border: 1px solid rgba(0,212,255,0.2);
  color: var(--accent-cyan);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
}

.tag .tag-remove {
  cursor: pointer;
  opacity: 0.6;
  transition: opacity var(--transition);
  font-size: 13px;
  line-height: 1;
}
.tag .tag-remove:hover { opacity: 1; }

/* ── 更新履歴タイムライン ── */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-left: 16px;
  border-left: 2px solid var(--border-subtle);
}

.timeline-item {
  position: relative;
  padding: 0 0 16px 20px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -5px; top: 4px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent-cyan);
  border: 2px solid var(--bg-card);
}

.timeline-time {
  font-size: 10px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 3px;
}

.timeline-note {
  font-size: 12px;
  color: var(--text-secondary);
}

.timeline-user {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── チップ選択（除外部署選択など） ── */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0;
}

.chip {
  padding: 5px 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border-mid);
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}
.chip:hover { border-color: var(--border-accent); color: var(--text-primary); }
.chip.selected {
  background: rgba(0, 255, 136, 0.1);
  border-color: rgba(0, 255, 136, 0.4);
  color: var(--accent-green);
}

/* ── パネルタブ ── */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 22px;
}

.tab-btn {
  padding: 10px 18px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition);
  font-family: inherit;
}
.tab-btn:hover { color: var(--text-secondary); }
.tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
}

/* ── CPU/MEM メーター ── */
.meter-group { display: flex; flex-direction: column; gap: 10px; }

.meter-item { display: flex; flex-direction: column; gap: 5px; }

.meter-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
}
.meter-label .meter-value { font-family: 'JetBrains Mono', monospace; }

.meter-bar {
  height: 5px;
  background: var(--bg-panel);
  border-radius: 99px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.8s cubic-bezier(.4,0,.2,1);
}

.meter-fill.cpu { background: var(--accent-cyan); }
.meter-fill.mem { background: var(--accent-purple); }
.meter-fill.high { background: var(--accent-red); }

/* ── 部署カード ── */
.dept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.dept-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
  transition: all var(--transition);
}
.dept-card:hover {
  border-color: var(--border-accent);
  transform: translateY(-2px);
}

.dept-name {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dept-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}

.dept-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.dept-meta-row .label {
  min-width: 70px;
  color: var(--text-muted);
}

.dept-meta-row .value {
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  word-break: break-all;
}

/* ── ユーザーアバターグループ ── */
.avatar-group {
  display: flex;
}
.avatar-group .avatar-item {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  border: 2px solid var(--bg-card);
  margin-left: -8px;
  font-size: 11px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.avatar-group .avatar-item:first-child { margin-left: 0; }

/* ── 友人セレクター (モダンチップ形式) ── */
.friend-selector-wrap {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
}

.friend-chips-area {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
  padding-right: 8px;
}

.friend-chip-selectable {
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: 99px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

.friend-chip-selectable:hover {
  border-color: var(--accent-cyan);
  color: var(--text-primary);
  background: rgba(0, 212, 255, 0.05);
}

.friend-chip-selectable.active {
  background: var(--accent-cyan);
  border-color: var(--accent-cyan);
  color: white;
  box-shadow: 0 4px 10px rgba(0, 212, 255, 0.3);
}

/* ── 強調行 ── */
.highlight-row {
  transition: all var(--transition);
}
.highlight-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* ── Discordチャット閲覧 ── */
.discord-chat-viewer {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 600px;
  overflow-y: auto;
  padding: 10px;
  background: rgba(0,0,0,0.2);
  border-radius: var(--radius-md);
}

.chat-msg {
  display: flex;
  gap: 12px;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background 0.1s;
}
.chat-msg:hover { background: rgba(255,255,255,0.03); }

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
}

.chat-content {
  flex: 1;
  min-width: 0;
}

.chat-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.chat-author {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 13.5px;
}

.chat-time {
  font-size: 10px;
  color: var(--text-muted);
}

.chat-body {
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: #dcddde;
}

.chat-attachment {
  margin-top: 6px;
  font-size: 11px;
}
.chat-attachment a {
  color: var(--accent-cyan);
  text-decoration: none;
}
.chat-attachment a:hover { text-decoration: underline; }

.chat-embed {
  position: relative;
  margin-top: 8px;
  max-width: 520px;
  background: #2b2d31;
  border-left: 4px solid #4f545c;
  border-radius: 4px;
  padding: 10px 12px 10px 10px;
  font-size: 13px;
  color: #dbdee1;
}
.chat-embed-inner { min-width: 0; }
.chat-embed-thumbnail {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 80px;
  height: 80px;
  border-radius: 4px;
  object-fit: cover;
}
.chat-embed-author {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
}
.chat-embed-author img {
  width: 20px;
  height: 20px;
  border-radius: 50%;
}
.chat-embed-title {
  display: block;
  font-weight: 700;
  color: #00a8fc;
  margin-bottom: 4px;
  text-decoration: none;
}
a.chat-embed-title:hover { text-decoration: underline; }
.chat-embed-description {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
  margin-bottom: 6px;
}
.chat-embed-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 6px;
}
.chat-embed-field { flex: 1 1 100%; min-width: 0; }
.chat-embed-field.inline { flex: 1 1 140px; max-width: 220px; }
.chat-embed-field-name {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 2px;
}
.chat-embed-field-value {
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-embed-image {
  display: block;
  max-width: 100%;
  margin-top: 8px;
  border-radius: 4px;
}
.chat-embed-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 11px;
  color: #949ba4;
}
.chat-embed-footer img {
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

/* ── レスポンシブ追加 (タブレット: ~900px) ── */
@media (max-width: 900px) {
  .form-row-3 {
    grid-template-columns: 1fr 1fr !important;
  }

  /* モーダル: 幅区域を使い切る */
  .modal-lg,
  .modal-xl {
    max-width: 96vw;
  }
}

/* ── レスポンシブ追加 (スマホ: ~640px) ── */
@media (max-width: 640px) {
  /* form-row: 1列 */
  .form-row {
    grid-template-columns: 1fr;
  }

  .form-row-3 {
    grid-template-columns: 1fr !important;
  }

  /* モーダル: ドロワースタイル */
  .modal {
    max-width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    margin-top: auto;
    max-height: 92vh;
  }

  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-header {
    padding: 14px 16px 12px;
  }

  .modal-footer {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .modal-footer .btn {
    flex: 1;
    justify-content: center;
    min-width: 100px;
  }

  /* 詳細行: 縦並び */
  .detail-row {
    flex-direction: column;
    gap: 4px;
  }

  .detail-label {
    min-width: unset;
  }

  /* 部署カード */
  .dept-card {
    padding: 14px;
  }

  .dept-meta-row .value {
    font-size: 10px;
    word-break: break-all;
  }

  /* Discordチャット */
  .chat-avatar {
    width: 32px;
    height: 32px;
  }

  .chat-author {
    font-size: 12px;
  }

  .chat-body {
    font-size: 12px;
  }

  /* チップ選択 */
  .friend-chip-selectable {
    padding: 5px 10px;
    font-size: 11px;
  }

  /* 履歴タイムライン */
  .timeline-note {
    font-size: 11px;
  }

  /* タブバー */
  .tab-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    flex-wrap: nowrap;
  }

  .tab-btn {
    padding: 8px 12px;
    font-size: 11.5px;
    white-space: nowrap;
  }

  /* アバターグループ */
  .p-logs-stats {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
}
