/* ============================================
   ダッシュボード専用スタイル
   dashboard.css
   ============================================ */

/* ============================================
   scroll-wrapper 上書き（action-bar なし）
   ============================================ */

.dashboard-page .scroll-wrapper {
  margin-top: calc(var(--header-height) + env(safe-area-inset-top));
  padding-top: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ============================================
   コンテナ
   ============================================ */

.dashboard-container {
  max-width: 860px;
  margin: 0 auto;
  padding: 8px 16px 48px;
}

/* ============================================
   挨拶・日付
   ============================================ */

.dashboard-greeting {
  margin-bottom: 24px;
}

.greeting-text {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 4px;
}

.greeting-date {
  font-size: 14px;
  color: var(--color-text-secondary);
}

/* ============================================
   バッジ行（件数サマリー）
   ============================================ */

.dashboard-badges {
  display: flex;
  gap: 10px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.badge-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  text-decoration: none;
  cursor: pointer;
  transition:
    box-shadow 0.2s,
    transform 0.2s;
  flex: 1;
  min-width: 140px;
}

.badge-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.badge-label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  flex: 1;
  white-space: nowrap;
  line-height: 1.4;
}

.badge-count {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  min-width: 32px;
  text-align: right;
  line-height: 1;
}

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

/* ============================================
   セクション共通
   ============================================ */

.dashboard-section {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text-primary);
}

.section-link {
  font-size: 13px;
  color: var(--color-primary);
  text-decoration: none;
  white-space: nowrap;
}

.section-link:hover {
  text-decoration: underline;
}

/* ローディング */
.section-loading {
  display: flex;
  justify-content: center;
  padding: 16px 0;
}

.section-loading .spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: dashboard-spin 0.8s linear infinite;
}

@keyframes dashboard-spin {
  to {
    transform: rotate(360deg);
  }
}

/* 空メッセージ */
.section-empty {
  font-size: 13px;
  color: var(--color-text-secondary);
  text-align: center;
  padding: 12px 0;
}

/* ローディング */
.section-loading {
  display: flex;
  justify-content: center;
  padding: 16px 0;
}

.section-loading .spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: dashboard-spin 0.8s linear infinite;
}

@keyframes dashboard-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================
   スケルトンローディング
   ============================================ */

.skeleton-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skeleton-item {
  height: 48px;
  border-radius: var(--radius-md);
  background: linear-gradient(
    90deg,
    var(--color-skeleton-base) 25%,
    var(--color-skeleton-shine) 50%,
    var(--color-skeleton-base) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-wave 1.4s ease-in-out infinite;
}

@keyframes skeleton-wave {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ============================================
   リスト共通
   ============================================ */

.dashboard-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.dashboard-list-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 6px;
}

.dashboard-list-item:last-child {
  border-bottom: none;
}

.dashboard-list-item:hover {
  background: var(--color-bg-hover);
}

.dashboard-list-item a {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  padding: 0 6px;
}

/* アイテム本文 */
.item-body {
  flex: 1;
  min-width: 0;
}

.item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.item-meta {
  font-size: 12px;
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 重要バッジ */
.item-important {
  font-size: 11px;
  font-weight: 700;
  color: #ef4444;
  background: #fee2e2;
  border-radius: 4px;
  padding: 1px 6px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}

[data-theme="dark"] .item-important {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

/* ニュースソース */
.item-source {
  font-size: 11px;
  color: var(--color-text-secondary);
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 1px 6px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}

/* バッジ群ラッパー */
.item-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

/* カテゴリバッジ インライン表示（タイトル左）*/
.item-title {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap; /* タイトルが長い場合は折り返す */
  margin-bottom: 2px;
}

.item-inline-category {
  flex-shrink: 0;
  margin-top: 0;
}

.item-title-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

@media (max-width: 768px) {
  .item-title-text {
    font-size: 13px;
  }
}

/* ステータスバッジ（申請状況） */
.item-status-badge {
  font-size: 11px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}

.item-status-pending {
  background: var(--color-status-pending-bg);
  color: var(--color-status-pending-text);
}

.item-status-approved {
  background: var(--color-status-approved-bg);
  color: var(--color-status-approved-text);
}

.item-status-rejected {
  background: var(--color-status-rejected-bg);
  color: var(--color-status-rejected-text);
}

.item-status-unapproved {
  background: var(--color-status-unapproved-bg);
  color: var(--color-status-unapproved-text);
}

/* ============================================
   スマホ対応
   ============================================ */

@media (max-width: 768px) {
  .dashboard-page .scroll-wrapper {
    padding-top: 0;
  }

  .dashboard-container {
    padding: 8px 12px 40px;
  }

  .greeting-text {
    font-size: 18px;
  }

  .dashboard-badges {
    gap: 8px;
  }

  .badge-card {
    padding: 10px 12px;
    min-width: 120px;
  }

  .badge-label {
    font-size: 13px;
  }

  .badge-count {
    font-size: 18px;
  }

  .dashboard-section {
    padding: 16px 12px;
  }

  .section-title {
    font-size: 14px;
  }

  .item-title {
    font-size: 13px;
  }
}

.dashboard-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0 20px;
}

.summary-card {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  align-items: end;
  justify-content: center;
  column-gap: 4px;
  row-gap: 4px;
  padding: 14px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.summary-card:hover {
  text-decoration: none;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.summary-card-label {
  grid-column: 1 / -1;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
}

.summary-card-count {
  grid-column: 1;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.summary-card-unit {
  grid-column: 2;
  font-size: 12px;
  color: var(--color-text-secondary);
  line-height: 1;
}

@media (max-width: 768px) {
  .dashboard-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 12px 0 16px;
  }

  .summary-card {
    padding: 12px 10px;
  }

  .summary-card-label {
    font-size: 12px;
  }

  .summary-card-count {
    font-size: 20px;
  }
}

/* ============================================================
   Dashboard summary mobile adjustment
   ホーム上部サマリーカード：スマホ表示の余白・高さ調整
   ============================================================ */

@media (max-width: 768px) {
  .dashboard-summary {
    gap: 8px;
    margin: 2px 0 12px;
  }

  .summary-card {
    min-height: 64px;
    padding: 9px 8px;
    row-gap: 3px;
    column-gap: 3px;
    border-radius: 14px;
  }

  .summary-card-label {
    font-size: 11.5px;
    line-height: 1.25;
    letter-spacing: -0.01em;
  }

  .summary-card-count {
    font-size: 19px;
    line-height: 1;
  }

  .summary-card-unit {
    font-size: 11px;
    line-height: 1;
  }
}

@media (max-width: 390px) {
  .dashboard-summary {
    gap: 7px;
    margin-top: 2px;
  }

  .summary-card {
    min-height: 60px;
    padding: 8px 6px;
  }

  .summary-card-label {
    font-size: 11px;
  }

  .summary-card-count {
    font-size: 18px;
  }
}

/* ============================================================
   Dashboard greeting mobile adjustment
   ホーム上部あいさつ：スマホ表示の下余白調整
   ============================================================ */

@media (max-width: 768px) {
  .dashboard-greeting {
    margin-bottom: 6px;
  }

  .greeting-text {
    margin-top: 0;
    margin-bottom: 3px;
  }

  .greeting-date {
    margin: 0;
    line-height: 1.25;
  }

  .dashboard-summary {
    margin-top: 4px;
  }
}

@media (max-width: 390px) {
  .dashboard-greeting {
    margin-bottom: 6px;
  }

  .dashboard-summary {
    margin-top: 4px;
  }
}
