/* ===================================
   Pivotalk - Global Styles
   =================================== */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;600;700&family=Noto+Serif+JP:wght@500;700&display=swap');

/* CSS Variables */
:root {
  --color-navy: #1B365D;
  --color-accent: #2563EB;
  --color-bg: #F8FAFC;
  --color-card: #FFFFFF;
  --color-border: #E2E8F0;
  --color-text-dark: #1E293B;
  --color-text-mid: #475569;
  --color-text-light: #94A3B8;
  --color-success: #059669;
  --color-warning: #D97706;
  --color-danger: #DC2626;
  --font-heading: 'Noto Serif JP', serif;
  --font-body: 'Noto Sans JP', sans-serif;
  --max-width: 840px;
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--color-text-dark);
  background: var(--color-bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.header {
  background: var(--color-navy);
  color: #fff;
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-logo {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
}

.header-tagline {
  font-size: 12px;
  color: var(--color-text-light);
  margin-left: 12px;
}

/* Page Title */
.page-title {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 700;
  color: var(--color-navy);
  margin: 24px 0 16px;
}

/* Cards */
.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-navy);
  margin-bottom: 12px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: #1d4ed8;
}

.btn-secondary {
  background: var(--color-bg);
  color: var(--color-text-mid);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  background: #e2e8f0;
}

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

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 16px;
}

/* Form Elements */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-dark);
  margin-bottom: 6px;
}

.form-label .required {
  color: var(--color-danger);
  margin-left: 4px;
}

.form-hint {
  font-size: 12px;
  color: var(--color-text-light);
  margin-top: 2px;
  margin-bottom: 6px;
}

.form-select,
.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--color-text-dark);
  background: var(--color-card);
  transition: border-color 0.2s;
  appearance: none;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394A3B8' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-select:focus,
.form-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Checkbox Group */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  user-select: none;
}

.checkbox-item:hover {
  border-color: var(--color-accent);
}

.checkbox-item.checked {
  background: #eff6ff;
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.checkbox-item input {
  display: none;
}

/* Form Section */
.form-section {
  margin-bottom: 24px;
}

.form-section-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 500;
  color: var(--color-navy);
  padding-bottom: 8px;
  border-bottom: 2px solid var(--color-navy);
  margin-bottom: 16px;
}

/* Step Progress Bar */
.step-bar {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 20px 0;
  padding: 0 4px;
  overflow-x: auto;
}

.step-item {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.step-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: var(--color-bg);
  border: 2px solid var(--color-border);
  color: var(--color-text-light);
  flex-shrink: 0;
}

.step-item.active .step-circle {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

.step-item.done .step-circle {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #fff;
}

.step-label {
  font-size: 10px;
  color: var(--color-text-light);
  margin-left: 4px;
  white-space: nowrap;
}

.step-item.active .step-label {
  color: var(--color-accent);
  font-weight: 600;
}

.step-item.done .step-label {
  color: var(--color-success);
}

.step-line {
  flex: 1;
  min-width: 8px;
  height: 2px;
  background: var(--color-border);
  margin: 0 2px;
}

.step-item.done + .step-line,
.step-line.done {
  background: var(--color-success);
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 20px;
  gap: 0;
}

.tab {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-light);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font-body);
}

.tab:hover {
  color: var(--color-text-mid);
}

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

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Badge */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.badge-step0 { background: #f1f5f9; color: var(--color-text-light); }
.badge-step1 { background: #dbeafe; color: #1d4ed8; }
.badge-step2 { background: #e0e7ff; color: #3730a3; }
.badge-step3 { background: #fef3c7; color: #92400e; }
.badge-step4 { background: #fce7f3; color: #9d174d; }
.badge-step5 { background: #d1fae5; color: #065f46; }
.badge-step6 { background: #e0f2fe; color: #0369a1; }

/* Funnel Chart */
.funnel-chart {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.funnel-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.funnel-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-mid);
  min-width: 72px;
  text-align: right;
}

.funnel-bar-wrap {
  flex: 1;
  height: 22px;
  background: var(--color-bg);
  border-radius: 4px;
  overflow: hidden;
}

.funnel-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
  min-width: 4px;
}

.funnel-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-dark);
  min-width: 32px;
}

/* Stale Alert */
.stale-alert {
  margin-top: 12px;
  padding: 12px 16px;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  font-size: 13px;
  color: var(--color-text-mid);
}

.stale-alert strong {
  color: var(--color-warning);
}

.stale-list {
  list-style: none;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stale-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.stale-list li:hover {
  color: var(--color-accent);
}

/* Report */
.report-page {
  font-size: 14px;
  line-height: 1.7;
  color: var(--color-text-dark);
}

.report-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--color-navy);
  margin-bottom: 16px;
}

.report-logo {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--color-navy);
}

.report-date {
  font-size: 13px;
  color: var(--color-text-light);
}

.report-title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  color: var(--color-navy);
  margin-bottom: 20px;
}

