/**
 * Elinom Copilot — command-centre workspace + nav + Live Chat separation.
 * Unique filename: nginx caches /css/ immutable.
 */

html body.erp-body #navbar #navMenu > li.copilot-li > a,
html body.erp-body #navbar #navMenu > li.copilot-li > a * {
  color: #c4b5fd !important;
  -webkit-text-fill-color: #c4b5fd !important;
}

@media (min-width: 1280px) {
  html[data-active-module="landing"] body.erp-body #navbar #navMenu > li.copilot-li {
    order: 9 !important;
    flex: 0 0 auto !important;
  }
}

@media (min-width: 1280px) and (max-width: 1399px) {
  html[data-active-module="landing"] body.erp-body #navbar #navMenu > li.nav-end-link:not(.connect-li):not(.copilot-li):not(.help-li) {
    display: none !important;
  }

  html[data-active-module="landing"] body.erp-body #navbar #navMenu > li.copilot-li,
  html[data-active-module="landing"] body.erp-body #navbar #navMenu > li.help-li {
    display: flex !important;
  }
}

/* Business Copilot no longer uses the bottom-right FAB. Live Chat keeps that corner. */
html.elin-ai-nav-entry #elin-ai-fab,
html.elin-ai-nav-entry #elin-ai-greet,
html.elin-ai-nav-entry #elin-ai-panel,
html[data-active-module="copilot"] #elin-ai-fab,
html[data-active-module="copilot"] #elin-ai-greet,
html[data-active-module="copilot"] #elin-ai-panel,
html[data-active-module="landing"] #elin-ai-fab,
html[data-active-module="landing"] #elin-ai-greet,
html[data-active-module="landing"] #elin-ai-panel {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

html.elin-ai-nav-entry #chatWidget,
html[data-active-module="landing"] #chatWidget,
html[data-active-module="copilot"] #chatWidget,
html:has(#elinom-copilot-workspace) #chatWidget {
  display: block !important;
  visibility: visible !important;
  pointer-events: auto !important;
  bottom: max(var(--erp-corner-orb-inset, 28px), env(safe-area-inset-bottom, 0px)) !important;
  right: max(var(--erp-corner-orb-inset, 28px), env(safe-area-inset-right, 0px)) !important;
}

#copilot.module-section {
  background-color: #070d1a;
  background-image:
    radial-gradient(ellipse 55% 45% at 92% 0%, rgba(99, 102, 241, 0.16), transparent 52%),
    radial-gradient(circle at 8% 80%, rgba(34, 211, 238, 0.06), transparent 42%),
    linear-gradient(180deg, #0b1426 0%, #070d1a 55%, #050a14 100%);
  color: #e8eef7;
}

.eco-shell {
  position: relative;
  display: grid;
  grid-template-columns: 15.5rem minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  align-content: stretch;
  width: 100%;
  max-width: 88rem;
  height: 100%;
  min-height: 0;
  margin: 0 auto;
  padding: 0.85rem 1.25rem 0.85rem;
  gap: 1.25rem;
  box-sizing: border-box;
}

.eco-rail {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-self: start;
  gap: 0.35rem;
  width: 100%;
  height: auto;
  min-height: max-content;
  padding: 1rem 0.75rem;
  border-radius: 1rem;
  overflow: visible;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-sizing: border-box;
}

.eco-brand {
  padding: 0.35rem 0.65rem 0.85rem;
}

.eco-brand h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.eco-brand p {
  margin: 0.2rem 0 0;
  color: #94a3b8;
  font-size: 0.78rem;
}

.eco-rail button {
  appearance: none;
  border: 0;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  padding: 0.62rem 0.75rem;
  border-radius: 0.7rem;
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
}

.eco-rail button[aria-current="page"] {
  background: rgba(99, 102, 241, 0.22);
  color: #fff;
}

