/* ==========================================================================
   吳鳳科技大學 生源及招生分析儀表板
   智能校務諮詢助理 (IR Smart Copilot) 樣式表
   RWD 現代化響應式設計 · 雙模智慧決策大腦
   ========================================================================== */

/* 1. 懸浮啟動鈕 (Floating Action Button - FAB) */
.copilot-fab-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #0f4c81 0%, #1a237e 60%, #0d9488 100%);
  color: #ffffff;
  border: 2px solid rgba(212, 175, 55, 0.7);
  border-radius: 50px;
  padding: 12px 22px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(15, 76, 129, 0.35), 0 0 15px rgba(212, 175, 55, 0.25);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.copilot-fab-btn:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 12px 30px rgba(15, 76, 129, 0.5), 0 0 20px rgba(212, 175, 55, 0.5);
  border-color: #d4af37;
}

.copilot-fab-icon-box {
  position: relative;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  font-size: 1.1rem;
  color: #ffd700;
}

.copilot-fab-pulse {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  background: #10b981;
  border-radius: 50%;
  border: 2px solid #ffffff;
  animation: copilotPing 1.8s infinite;
}

@keyframes copilotPing {
  0% { transform: scale(0.9); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.5; }
  100% { transform: scale(0.9); opacity: 1; }
}

.copilot-fab-text {
  letter-spacing: 0.5px;
  display: inline-block;
}

.copilot-fab-badge {
  background: #d4af37;
  color: #0f4c81;
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 800;
  margin-left: 2px;
}

/* 2. 智慧對話抽屜視窗 (Chat Window) */
.copilot-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 440px;
  max-width: calc(100vw - 32px);
  height: 640px;
  max-height: calc(100vh - 48px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.28), 0 0 0 1px rgba(15, 76, 129, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transform: translateY(30px) scale(0.96);
  transition: all 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

.copilot-panel.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* 視窗頂部 Header */
.copilot-header {
  background: linear-gradient(135deg, #0f4c81 0%, #1a237e 100%);
  color: #ffffff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #d4af37;
}

.copilot-header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.copilot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #d4af37 0%, #f59e0b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: #1a237e;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

.copilot-title-group h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.copilot-status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: #cbd5e1;
  margin-top: 3px;
}

.copilot-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
}

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

.copilot-btn-icon {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.copilot-btn-icon:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.08);
}

/* 快捷問題推薦標籤列 (Suggestions Chips) */
.copilot-suggestions-bar {
  padding: 10px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  overflow-x: auto;
  white-space: nowrap;
  display: flex;
  gap: 8px;
  scrollbar-width: thin;
}

.copilot-suggestions-bar::-webkit-scrollbar {
  height: 4px;
}
.copilot-suggestions-bar::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.copilot-chip {
  background: #ffffff;
  color: #334155;
  border: 1px solid #cbd5e1;
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.copilot-chip:hover {
  background: #0f4c81;
  color: #ffffff;
  border-color: #0f4c81;
  transform: translateY(-1px);
}

/* 訊息區域 (Messages Container) */
.copilot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #f8fafc;
  scroll-behavior: smooth;
}

/* 訊息氣泡通用 */
.copilot-msg-row {
  display: flex;
  gap: 10px;
  max-width: 92%;
  animation: copilotMsgFadeIn 0.28s ease;
}

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

.copilot-msg-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.copilot-msg-row.assistant {
  align-self: flex-start;
}

.copilot-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.6;
  position: relative;
  word-break: break-word;
}

.copilot-msg-row.user .copilot-bubble {
  background: linear-gradient(135deg, #0f4c81 0%, #1e40af 100%);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(15, 76, 129, 0.25);
}

.copilot-msg-row.assistant .copilot-bubble {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}

/* 回答內容排版 */
.copilot-bubble h4 {
  margin: 0 0 8px 0;
  font-size: 0.95rem;
  color: #0f4c81;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px dashed #cbd5e1;
  padding-bottom: 6px;
}

.copilot-bubble p {
  margin: 0 0 8px 0;
}
.copilot-bubble p:last-child {
  margin-bottom: 0;
}

.copilot-bubble ul, .copilot-bubble ol {
  margin: 6px 0 10px 0;
  padding-left: 20px;
}

.copilot-bubble li {
  margin-bottom: 4px;
}

/* 關鍵指標小卡片群 (Metric Badges) */
.copilot-metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 10px 0;
}

