@import url("/theme-tokens.css");

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: radial-gradient(1200px 600px at 50% -10%, var(--login-gradient-from), var(--login-gradient-to) 60%);
  color: var(--text);
  height: 100vh;
}

#app { height: 100vh; display: flex; flex-direction: column; }

.center { height: 100%; display: flex; align-items: center; justify-content: center; }
.muted { color: var(--muted); }

/* Auth-kaart */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card {
  width: min(440px, 94vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 30px 80px color-mix(in srgb, var(--text) 12%, transparent);
}
.brand { text-align: center; margin-bottom: 22px; }
.brand-icon {
  display: block;
  width: 72px;
  height: 72px;
  margin: 0 auto 14px;
  border-radius: 16px;
  object-fit: contain;
}
.brand-logo {
  font-family: var(--font-sans);
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--brand);
}
.brand-tag { display: block; margin-top: 6px; color: var(--muted); font-size: 14px; }
.auth-card label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.auth-card input {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-size: 15px;
}
.err { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); cursor: pointer; font-size: 14px;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--text-on-accent); font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-block { width: 100%; margin-top: 18px; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* App-layout */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-bottom: 1px solid var(--border); background: var(--bg-panel);
  position: sticky; top: 0; z-index: 20; flex-shrink: 0;
}
.topbar .who { font-weight: 600; }
.topbar .who small { color: var(--muted); font-weight: 400; margin-left: 8px; }
.layout { flex: 1; display: flex; min-height: 0; background: var(--bg); }
.main-area {
  flex: 1;
  display: flex;
  min-width: 0;
  min-height: 0;
}
.sidebar { width: 280px; border-right: 1px solid var(--border); overflow-y: auto; background: var(--bg-panel); flex-shrink: 0; }
.sidebar h4 { margin: 0; padding: 14px 16px 8px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.conv-item { padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--border); }
.conv-item:hover { background: var(--bg-elevated); }
.conv-item.active { background: var(--bg-elevated); border-left: 3px solid var(--accent); }
.conv-item .title { font-weight: 600; font-size: 14px; }
.conv-item .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.chat.with-file-panel { flex: 1 1 70%; }
.chat.chat-hidden { display: none; }

.main-area.file-panel-expanded .file-side-panel {
  flex: 1 1 auto;
  width: auto;
  max-width: none;
}
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.messages-anchor { flex-shrink: 0; height: 0; width: 100%; overflow: hidden; pointer-events: none; }

/* Berichten — host/gebruiker links, gast rechts, WalkingGround in het midden */
.msg-row { display: flex; gap: 8px; align-items: flex-start; width: 100%; max-width: 100%; }
.msg-row.row-host { justify-content: flex-start; }
.msg-row.row-guest { justify-content: flex-end; }
.msg-row.row-center { justify-content: center; }
.msg-avatar {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
  border: 1px solid var(--border); background: var(--bg-elevated);
}
.bubble {
  max-width: 76%; padding: 10px 14px; border-radius: var(--radius); line-height: 1.55;
  white-space: pre-wrap; word-wrap: break-word;
  background: var(--bg-elevated); border: 1px solid var(--border);
}
.bubble .author { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.bubble-text { white-space: pre-wrap; word-wrap: break-word; font-family: var(--font-serif); font-size: 1.05rem; line-height: 1.65; }
.bubble-sent-at {
  font-size: 10px;
  color: var(--muted);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
  opacity: 0.9;
}
.bubble-guest .bubble-sent-at { text-align: right; }
.bubble-host .bubble-sent-at { text-align: left; }
.bubble-center .bubble-sent-at { text-align: center; }
.bubble-host {
  border-radius: 4px var(--radius) var(--radius) var(--radius);
}
.bubble-guest {
  background: var(--accent-dim);
  color: var(--text-on-accent-bright);
  border-color: var(--accent-dim);
  border-radius: var(--radius) 4px var(--radius) var(--radius);
}
.bubble-center {
  background: var(--bg-panel);
  border-radius: var(--radius);
  max-width: 88%;
}

/* YouTube / zoekmedia in chat */
.msg-row-with-media { flex-direction: column; align-items: stretch; }
.msg-center-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}
.msg-center-line { display: flex; gap: 8px; align-items: flex-start; justify-content: center; width: 100%; }
.msg-media-stack { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.msg-line { display: flex; gap: 8px; align-items: flex-start; width: 100%; }
.msg-line-guest { justify-content: flex-end; }
.msg-line-host { justify-content: flex-start; }

.search-media-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(100%, 560px);
}
.row-center .search-media-panel { margin: 0 auto; }
.row-host .search-media-panel { margin-right: auto; max-width: min(100%, 420px); }
.row-guest .search-media-panel { margin-left: auto; max-width: min(100%, 420px); }