.report-section {
  margin-bottom: 20px;
}

.report-section h2 {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  color: var(--color-navy);
  padding: 4px 8px;
  background: #f0f4ff;
  border-left: 3px solid var(--color-accent);
  margin-bottom: 10px;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 8px;
  font-size: 13px;
}

.report-table th,
.report-table td {
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  text-align: left;
}

.report-table th {
  background: var(--color-bg);
  font-weight: 600;
  color: var(--color-text-mid);
  white-space: nowrap;
  width: 100px;
}

.report-memo {
  padding: 8px 12px;
  background: #fefce8;
  border-radius: 6px;
  font-size: 13px;
  margin-top: 6px;
  line-height: 1.6;
}

.report-ai-summary {
  padding: 8px 12px;
  background: #f0f4ff;
  border-radius: 6px;
  font-size: 13px;
  margin-top: 6px;
  line-height: 1.6;
  color: var(--color-text-mid);
}

/* Case List */
.case-list {
  list-style: none;
}

.case-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.case-item:hover {
  border-color: var(--color-accent);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
}

.case-item-main {
  flex: 1;
  min-width: 0;
}

.case-item-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--color-text-dark);
  margin-bottom: 4px;
}

.case-item-meta {
  font-size: 13px;
  color: var(--color-text-light);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.case-item-action {
  font-size: 12px;
  color: var(--color-accent);
  font-weight: 500;
  text-align: right;
  flex-shrink: 0;
  margin-left: 12px;
}

/* Sheet Output */
.sheet-output {
  font-size: 15px;
  line-height: 1.9;
}

.sheet-output h2 {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--color-navy);
  margin: 28px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--color-border);
}

.sheet-output h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-dark);
  margin: 20px 0 8px;
}

.sheet-output p {
  margin-bottom: 12px;
  color: var(--color-text-mid);
}

.sheet-output .disclaimer {
  font-size: 11px;
  color: var(--color-text-light);
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

/* Chat (Simulation) */
.chat-area {
  min-height: 400px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 16px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin-bottom: 12px;
}

.chat-msg {
  margin-bottom: 16px;
  max-width: 85%;
}

.chat-msg.president {
  margin-right: auto;
}

.chat-msg.user {
  margin-left: auto;
}

.chat-msg-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-light);
  margin-bottom: 4px;
}

.chat-msg-bubble {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.7;
}

.chat-msg.president .chat-msg-bubble {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: 4px;
}

.chat-msg.user .chat-msg-bubble {
  background: var(--color-accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-meta {
  margin-top: 8px;
  padding: 10px 14px;
  background: #fefce8;
  border-left: 3px solid var(--color-warning);
  border-radius: 4px;
  font-size: 13px;
  color: var(--color-text-mid);
  line-height: 1.6;
}

.chat-meta.ng {
  background: #fef2f2;
  border-left-color: var(--color-danger);
}

.chat-meta.turning-point {
  background: #eff6ff;
  border-left-color: var(--color-accent);
}

.chat-input-area {
  display: flex;
  gap: 8px;
}

.chat-input-area .form-input {
  flex: 1;
}

/* Review Chat (振り返り対話) */
.review-chat-area {
  border-top: 1px solid var(--color-border);
  padding-top: 16px;
}

.review-chat-log {
  min-height: 120px;
  max-height: 400px;
  overflow-y: auto;
  padding: 12px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
}

.review-chat-log .chat-msg.president .chat-msg-bubble {
  background: #f0f4ff;
  border-color: #c7d7fe;
}

.review-chat-log .chat-msg-label {
  font-size: 11px;
}

/* Overlay / Modal */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.overlay.hidden {
  display: none;
}

.modal {
  background: var(--color-card);
  border-radius: 12px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--color-navy);
  margin-bottom: 16px;
}

/* Loading */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 12px;
}

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

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

