/* ================================================
   営業数値進捗管理ダッシュボード - スタイル v0.4
   ================================================ */

:root {
  --c-bg: #f8fafc;
  --c-surface: #ffffff;
  --c-text: #0f172a;
  --c-text-sub: #64748b;
  --c-border: #e2e8f0;
  --c-electric: #f59e0b;
  --c-electric-bg: #fef3c7;
  --c-tsushin: #0ea5e9;
  --c-tsushin-bg: #e0f2fe;
  --c-intern: #10b981;
  --c-intern-bg: #d1fae5;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  background:
    radial-gradient(circle at 15% 10%, rgba(59,130,246,0.06) 0%, transparent 40%),
    radial-gradient(circle at 90% 20%, rgba(251,191,36,0.05) 0%, transparent 45%),
    linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
  min-height: 100vh;
  letter-spacing: 0.01em;
}

.display-num {
  font-family: "Oswald", -apple-system, sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

table { font-variant-numeric: tabular-nums; }
#individual-chart { width: 100% !important; height: 100% !important; }

.nav-active {
  background-color: #0f172a !important;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.25);
}

/* ================================================
   TOP3 ポディウム
   ================================================ */
.podium {
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  gap: 1rem;
  align-items: end;
  padding: 1.5rem 0.5rem 0.5rem;
  position: relative;
}

/* 背景の放射状グロー */
.podium::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 30%, rgba(251,191,36,0.15) 0%, transparent 50%),
    radial-gradient(circle at 20% 60%, rgba(148,163,184,0.10) 0%, transparent 40%),
    radial-gradient(circle at 80% 60%, rgba(234,88,12,0.10) 0%, transparent 40%);
  z-index: -1;
  pointer-events: none;
}

.podium-card {
  position: relative;
  border-radius: 1.25rem;
  padding: 1.5rem 1rem 1.25rem;
  color: #fff;
  text-align: center;
  box-shadow:
    0 12px 36px rgba(0,0,0,0.18),
    0 2px 6px rgba(0,0,0,0.08),
    inset 0 1px 0 rgba(255,255,255,0.35);
  overflow: hidden;
  transition: transform 0.25s cubic-bezier(.2,.8,.2,1), box-shadow 0.25s;
  isolation: isolate;
}
.podium-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 20px 48px rgba(0,0,0,0.22), 0 3px 8px rgba(0,0,0,0.12);
}

/* カード内の光沢レイヤー */
.podium-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    160deg,
    rgba(255,255,255,0.35) 0%,
    rgba(255,255,255,0) 40%,
    rgba(0,0,0,0.12) 100%
  );
  pointer-events: none;
  z-index: 1;
}
.podium-card > * { position: relative; z-index: 2; }

.podium-gold {
  background: linear-gradient(145deg, #fef3c7 0%, #fbbf24 40%, #d97706 100%);
  min-height: 240px;
  animation: float-gold 4s ease-in-out infinite;
}
.podium-silver {
  background: linear-gradient(145deg, #f1f5f9 0%, #cbd5e1 45%, #64748b 100%);
  min-height: 210px;
}
.podium-bronze {
  background: linear-gradient(145deg, #fed7aa 0%, #fb923c 45%, #9a3412 100%);
  min-height: 195px;
}

@keyframes float-gold {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.podium-card.podium-gold:hover { animation: none; }

.podium-crown {
  font-size: 2.8rem;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.25));
  margin-bottom: 0.25rem;
  display: inline-block;
}
.podium-gold .podium-crown {
  animation: crown-pulse 2s ease-in-out infinite;
}
@keyframes crown-pulse {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.08) rotate(-3deg); }
}

.podium-rank-num {
  position: absolute;
  top: 0.4rem;
  right: 0.75rem;
  font-family: "Oswald", sans-serif;
  font-size: 3.5rem;
  font-weight: 900;
  font-style: italic;
  color: rgba(255,255,255,0.32);
  line-height: 0.9;
  letter-spacing: -0.05em;
  z-index: 1;
}

.podium-name {
  font-size: 1.15rem;
  font-weight: 800;
  margin-top: 0.25rem;
  text-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.podium-team {
  font-size: 0.7rem;
  opacity: 0.92;
  margin-top: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 0.5rem;
}

.podium-value {
  font-family: "Oswald", sans-serif;
  font-size: 2.9rem;
  font-weight: 700;
  margin-top: 0.6rem;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0,0,0,0.25);
  letter-spacing: -0.02em;
}
.podium-value-unit {
  font-size: 1rem;
  font-weight: 600;
  opacity: 0.85;
  margin-left: 0.2rem;
}

