/* ==========================================================================
   Nexify Wire Studio CSS
   Full-page real-time developer studio matching ArgusKit Builder standards
   ========================================================================== */

#nexify-studio {
  font-family: var(--ak-font, 'Outfit', 'Inter', -apple-system, sans-serif);
  background: var(--ak-bg, #090d16);
  color: var(--ak-text, #f1f5f9);
  min-height: 100vh;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

#nexify-studio *,
#nexify-studio *::before,
#nexify-studio *::after {
  box-sizing: border-box;
}

/* Ambient glow backgrounds */
#nexify-studio::before {
  content: '';
  position: fixed;
  top: -15%;
  left: 20%;
  width: 50vw;
  height: 40vh;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.09) 0%, transparent 70%);
  filter: blur(85px);
  pointer-events: none;
  z-index: 0;
}

#nexify-studio::after {
  content: '';
  position: fixed;
  bottom: -10%;
  right: 15%;
  width: 45vw;
  height: 40vh;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.08) 0%, transparent 70%);
  filter: blur(95px);
  pointer-events: none;
  z-index: 0;
}

/* Topbar custom logo & pills */
.nw-logo-icon {
  background: linear-gradient(135deg, #06b6d4 0%, #6366f1 50%, #8b5cf6 100%) !important;
  box-shadow: 0 4px 16px rgba(6, 182, 212, 0.35) !important;
}

.nw-badge-live {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.nw-url-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-family: var(--ak-font-mono, 'Fira Code', monospace);
  font-size: 0.78rem;
  color: #94a3b8;
}

/* Sidebar Custom Styling */
.nw-sidebar-section {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--ak-card-border, rgba(255, 255, 255, 0.08));
}

.nw-sidebar-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ak-text-dim, #64748b);
  margin-bottom: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nw-channel-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nw-channel-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.55rem 0.75rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--ak-text-muted, #94a3b8);
  font-family: var(--ak-font, inherit);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.nw-channel-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.06);
}

.nw-channel-btn.active {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.35);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
}

.nw-channel-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nw-channel-hash {
  color: var(--ak-primary-light, #818cf8);
  font-weight: 700;
}

.nw-channel-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  font-family: var(--ak-font-mono, monospace);
}

.nw-channel-btn.active .nw-channel-badge {
  background: rgba(99, 102, 241, 0.3);
  color: #c7d2fe;
}

/* User & Connection Bar in Sidebar */
.nw-handle-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.nw-handle-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--ak-card-border, rgba(255, 255, 255, 0.1));
  border-radius: 6px;
  padding: 0.4rem 0.65rem;
  color: #fff;
  font-size: 0.82rem;
  font-family: var(--ak-font-mono, monospace);
  outline: none;
  transition: border-color 0.2s;
}