.loading-text {
  font-size: 14px;
  color: var(--color-text-light);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-light);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state-text {
  font-size: 15px;
  margin-bottom: 20px;
}

/* Utility */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Onboarding */
.onboarding-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.onboarding-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  background: var(--color-bg);
  border-radius: 8px;
}

.onboarding-step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.onboarding-step-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-dark);
  margin-bottom: 4px;
}

.onboarding-step-desc {
  font-size: 13px;
  color: var(--color-text-mid);
  line-height: 1.6;
}

.onboarding-flow-box {
  background: #f0f4ff;
  border: 1px solid #c7d7fe;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 8px;
}

.onboarding-flow-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.flow-chip {
  background: var(--color-accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
  white-space: nowrap;
}

.flow-chip-sm {
  font-size: 11px;
  padding: 5px 10px;
}

.flow-arrow {
  color: var(--color-accent);
  font-size: 16px;
  font-weight: 700;
}

/* Responsive */
@media (max-width: 640px) {
  .header-tagline {
    display: none;
  }

  .page-title {
    font-size: 18px;
  }

  .card {
    padding: 16px;
  }

  .step-label {
    font-size: 9px;
  }

  .step-circle {
    width: 24px;
    height: 24px;
    font-size: 11px;
  }

  .step-item {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .step-label {
    margin-left: 0;
    margin-top: 4px;
  }

  .case-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .case-item-action {
    margin-left: 0;
    text-align: left;
  }

  .tab {
    padding: 8px 12px;
    font-size: 13px;
  }

  .chat-msg {
    max-width: 92%;
  }

  .checkbox-item {
    font-size: 13px;
    padding: 5px 10px;
  }
}

/* Print Styles */
@media print {
  body {
    background: #fff;
    font-size: 12pt;
    color: #000;
  }

  .header,
  .step-bar,
  .tabs,
  #onboarding-overlay,
  #settings-overlay,
  .btn,
  .chat-input-area,
  .review-chat-area,
  #sim-setup,
  #sim-active,
  #page-dashboard,
  #page-new-case,
  .form-group,
  form,
  button {
    display: none !important;
  }

  /* 表示中のタブコンテンツを印刷対象に */
  .tab-content.active {
    display: block !important;
  }

  /* Step6のカード内容は表示 */
  #review-content .card {
    display: block !important;
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
    page-break-inside: avoid;
  }

  /* シート/ガイド/ヒントの生成結果は表示 */
  #sheet-result,
  #sheet-output {
    display: block !important;
  }

  #sheet-result {
    border: none;
    box-shadow: none;
  }

  .sheet-output h2 {
    font-size: 16pt;
    color: #000;
    border-bottom: 1px solid #ccc;
  }

  .sheet-output h3 {
    font-size: 14pt;
    color: #333;
  }

  .sheet-output p {
    color: #333;
    line-height: 1.8;
  }

  .container {
    max-width: 100%;
    padding: 0;
  }

  .card {
    border: none;
    box-shadow: none;
    padding: 0;
  }

  .page-title {
    font-size: 18pt;
    color: #000;
    margin-top: 0;
  }

  /* ページ前の生成結果を独立ページに */
  .sheet-output,
  #review-content {
    page-break-before: auto;
  }

  /* 隠れたタブ以外のコンテンツを非表示 */
  .tab-content:not(.active) {
    display: none !important;
  }

  /* 印刷時のヘッダー代わり */
  #detail-title::before {
    content: "Pivotalk - ";
    font-size: 10pt;
    color: #999;
  }
}
