/* ============================================================
   訪問レポートアシスタント - スタイルシート
   Mobile-first (iPhone Safari 対応)
   ============================================================ */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --danger: #dc2626;
  --danger-dark: #b91c1c;
  --success: #16a34a;
  --warning: #d97706;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --doctor-color: #7c3aed;
  --doctor-light: #ede9fe;
  --care-color: #0891b2;
  --care-light: #cffafe;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN',
    'Yu Gothic', 'Noto Sans JP', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--gray-900);
  background: var(--gray-50);
  min-height: 100vh;
}

.screen {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 0 80px;
}

.hidden {
  display: none !important;
}

/* ============================================================
   Header
   ============================================================ */

.app-header, .pc-header {
  background: var(--primary);
  color: white;
  padding: 20px 20px 16px;
  text-align: center;
}

.app-header h1, .pc-header h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

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

.pc-badge {
  background: rgba(255,255,255,0.25);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

/* ============================================================
   患者名入力
   ============================================================ */

.patient-section {
  padding: 20px 20px 0;
}

.patient-section label {
  display: block;
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 6px;
  font-weight: 500;
}

.patient-section input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 16px;
  background: white;
  color: var(--gray-900);
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

.patient-section input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ============================================================
   マイクボタン
   ============================================================ */

.mic-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 20px 24px;
  gap: 20px;
}

.mic-btn {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: white;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-lg), 0 0 0 8px var(--primary-light);
  transition: all 0.2s ease;
  -webkit-user-select: none;
  user-select: none;
}

.mic-btn:active {
  transform: scale(0.95);
}

.mic-btn.recording {
  background: var(--danger);
  box-shadow: var(--shadow-lg), 0 0 0 8px rgba(220,38,38,0.15);
  animation: pulse-recording 1.5s infinite;
}

.mic-btn.processing {
  background: var(--warning);
  box-shadow: var(--shadow-lg), 0 0 0 8px rgba(217,119,6,0.15);
  cursor: not-allowed;
}

@keyframes pulse-recording {
  0%, 100% { box-shadow: var(--shadow-lg), 0 0 0 8px rgba(220,38,38,0.15); }
  50%       { box-shadow: var(--shadow-lg), 0 0 0 16px rgba(220,38,38,0.08); }
}

.mic-icon {
  width: 48px;
  height: 48px;
}

#mic-btn-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ============================================================
   ステータスバー
   ============================================================ */

.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 40px;
  font-size: 14px;
  font-weight: 600;
  min-width: 200px;
  justify-content: center;
}

.status-idle    { background: var(--gray-100); color: var(--gray-500); }
.status-recording { background: rgba(220,38,38,0.1); color: var(--danger); }
.status-transcribing { background: rgba(217,119,6,0.1); color: var(--warning); }
.status-generating { background: var(--primary-light); color: var(--primary-dark); }
.status-done    { background: rgba(22,163,74,0.1); color: var(--success); }
.status-error   { background: rgba(220,38,38,0.08); color: var(--danger); }