.eco-main {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.eco-panel {
  display: none;
}

.eco-panel.is-active {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}

.eco-panel.is-active:not([data-eco-panel="home"]) {
  overflow: auto;
}

.eco-hero {
  padding: 1.4rem 1.5rem 1.2rem;
  border-radius: 1.15rem;
  background:
    radial-gradient(circle at 12% 0%, rgb(99 102 241 / 22%), transparent 42%),
    linear-gradient(180deg, #111827 0%, #0b1220 100%);
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.eco-hero h2 {
  margin: 0;
  font-size: 1.7rem;
  letter-spacing: -0.03em;
}

.eco-hero .eco-kicker {
  margin: 0.35rem 0 1rem;
  color: #a5b4fc;
  font-size: 0.92rem;
}

.eco-command {
  display: block;
}

.eco-command-field {
  position: relative;
  min-width: 0;
}

.eco-command textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 3.25rem;
  max-height: 10rem;
  resize: none;
  overflow-y: auto;
  border-radius: 0.85rem;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(2, 6, 23, 0.55);
  color: #f8fafc;
  padding: 0.85rem 3.6rem 0.85rem 1rem;
  font: inherit;
  font-size: 1rem;
  box-sizing: border-box;
}

#elinom-copilot-workspace .eco-command .eco-send {
  position: absolute;
  right: 0.45rem;
  bottom: 0.45rem;
  width: 2.75rem;
  height: 2.75rem;
  min-width: 2.75rem;
  max-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: linear-gradient(120deg, #38bdf8, #6366f1 55%, #a855f7);
  color: #fff;
  cursor: pointer;
}

.eco-send-icon {
  width: 1.15rem;
  height: 1.15rem;
  display: block;
}

.eco-send-icon--busy {
  display: none;
  width: 1.45rem;
  height: 1.45rem;
  place-items: center;
}

#elinom-copilot-workspace .eco-command.is-busy .eco-send {
  background: #0b1220;
}

.eco-command.is-busy .eco-send-icon--arrow {
  display: none;
}

.eco-command.is-busy .eco-send-icon--busy {
  display: grid;
}

.eco-send-ring {
  grid-area: 1 / 1;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #38bdf8, #6366f1 40%, #a855f7 68%, transparent 78%);
  animation: eco-send-spin 0.85s linear infinite;
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
}

.eco-send-square {
  grid-area: 1 / 1;
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 2px;
  background: #fff;
  justify-self: center;
  align-self: center;
}

.eco-btn {
  border: 0;
  border-radius: 0.85rem;
  background: linear-gradient(120deg, #38bdf8, #6366f1 55%, #a855f7);
  color: #fff;
  font: inherit;
  font-weight: 700;
  padding: 0 1.15rem;
  cursor: pointer;
}

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

@media (prefers-reduced-motion: reduce) {
  .eco-send-ring {
    animation: none;
  }
}

.eco-hint {
  margin: 0.75rem 0 0;
  color: #94a3b8;
  font-size: 0.82rem;
}

.eco-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 1rem;
}

.eco-chips button {
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.7);
  color: #e2e8f0;
  border-radius: 999px;
  padding: 0.38rem 0.75rem;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

.eco-chat {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}

.eco-thread {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.35rem 0.2rem 1rem;
}

.eco-thread .eco-hero {
  margin: auto;
  width: min(46rem, 100%);
}

.eco-composer {
  flex: 0 0 auto;
  width: min(46rem, 100%);
  margin: 0 auto;
  padding: 0.35rem 0 0.85rem;
  background: linear-gradient(180deg, rgba(7, 13, 26, 0), #070d1a 22%);
}

.eco-msg {
  padding: 0.15rem 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  white-space: pre-wrap;
  line-height: 1.55;
  max-width: 46rem;
}

.eco-msg--assistant {
  align-self: stretch;
}

.eco-msg--user {
  align-self: flex-end;
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  max-width: min(40rem, 88%);
  padding: 0.75rem 0.95rem;
  border-radius: 1.1rem;
  background: rgba(99, 102, 241, 0.22);
  border: 1px solid rgba(165, 180, 252, 0.18);
}

.eco-msg-body {
  min-width: 0;
  flex: 1 1 auto;
}

.eco-msg-text {
  white-space: pre-wrap;
}

.eco-msg-edit {
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #c7d2fe;
  cursor: pointer;
}

.eco-msg-edit:hover {
  background: rgba(15, 23, 42, 0.45);
  color: #fff;
}

.eco-msg-editor textarea {
  display: block;
  width: 100%;
  min-height: 4.2rem;
  resize: vertical;
  border-radius: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(2, 6, 23, 0.72);
  color: #f8fafc;
  padding: 0.7rem 0.8rem;
  font: inherit;
  box-sizing: border-box;
}

.eco-msg-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-top: 0.45rem;
}

.eco-msg-cancel,
.eco-msg-save {
  border: 0;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.eco-msg-cancel {
  background: transparent;
  color: #cbd5e1;
}

.eco-msg-save {
  background: linear-gradient(120deg, #38bdf8, #6366f1 55%, #a855f7);
  color: #fff;
}

.eco-msg.is-editing .eco-msg-text,
.eco-msg.is-editing .eco-msg-edit {
  display: none;
}

.eco-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 0.85rem;
}

.eco-card {
  padding: 1rem 1.05rem;
  border-radius: 0.95rem;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.14);
}

.eco-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.eco-meta {
  color: #94a3b8;
  font-size: 0.78rem;
}

.eco-status {
  display: inline-flex;
  margin-top: 0.45rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(52, 211, 153, 0.14);
  color: #6ee7b7;
}

.eco-status.is-pending,
.eco-status.is-approval {
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
}

.eco-status.is-disabled {
  background: rgba(148, 163, 184, 0.14);
  color: #cbd5e1;
}

.eco-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.eco-btn-ghost {
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(15, 23, 42, 0.7);
  color: #e2e8f0;
  border-radius: 0.7rem;
  padding: 0.4rem 0.8rem;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.eco-empty {
  color: #94a3b8;
  padding: 1.2rem 0;
}

.eco-approval-note {
  margin: 0 0 0.85rem;
  padding: 0.7rem 0.9rem;
  border-radius: 0.8rem;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.28);
  color: #e2e8f0;
  font-size: 0.92rem;
}

.eco-history {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(5, 10, 20, 0.72);
  box-sizing: border-box;
}

.eco-history[hidden] {
  display: none !important;
}

.eco-history-card {
  display: flex;
  flex-direction: column;
  width: min(28rem, 100%);
  max-height: min(32rem, 100%);
  padding: 1rem;
  border-radius: 1rem;
  background: #0b1220;
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: 0 1.25rem 3rem rgba(2, 6, 23, 0.45);
  box-sizing: border-box;
}

.eco-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.eco-history-head h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.eco-history-list {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.eco-history-item {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 0.75rem;
  background: rgba(15, 23, 42, 0.7);
  color: #e8eef7;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.eco-history-item[aria-current="true"] {
  border-color: rgba(99, 102, 241, 0.7);
  background: rgba(99, 102, 241, 0.22);
}

.eco-history-title {
  font-size: 0.9rem;
  line-height: 1.35;
}

.eco-history-when {
  color: #94a3b8;
  font-size: 0.75rem;
}

#elinom-copilot-workspace .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 900px) {
  .eco-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    padding: 0.65rem 0.85rem 0.5rem;
  }

  .eco-rail {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    height: auto;
    min-height: max-content;
    gap: 0.4rem;
    padding: 0.5rem;
  }

  .eco-brand {
    display: none;
  }

  .eco-rail button {
    flex: 0 0 auto;
    min-height: 2.75rem;
    text-align: center;
    white-space: nowrap;
  }

  #elinom-copilot-workspace .eco-command .eco-send {
    width: 2.75rem;
    min-width: 2.75rem;
    max-width: 2.75rem;
    min-height: 2.75rem;
  }

  .eco-btn {
    min-height: 2.75rem;
  }

  .eco-hero {
    padding: 1.1rem 1rem;
  }

  .eco-hero h2 {
    font-size: 1.35rem;
  }

  .eco-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* The ERP shell paints every live module light grey and clips overflow so
   iframes can scroll. Copilot is native, so it keeps the header navy and
   scrolls inside its own section. */