.copilot-metric-card {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 10px;
  text-align: center;
}

.copilot-metric-label {
  font-size: 0.72rem;
  color: #64748b;
  font-weight: 600;
  margin-bottom: 2px;
}

.copilot-metric-value {
  font-size: 1.05rem;
  font-weight: 800;
  color: #0f4c81;
}

/* 快捷動作工具列 (Action Bar) */
.copilot-actions-bar {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.copilot-action-btn {
  background: #f1f5f9;
  color: #0f4c81;
  border: 1px solid #cbd5e1;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.copilot-action-btn:hover {
  background: #0f4c81;
  color: #ffffff;
  border-color: #0f4c81;
}

.copilot-action-btn.deeplink {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.copilot-action-btn.deeplink:hover {
  background: #059669;
  color: #ffffff;
  border-color: #059669;
}

/* 打字等待動態 (Typing Indicator) */
.copilot-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
}

.copilot-dot {
  width: 7px;
  height: 7px;
  background: #0f4c81;
  border-radius: 50%;
  animation: copilotDotBounce 1.4s infinite ease-in-out both;
}
.copilot-dot:nth-child(1) { animation-delay: -0.32s; }
.copilot-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes copilotDotBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* 輸入框區域 (Input Area) */
.copilot-input-area {
  padding: 12px 16px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.copilot-input-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 24px;
  padding: 4px 6px 4px 14px;
  transition: all 0.2s ease;
}

.copilot-input-box:focus-within {
  border-color: #0f4c81;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(15, 76, 129, 0.12);
}

.copilot-text-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.88rem;
  color: #1e293b;
  outline: none;
  padding: 6px 0;
}

.copilot-text-input::placeholder {
  color: #94a3b8;
  font-size: 0.85rem;
}

.copilot-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #0f4c81 0%, #1a237e 100%);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

.copilot-send-btn:hover {
  background: #d4af37;
  color: #0f4c81;
  transform: scale(1.06);
}

.copilot-send-btn:disabled {
  background: #cbd5e1;
  color: #94a3b8;
  cursor: not-allowed;
  transform: none;
}

.copilot-footer-hint {
  font-size: 0.7rem;
  color: #64748b;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* 3. 設定彈窗 (Settings Modal) */
.copilot-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
}

.copilot-modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.copilot-modal-card {
  width: 100%;
  max-width: 480px;
  background: #ffffff;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25);
  border: 1px solid #cbd5e1;
  transform: translateY(20px);
  transition: all 0.28s ease;
}

.copilot-modal-backdrop.active .copilot-modal-card {
  transform: translateY(0);
}

.copilot-modal-header {
  background: #0f4c81;
  color: #ffffff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.copilot-modal-body {
  padding: 20px;
}

/* 4. 目標圖表聚焦高亮動態 (Deep Link Highlighting) */
@keyframes copilotTargetGlow {
  0% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.9); border-color: #d4af37; }
  50% { box-shadow: 0 0 25px 8px rgba(212, 175, 55, 0.6); border-color: #d4af37; }
  100% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0); }
}

.copilot-highlight {
  animation: copilotTargetGlow 2.5s ease-out;
  border-radius: 12px;
}

/* 5. 行動裝置 RWD 適配 (Mobile & iPhone / iPad) */
@media (max-width: 640px) {
  .copilot-fab-btn {
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    right: 16px;
    padding: 10px 16px;
    font-size: 0.86rem;
    box-shadow: 0 6px 20px rgba(15, 76, 129, 0.4);
  }
  
  .copilot-panel {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 88vh;
    max-height: calc(100vh - 40px);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -10px 40px rgba(15, 23, 42, 0.35);
  }

  .copilot-input-area {
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }

  .copilot-suggestions-bar {
    padding: 8px 12px;
    gap: 6px;
  }

  .copilot-chip {
    font-size: 0.74rem;
    padding: 4px 10px;
  }

  .copilot-metrics-grid {
    grid-template-columns: 1fr;
  }
}
