/* ========================================
   AI対話ナビ KOTONA v3 - Custom Styles
   White-based, Modern & Advanced Design
   ======================================== */

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

:root {
/*  --primary: #4F46E5;
  --primary-light: #818CF8;
  --primary-dark: #3730A3;
  --primary-gradient: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
  --accent: #06B6D4;
  --accent-light: #67E8F9;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #3B82F6;
*/

 /* ロゴの中間的なブルーをベースに */
  --primary: #006994;
  /* ロゴの最も明るいブルー（Kの縦線など） */
  --primary-light: #0091C8;
  /* ロゴのテキストや影のネイビー */
  --primary-dark: #003C66;
  /* ロゴの立体感を表現するグラデーション */
  --primary-gradient: linear-gradient(135deg, #0091C8 0%, #003C66 100%);
  
  /* アクセントはベースより少し鮮やかなシアン系で爽やかに */
  --accent: #00B4D8;
  --accent-light: #90E0EF;

  /* ステータスカラー (全体に馴染むよう少し落ち着いたトーン) */
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #0EA5E9; /* Primaryと被らないよう少し水色寄りに */

  /**--bg-primary: #FFFFFF;
  --bg-secondary: #F8FAFC;
  --bg-tertiary: #F1F5F9;
  --bg-glass: rgba(255, 255, 255, 0.85);

  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-tertiary: #94A3B8;
  --text-inverse: #FFFFFF;

  --border-light: #E2E8F0;
  --border-medium: #CBD5E1;*/

  /* 背景 (ほんのりクールな白〜淡いブルーグレー) */
  --bg-primary: #FFFFFF;
  --bg-secondary: #F4F7F9; /* 少しだけ青みを感じるオフホワイト */
  --bg-tertiary: #E9EFF4;
  --bg-glass: rgba(255, 255, 255, 0.85);

  /* テキスト (真っ黒ではなく、ロゴのネイビーを極限まで暗くした色) */
  --text-primary: #0A1929; /* 強いコントラストでありながら青と馴染む */
  --text-secondary: #3B4E60;
  --text-tertiary: #6C8299;
  --text-inverse: #FFFFFF;

  /* ボーダー */
  --border-light: #D1DBE5;
  --border-medium: #A6B9CC;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 36px rgba(0,0,0,0.08);
  --shadow-xl: 0 24px 48px rgba(0,0,0,0.1);
  --shadow-glow: 0 0 30px rgba(79, 70, 229, 0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);

  --sidebar-width: 260px;
}

/* ========== Reset & Base ========== */
* { box-sizing: border-box; }

body {
  font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  margin: 0;
}

/* ========== Customer Login Page (C-01) ========== */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-wrapper.customer-login {
  background: linear-gradient(135deg, #F8FAFC 0%, #EEF2FF 50%, #F0F9FF 100%);
}

.login-wrapper.customer-login::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(79,70,229,0.08) 0%, transparent 70%);
  top: -200px; right: -100px;
  border-radius: 50%;
  animation: float 8s ease-in-out infinite;
}

.login-wrapper.customer-login::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(6,182,212,0.06) 0%, transparent 70%);
  bottom: -100px; left: -50px;
  border-radius: 50%;
  animation: float 10s ease-in-out infinite reverse;
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-30px) rotate(5deg); }
}

/* ========== Admin Login Page (A-01) - Dark Theme ========== */
.login-wrapper.admin-login {
  background: linear-gradient(135deg, #0F172A 0%, #1E293B 50%, #1A1A2E 100%);
}

.login-wrapper.admin-login::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(79,70,229,0.15) 0%, transparent 70%);
  top: -200px; right: -100px;
  border-radius: 50%;
  animation: float 8s ease-in-out infinite;
}

.login-wrapper.admin-login::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(124,58,237,0.1) 0%, transparent 70%);
  bottom: -100px; left: -50px;
  border-radius: 50%;
  animation: float 10s ease-in-out infinite reverse;
}

.admin-login-card {
  background: rgba(30, 41, 59, 0.9) !important;
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1) !important;
}

.admin-login-card .login-logo h1 {
  color: #E2E8F0;
}

.admin-login-card .login-logo h1 small {
  color: #94A3B8;
}