.youtube-embed-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elevated);
  box-shadow: 0 4px 20px color-mix(in srgb, var(--text) 8%, transparent);
}
.youtube-embed-frame-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}
.youtube-embed-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.youtube-embed-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
}
.youtube-embed-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  line-height: 1.35;
}
.youtube-embed-title:hover { color: var(--accent); }
.youtube-embed-channel { font-size: 12px; }

/* Release-log (portal) */
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--bg-elevated); }
.release-overlay {
  position: fixed; inset: 0; background: var(--overlay);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.release-card {
  width: min(560px, 96vw); max-height: 84vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 22px 24px; box-shadow: 0 30px 80px color-mix(in srgb, var(--text) 12%, transparent);
}
.release-topbar { display: flex; align-items: center; justify-content: space-between; }
.release-topbar h3 { margin: 0; font-size: 18px; }
.release-intro { margin: 6px 0 18px; line-height: 1.5; font-size: 14px; color: var(--text-muted); }
.release-entry { padding: 14px 0; border-top: 1px solid var(--border); }
.release-entry:first-of-type { border-top: none; }
.release-head { display: flex; align-items: baseline; gap: 10px; }
.release-version { font-weight: 700; font-size: 15px; }
.release-date { color: var(--muted); font-size: 12px; }
.release-items { margin: 8px 0 0; padding-left: 18px; }
.release-items li { margin: 4px 0; line-height: 1.5; font-size: 14px; color: var(--text); }

.composer { flex-shrink: 0; display: flex; gap: 10px; padding: 14px 18px 10px; border-top: 1px solid var(--border); background: var(--bg-panel); }
.composer-footer {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  padding: 0 18px 14px;
  background: var(--bg-panel);
  border-top: 1px solid color-mix(in srgb, var(--border) 65%, transparent);
}
.composer-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.chat-context-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}
.chat-context-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 12px;
  line-height: 1.3;
  cursor: pointer;
  font-family: inherit;
}
.chat-context-chip:hover:not(.muted) {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-elevated));
}
.chat-context-chip.muted {
  color: var(--muted);
  cursor: default;
  opacity: 0.85;
}
.app-preview-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.app-preview-status-label {
  font-weight: 500;
  color: var(--text);
}
.status-light {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 15%, transparent);
}
.status-light-green {
  background: #22c55e;
  color: #22c55e;
  box-shadow: 0 0 8px color-mix(in srgb, #22c55e 55%, transparent);
}
.status-light-red {
  background: #ef4444;
  color: #ef4444;
  box-shadow: 0 0 8px color-mix(in srgb, #ef4444 45%, transparent);
}
.app-preview-status-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}
.app-preview-status-link:hover {
  text-decoration: underline;
}
.info-overlay {
  position: fixed; inset: 0; background: var(--overlay);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.info-card {
  width: min(520px, 96vw); max-height: 84vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 22px 24px; box-shadow: 0 30px 80px color-mix(in srgb, var(--text) 12%, transparent);
}
.info-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.info-topbar h3 { margin: 0; font-size: 18px; }
.info-body { margin-top: 12px; }
.info-intro { margin: 0 0 14px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.info-muted { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.5; }
.info-section { margin: 14px 0 0; }
.info-section h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.info-section p { margin: 0; font-size: 14px; line-height: 1.55; color: var(--text); white-space: pre-wrap; }
.info-list { margin: 0; padding-left: 18px; }
.info-list li { margin: 4px 0; font-size: 14px; line-height: 1.45; color: var(--text); }
.chat-id-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}
.chat-id-value {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
  color: var(--text);
}
.chat-context-chip-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
}
.chat-context-chip-agent {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  color: var(--accent);
  font-weight: 600;
}
.composer textarea {
  flex: 1; resize: none; padding: 12px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--bg-elevated); color: var(--text); font-size: 15px; font-family: inherit; min-height: 46px; max-height: 160px;
}
.empty { color: var(--muted); text-align: center; margin: auto; }
.pending { color: var(--muted); font-style: italic; align-self: flex-start; }

