/* AESChat - Super Clean, Minimalist Dark Theme */

:root {
  --bg: #111111;
  --surface: #181818;
  --surface-alt: #222222;
  --border: #2e2e2e;
  --text: #eaeaea;
  --text-muted: #888888;
  --accent: #10b981;
  --accent-hover: #059669;
  --danger: #ef4444;
  --outgoing: #193628;
  --outgoing-border: #23523d;
  --incoming: #202020;
  --incoming-border: #2e2e2e;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 14px;
}

/* Navbar */
.navbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 4px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  justify-self: start;
}

.logo {
  font-weight: 700;
  font-size: 1rem;
}

.cipher-tag {
  font-size: 11px;
  font-family: monospace;
  background: #252525;
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--accent);
}

.status-badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
  text-transform: uppercase;
}

.status-badge.waiting { color: #f59e0b; border-color: #78350f; }
.status-badge.connected { color: #10b981; border-color: #065f46; background: #064e3b33; }
.status-badge.disconnected { color: #ef4444; border-color: #7f1d1d; }

.latency-tag {
  font-size: 11px;
  font-family: monospace;
  color: var(--text-muted);
}

/* Centered Logo & Portfolio Link */
.nav-center {
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  position: relative;
  z-index: 10; /* let the logo paint over the content below when it overflows */
}

.creator-badge {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  line-height: 0;
  transition: opacity 0.15s ease;
}

.creator-badge:hover {
  opacity: 0.75;
}

.creator-logo {
  height: 64px;
  width: auto;
  max-width: 260px;
  object-fit: contain;
  display: block;
  /* Overflow the thin bar instead of stretching it: the negative margins keep
     the navbar row short while the image renders at full height, centered. */
  margin-top: -16px;
  margin-bottom: -16px;
}

.creator-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  justify-self: end;
}

/* Buttons & Inputs */
.btn {
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn:hover:not(:disabled) {
  background: #2e2e2e;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-sm {
  padding: 3px 8px;
  font-size: 12px;
}

.text-input {
  background: #0d0d0d;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 14px;
  outline: none;
}

.text-input:focus {
  border-color: var(--accent);
}

/* Layout */
.app-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

.chat-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Setup Card */
.setup-card {
  max-width: 440px;
  margin: 30px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.setup-card h2 {
  font-size: 1.15rem;
}

.desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 12px;
  color: var(--text-muted);
}

/* Clean Bot Verification Box (NO ugly thick left line) */
.bot-box {
  background: #0d0d0d;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bot-quote {
  font-size: 12.5px;
  font-style: italic;
  font-family: monospace;
  color: #d1d5db;
  line-height: 1.4;
}

.bot-check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.bot-check-label input {
  cursor: pointer;
  accent-color: var(--accent);
}

.verified-msg {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

/* Messages List */
.messages-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 75%;
}

.msg-row.out {
  align-self: flex-end;
  align-items: flex-end;
}

.msg-row.in {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-bubble {
  padding: 8px 12px;
  border-radius: 6px;
  line-height: 1.4;
  word-break: break-word;
  cursor: pointer;
}

.msg-row.out .msg-bubble {
  background: var(--outgoing);
  border: 1px solid var(--outgoing-border);
  color: #f0fdf4;
}

.msg-row.in .msg-bubble {
  background: var(--incoming);
  border: 1px solid var(--incoming-border);
  color: var(--text);
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  padding: 0 2px;
}

.msg-lock {
  font-family: monospace;
  font-size: 10px;
  background: #222;
  color: var(--accent);
  padding: 1px 4px;
  border-radius: 2px;
  border: 1px solid #333;
  cursor: pointer;
}

.msg-sender {
  font-size: 11px;
  font-weight: 600;
  color: #38bdf8;
  margin-bottom: 2px;
}

.system-notice {
  align-self: center;
  font-size: 12px;
  color: var(--text-muted);
  background: #1e1e1e;
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 3px;
  font-family: monospace;
}

.typing-notice {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  padding: 4px 8px;
}

/* Input Bar */
.input-bar {
  padding: 10px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-form {
  display: flex;
  gap: 8px;
}

.message-field {
  flex: 1;
}

/* Wire Inspector Drawer */
.inspector-drawer {
  width: 320px;
  background: #141414;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  font-family: monospace;
  font-size: 11.5px;
}

.inspector-top {
  padding: 10px 12px;
  background: #1c1c1c;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.inspector-packets {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.packet-entry {
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.packet-dir {
  font-weight: 700;
}
.packet-entry.out .packet-dir { color: var(--accent); }
.packet-entry.in .packet-dir { color: #38bdf8; }

.packet-val {
  background: #0d0d0d;
  padding: 3px 5px;
  border-radius: 2px;
  color: #bbb;
  overflow-x: auto;
  white-space: nowrap;
}

.empty-log {
  color: var(--text-muted);
  text-align: center;
  margin-top: 20px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 100%;
  max-width: 440px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-top h3 {
  font-size: 1rem;
}

.link-row {
  display: flex;
  gap: 6px;
}

.link-row input {
  flex: 1;
  font-family: monospace;
  font-size: 12px;
}

.qr-wrap {
  display: flex;
  justify-content: center;
  padding: 12px;
  background: #fff;
  border-radius: 4px;
  width: fit-content;
  margin: 0 auto;
}

.safety-code {
  font-family: monospace;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  background: #0d0d0d;
  padding: 12px;
  text-align: center;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.payload-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
}

.payload-details code {
  display: block;
  background: #0d0d0d;
  padding: 4px 6px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 11px;
  color: #ccc;
  word-break: break-all;
  white-space: pre-wrap;
  margin-top: 2px;
}

/* How It Works Explainer Modal */
.how-it-works-box {
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
}

.explainer-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 4px 0;
}

.explainer-item {
  background: #121212;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
}

.explainer-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 4px;
}

.explainer-item p {
  font-size: 12.5px;
  line-height: 1.45;
  color: #bbb;
}

.explainer-item code {
  background: #202020;
  padding: 2px 5px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 11.5px;
  color: #eaeaea;
}

.explainer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.credit-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

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

.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 700px) {
  .navbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .nav-center {
    order: 3;
    width: 100%;
    justify-self: auto;
    justify-content: center;
    padding-top: 4px;
    border-top: 1px solid var(--border);
  }
  .creator-logo {
    height: 40px;
  }
  .inspector-drawer {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 90%;
    z-index: 50;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.7);
  }
}