html[data-active-module="copilot"] body.erp-body .erp-container > .main-content,
html[data-active-module="copilot"] body.erp-body .erp-content-scroll,
html[data-active-module="copilot"] body.erp-body #copilot.module-section,
html[data-active-module="copilot"] body.erp-body #copilot.module-section.active {
  background-color: #070d1a !important;
  background-image:
    radial-gradient(ellipse 55% 45% at 92% 0%, rgba(99, 102, 241, 0.16), transparent 52%),
    radial-gradient(circle at 8% 80%, rgba(34, 211, 238, 0.06), transparent 42%),
    linear-gradient(180deg, #0b1426 0%, #070d1a 55%, #050a14 100%) !important;
  color: #e8eef7 !important;
}

html[data-active-module="copilot"] body.erp-body #copilot.module-section,
html[data-active-module="copilot"] body.erp-body #copilot.module-section.active {
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  min-height: 0 !important;
  height: 100% !important;
}

html[data-active-module="copilot"] #elinom-copilot-workspace {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}

#elinom-copilot-workspace,
#copilot.module-section {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.45) #070d1a;
}

#elinom-copilot-workspace * {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.45) #070d1a;
}

#elinom-copilot-workspace *::-webkit-scrollbar,
#copilot.module-section::-webkit-scrollbar {
  width: 10px;
  height: 10px;
  background: #070d1a;
}

#elinom-copilot-workspace *::-webkit-scrollbar-track,
#copilot.module-section::-webkit-scrollbar-track {
  background: #070d1a;
}

#elinom-copilot-workspace *::-webkit-scrollbar-thumb,
#copilot.module-section::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.45);
  border: 2px solid #070d1a;
  border-radius: 999px;
}

html[data-active-module="copilot"] #elinom-copilot-workspace,
html[data-active-module="copilot"] #elinom-copilot-workspace * {
  box-sizing: border-box;
}

html[data-active-module="copilot"] #elinom-copilot-workspace img,
html[data-active-module="copilot"] #elinom-copilot-workspace textarea,
html[data-active-module="copilot"] #elinom-copilot-workspace button {
  max-width: 100%;
}
