/* ===========================================================
   Ned temp admin shell — dark industrial theme
   Navy #0D1B2A background, electric blue #1E90FF accents.
   Touch friendly: interactive targets >= 48px.
   =========================================================== */

:root {
  --bg:        #0D1B2A;
  --bg-raised: #122438;
  --bg-input:  #0a1622;
  --accent:    #1E90FF;
  --accent-dim:#1668b8;
  --text:      #e6eef6;
  --text-dim:  #8da2b8;
  --border:    #1d3349;
  --user-bub:  #1E90FF;
  --ned-bub:   #16293d;
  --danger:    #ff5b5b;
  --ok:        #3ddc84;
  --tap: 48px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

.shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  gap: 8px;
  padding: 8px;
}

/* ---------- Chat panel (TOP) ---------- */
.chat-panel {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #14283d, #0f2032);
}

.chat-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.2px;
  flex: 1 1 auto;
}

.status-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--text-dim);
  box-shadow: 0 0 0 0 rgba(30,144,255,0.5);
}
.status-dot[data-state="booting"] { background: #d9a441; animation: pulse 1.2s infinite; }
.status-dot[data-state="ready"]   { background: var(--ok); }
.status-dot[data-state="error"]   { background: var(--danger); }
.status-dot[data-state="thinking"]{ background: var(--accent); animation: pulse 1s infinite; }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(30,144,255,0.5); }
  70%  { box-shadow: 0 0 0 8px rgba(30,144,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(30,144,255,0); }
}

.spin-badge {
  font-size: 0.72rem;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  white-space: nowrap;
}

.chat-history {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.msg.user {
  align-self: flex-end;
  background: var(--user-bub);
  color: #04121f;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}
.msg.ned {
  align-self: flex-start;
  background: var(--ned-bub);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg.system {
  align-self: center;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.8rem;
  text-align: center;
  max-width: 90%;
}
.msg .msg-img {
  max-width: 220px;
  max-height: 220px;
  border-radius: 8px;
  display: block;
  margin-top: 6px;
}
.msg.thinking { opacity: 0.7; font-style: italic; }

/* ---------- Attachment preview strip ---------- */
.attach-strip {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  overflow-x: auto;
}
.attach-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 0.78rem;
  white-space: nowrap;
}
.attach-chip img {
  width: 34px; height: 34px; object-fit: cover; border-radius: 4px;
}
.attach-chip button {
  background: none; border: none; color: var(--danger);
  cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 2px;
}

/* ---------- Input bar ---------- */
.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-input);
}

.chat-input {
  flex: 1 1 auto;
  min-height: var(--tap);
  max-height: 160px;
  resize: none;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  line-height: 1.4;
}
.chat-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(30,144,255,0.25);
}
.chat-input:disabled {
  color: var(--text-dim);
  cursor: not-allowed;
}

.icon-btn {
  flex: 0 0 auto;
  width: var(--tap);
  height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.icon-btn:active:not(:disabled) { transform: translateY(1px); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn.small { width: 40px; height: 40px; }

.send-btn { background: var(--accent); color: #04121f; border-color: var(--accent); }
.send-btn:hover:not(:disabled) { background: #3aa0ff; color: #04121f; }
.send-btn:disabled { background: var(--accent-dim); }

.icon-btn.recording {
  color: var(--danger);
  border-color: var(--danger);
  animation: pulse 1s infinite;
}

/* ---------- Staging panel (BOTTOM) ---------- */
.staging-panel {
  flex: 0 0 32vh;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.staging-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-dim);
}
.staging-url {
  flex: 1 1 auto;
  height: 40px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0 10px;
  font: inherit;
  font-size: 0.82rem;
}
.staging-url:focus { outline: none; border-color: var(--accent); }
.staging-frame {
  flex: 1 1 auto;
  width: 100%;
  border: 0;
  background: #fff;
}

/* ---------- Drag/drop overlay ---------- */
.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13,27,42,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.drop-inner {
  border: 2px dashed var(--accent);
  border-radius: 16px;
  padding: 40px 60px;
  font-size: 1.2rem;
  color: var(--accent);
}

/* ---------- Scrollbar ---------- */
.chat-history::-webkit-scrollbar { width: 8px; }
.chat-history::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

@media (min-width: 900px) {
  .shell { flex-direction: row; }
  .chat-panel { flex: 2 1 0; }
  .staging-panel { flex: 1 1 0; height: auto; }
}
