/* صفحه نمایش زنده معماری AI — سامانه جامع ERP+AI */

:root {
  --bg: #1a1d22;
  --bg-2: #12151a;
  --panel: #242830;
  --panel-2: #2a2f38;
  --border: #4a5160;
  --text: #f2f4f7;
  --muted: #9aa3b2;
  --accent: #7eb6ff;
  --accent-soft: rgba(126, 182, 255, 0.18);
  --active: #3ddc97;
  --active-glow: rgba(61, 220, 151, 0.45);
  --skip: #3a4050;
  --error: #ff6b7a;
  --cost: #ffd166;
  --radius: 12px;
  --font: Tahoma, "Segoe UI", "Iranian Sans", sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, #2a3344 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #1e2a28 0%, transparent 50%),
    var(--bg-2);
  color: var(--text);
  font-family: var(--font);
}

.app {
  max-width: 1600px;
  margin: 0 auto;
  padding: 16px 18px 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #3d7cff, #1f9d7a);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.top-metrics {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.metric {
  min-width: 88px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  text-align: center;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  margin-bottom: 4px;
}

.metric strong {
  font-size: 1rem;
}

.metric--cost strong {
  color: var(--cost);
}

.layout {
  display: grid;
  grid-template-columns: 1.05fr 1.35fr 0.85fr;
  gap: 14px;
  align-items: stretch;
}

.panel {
  background: rgba(36, 40, 48, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(74, 81, 96, 0.6);
}

.panel-head h2 {
  margin: 0;
  font-size: 0.95rem;
}

.chat-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.store-select-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--muted);
}

.store-select-wrap select {
  max-width: 220px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  padding: 5px 8px;
  font-family: inherit;
  font-size: 0.8rem;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.live-badge.is-running {
  background: rgba(61, 220, 151, 0.12);
  color: var(--active);
  border-color: rgba(61, 220, 151, 0.4);
  animation: pulse 1.2s ease-in-out infinite;
}

.live-badge.is-done {
  background: rgba(126, 182, 255, 0.12);
  color: var(--accent);
  border-color: rgba(126, 182, 255, 0.35);
}

.live-badge.is-error {
  background: rgba(255, 107, 122, 0.12);
  color: var(--error);
  border-color: rgba(255, 107, 122, 0.4);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* چت */
.chat-panel {
  min-height: 620px;
}

.messages {
  flex: 1;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 12px;
  line-height: 1.65;
  font-size: 0.92rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg--user {
  align-self: flex-start;
  background: #31405a;
  border: 1px solid #46608a;
}

.msg--ai {
  align-self: flex-end;
  background: #24352f;
  border: 1px solid #2f6b58;
}

.msg--sys {
  align-self: center;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  border: 1px dashed #3d4454;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(74, 81, 96, 0.6);
}

.composer textarea {
  resize: none;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.92rem;
  outline: none;
}

.composer textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-primary,
.btn-ghost {
  border: none;
  cursor: pointer;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.88rem;
}

.btn-primary {
  background: linear-gradient(145deg, #3d7cff, #249d78);
  color: #fff;
  padding: 0 18px;
  min-width: 84px;
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 5px 10px;
}

.btn-ghost:hover {
  color: var(--text);
}

/* معماری */
.arch-panel {
  min-height: 620px;
}

.arch-wrap {
  padding: 8px 8px 0;
  flex: 1;
  min-height: 440px;
  background: #1c1f25;
  overflow: auto;
}

#archSvg {
  width: 100%;
  height: auto;
  display: block;
}

.arch-node rect {
  fill: #2b3038;
  stroke: #8b93a3;
  stroke-width: 1.5;
  rx: 4;
  transition: fill 0.25s ease, stroke 0.25s ease, filter 0.25s ease;
}

.arch-node text {
  fill: #f5f7fa;
  font-family: var(--font);
  font-size: 12px;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

.arch-node.is-active rect {
  fill: #1f4d3a;
  stroke: var(--active);
  filter: drop-shadow(0 0 8px var(--active-glow));
}

.arch-node.is-done rect {
  fill: #243447;
  stroke: var(--accent);
}

.arch-node.is-skip rect {
  fill: #22262e;
  stroke: #3f4654;
  opacity: 0.45;
}

.arch-node.is-skip text {
  fill: #7a8496;
}

.arch-node.is-error rect {
  fill: #4a2228;
  stroke: var(--error);
}

.arch-edge {
  fill: none;
  stroke: #7eb6ff;
  stroke-width: 1.6;
  marker-end: url(#arrowHead);
  opacity: 0.55;
  transition: opacity 0.25s ease, stroke 0.25s ease, stroke-width 0.25s ease;
}

.arch-edge.is-active {
  opacity: 1;
  stroke: var(--active);
  stroke-width: 2.4;
}

.arch-edge.is-done {
  opacity: 0.9;
  stroke: var(--accent);
}

.arch-edge.is-skip {
  opacity: 0.18;
}

.arch-label {
  fill: #9eb6d8;
  font-size: 10px;
  font-family: var(--font);
  text-anchor: middle;
}

.activity {
  border-top: 1px solid rgba(74, 81, 96, 0.6);
  max-height: 160px;
  display: flex;
  flex-direction: column;
}

.activity-title {
  padding: 8px 12px 4px;
  color: var(--muted);
  font-size: 0.75rem;
}

#activityList,
#phaseList {
  list-style: none;
  margin: 0;
  padding: 0 12px 10px;
  overflow: auto;
  flex: 1;
}

#activityList li,
#phaseList li {
  font-size: 0.78rem;
  color: #c9d2e0;
  padding: 4px 0;
  border-bottom: 1px solid rgba(74, 81, 96, 0.35);
}

#activityList li time,
#phaseList li time {
  color: var(--muted);
  margin-left: 6px;
}

/* هزینه */
.cost-panel {
  min-height: 620px;
}

.cost-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px;
}

.cost-card {
  background: var(--panel-2);
  border: 1px solid rgba(74, 81, 96, 0.7);
  border-radius: 10px;
  padding: 10px;
}

.cost-card span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  margin-bottom: 6px;
}

.cost-card strong {
  font-size: 1rem;
}

.cost-card--wide {
  grid-column: 1 / -1;
}

.cost-card--total {
  background: linear-gradient(145deg, #2f3b28, #243447);
  border-color: #4f7a58;
}

.cost-card--total strong {
  color: var(--cost);
  font-size: 1.2rem;
}

.phases {
  border-top: 1px solid rgba(74, 81, 96, 0.6);
  flex: 1;
  min-height: 120px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .arch-panel,
  .chat-panel,
  .cost-panel {
    min-height: auto;
  }
  .arch-wrap {
    min-height: 520px;
  }
}