.podium-metric-label {
  font-size: 0.7rem;
  opacity: 0.9;
  margin-top: 0.4rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Sparkle for gold */
.podium-gold::after {
  content: "✨";
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 1.3rem;
  animation: sparkle 2.5s ease-in-out infinite;
  z-index: 3;
}
@keyframes sparkle {
  0%, 100% { opacity: 0.35; transform: scale(1) rotate(0); }
  50% { opacity: 1; transform: scale(1.25) rotate(15deg); }
}

/* ================================================
   ランキングテーブル
   ================================================ */
.rank-row-1 {
  background: linear-gradient(90deg, rgba(251,191,36,0.22) 0%, rgba(251,191,36,0.04) 100%) !important;
  border-left: 4px solid #f59e0b;
}
.rank-row-2 {
  background: linear-gradient(90deg, rgba(148,163,184,0.20) 0%, rgba(148,163,184,0.04) 100%) !important;
  border-left: 4px solid #94a3b8;
}
.rank-row-3 {
  background: linear-gradient(90deg, rgba(234,88,12,0.18) 0%, rgba(234,88,12,0.04) 100%) !important;
  border-left: 4px solid #ea580c;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 0.9rem;
  font-family: "Oswald", sans-serif;
}
.rank-1 { background: linear-gradient(135deg, #fde68a, #f59e0b); color: #78350f; box-shadow: 0 3px 10px rgba(245,158,11,0.5); }
.rank-2 { background: linear-gradient(135deg, #e2e8f0, #94a3b8); color: #1e293b; box-shadow: 0 3px 10px rgba(148,163,184,0.45); }
.rank-3 { background: linear-gradient(135deg, #fed7aa, #ea580c); color: #7c2d12; box-shadow: 0 3px 10px rgba(234,88,12,0.45); }
.rank-other { background: #f1f5f9; color: #475569; font-family: inherit; }

.sort-highlight { background-color: #fef3c7 !important; font-weight: 800 !important; color: #0f172a !important; }
.rank-row-1 .sort-highlight { background-color: rgba(245,158,11,0.25) !important; }
.rank-row-2 .sort-highlight { background-color: rgba(148,163,184,0.25) !important; }
.rank-row-3 .sort-highlight { background-color: rgba(234,88,12,0.25) !important; }

/* ================================================
   部門バッジ
   ================================================ */
.dept-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.dept-電気       { background: var(--c-electric-bg); color: #92400e; }
.dept-通信       { background: var(--c-tsushin-bg);  color: #075985; }
.dept-インターン  { background: var(--c-intern-bg);   color: #065f46; }
.dept-未定       { background: #f1f5f9; color: #475569; }

/* ================================================
   メトリックボタン
   ================================================ */
.metric-btn {
  transition: all 0.15s ease;
  font-weight: 500;
}
.metric-btn:hover:not(.metric-btn-active) {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}
.metric-btn-active {
  background: linear-gradient(135deg, #0f172a, #334155);
  color: white;
  border-color: #0f172a;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.28);
}

/* ================================================
   カード共通
   ================================================ */
.card {
  background: white;
  border-radius: 0.875rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
  border: 1px solid var(--c-border);
}

.stat-card {
  background: white;
  border-radius: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--c-border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.stat-target   { }
.stat-target::before   { background: linear-gradient(90deg, #64748b, #94a3b8); }
.stat-actual::before   { background: linear-gradient(90deg, #10b981, #34d399); }
.stat-progress::before { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.stat-pace::before     { background: linear-gradient(90deg, #f59e0b, #fbbf24); }

/* ================================================
   プログレスバー（個人別数値）
   ================================================ */
.progress-track {
  position: relative;
  height: 14px;
  background: #f1f5f9;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(.2,.8,.2,1);
  position: relative;
}
.progress-fill.bar-green {
  background: linear-gradient(90deg, #10b981, #34d399 50%, #6ee7b7 100%);
  box-shadow: 0 0 14px rgba(16,185,129,0.55), inset 0 1px 0 rgba(255,255,255,0.4);
}
.progress-fill.bar-red {
  background: linear-gradient(90deg, #f43f5e, #fb7185 50%, #fda4af 100%);
  box-shadow: 0 0 14px rgba(244,63,94,0.55), inset 0 1px 0 rgba(255,255,255,0.4);
}
.progress-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -45deg,
    rgba(255,255,255,0.15) 0 8px,
    transparent 8px 16px
  );
  animation: slide-stripes 1.6s linear infinite;
}
@keyframes slide-stripes {
  from { background-position: 0 0; }
  to   { background-position: 24px 0; }
}

/* 理想ペースのマーカー */
.progress-ideal-marker {
  position: absolute;
  top: -4px; bottom: -4px;
  width: 2px;
  background: rgba(15,23,42,0.55);
  box-shadow: 0 0 6px rgba(15,23,42,0.25);
  z-index: 2;
}
.progress-ideal-marker::after {
  content: "理想";
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: #0f172a;
  background: white;
  border: 1px solid #cbd5e1;
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
}

/* ================================================
   達成 100% コンフェッティ
   ================================================ */
.confetti {
  position: fixed;
  top: -10px;
  width: 8px;
  height: 14px;
  opacity: 0.9;
  pointer-events: none;
  z-index: 50;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  to {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0;
  }
}

/* ================================================
   アバター（個人別数値）
   ================================================ */
.avatar-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.25rem;
  color: white;
  background: linear-gradient(135deg, #0f172a, #475569);
  box-shadow: 0 4px 14px rgba(15,23,42,0.25);
}
.avatar-dept-電気       { background: linear-gradient(135deg, #d97706, #fbbf24); }
.avatar-dept-通信       { background: linear-gradient(135deg, #0284c7, #38bdf8); }
.avatar-dept-インターン  { background: linear-gradient(135deg, #059669, #34d399); }

/* ================================================
   モバイル対応
   ================================================ */
@media (max-width: 768px) {
  .podium {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    padding: 1rem 0;
  }
  .podium-gold   { order: 1; min-height: 200px; }
  .podium-silver { order: 2; min-height: 160px; }
  .podium-bronze { order: 3; min-height: 150px; }

  .podium-value { font-size: 2.4rem; }

  nav {
    overflow-x: auto;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
  }
  nav a { flex-shrink: 0; }

  .stat-card .display-num { font-size: 1.75rem; }
}

@media (max-width: 480px) {
  h1 { font-size: 1rem !important; }
  .metric-btn { font-size: 0.8rem; padding: 0.5rem 0.75rem !important; }
}

/* ================================================
   ダークモード（prefers-color-scheme 対応）
   ※ 営業現場の朝礼モニター向け
   ================================================ */
@media (prefers-color-scheme: dark) {
  body.theme-auto {
    background:
      radial-gradient(circle at 15% 10%, rgba(59,130,246,0.10) 0%, transparent 40%),
      linear-gradient(180deg, #0f172a 0%, #020617 100%);
    color: #e2e8f0;
  }
}

/* 手動ダークモード切替 */
body.theme-dark {
  background:
    radial-gradient(circle at 15% 10%, rgba(59,130,246,0.12) 0%, transparent 40%),
    linear-gradient(180deg, #0f172a 0%, #020617 100%) !important;
  color: #e2e8f0;
}
body.theme-dark .card,
body.theme-dark .stat-card {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}
body.theme-dark header { background: rgba(15,23,42,0.92) !important; border-color: #334155 !important; }
body.theme-dark h1, body.theme-dark h2, body.theme-dark h3 { color: #f1f5f9 !important; }
body.theme-dark .text-slate-900 { color: #e2e8f0 !important; }
body.theme-dark .text-slate-700 { color: #cbd5e1 !important; }
body.theme-dark .text-slate-600 { color: #94a3b8 !important; }
body.theme-dark .text-slate-500 { color: #94a3b8 !important; }
body.theme-dark .text-slate-400 { color: #64748b !important; }
body.theme-dark .bg-slate-50 { background: #0f172a !important; }
body.theme-dark table thead { background: #0f172a !important; }
body.theme-dark tbody tr { border-color: #334155 !important; }
body.theme-dark .hover\:bg-slate-50:hover { background: #334155 !important; }
body.theme-dark .border-slate-200 { border-color: #334155 !important; }
body.theme-dark input, body.theme-dark select {
  background: #0f172a;
  color: #e2e8f0;
  border-color: #334155;
}
body.theme-dark .progress-track { background: #334155; border-color: #475569; }

/* ================================================
   ユーティリティ
   ================================================ */
.theme-toggle {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.75rem;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
}
.theme-toggle:hover { background: #e2e8f0; }
body.theme-dark .theme-toggle {
  background: #1e293b;
  border-color: #475569;
  color: #cbd5e1;
}

.pulse-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #10b981;
  margin-right: 4px;
  box-shadow: 0 0 0 0 rgba(16,185,129,0.6);
  animation: pulse-dot 1.8s infinite;
}
@keyframes pulse-dot {
  0%   { box-shadow: 0 0 0 0 rgba(16,185,129,0.6); }
  70%  { box-shadow: 0 0 0 8px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}