.admin-login-card .login-subtitle {
  color: #94A3B8;
}

.admin-login-card .form-control {
  background: rgba(15, 23, 42, 0.6);
  border-color: rgba(255,255,255,0.15);
  color: #E2E8F0;
}

.admin-login-card .form-control:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.admin-login-card .form-floating label {
  color: #94A3B8;
}

.admin-logo-icon {
  background: linear-gradient(135deg, #3730A3 0%, #581C87 100%) !important;
}

.btn-admin-gradient {
  background: linear-gradient(135deg, #3730A3 0%, #581C87 100%);
  border: none;
  color: white;
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.btn-admin-gradient:hover {
  opacity: 0.9;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 0 20px rgba(79, 70, 229, 0.3);
}

.admin-footer {
  color: #64748B !important;
}

/* ========== Login Card (shared) ========== */
.login-card {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-xl);
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-logo .logo-icon {
  width: 56px; height: 56px;
  background: var(--primary-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: white;
  margin: 0 auto 1rem;
  box-shadow: var(--shadow-glow);
}

.login-logo h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin: 0;
}

.login-logo h1 small {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-tertiary);
  margin-top: 2px;
  letter-spacing: 0.05em;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1.75rem;
  text-align: center;
}

.login-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.login-options .form-check-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.login-options a {
  font-size: 0.82rem;
  color: var(--primary);
  text-decoration: none;
}

.login-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 1.5rem;
  margin-bottom: 0;
}

.mock-toggle-link {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  text-decoration: none;
  opacity: 0.7;
  transition: var(--transition-fast);
}

.mock-toggle-link:hover {
  opacity: 1;
  color: var(--primary-light);
}

/* ========== App Layout ========== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ========== Sidebar ========== */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-primary);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 1.25rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-header .logo-icon {
  width: 36px; height: 36px;
  background: var(--primary-gradient);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: white;
  flex-shrink: 0;
}

.logo-text {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.logo-text small {
  display: block;
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--text-tertiary);
  letter-spacing: 0.05em;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem;
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  padding: 0.75rem 0.75rem 0.5rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--transition-fast);
  margin-bottom: 2px;
}

.sidebar-link:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.sidebar-link.active {
  background: rgba(79, 70, 229, 0.08);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-link i {
  font-size: 1rem;
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-light);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 34px; height: 34px;
  background: var(--primary-gradient);
  color: white;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.user-info {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
}

.user-info small {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-tertiary);
}

/* ========== Main Area ========== */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
}

.app-topbar {
  height: 60px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-content {
  padding: 1.5rem;
  flex: 1;
}

/* ========== Cards ========== */
.card-modern {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-modern .card-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  padding: 0.85rem 1.25rem;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-primary);
}

.card-modern .card-body {
  padding: 1.25rem;
}

/* ========== Buttons ========== */
.btn-primary-gradient {
  background: var(--primary-gradient);
  border: none;
  color: white;
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.btn-primary-gradient:hover {
  opacity: 0.9;
  color: white;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-outline-subtle {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.btn-outline-subtle:hover {
  background: var(--bg-secondary);
  border-color: var(--border-medium);
  color: var(--text-primary);
}

/* ========== Stat Cards ========== */
.stat-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin: 0 auto 0.75rem;
}

.stat-icon.purple { background: rgba(79,70,229,0.1); color: var(--primary); }
.stat-icon.cyan { background: rgba(6,182,212,0.1); color: var(--accent); }
.stat-icon.green { background: rgba(16,185,129,0.1); color: var(--success); }
.stat-icon.amber { background: rgba(245,158,11,0.1); color: var(--warning); }

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.hover-lift {
  transition: var(--transition);
}

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

/* ========== Table ========== */
.table-modern {
  font-size: 0.85rem;
}

.table-modern thead th {
  background: var(--bg-secondary);
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border-light);
  padding: 0.75rem 1rem;
}

.table-modern tbody td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-light);
}

.table-modern tbody tr:hover {
  background: var(--bg-secondary);
}

