/* Spela AI Outbound Call - Demo shared styles */

:root {
  --brand: #6366f1;
  --brand-dark: #4338ca;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f9fafb;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

/* ダブルクリックによる文字列選択・誤動作を抑止 (入力系は除外) */
button, label, a, .btn, .target-item, .inbox-item, .phone-card, .qs-item,
.nav-link, .phase-step, .kw-tag, .sp-kw, .msg-bubble, .call-panel, .target-list,
.inbox-list, .sysprompt-panel, h1, h2, h3, h4 {
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
}
input, textarea, pre, code, .mail-body {
  user-select: text;
  -webkit-user-select: text;
  -ms-user-select: text;
}

.nav {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.nav-brand {
  font-weight: 700;
  font-size: 16px;
  color: var(--brand);
  letter-spacing: 0.02em;
}
.nav-brand small { color: var(--muted); font-weight: 400; margin-left: 8px; font-size: 12px; }
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-link {
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.15s;
}
.nav-link:hover { background: #f3f4f6; color: var(--text); }
.nav-link.active { background: #eef2ff; color: var(--brand-dark); font-weight: 600; }
.nav-badge {
  padding: 4px 10px;
  background: #fef3c7;
  border-radius: 999px;
  font-size: 11px;
  color: #92400e;
}

.container { max-width: 1280px; margin: 0 auto; padding: 24px; }
.page-title { font-size: 22px; font-weight: 700; margin: 0 0 4px 0; }
.page-sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.card-value { font-size: 28px; font-weight: 700; }
.card-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

/* inbox list */
.inbox-layout { display: grid; grid-template-columns: 360px 1fr; gap: 16px; height: calc(100vh - 180px); }
.inbox-list {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow-y: auto;
}
.inbox-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.inbox-item:hover { background: #f9fafb; }
.inbox-item.selected { background: #eef2ff; border-left: 3px solid var(--brand); padding-left: 13px; }
.inbox-item-from { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.inbox-item-subject { font-size: 13px; color: var(--text); margin-bottom: 4px; }
.inbox-item-preview { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-item-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.inbox-item-date { font-size: 11px; color: var(--muted); }

.inbox-detail {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  overflow-y: auto;
}
.mail-body {
  background: #f9fafb;
  padding: 16px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  color: var(--text);
  border: 1px solid var(--border);
  font-family: "SF Mono", Monaco, Consolas, monospace;
}
.extract-section { margin-top: 24px; }
.extract-section h3 { font-size: 14px; margin: 0 0 12px 0; display: flex; align-items: center; gap: 8px; }
.extract-section .ai-pill {
  font-size: 10px; padding: 2px 8px; background: #eef2ff; color: var(--brand-dark);
  border-radius: 4px; font-weight: 600; letter-spacing: 0.04em;
}
.kv-grid {
  display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; font-size: 13px;
}
.kv-key { color: var(--muted); }
.kv-val { font-weight: 500; }
.kw-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.kw-tag { padding: 3px 10px; background: #f3f4f6; border-radius: 999px; font-size: 12px; color: #374151; }
.phone-card {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: #f9fafb; border: 1px solid var(--border);
  border-radius: 8px; margin-top: 8px; font-size: 13px;
}
.phone-number { font-family: "SF Mono", Monaco, Consolas, monospace; font-weight: 600; }

/* call simulation */
.call-layout { display: grid; grid-template-columns: 260px 1fr 380px; gap: 12px; min-height: calc(100vh - 180px); }
@media (max-width: 1400px) { .call-layout { grid-template-columns: 240px 1fr 340px; } }
@media (max-width: 1200px) { .call-layout { grid-template-columns: 220px 1fr; } .sysprompt-panel { display: none; } }
.target-list {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow-y: auto;
}
.target-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.target-item.selected { background: #eef2ff; border-left: 3px solid var(--brand); padding-left: 13px; }
.target-item:hover { background: #f9fafb; }
.target-name { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.target-meta { font-size: 11px; color: var(--muted); }

.call-panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
}
.call-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.call-phone { font-family: "SF Mono", Monaco, Consolas, monospace; font-size: 18px; font-weight: 700; }
.call-phone-label { color: var(--muted); font-size: 12px; margin-top: 2px; }
.call-status {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
}
.call-timer {
  font-family: "SF Mono", Monaco, Consolas, monospace;
  font-size: 16px;
  font-weight: 700;
  color: var(--brand-dark);
}
.phase-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
}
.phase-step {
  flex: 1;
  padding: 8px 4px;
  text-align: center;
  font-size: 11px;
  background: #f3f4f6;
  color: var(--muted);
  border-radius: 6px;
  font-weight: 600;
}
.phase-step.done { background: #d1fae5; color: #065f46; }
.phase-step.current { background: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(99,102,241,0.3); }

.transcript {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f9fafb;
  border-radius: 8px;
  min-height: 320px;
  border: 1px solid var(--border);
}
.msg { margin-bottom: 14px; display: flex; gap: 10px; align-items: flex-start; animation: fadeIn 0.4s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.msg.ai { justify-content: flex-start; }
.msg.customer { flex-direction: row-reverse; }
.msg-avatar {
  width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.msg.ai .msg-avatar { background: #eef2ff; color: var(--brand-dark); }
.msg.customer .msg-avatar { background: #dbeafe; color: #1e40af; }
.msg-bubble {
  max-width: 75%; padding: 10px 14px; border-radius: 12px; font-size: 13px; line-height: 1.6;
}
.msg.ai .msg-bubble { background: #fff; border: 1px solid var(--border); }
.msg.customer .msg-bubble { background: #dbeafe; }

/* 合成中ローディングドット */
.msg .dot { display:inline-block; animation: dotBlink 1.2s infinite; color:#6366f1; margin:0 1px; }
.msg .dot:nth-child(2) { animation-delay: 0.15s; }
.msg .dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes dotBlink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }
.msg.system .msg-bubble {
  background: #fef3c7; color: #78350f; font-size: 12px; border: 1px solid #fde68a;
  margin: 0 auto; max-width: 90%; text-align: center;
}
.msg-meta { font-size: 10px; color: var(--muted); margin-top: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }

.msg-speaking .msg-bubble {
  box-shadow: 0 0 0 2px var(--brand), 0 0 12px rgba(99,102,241,0.35);
  animation: speakPulse 1.6s ease-in-out infinite;
}
@keyframes speakPulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--brand), 0 0 8px rgba(99,102,241,0.20); }
  50%      { box-shadow: 0 0 0 2px var(--brand), 0 0 16px rgba(99,102,241,0.55); }
}

.call-controls { display: flex; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); align-items: center; }
.btn {
  padding: 10px 20px; border: none; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all 0.15s; font-family: inherit;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-secondary { background: #f3f4f6; color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: #e5e7eb; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* System Prompt Side Panel */
.sysprompt-panel {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.6;
  border: 1px solid #1e293b;
  position: relative;
}
.sysprompt-header {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 10px; margin-bottom: 10px;
  border-bottom: 1px solid #334155;
}
.sysprompt-title { font-weight: 700; font-size: 13px; letter-spacing: 0.03em; color: #fff; }
.sysprompt-badge {
  font-size: 10px; padding: 2px 6px; background: #6366f1; color: #fff;
  border-radius: 4px; font-weight: 600; letter-spacing: 0.05em;
}
.sp-section { margin-bottom: 14px; }
.sp-section-title {
  font-size: 10px; font-weight: 700; color: #94a3b8;
  letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 6px;
}
.sp-text { color: #cbd5e1; white-space: pre-wrap; font-size: 11.5px; }
.sp-context-row { display: flex; gap: 8px; margin-bottom: 3px; font-size: 11.5px; }
.sp-context-key { color: #94a3b8; min-width: 64px; }
.sp-context-val { color: #f1f5f9; font-weight: 500; }
.sp-kw { display: inline-block; padding: 1px 6px; background: #1e293b; border-radius: 3px; font-size: 10px; color: #e2e8f0; margin: 1px 2px 1px 0; }

.qs-list { display: flex; flex-direction: column; gap: 4px; }
.qs-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 6px 8px; border-radius: 6px; background: #1e293b; transition: all 0.3s;
  font-size: 11.5px;
}
.qs-item.checked { background: #065f46; color: #d1fae5; }
.qs-item.checked .qs-priority { color: #6ee7b7; }
.qs-item.checked .qs-label { color: #ecfdf5; }
.qs-checkbox {
  width: 14px; height: 14px; border-radius: 3px; border: 1.5px solid #64748b;
  flex-shrink: 0; margin-top: 2px; display: flex; align-items: center; justify-content: center;
  transition: all 0.3s;
}
.qs-item.checked .qs-checkbox { background: #10b981; border-color: #10b981; }
.qs-item.checked .qs-checkbox::after { content: "✓"; color: #fff; font-size: 11px; font-weight: 900; }
.qs-priority { font-size: 9px; color: #94a3b8; font-weight: 600; letter-spacing: 0.05em; margin-bottom: 2px; }
.qs-label { color: #e2e8f0; font-size: 11.5px; }
.qs-pulse {
  animation: qsPulse 0.8s ease-out;
}
@keyframes qsPulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.summary-card {
  margin-top: 16px;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 8px;
  padding: 16px;
}
.summary-card h4 { margin: 0 0 8px 0; font-size: 13px; color: #065f46; }
.summary-card p { margin: 0; font-size: 13px; line-height: 1.7; }

/* report */
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.bar-row { margin-bottom: 12px; }
.bar-row-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.bar-track { height: 10px; background: #f3f4f6; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand) 0%, var(--brand-dark) 100%); border-radius: 6px; transition: width 0.6s ease-out; }

.footer-note {
  margin-top: 32px;
  padding: 16px;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 8px;
  font-size: 12px;
  color: #78350f;
  line-height: 1.7;
}
