/* Zedly Setup Dashboard */

.setup-container {
  display: flex;
  min-height: calc(100vh - 140px);
  max-width: 1400px;
  margin: 0 auto;
  padding: 30px 20px;
  gap: 40px;
}

/* ── Sidebar ── */

.setup-sidebar {
  width: 240px;
  flex-shrink: 0;
}

.setup-sidebar h2 {
  font-size: 1.4rem;
  color: #0b0f19;
  margin-bottom: 20px;
  padding-left: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.setup-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.setup-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  color: #555;
  text-decoration: none;
  font-size: 0.95rem;
  transition: all 0.15s;
}

.setup-nav-item:hover {
  background: #f5f0ff;
  color: #5b21b6;
}

.setup-nav-item.active {
  background: #7c3aed;
  color: #fff;
}

.setup-nav-item.active svg { stroke: #fff; }
.setup-nav-item svg { stroke: #666; }

.setup-session-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.setup-session-list .setup-nav-item {
  font-size: 0.88rem;
  padding: 8px 12px;
}

.setup-sidebar .back-link {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 30px;
  padding: 12px;
  color: #666;
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s;
}

.setup-sidebar .back-link:hover { color: #7c3aed; }

/* ── Content area ── */

.setup-content {
  flex: 1;
  min-width: 0;
}

.setup-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.setup-header h1 {
  font-size: 1.6rem;
  color: #0b0f19;
  margin: 0 0 4px;
}

.setup-header p {
  color: #666;
  margin: 0;
  font-size: 0.95rem;
}

.header-actions {
  display: flex;
  gap: 8px;
}

/* ── Stats cards ── */

.setup-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.setup-stat-card {
  background: #fff;
  border: 1px solid #e8eaed;
  border-radius: 10px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setup-stat-label {
  font-size: 0.82rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.setup-stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: #0b0f19;
}

.setup-stat-connected { color: #059669; }
.setup-stat-pending { color: #d69e2e; }
.setup-stat-ended { color: #888; }

/* ── Sections ── */

.setup-section {
  background: #fff;
  border: 1px solid #e8eaed;
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 20px;
}

.setup-section h3 {
  font-size: 1.1rem;
  color: #0b0f19;
  margin: 0 0 16px;
}

/* ── Tables ── */

.setup-table-wrap {
  overflow-x: auto;
}

.setup-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.setup-table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid #e8eaed;
  color: #888;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.setup-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f2f5;
  color: #333;
  vertical-align: middle;
}

.setup-table tbody tr:hover { background: #faf9ff; }

.setup-table .empty-state {
  text-align: center;
  color: #aaa;
  padding: 40px 12px;
}

.setup-table a {
  color: #7c3aed;
  text-decoration: none;
}

.setup-table a:hover { text-decoration: underline; }

/* Status badges */
.setup-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 600;
}

.setup-badge-connected { background: #ecfdf5; color: #059669; }
.setup-badge-configuring { background: #eff6ff; color: #2563eb; }
.setup-badge-pending { background: #fffbeb; color: #d97706; }
.setup-badge-completed { background: #f3f4f6; color: #4b5563; }
.setup-badge-disconnected { background: #fef2f2; color: #dc2626; }

/* ── Connection indicator ── */

.connection-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}

.connection-dot.alive {
  background: #059669;
  box-shadow: 0 0 6px rgba(5, 150, 105, 0.5);
  animation: pulse-dot 2s ease infinite;
}

.connection-dot.dead {
  background: #dc2626;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Inline rename ── */

.label-cell .label-display {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-rename {
  background: none;
  border: none;
  padding: 2px;
  cursor: pointer;
  color: #94a3b8;
  border-radius: 4px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

tr:hover .btn-rename { opacity: 1; }
.btn-rename:hover { color: #6366f1; }

.rename-input {
  width: 100%;
  padding: 4px 8px;
  font-size: 0.85rem;
  border: 1.5px solid #6366f1;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.06);
  outline: none;
  color: inherit;
  font-family: inherit;
}

/* ── Chat area ── */

.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 220px);
  min-height: 450px;
  border: 1px solid #e8eaed;
  border-radius: 10px;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fafbfc;
}

.chat-msg {
  max-width: 80%;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-break: break-word;
}

.chat-msg.user {
  align-self: flex-end;
  background: #7c3aed;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg.agent {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e8eaed;
  color: #333;
  border-bottom-left-radius: 4px;
}

.chat-msg.system {
  align-self: center;
  background: #fffbeb;
  border: 1px solid #f59e0b;
  color: #92400e;
  font-size: 0.85rem;
  border-radius: 8px;
}

.chat-msg.agent.pending {
  opacity: 0.5;
  font-style: italic;
}

.chat-msg pre {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 10px 14px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.82rem;
  margin: 0;
}

.chat-msg .code-block-wrap {
  position: relative;
  margin: 8px 0 0;
}

.chat-msg .copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(255,255,255,0.12);
  color: #cdd6f4;
  border: none;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.7rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.chat-msg .code-block-wrap:hover .copy-btn {
  opacity: 1;
}

.chat-msg .copy-btn:hover {
  background: rgba(255,255,255,0.25);
}

.chat-msg code {
  background: rgba(0,0,0,0.06);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.85em;
}

.chat-msg.agent code {
  background: rgba(0,0,0,0.06);
}

.chat-msg.user code {
  background: rgba(255,255,255,0.15);
}

.chat-timestamp {
  font-size: 0.72rem;
  color: #aaa;
  margin-top: 4px;
}

.instant-table {
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 0.85rem;
}

.instant-table td {
  padding: 3px 12px 3px 0;
  border-bottom: 1px solid #eee;
  color: #444;
}

.instant-table tr:last-child td {
  border-bottom: none;
}

.instant-step {
  margin: 2px 0;
  padding-left: 4px;
}

.prereq-list {
  margin: 0 0 12px;
  padding-left: 22px;
  line-height: 1.8;
}

.prereq-list li {
  margin-bottom: 4px;
}

.prereq-link {
  color: #7c3aed;
  font-size: 0.82em;
  font-weight: 600;
  text-decoration: none;
  margin-left: 4px;
}

.prereq-link:hover {
  text-decoration: underline;
}

.prereq-info {
  position: relative;
  cursor: pointer;
  color: #7c3aed;
  font-size: 0.95em;
  margin-left: 3px;
  font-weight: 600;
}

.prereq-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  padding: 10px 13px;
  background: #1e1b2e;
  color: #eee;
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.5;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  z-index: 100;
  pointer-events: none;
}

.prereq-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1e1b2e;
}

.prereq-info:hover .prereq-tooltip,
.prereq-info:focus .prereq-tooltip {
  display: block;
}

.thinking-strip {
  overflow: hidden;
  max-height: 0;
  padding: 0 16px;
  font-size: 0.8rem;
  font-style: italic;
  color: #888;
  background: #fafbfc;
  border-bottom: 1px solid #e8eaed;
  transition: max-height 0.25s ease, padding 0.25s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.thinking-strip.active {
  max-height: 36px;
  padding: 6px 16px;
}

.thinking-strip::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7c3aed;
  animation: pulse-dot 1.2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid #e8eaed;
  background: #fff;
  flex-shrink: 0;
}

.chat-input-bar input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

.chat-input-bar input:focus {
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.chat-input-bar button {
  padding: 10px 20px;
  background: #7c3aed;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.chat-input-bar button:hover { background: #6d28d9; }
.chat-input-bar button:disabled { background: #c4b5fd; cursor: not-allowed; }

/* ── Chat resize handle ── */

.chat-resize-handle {
  height: 10px;
  flex-shrink: 0;
  cursor: ns-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f2f5;
  border-top: 1px solid #e8eaed;
  transition: background 0.15s;
  user-select: none;
}

.chat-resize-handle:hover,
.chat-resize-handle.dragging {
  background: #e0dfe6;
}

.chat-resize-handle span {
  width: 36px;
  height: 3px;
  border-radius: 2px;
  background: #bbb;
  transition: background 0.15s;
}

.chat-resize-handle:hover span,
.chat-resize-handle.dragging span {
  background: #888;
}

/* ── Task checklist ── */

.task-checklist {
  list-style: none;
  padding: 0;
  margin: 0;
}

.task-checklist li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #f0f2f5;
  font-size: 0.9rem;
  color: #333;
}

.task-checklist li:last-child { border-bottom: none; }

.task-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #ddd;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.task-check.done {
  border-color: #059669;
  background: #059669;
  color: #fff;
}

/* ── Curl block ── */

.curl-block {
  background: #1e1e2e;
  border-radius: 8px;
  padding: 16px 20px;
  color: #cdd6f4;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
  position: relative;
  overflow-x: auto;
  margin: 12px 0;
}

.curl-block .btn-copy-curl {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  background: rgba(255,255,255,0.1);
  color: #cdd6f4;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.15s;
}

.curl-block .btn-copy-curl:hover { background: rgba(255,255,255,0.2); }

/* ── Buttons ── */

.btn-primary-setup {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: #7c3aed;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary-setup:hover { background: #6d28d9; }

.btn-secondary-setup {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #fff;
  color: #7c3aed;
  border: 1px solid #7c3aed;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary-setup:hover {
  background: #f5f0ff;
}

.btn-sm { padding: 6px 12px; font-size: 0.82rem; }

.btn-danger {
  padding: 6px 12px;
  font-size: 0.82rem;
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-danger:hover { background: #fee2e2; }

/* ── Modal ── */

.setup-modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.setup-modal-overlay.visible { display: flex; }

.setup-modal-box {
  background: #fff;
  border-radius: 14px;
  padding: 32px;
  max-width: 560px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.setup-modal-box h3 {
  margin: 0 0 8px;
  font-size: 1.2rem;
  color: #0b0f19;
}

.setup-modal-box p {
  color: #666;
  font-size: 0.9rem;
  margin: 0 0 20px;
}

.setup-form-group {
  margin-bottom: 16px;
}

.setup-form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 6px;
}

.setup-form-group input,
.setup-form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.9rem;
}

.setup-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ── Tunnel details (collapsible) ── */

.tunnel-details summary {
  font-size: 1.1rem;
  font-weight: 600;
  color: #0b0f19;
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tunnel-details summary::before {
  content: '\25B6';
  font-size: 0.7rem;
  transition: transform 0.2s;
}

.tunnel-details[open] summary::before {
  transform: rotate(90deg);
}

.tunnel-details summary::-webkit-details-marker { display: none; }

/* ── Quick-action cards ── */

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  padding: 12px 16px 8px;
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fafbfc;
  border-bottom: 1px solid #e8eaed;
  flex-shrink: 0;
}

.quick-actions-title {
  width: 100%;
  text-align: center;
  font-size: 0.88rem;
  color: #666;
  margin: 0 0 4px;
}
.qa-toggle-link {
  font-size: 0.78rem;
  color: #7c3aed;
  text-decoration: none;
  margin-left: 8px;
  font-weight: 400;
}
.qa-toggle-link:hover {
  text-decoration: underline;
}

.quick-action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: #fff;
  border: 1px solid #e0dfe6;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  min-width: 200px;
  text-align: left;
}

.quick-action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.12);
  border-color: #c4b5fd;
}

.quick-action-btn:active {
  transform: translateY(0);
}

.qa-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #f5f0ff;
  color: #7c3aed;
  flex-shrink: 0;
}

.qa-icon svg { stroke: #7c3aed; }

.qa-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: #333;
}

/* ── Refresh config button ── */

.btn-icon-setup {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  background: #fff;
  color: #666;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-icon-setup:hover { background: #f3f0ff; color: #7c3aed; border-color: #c4b5fd; }
.btn-icon-setup:disabled { opacity: 0.4; cursor: default; }
.btn-icon-setup.spinning svg { animation: spin-once 0.8s ease; }
@keyframes spin-once { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ── Quick-reply buttons ── */

.quick-reply-bar {
  display: flex;
  gap: 8px;
  padding: 10px 0 4px;
  flex-wrap: wrap;
}
.quick-reply-btn {
  background: var(--accent, #6366f1);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.quick-reply-btn:hover {
  background: var(--accent-hover, #4f46e5);
  transform: translateY(-1px);
}
.quick-reply-btn:active {
  transform: translateY(0);
}

/* ── Secure input widget ── */

.secure-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  margin-top: 10px;
  background: var(--surface-alt, #1e1e2e);
  border: 1px solid var(--border, #333);
  border-radius: 10px;
  flex-wrap: wrap;
}
.secure-lock-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}
.secure-input-field {
  flex: 1;
  min-width: 180px;
  padding: 8px 12px;
  border: 1px solid var(--border, #444);
  border-radius: 6px;
  background: var(--surface, #111);
  color: var(--text, #eee);
  font-size: 0.9rem;
  font-family: monospace;
}
.secure-input-field:focus {
  outline: none;
  border-color: var(--accent, #6366f1);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}
.secure-input-btn {
  background: var(--accent, #6366f1);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.secure-input-btn:hover {
  background: var(--accent-hover, #4f46e5);
}
.secure-input-btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.secure-input-status {
  width: 100%;
  font-size: 0.8rem;
  color: #f87171;
  min-height: 0;
}
.secure-input-status:empty {
  display: none;
}

/* ── Responsive ── */

@media (max-width: 900px) {
  .setup-container {
    flex-direction: column;
    padding: 20px 16px;
    gap: 20px;
  }
  .setup-sidebar {
    width: 100%;
    order: -1;
  }
  .setup-nav {
    flex-direction: row;
    overflow-x: auto;
  }
  .setup-session-list {
    flex-direction: row;
    overflow-x: auto;
  }
  .chat-container {
    height: calc(100vh - 220px);
    min-height: 350px;
  }
}
