/* Grex Portal — dark theme inspired by Unreal Engine editor aesthetic */

:root {
  --bg-base: #0d0f14;
  --bg-panel: #12151c;
  --bg-surface: #1a1e28;
  --bg-hover: #222738;
  --border: #2a2f3d;
  --accent-cyan: #00e5ff;
  --accent-violet: #7c3aed;
  --accent-glow: rgba(0, 229, 255, 0.15);
  --accent-violet-glow: rgba(124, 58, 237, 0.2);
  --text-primary: #e8eaf0;
  --text-secondary: #8892a4;
  --text-muted: #4a5568;
  --status-ok: #22c55e;
  --status-warn: #f59e0b;
  --status-error: #ef4444;
  --font-display: "Orbitron", sans-serif;
  --font-body: "Rajdhani", sans-serif;
  --radius: 6px;
  --radius-lg: 12px;
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
}

#app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  background: var(--bg-base);
}

/*  Header  */
#grex-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  height: 48px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.grex-logo {
  font-size: 20px;
  color: var(--accent-cyan);
  filter: drop-shadow(0 0 6px var(--accent-cyan));
  line-height: 1;
}

.grex-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--accent-cyan);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s, box-shadow 0.3s;
}

.status-dot[data-state="connected"] {
  background: var(--status-ok);
  box-shadow: 0 0 6px var(--status-ok);
  animation: pulse-dot 2s infinite;
}

.status-dot[data-state="connecting"] {
  background: var(--status-warn);
  box-shadow: 0 0 6px var(--status-warn);
  animation: pulse-dot 0.8s infinite;
}

.status-dot[data-state="error"] {
  background: var(--status-error);
  box-shadow: 0 0 6px var(--status-error);
}

@keyframes pulse-dot {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.45;
  }
}

/*  Mode tabs  */
.mode-tabs {
  display: flex;
  gap: 2px;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.04em;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.tab-btn.active {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  background: var(--accent-glow);
}

/*  Main panels  */
#grex-main {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.mode-panel {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.mode-panel.active {
  display: flex;
}

/*  Chat panel  */
#chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.msg {
  max-width: 82%;
  padding: 8px 12px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  animation: msg-in 0.18s ease-out;
}

@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg-grex {
  align-self: flex-start;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 2px;
  color: var(--text-primary);
}

.msg-grex .msg-sender {
  font-size: 11px;
  color: var(--accent-cyan);
  font-weight: 600;
  margin-bottom: 3px;
  font-family: var(--font-display);
  letter-spacing: 0.06em;
}

.msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent-violet), #5b21b6);
  border-bottom-right-radius: 2px;
  color: #fff;
}

.msg-system {
  align-self: center;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
  padding: 2px 0;
}

.msg-streaming {
  opacity: 0.75;
}

.msg-streaming::after {
  content: "▌";
  animation: blink 0.7s steps(1) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/*  Voice panel  */
#panel-voice {
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: radial-gradient(ellipse at center, #111422 0%, var(--bg-base) 70%);
}

#avatar-wrap {
  position: relative;
}

#grex-avatar {
  width: 96px;
  height: 96px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid var(--accent-cyan);
  opacity: 0.4;
}

.ring-1 {
  width: 100%;
  height: 100%;
}

.ring-2 {
  width: 130%;
  height: 130%;
  opacity: 0.15;
}

.avatar-icon {
  font-size: 42px;
  color: var(--accent-cyan);
  filter: drop-shadow(0 0 12px var(--accent-cyan));
  z-index: 1;
}

#grex-avatar.avatar-speaking .ring-1 {
  animation: ring-pulse 0.6s ease-in-out infinite alternate;
  opacity: 0.9;
  border-color: var(--accent-cyan);
}

#grex-avatar.avatar-speaking .ring-2 {
  animation: ring-pulse 0.6s ease-in-out 0.1s infinite alternate;
  opacity: 0.5;
}

#grex-avatar.avatar-listening .ring-1 {
  animation: ring-pulse 1.2s ease-in-out infinite alternate;
  opacity: 0.6;
  border-color: var(--accent-violet);
}

@keyframes ring-pulse {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.15);
  }
}

#waveform {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 40px;
}

.bar {
  width: 4px;
  background: var(--accent-cyan);
  border-radius: 2px;
  height: 4px;
  transition: height 0.1s ease;
  opacity: 0.5;
}

.waveform-active .bar {
  opacity: 1;
}

#voice-status {
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
}

.transcript {
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
  text-align: center;
  max-width: 80%;
  min-height: 18px;
}

/*  Share panel  */
#panel-share {
  align-items: center;
  justify-content: flex-start;
  padding: 14px;
  gap: 14px;
  overflow-y: auto;
}

#media-previews {
  display: flex;
  gap: 10px;
  width: 100%;
}

.preview-card {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16/9;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-card video[srcObject="null"],
.preview-card video:not([srcObject]) {
  display: none;
}

.preview-label {
  position: absolute;
  bottom: 6px;
  left: 8px;
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.5);
  padding: 1px 6px;
  border-radius: 3px;
}

#share-controls {
  display: flex;
  gap: 10px;
}

.share-btn {
  flex: 1;
  padding: 9px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.share-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.share-btn[data-active="true"] {
  background: var(--accent-glow);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-glow);
}

#share-status {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

/*  Footer  */
#grex-footer {
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

#input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

#text-input {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 14px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

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

#text-input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#text-input::placeholder {
  color: var(--text-muted);
}

#btn-send,
.mic-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

#btn-send:hover:not(:disabled),
.mic-btn:hover:not(:disabled) {
  background: var(--accent-glow);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

#btn-send:disabled,
.mic-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.mic-btn[data-active="true"] {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--status-error);
  color: var(--status-error);
  animation: mic-pulse 1.2s ease-in-out infinite;
}

@keyframes mic-pulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }

  50% {
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
  }
}

#footer-actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  flex: 1;
  padding: 7px 0;
  border-radius: var(--radius);
  border: 1px solid var(--accent-cyan);
  background: var(--accent-glow);
  color: var(--accent-cyan);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:hover {
  background: rgba(0, 229, 255, 0.25);
  box-shadow: 0 0 12px var(--accent-glow);
}

.action-btn.danger {
  border-color: var(--status-error);
  background: rgba(239, 68, 68, 0.1);
  color: var(--status-error);
}

.action-btn.danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

.hidden {
  display: none !important;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}