/* ========== Badges ========== */
.badge-status {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-complete { background: rgba(16,185,129,0.1); color: #059669; }
.badge-open { background: rgba(16,185,129,0.1); color: #059669; }
.badge-progress { background: rgba(79,70,229,0.1); color: var(--primary); }
.badge-draft { background: rgba(148,163,184,0.15); color: var(--text-secondary); }
.badge-closed { background: rgba(239,68,68,0.1); color: var(--danger); }
.badge-upcoming { background: rgba(245,158,11,0.1); color: #D97706; }

.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: linear-gradient(135deg, rgba(79,70,229,0.08), rgba(124,58,237,0.08));
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary);
}

/* ========== Divider ========== */
.divider {
  height: 1px;
  background: var(--border-light);
  margin: 1.25rem 0;
}

/* ========== Section Heading ========== */
.section-heading {
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.section-heading i {
  color: var(--primary);
}

/* ========== Search Bar ========== */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0 12px;
}

.search-bar i {
  color: var(--text-tertiary);
}

.search-bar input {
  flex: 1;
  border: none;
  outline: none;
  padding: 8px 0;
  font-size: 0.85rem;
  background: transparent;
}

/* ========== Subsidy Cards ========== */
.subsidy-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  cursor: pointer;
  transition: var(--transition);
}

.subsidy-card:hover {
  border-color: var(--primary-light);
}

.subsidy-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.subsidy-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 0.75rem;
}

.subsidy-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--text-tertiary);
}

.subsidy-meta i {
  margin-right: 3px;
}

/* ========== Section List ========== */
.section-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: var(--transition-fast);
  border-bottom: 1px solid var(--border-light);
}

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

.section-item:hover {
  background: var(--bg-secondary);
}

.section-item.active {
  background: rgba(79, 70, 229, 0.06);
  border-left: 3px solid var(--primary);
}

.section-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.section-status.not_started,
.section-status.not-started { background: var(--border-medium); }
.section-status.in_progress,
.section-status.in-progress { background: var(--primary); animation: pulse 2s infinite; }
.section-status.completed { background: var(--success); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.section-title {
  font-weight: 600;
  font-size: 0.82rem;
}

.section-meta {
  font-size: 0.68rem;
  color: var(--text-tertiary);
}

/* ========== Document Group Header (v3: hierarchy) ========== */
.document-group-header {
  padding: 0.5rem 1rem;
  background: var(--bg-tertiary);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary-dark);
  border-bottom: 1px solid var(--border-light);
  text-transform: none;
  letter-spacing: 0;
}

/* ========== Chat ========== */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 500px;
}

.chat-info {
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.chat-info p {
  margin: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-bubble {
  max-width: 90%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  line-height: 1.7;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-bubble.assistant {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

.chat-bubble.user {
  background: var(--primary-gradient);
  color: white;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

.chat-bubble.thinking {
  background: var(--bg-secondary);
}

.thinking-message {
  margin-bottom: 4px;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

/* ========== Chat Avatar (v3 new) ========== */
.chat-avatar-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.chat-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--border-light);
}

.chat-bubble-content {
  flex: 1;
  min-width: 0;
}

.chat-bubble-content > :first-child {
  margin-top: 0;
}

.chat-bubble-content > :last-child {
  margin-bottom: 0;
}

.chat-bubble-content p {
  margin: 0 0 0.5rem;
}

.chat-bubble-content ul,
.chat-bubble-content ol {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
}

.chat-bubble-content li + li {
  margin-top: 0.25rem;
}

.chat-bubble-content pre {
  margin: 0.75rem 0;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.06);
  overflow-x: auto;
  white-space: pre-wrap;
}

.chat-bubble-content code {
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.08);
  font-size: 0.9em;
}

.chat-bubble-content pre code {
  padding: 0;
  background: transparent;
}

/* ========== Thinking Dots ========== */
.thinking-dots {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.thinking-dots span {
  width: 8px;
  height: 8px;
  background: var(--text-tertiary);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.thinking-dots span:nth-child(1) { animation-delay: -0.32s; }
.thinking-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1.0); }
}

.chat-input-area {
  border-top: 1px solid var(--border-light);
  padding: 0.75rem 1rem;
}

.chat-input-area textarea {
  width: 100%;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  resize: none;
  height: 60px;
  font-family: inherit;
  outline: none;
  transition: var(--transition-fast);
}

.chat-input-area textarea:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.chat-input-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
}