.portal-footer {
  flex-shrink: 0;
  padding: 8px 16px 12px;
  text-align: center;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
}

.portal-footer-copyright { opacity: 0.85; max-width: 520px; margin: 0 auto; }

.auth-copyright {
  margin-top: 20px;
  font-size: 11px;
  line-height: 1.4;
  text-align: center;
  color: var(--muted);
  opacity: 0.75;
}

.topbar-actions .btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

.explorer-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

.explorer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}

.explorer-path {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.explorer-scope {
  margin: 0;
  padding: 8px 16px 0;
  font-size: 12px;
  line-height: 1.45;
}

.explorer-empty {
  padding: 16px;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.explorer-list {
  max-height: 220px;
  overflow-y: auto;
  border-bottom: 1px solid var(--border);
}

.explorer-list-full {
  flex: 1;
  max-height: none;
  overflow-y: auto;
  border-bottom: none;
}

.file-side-panel {
  position: relative;
  flex: 0 0 30%;
  width: 30%;
  min-width: 220px;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--border);
  background: var(--bg-panel);
}

.file-side-expand {
  position: absolute;
  left: 0;
  top: 50%;
  z-index: 10;
  width: 26px;
  height: 52px;
  margin: 0;
  padding: 0;
  transform: translate(-50%, -50%);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 10px 0 0 10px;
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  box-shadow: -3px 0 10px color-mix(in srgb, var(--text) 10%, transparent);
  transition: transform 0.2s ease, background 0.15s ease;
}

.file-side-expand:hover {
  background: var(--bg-panel);
  border-color: var(--accent);
  color: var(--accent);
}

.file-side-expand.expanded {
  transform: translate(-50%, -50%) rotate(180deg);
}

.file-side-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  flex-shrink: 0;
}

.file-side-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  font-size: 13px;
  line-height: 1.35;
}

.file-side-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.file-side-close {
  flex-shrink: 0;
  font-size: 16px;
  line-height: 1;
  padding: 6px 10px;
}

.file-side-loading,
.file-side-error {
  padding: 16px 12px;
  font-size: 13px;
}

.file-side-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.file-side-preview {
  flex: 1;
  min-height: 0;
}

.file-side-image-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 8px;
}

.file-side-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

.file-side-editor {
  width: 100%;
  border: 0;
  background: var(--bg);
  color: var(--text);
  resize: none;
  outline: none;
}

.file-side-versions {
  max-height: 100px;
  flex-shrink: 0;
}

.explorer-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px;
  width: 100%;
  text-align: left;
  padding: 8px 16px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

.explorer-item:hover {
  background: var(--bg-elevated);
}

.explorer-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  font-size: 13px;
}

.explorer-preview {
  flex: 1;
  margin: 0;
  padding: 14px 16px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.explorer-head-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.explorer-perm-badge {
  font-size: 11px;
  margin-left: 6px;
}

.explorer-perm-fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 12px 0;
}

.explorer-perm-option {
  display: block;
  margin: 6px 0;
  font-size: 13px;
}

.explorer-host-access {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.explorer-no-write {
  font-size: 12px;
}

.explorer-preview-head {
  flex-wrap: wrap;
}

.explorer-dates {
  font-size: 11px;
  flex-basis: 100%;
  padding-left: 22px;
}

.explorer-file-dates {
  margin: 0;
  padding: 6px 16px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}

.explorer-versions {
  border-bottom: 1px solid var(--border);
  max-height: 140px;
  overflow-y: auto;
}

.explorer-versions-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 4px;
  font-size: 12px;
}

.explorer-version-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 16px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}

.explorer-version-item:hover,
.explorer-version-item.active {
  background: var(--bg-elevated);
}
