/* Shared AI Copilot FAB — HR / e-Office SPA */
.ai-copilot-widget {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9200;
  pointer-events: none;
  font-family: "Segoe UI", system-ui, sans-serif;
}
.ai-copilot-widget > * { pointer-events: auto; }
.ai-copilot-widget.hidden { display: none !important; }
.ai-copilot-fab {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(145deg, #ff781f, #e76f51);
  color: #fff;
  box-shadow: 0 8px 28px rgba(231, 111, 81, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.ai-copilot-fab:hover { transform: scale(1.05); }
.ai-copilot-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 9190;
}
.ai-copilot-backdrop.hidden { display: none !important; }
.ai-copilot-panel {
  position: absolute;
  right: 0;
  bottom: 70px;
  width: min(380px, calc(100vw - 28px));
  height: min(520px, calc(100vh - 110px));
  background: #121824;
  color: #f1f5f9;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ai-copilot-panel.hidden { display: none !important; }
html[data-erp-theme="light"] .ai-copilot-panel {
  background: #fff;
  color: #1a1714;
  border-color: #ddd4c6;
  box-shadow: 0 12px 36px rgba(40,30,10,0.14);
}
.ai-copilot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(90deg, #0f1520, #1a2334);
  gap: 8px;
}
html[data-erp-theme="light"] .ai-copilot-header {
  background: #f7f4ef;
  border-bottom-color: #ddd4c6;
}
.ai-copilot-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.ai-copilot-mode-toggle {
  display: inline-flex;
  padding: 2px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.2);
}
html[data-erp-theme="light"] .ai-copilot-mode-toggle {
  border-color: #ddd4c6;
  background: #fff;
}
.ai-copilot-mode-btn {
  border: none;
  background: transparent;
  color: inherit;
  opacity: 0.65;
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.ai-copilot-mode-btn.is-active {
  opacity: 1;
  background: rgba(255, 120, 31, 0.22);
  color: #ff781f;
}
.ai-copilot-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
  white-space: normal;
  padding: 8px;
  border-radius: 10px;
  border: 1px dashed rgba(56, 189, 248, 0.35);
  background: rgba(14, 165, 233, 0.08);
}
.ai-copilot-steps-label {
  font-size: 11px;
  font-weight: 700;
  color: #38bdf8;
  margin-bottom: 2px;
}
.ai-copilot-mode-banner {
  padding: 8px 12px;
  font-size: 11px;
  line-height: 1.4;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: rgba(255, 120, 31, 0.1);
  color: inherit;
  opacity: 0.95;
}
.ai-copilot-panel.is-agent-mode .ai-copilot-mode-banner {
  background: rgba(14, 165, 233, 0.12);
}
.ai-copilot-panel.is-agent-mode .ai-copilot-mode-btn.is-active {
  background: rgba(14, 165, 233, 0.22);
  color: #38bdf8;
}
.ai-copilot-mode-banner strong { font-weight: 700; }
.ai-copilot-step {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 11px;
  line-height: 1.35;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.18);
}
html[data-erp-theme="light"] .ai-copilot-step {
  border-color: #ddd4c6;
  background: #fff;
}
.ai-copilot-step-icon { flex-shrink: 0; width: 14px; font-weight: 700; }
.ai-copilot-step.is-ok .ai-copilot-step-icon { color: #4ade80; }
.ai-copilot-step.is-error .ai-copilot-step-icon { color: #f87171; }
.ai-copilot-step-name { font-weight: 700; }
.ai-copilot-step-preview {
  margin-top: 2px;
  opacity: 0.8;
  max-height: 3.6em;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-copilot-title { font-weight: 700; font-size: 14px; }
.ai-copilot-sub { font-size: 11px; opacity: 0.7; margin-top: 2px; }
.ai-copilot-close {
  border: 1px solid rgba(255,255,255,0.15);
  background: transparent;
  color: inherit;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.ai-copilot-box {
  flex: 1;
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ai-copilot-msg-user { display: flex; justify-content: flex-end; }
.ai-copilot-msg-ai { display: flex; justify-content: flex-start; }
.ai-copilot-bubble-user {
  max-width: 85%;
  background: #ff781f;
  color: #fff;
  padding: 8px 12px;
  border-radius: 14px 14px 4px 14px;
  font-size: 13px;
  white-space: pre-wrap;
}
.ai-copilot-bubble-ai {
  max-width: 90%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 8px 12px;
  border-radius: 14px 14px 14px 4px;
  font-size: 13px;
  white-space: pre-wrap;
  line-height: 1.45;
}
html[data-erp-theme="light"] .ai-copilot-bubble-ai {
  background: #f7f4ef;
  border-color: #ddd4c6;
}
.ai-copilot-hint { margin-top: 6px; font-size: 11px; opacity: 0.75; }
.ai-copilot-input {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
html[data-erp-theme="light"] .ai-copilot-input { border-top-color: #ddd4c6; }
.ai-copilot-input textarea {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  resize: vertical;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #f1f5f9;
  color: #0f172a;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
}
.ai-copilot-input button {
  min-height: 44px;
  padding: 0 14px;
  border: none;
  border-radius: 10px;
  background: #ff781f;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
@media (max-width: 640px) {
  .ai-copilot-widget { right: 14px; bottom: 14px; }
  .ai-copilot-panel {
    width: calc(100vw - 28px);
    height: min(70vh, 560px);
  }
}