/* ========== Document Canvas (v3 new) ========== */
.canvas-content {
  font-size: 0.88rem;
  line-height: 2;
  color: var(--text-primary);
  min-height: 200px;
}

.canvas-editor {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.85rem;
  line-height: 1.8;
  min-height: 300px;
  resize: vertical;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

/* ========== WYSIWYG Canvas Editor ========== */
.wysiwyg-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.wysiwyg-toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 26px;
  padding: 0 6px;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: var(--transition-fast);
}

.wysiwyg-toolbar button:hover {
  background: var(--bg-secondary);
  border-color: var(--primary-light);
  color: var(--primary);
}

.wysiwyg-toolbar .toolbar-sep {
  width: 1px;
  background: var(--border-light);
  margin: 2px 2px;
}

.canvas-wysiwyg {
  font-size: 0.88rem;
  line-height: 1.9;
  color: var(--text-primary);
  min-height: 300px;
  max-height: 500px;
  overflow-y: auto;
  padding: 1rem;
  border: 1px solid var(--border-light);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--bg-primary);
  outline: none;
}

.canvas-wysiwyg:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.08);
}

.canvas-wysiwyg:empty:before {
  content: attr(data-placeholder);
  color: var(--text-tertiary);
  pointer-events: none;
  font-style: italic;
}

