/* ============================================
   Threads管理ダッシュボード - ダークモードスタイル
   ============================================ */

:root {
  --bg-primary: #1a1a2e;
  --bg-card: #16213e;
  --bg-accent: #0f3460;
  --highlight: #e94560;
  --text-primary: #eee;
  --text-secondary: #aab;
  --text-muted: #778;
  --border: #2a2a4a;
  --success: #2ecc71;
  --warning: #f39c12;
  --danger: #e94560;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── ヘッダー ── */
.header {
  background: linear-gradient(135deg, var(--bg-accent), var(--bg-card));
  padding: 1.5rem 2rem;
  border-bottom: 2px solid var(--highlight);
  text-align: center;
}

.header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.header-sub {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* ── メインコンテナ ── */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ── セクション ── */
.section {
  margin-bottom: 2rem;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* ── サマリーカード ── */
.summary-cards {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.card {
  flex: 1;
  min-width: 200px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
  border-left: 3px solid var(--highlight);
  transition: transform 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
}

.card-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.card-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.card-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ── グラフエリア ── */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.chart-container {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.chart-container h3 {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-weight: 500;
}

.chart-container canvas {
  max-height: 300px;
}

/* ── テーブル ── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  font-size: 0.9rem;
}

.data-table thead th {
  background: var(--bg-accent);
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
}

.data-table thead th.sortable {
  cursor: pointer;
  user-select: none;
}

.data-table thead th.sortable:hover {
  background: #123a6e;
}

.sort-icon {
  font-size: 0.7rem;
  margin-left: 4px;
  opacity: 0.5;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
}

.data-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.data-table tbody tr:hover {
  background: rgba(233, 69, 96, 0.08);
}

.data-table td {
  padding: 0.7rem 1rem;
  vertical-align: middle;
}

.loading-cell {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem !important;
}

/* ステータスバッジ */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-pending {
  background: rgba(243, 156, 18, 0.2);
  color: var(--warning);
  border: 1px solid rgba(243, 156, 18, 0.4);
}

.badge-posted {
  background: rgba(46, 204, 113, 0.2);
  color: var(--success);
  border: 1px solid rgba(46, 204, 113, 0.4);
}

.badge-failed {
  background: rgba(233, 69, 96, 0.2);
  color: var(--danger);
  border: 1px solid rgba(233, 69, 96, 0.4);
}

/* ページネーション */
.pagination {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.pagination button {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s;
}

.pagination button:hover {
  background: var(--bg-accent);
}

.pagination button.active {
  background: var(--highlight);
  border-color: var(--highlight);
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── フォーム ── */
.post-form {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

textarea,
input[type="datetime-local"],
input[type="text"] {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s;
  resize: vertical;
}

textarea:focus,
input:focus {
  outline: none;
  border-color: var(--highlight);
}

.char-count {
  text-align: right;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn {
  display: inline-block;
  padding: 0.6rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--highlight);
  color: #fff;
}

.btn-primary:hover {
  background: #d63a52;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

.btn-danger:hover {
  background: rgba(233, 69, 96, 0.15);
}

.form-message {
  font-size: 0.85rem;
}

.form-message.success {
  color: var(--success);
}

.form-message.error {
  color: var(--danger);
}

/* ── ベスト投稿 ── */
.best-posts {
  display: grid;
  gap: 0.75rem;
}

.best-post-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}

.best-post-item:hover {
  transform: translateX(4px);
}

.best-post-rank {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--highlight);
  min-width: 2rem;
  text-align: center;
}

.best-post-content {
  flex: 1;
}

.best-post-text {
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 0.3rem;
}

.best-post-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.best-post-stats span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* ── フッター ── */
.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

/* ── レスポンシブ ── */
@media (max-width: 768px) {
  .summary-cards {
    flex-direction: column;
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

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

  .header h1 {
    font-size: 1.3rem;
  }

  .container {
    padding: 1rem;
  }

  .data-table {
    font-size: 0.8rem;
  }

  .data-table td,
  .data-table th {
    padding: 0.5rem 0.6rem;
  }
}

@media (max-width: 480px) {
  .card {
    min-width: 100%;
  }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .best-post-item {
    flex-direction: column;
    gap: 0.5rem;
  }
}