.recording-timer {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

/* ============================================================
   文字起こしエリア
   ============================================================ */

.transcript-section {
  margin: 0 20px 16px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.transcript-section h2 {
  font-size: 14px;
  color: var(--gray-500);
  margin-bottom: 10px;
  font-weight: 600;
}

.transcript-text {
  font-size: 15px;
  color: var(--gray-700);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ============================================================
   タブ（医師用 / ケアマネ用）
   ============================================================ */

.tab-bar {
  display: flex;
  margin: 0 20px 0;
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
  border: 1px solid var(--gray-200);
  border-bottom: none;
}

.tab-btn {
  flex: 1;
  padding: 12px;
  border: none;
  background: var(--gray-100);
  color: var(--gray-500);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: white;
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
}

.tab-content {
  margin: 0 20px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.tab-content.hidden { display: none !important; }

.report-header {
  margin-bottom: 12px;
}

.report-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

.report-badge.doctor     { background: var(--doctor-light); color: var(--doctor-color); }
.report-badge.caremanager { background: var(--care-light);   color: var(--care-color); }

.report-text {
  font-size: 15px;
  line-height: 1.8;
  color: var(--gray-700);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ============================================================
   アクションボタン
   ============================================================ */

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px 20px 0;
}

.result-section {
  margin-top: 12px;
}

.btn-primary, .btn-secondary {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.02em;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

.btn-primary:active { background: var(--primary-dark); transform: scale(0.98); }

.btn-secondary {
  background: white;
  color: var(--gray-700);
  border: 1.5px solid var(--gray-300);
}

.btn-secondary:active { background: var(--gray-100); transform: scale(0.98); }

/* ============================================================
   送信完了
   ============================================================ */

.send-success {
  margin: 24px 20px;
  background: rgba(22,163,74,0.08);
  border: 1px solid rgba(22,163,74,0.3);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
}

.success-icon { font-size: 48px; margin-bottom: 12px; }

.send-success p {
  font-size: 16px;
  color: var(--gray-700);
  margin-bottom: 20px;
  line-height: 1.7;
}

/* ============================================================
   PC 受信画面
   ============================================================ */

.pc-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
  color: var(--gray-500);
}

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

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

.pc-content {
  padding: 20px;
}

.pc-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 8px;
}

.pc-patient {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
}

.pc-time {
  font-size: 13px;
  color: var(--gray-500);
}

.pc-reports {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.pc-report-block {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.pc-report-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.pc-report-title-row h2 {
  font-size: 16px;
  color: var(--gray-900);
}

.copy-btn {
  padding: 8px 16px;
  border: 1.5px solid var(--gray-300);
  border-radius: 8px;
  background: white;
  color: var(--gray-700);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.copy-btn:hover { background: var(--gray-100); }
.copy-btn.copied { background: var(--success); color: white; border-color: var(--success); }

.pc-report-text {
  font-size: 15px;
  line-height: 1.9;
  color: var(--gray-700);
  white-space: pre-wrap;
  word-break: break-all;
}

.pc-actions {
  margin-top: 24px;
  display: flex;
  gap: 12px;
}

.pc-actions .btn-primary {
  flex: 1;
}

.pc-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-500);
  line-height: 1.8;
  font-size: 16px;
}

/* ============================================================
   患者カード（PC受信画面 - 複数患者対応）
   ============================================================ */

.pc-cards-container {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.patient-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.patient-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  flex-wrap: wrap;
}

.patient-card-number {
  background: var(--primary);
  color: white;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.patient-card-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  flex: 1;
}

.patient-card-time {
  font-size: 12px;
  color: var(--gray-500);
  white-space: nowrap;
}

.patient-card-tabs {
  display: flex;
  border-bottom: 1px solid var(--gray-200);
}

.pc-tab-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: var(--gray-100);
  color: var(--gray-500);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.pc-tab-btn.active {
  background: white;
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
}

.patient-card-content {
  padding: 16px;
}

.pc-tab-pane.hidden {
  display: none !important;
}

#pc-actions {
  padding: 0 20px 32px;
}

#pc-actions .btn-primary {
  width: 100%;
}

/* ============================================================
   印刷スタイル
   ============================================================ */

@media print {
  .app-header, .pc-header, .copy-btn, .pc-actions,
  .patient-card-tabs, .action-buttons, .status-bar,
  .mic-section, .patient-section { display: none !important; }

  .patient-card {
    box-shadow: none;
    border: 1px solid #ccc;
    page-break-inside: avoid;
    margin-bottom: 24px;
  }

  .pc-tab-pane.hidden { display: block !important; }

  body { background: white; }
}

/* ============================================================
   PC 大画面レイアウト
   ============================================================ */

@media (min-width: 640px) {
  .screen {
    padding: 0 0 40px;
  }
}