.canvas-wysiwyg h3,
.canvas-wysiwyg h4,
.canvas-wysiwyg h5 {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

.canvas-wysiwyg ul,
.canvas-wysiwyg ol {
  margin-left: 1.5rem;
  margin-bottom: 0.5rem;
}

.canvas-wysiwyg li {
  margin-bottom: 0.25rem;
}

.canvas-wysiwyg p {
  margin-bottom: 0.6rem;
}

.canvas-preview {
  min-height: 300px;
  max-height: 500px;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.canvas-preview h3,
.canvas-preview h4,
.canvas-preview h5 {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

.canvas-preview ul {
  margin-left: 1.5rem;
  margin-bottom: 0.5rem;
}

.canvas-preview li {
  margin-bottom: 0.25rem;
}

.revision-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  background: rgba(79,70,229,0.08);
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary);
}

.revision-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.revision-buttons .btn {
  font-size: 0.72rem;
  padding: 2px 10px;
}

/* ========== Upload Area ========== */
.upload-area {
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-md);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

.upload-area:hover {
  border-color: var(--primary-light);
  background: rgba(79, 70, 229, 0.02);
}

.upload-area i {
  font-size: 2rem;
  color: var(--text-tertiary);
  display: block;
  margin-bottom: 0.5rem;
}

.upload-area p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.upload-area small {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

/* ========== Uploaded Files ========== */
.uploaded-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-info i {
  font-size: 1.5rem;
  color: var(--danger);
}

.file-info i.bi-file-earmark-image {
  color: var(--info);
}

.file-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.file-meta {
  font-size: 0.72rem;
  color: var(--text-tertiary);
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.summarizing-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: rgba(245,158,11,0.1);
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  color: #D97706;
  animation: pulse 1.5s infinite;
}

.summary-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: rgba(79,70,229,0.08);
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.summary-badge:hover {
  background: rgba(79,70,229,0.15);
}

/* ========== Modal Overlay ========== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.summary-modal {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
}

.summary-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  font-weight: 700;
  font-size: 0.9rem;
}

.summary-modal-body {
  padding: 1.25rem;
  font-size: 0.85rem;
  line-height: 1.8;
  color: var(--text-secondary);
  overflow-y: auto;
  max-height: calc(80vh - 60px);
}

/* ========== Partner Cards ========== */
.partner-card {
  background: var(--bg-primary);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  transition: var(--transition);
}

.partner-card.active {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}

.partner-icon {
  width: 48px;
  height: 48px;
  background: var(--primary-gradient);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.partner-card h6 {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.partner-name {
  font-size: 0.82rem;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.partner-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 1rem;
}

.partner-price {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

/* ========== Alerts ========== */
.alert-info-custom {
  background: rgba(79,70,229,0.05);
  border: 1px solid rgba(79,70,229,0.15);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--primary);
  padding: 0.75rem 1rem;
}

.alert-warning-custom {
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: #92400E;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

/* ========== Disabled Overlay ========== */
.disabled-overlay {
  opacity: 0.5;
  pointer-events: none;
  filter: grayscale(0.3);
}

/* ========== Result Preview ========== */
.result-preview {
  font-size: 0.88rem;
  line-height: 2;
  color: var(--text-primary);
}

/* ========== Preview (v3: integrated in C-05) ========== */
.preview-body {
  max-width: 900px;
  margin: 0 auto;
}

.preview-header {
  text-align: center;
  margin-bottom: 2rem;
}

.preview-header h4 {
  font-weight: 800;
  color: var(--text-primary);
}

.preview-header p {
  color: var(--text-tertiary);
  font-size: 0.85rem;
}

.preview-content {
  font-size: 0.88rem;
  line-height: 2;
}

.preview-document-title {
  font-weight: 800;
  font-size: 1rem;
  color: var(--primary-dark);
  margin-top: 2rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary);
}

.preview-section {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.preview-section-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
}

/* ========== Fact Check (v3 new) ========== */
.fact-check-result {
  background: rgba(16,185,129,0.05);
  border: 1px solid rgba(16,185,129,0.2);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.fact-check-header {
  padding: 0.5rem 0.75rem;
  background: rgba(16,185,129,0.08);
  font-size: 0.78rem;
  font-weight: 700;
  color: #059669;
}

.fact-check-body {
  padding: 0.75rem;
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

/* ========== Token Summary (v3 new) ========== */
.token-summary-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 1rem;
  text-align: center;
}

.token-summary-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.token-summary-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0.25rem 0;
}

.token-summary-sub {
  font-size: 0.72rem;
  color: var(--text-tertiary);
}

/* ========== Strategy Master Items ========== */
.strategy-master-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

/* ========== Subsidy Section Edit ========== */
.subsidy-section-edit {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
}

/* ========== Document Edit Group (v3 new) ========== */
.document-edit-group {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  background: var(--bg-secondary);
}

/* ========== Page Transition ========== */
.page-content {
  animation: fadeIn 0.3s ease;
}

/* ========== Form Switch ========== */
.form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

/* ========== Responsive ========== */
@media (max-width: 991px) {
  .chat-container {
    height: 400px;
  }
}

@media (max-width: 768px) {
  .app-sidebar {
    width: 200px;
  }
  .app-main {
    margin-left: 200px;
  }
  .app-content {
    padding: 1rem;
  }
}

/* ========== Three-Pane Full Height Layout ========== */
.three-pane-row {
  align-items: stretch;
}

.three-pane-row > [class*='col'] {
  display: flex;
}

.three-pane-row > [class*='col'] > .card-modern {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  min-height: 400px;
}

.three-pane-row > [class*='col'] > .card-modern > .card-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.three-pane-row .chat-container {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.three-pane-row .canvas-editor {
  flex: 1;
  min-height: 200px;
  resize: none;
}

/* ========== Chat Start Overlay ========== */
.chat-messages {
  position: relative;
}

.chat-start-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-sm);
  z-index: 10;
}

@media (max-width: 991px) {
  .three-pane-row > [class*='col'] > .card-modern {
    height: 400px;
  }
}

/* ========== Print / PDF ========== */
.no-print {
  /* Utility: hide during print */
}

@media print {
  /* Hide navigation and chrome */
  .app-sidebar,
  .app-topbar,
  .no-print {
    display: none !important;
  }

  /* Full-width main area */
  .app-main {
    margin-left: 0 !important;
    padding: 0 !important;
  }

  .app-content {
    padding: 0 !important;
  }

  .page-content {
    padding: 0 !important;
  }

  /* Card: remove shadow / border for print */
  .card-modern {
    box-shadow: none !important;
    border: none !important;
  }

  .preview-section {
    background: #fff !important;
    border: 1px solid #ccc !important;
    break-inside: avoid;
  }

  .fact-check-result {
    break-inside: avoid;
  }

  /* Ensure text is black for print */
  body {
    color: #000 !important;
  }

  a {
    color: #000 !important;
    text-decoration: none !important;
  }
}