.nw-handle-input:focus {
  border-color: var(--ak-primary, #6366f1);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* Quick Payloads Grid */
.nw-presets-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.nw-preset-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.6rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 6px;
  color: var(--ak-text, #f1f5f9);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.nw-preset-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(99, 102, 241, 0.3);
  color: #fff;
  transform: translateY(-1px);
}

/* Diagnostics Mini Card */
.nw-diag-card {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--ak-card-border, rgba(255, 255, 255, 0.06));
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-family: var(--ak-font-mono, monospace);
  font-size: 0.75rem;
}

.nw-diag-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nw-diag-label {
  color: var(--ak-text-dim, #64748b);
}

.nw-diag-val {
  color: #a5f3fc;
  font-weight: 600;
}

/* Main Studio Layout */
.nw-main-header {
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--ak-card-border, rgba(255, 255, 255, 0.08));
  background: rgba(15, 21, 36, 0.4);
}

.nw-room-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nw-room-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.nw-room-desc {
  font-size: 0.82rem;
  color: var(--ak-text-dim, #64748b);
  margin: 0;
}

/* Chat Feed Pane */
.nw-chat-workspace {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 175px);
  position: relative;
}

.nw-chat-feed {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  scroll-behavior: smooth;
}

.nw-system-line {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0.5rem 0;
}

.nw-system-line span {
  font-size: 0.78rem;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  backdrop-filter: blur(8px);
}

/* Message Rows */
.nw-message-row {
  display: flex;
  gap: 0.75rem;
  max-width: 82%;
  animation: nw-slide-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes nw-slide-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.nw-message-row.outgoing {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.nw-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.nw-message-row.outgoing .nw-avatar {
  background: linear-gradient(135deg, #ef4444, #f43f5e);
}

.nw-message-row.bot .nw-avatar {
  background: linear-gradient(135deg, #10b981, #06b6d4);
}

.nw-bubble-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nw-message-row.outgoing .nw-bubble-wrap {
  align-items: flex-end;
}

.nw-author-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.76rem;
  color: var(--ak-text-dim, #64748b);
}

.nw-author-name {
  font-weight: 600;
  color: #e2e8f0;
}

.nw-bubble {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 0.7rem 0.95rem;
  color: #f1f5f9;
  font-size: 0.88rem;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.nw-message-row.outgoing .nw-bubble {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(79, 70, 229, 0.35));
  border-color: rgba(99, 102, 241, 0.4);
  color: #fff;
  border-top-right-radius: 2px;
}

.nw-message-row.incoming .nw-bubble {
  border-top-left-radius: 2px;
}

.nw-message-row.fragment .nw-bubble {
  border-left: 3px solid #06b6d4;
  background: rgba(6, 182, 212, 0.08);
}

/* Chat Input Bar */
.nw-input-container {
  padding: 0.85rem 1.5rem;
  background: rgba(9, 13, 22, 0.85);
  border-top: 1px solid var(--ak-card-border, rgba(255, 255, 255, 0.08));
  backdrop-filter: blur(15px);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.nw-chips-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  overflow-x: auto;
}

.nw-chip-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--ak-text-dim, #64748b);
  margin-right: 0.25rem;
  white-space: nowrap;
}

.nw-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.76rem;
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.nw-chip:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.35);
  color: #fff;
}

.nw-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.nw-input-field {
  flex: 1;
  background: rgba(15, 21, 36, 0.9);
  border: 1px solid var(--ak-card-border, rgba(255, 255, 255, 0.1));
  border-radius: 10px;
  padding: 0.65rem 1rem;
  color: #fff;
  font-size: 0.9rem;
  outline: none;
  transition: all 0.2s ease;
}

.nw-input-field:focus {
  border-color: var(--ak-primary, #6366f1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
  background: rgba(15, 21, 36, 1);
}

/* Fragment Sandbox Tab */
.nw-sandbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  padding: 1.5rem;
}

@media (max-width: 1024px) {
  .nw-sandbox-grid {
    grid-template-columns: 1fr;
  }
}

.nw-sandbox-card {
  background: var(--ak-card-bg, rgba(17, 24, 39, 0.7));
  border: 1px solid var(--ak-card-border, rgba(255, 255, 255, 0.08));
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.nw-target-box {
  min-height: 160px;
  background: rgba(0, 0, 0, 0.3);
  border: 2px dashed rgba(6, 182, 212, 0.35);
  border-radius: 10px;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  position: relative;
}

.nw-target-box.pulse-update {
  border-color: #06b6d4;
  box-shadow: 0 0 25px rgba(6, 182, 212, 0.45);
  animation: nw-target-flash 0.6s ease;
}

@keyframes nw-target-flash {
  0% { transform: scale(0.98); background: rgba(6, 182, 212, 0.2); }
  50% { transform: scale(1.01); background: rgba(6, 182, 212, 0.1); }
  100% { transform: scale(1); background: rgba(0, 0, 0, 0.3); }
}

/* Telemetry Console Tab */
.nw-telemetry-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 175px);
  padding: 1rem 1.5rem;
  gap: 0.85rem;
}

.nw-telemetry-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.nw-filter-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.nw-filter-btn {
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ak-text-muted, #94a3b8);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nw-filter-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nw-filter-btn.active {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.4);
  color: #fff;
}

.nw-telemetry-table-wrap {
  flex: 1;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--ak-card-border, rgba(255, 255, 255, 0.08));
  border-radius: 10px;
}

.nw-telemetry-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--ak-font-mono, 'Fira Code', monospace);
  font-size: 0.78rem;
}

.nw-telemetry-table th {
  position: sticky;
  top: 0;
  background: rgba(15, 21, 36, 0.95);
  backdrop-filter: blur(10px);
  text-align: left;
  padding: 0.6rem 0.9rem;
  color: var(--ak-text-dim, #64748b);
  border-bottom: 1px solid var(--ak-card-border, rgba(255, 255, 255, 0.08));
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}

.nw-telemetry-table td {
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
}

.nw-telemetry-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.nw-dir-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
}

.nw-dir-in {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.nw-dir-out {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.nw-dir-rest {
  background: rgba(6, 182, 212, 0.15);
  color: #67e8f9;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

/* REST Publish Bridge Tab */
.nw-rest-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  padding: 1.5rem;
}

@media (max-width: 1024px) {
  .nw-rest-grid {
    grid-template-columns: 1fr;
  }
}

.nw-code-block {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--ak-card-border, rgba(255, 255, 255, 0.08));
  border-radius: 8px;
  padding: 1rem;
  font-family: var(--ak-font-mono, monospace);
  font-size: 0.8rem;
  color: #e2e8f0;
  overflow-x: auto;
  line-height: 1.5;
}
