/* live-server: 共通スタイル (ビルド不要のバニラCSS, モバイルファースト) */

:root {
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-danger: #dc2626;
  --color-danger-hover: #b91c1c;
  --color-success: #16a34a;
  --color-live: #dc2626;
  --color-offline: #94a3b8;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.06);
  --header-height: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0f172a;
    --color-surface: #1e293b;
    --color-border: #334155;
    --color-text: #e2e8f0;
    --color-text-muted: #94a3b8;
    --color-primary: #3b82f6;
    --color-primary-hover: #60a5fa;
    --color-danger: #f87171;
    --color-danger-hover: #fca5a5;
    --color-success: #4ade80;
    --color-offline: #64748b;
  }
}

* {
  box-sizing: border-box;
}

/* display:flex等を指定するクラスと併用しても hidden 属性(JSでの要素の
   表示/非表示切り替えに多用)が確実に効くようにする。同じ詳細度の場合
   author CSSがUAスタイルシートの[hidden]{display:none}より優先されて
   しまうため、明示的に上書きしておく必要がある。 */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

img,
video {
  max-width: 100%;
}

/* ---------- レイアウト ---------- */

.header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.header__brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-text);
}
.header__brand:hover {
  text-decoration: none;
}

.header__nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.container--narrow {
  max-width: 440px;
}

/* ---------- カード/グリッド ---------- */

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 640px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.stream-card {
  display: block;
  color: inherit;
  overflow: hidden;
  padding: 0;
}
.stream-card:hover {
  text-decoration: none;
  border-color: var(--color-primary);
}

.stream-card__thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #0f172a;
  overflow: hidden;
}

.stream-card__thumb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stream-card__thumb .badge--live {
  position: absolute;
  top: 8px;
  left: 8px;
}

.stream-card__body {
  padding: 12px 14px 14px;
}

.stream-card__title {
  font-weight: 600;
  margin: 0 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stream-card__meta {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.empty-state {
  text-align: center;
  color: var(--color-text-muted);
  padding: 48px 16px;
}

/* ---------- バッジ ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.8;
}

.badge--live {
  background: rgba(220, 38, 38, 0.12);
  color: var(--color-live);
}
.badge--live .badge__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-live);
  animation: pulse 1.6s infinite;
}

.badge--offline {
  background: rgba(148, 163, 184, 0.16);
  color: var(--color-offline);
}

.badge--public {
  background: rgba(37, 99, 235, 0.12);
  color: var(--color-primary);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

/* ---------- フォーム ---------- */

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-text-muted);
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="search"],
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-text);
  font-family: inherit;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

textarea {
  resize: vertical;
  min-height: 72px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.checkbox-row input {
  width: auto;
}

/* ---------- ボタン ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--color-primary);
  color: #fff;
  white-space: nowrap;
}
.btn:hover {
  background: var(--color-primary-hover);
  text-decoration: none;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--secondary {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn--secondary:hover {
  background: var(--color-border);
}

.btn--danger {
  background: var(--color-danger);
}
.btn--danger:hover {
  background: var(--color-danger-hover);
}

.btn--sm {
  padding: 5px 10px;
  font-size: 0.82rem;
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- テーブル ---------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
  white-space: nowrap;
}

th {
  color: var(--color-text-muted);
  font-weight: 600;
  background: rgba(100, 116, 139, 0.06);
}

tr:last-child td {
  border-bottom: none;
}

/* ---------- 動画プレイヤー ---------- */

.player-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
}

.player-wrap:fullscreen,
.player-wrap:-webkit-full-screen {
  aspect-ratio: unset;
  border-radius: 0;
}

.player-wrap video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.player-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #cbd5e1;
  background: #0f172a;
  font-size: 0.95rem;
  text-align: center;
  padding: 16px;
}

/* 常に映像の上に重ねて表示するため、サイトのライト/ダーク配色設定に関わらず
   常時暗い背景を前提にした配色で固定する。 */
.player-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75), transparent);
  flex-wrap: wrap;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.player-controls.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.player-controls .text-muted {
  color: #cbd5e1;
}

.player-controls .btn--secondary {
  background: rgba(255, 255, 255, 0.12);
  color: #f8fafc;
  border-color: rgba(255, 255, 255, 0.35);
}

.player-controls .btn--secondary:hover {
  background: rgba(255, 255, 255, 0.24);
}

.volume-slider {
  width: 100px;
  accent-color: var(--color-primary);
}

/* ---------- ユーティリティ ---------- */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 20px;
  overflow-x: auto;
}

.tab {
  padding: 10px 14px;
  font-weight: 600;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  font-size: 0.95rem;
}

.tab.is-active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.tab-panel {
  display: none;
}
.tab-panel.is-active {
  display: block;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 28px 0 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.section-title h2 {
  margin: 0;
  font-size: 1.1rem;
}
.section-title:first-child {
  margin-top: 0;
}

.stream-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  background: rgba(100, 116, 139, 0.12);
  padding: 8px 10px;
  border-radius: 6px;
  word-break: break-all;
}

.help-text {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: var(--color-bg);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.toast.is-visible {
  opacity: 1;
}

.error-text {
  color: var(--color-danger);
  font-size: 0.88rem;
  margin-top: 8px;
}

.text-muted {
  color: var(--color-text-muted);
}

.mt-0 { margin-top: 0; }
.flex-spacer { flex: 1; }

.kv-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  font-size: 0.92rem;
}
.kv-list dt {
  color: var(--color-text-muted);
}
.kv-list dd {
  margin: 0;
}

code.inline {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: rgba(100, 116, 139, 0.12);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}
