/* Rev1 Energy — Riley floating AI agent
 * Palette: Rev1 Navy + Rev1 Red.
 */

:root {
  --riley-navy: #061633;
  --riley-navy-2: #0a2b5c;
  --riley-red: #ce1126;
  --riley-red-hover: #e2253a;
  --riley-red-active: #870a17;
  --riley-text: #ffffff;
  --riley-text-mute: rgba(255, 255, 255, 0.72);
  --riley-text-faint: rgba(255, 255, 255, 0.5);
  --riley-surface: rgba(6, 22, 51, 0.98);
  --riley-surface-2: rgba(10, 43, 92, 0.7);
  --riley-border: rgba(255, 255, 255, 0.12);
  --riley-border-strong: rgba(255, 255, 255, 0.22);
  --riley-shadow: 0 24px 80px rgba(0, 0, 0, 0.45),
    0 8px 24px rgba(0, 0, 0, 0.3);
  --riley-radius: 18px;
  --riley-radius-sm: 10px;
  --riley-fab-size: 64px;
  --riley-z: 2147483600;
}

/* ------------- FAB ------------- */
.riley-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: var(--riley-fab-size);
  height: var(--riley-fab-size);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--riley-red) 0%, var(--riley-red-active) 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 32px rgba(206, 17, 38, 0.45),
    0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: var(--riley-z);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.riley-fab:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 16px 40px rgba(206, 17, 38, 0.55),
    0 6px 16px rgba(0, 0, 0, 0.35);
}
.riley-fab:active {
  transform: translateY(0) scale(0.98);
}
.riley-fab:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}
.riley-fab svg {
  width: 28px;
  height: 28px;
}
.riley-fab__pulse {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--riley-red);
  opacity: 0;
  pointer-events: none;
  animation: rileyPulse 2.4s ease-out infinite;
}
@keyframes rileyPulse {
  0% { opacity: 0.6; transform: scale(0.95); }
  70% { opacity: 0; transform: scale(1.4); }
  100% { opacity: 0; transform: scale(1.4); }
}

/* ------------- Panel ------------- */
.riley-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 130px);
  background: var(--riley-surface);
  background-image: linear-gradient(180deg,
    rgba(206, 17, 38, 0.12) 0%,
    rgba(6, 22, 51, 0) 35%);
  color: var(--riley-text);
  border-radius: var(--riley-radius);
  border: 1px solid var(--riley-border);
  box-shadow: var(--riley-shadow);
  z-index: var(--riley-z);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.riley-panel--open {
  display: flex;
  animation: rileySlideUp 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes rileySlideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ------------- Header ------------- */
.riley-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--riley-border);
  background: rgba(6, 22, 51, 0.6);
  flex-shrink: 0;
}
.riley-header__left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.riley-header__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--riley-red), var(--riley-red-active));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}
.riley-header__title {
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.riley-header__sub {
  font-size: 11px;
  color: var(--riley-text-mute);
  display: flex;
  align-items: center;
  gap: 6px;
}
.riley-header__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #5dd084;
  display: inline-block;
}
.riley-header__dot--idle { background: #d0a23d; }
.riley-header__dot--off  { background: rgba(255, 255, 255, 0.35); }
.riley-close {
  background: transparent;
  border: 1px solid var(--riley-border);
  color: var(--riley-text);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.riley-close:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--riley-border-strong);
}
.riley-close svg { width: 16px; height: 16px; }

/* ------------- Stage ------------- */
.riley-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: linear-gradient(180deg, var(--riley-navy-2), var(--riley-navy));
  flex-shrink: 0;
  overflow: hidden;
}
.riley-stage__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--riley-navy);
}
.riley-stage__placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--riley-text-mute);
  text-align: center;
  padding: 16px;
  pointer-events: none;
}
.riley-stage__placeholder svg {
  width: 56px;
  height: 56px;
  opacity: 0.6;
  margin-bottom: 10px;
  color: var(--riley-red);
}
.riley-stage__hint {
  font-size: 12px;
  color: var(--riley-text-faint);
}
.riley-stage__overlay {
  position: absolute;
  left: 12px;
  bottom: 12px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--riley-border);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  display: none;
  align-items: center;
  gap: 6px;
}
.riley-stage__overlay--visible {
  display: inline-flex;
}
.riley-stage__overlay-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--riley-red);
  animation: rileyBlink 1.2s ease-in-out infinite;
}
@keyframes rileyBlink {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* ------------- Transcript ------------- */
.riley-transcript {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(6, 22, 51, 0.45);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
.riley-transcript::-webkit-scrollbar { width: 6px; }
.riley-transcript::-webkit-scrollbar-track { background: transparent; }
.riley-transcript::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 3px;
}
.riley-msg {
  max-width: 88%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
  word-wrap: break-word;
  animation: rileyFadeIn 0.2s ease;
}
@keyframes rileyFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.riley-msg--user {
  align-self: flex-end;
  background: var(--riley-red);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.riley-msg--avatar {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid var(--riley-border);
  border-bottom-left-radius: 4px;
}
.riley-msg--system {
  align-self: center;
  background: transparent;
  color: var(--riley-text-faint);
  font-size: 11px;
  font-style: italic;
  padding: 4px 8px;
  text-align: center;
  max-width: 100%;
}
.riley-msg__role {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.7;
  margin-bottom: 2px;
  font-weight: 600;
}
.riley-msg__link {
  color: #ff5566;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  word-break: break-all;
  transition: color 0.15s ease;
}
.riley-msg__link:hover {
  color: #ff8090;
}
.riley-msg--user .riley-msg__link {
  color: #fff;
  text-decoration-color: rgba(255, 255, 255, 0.7);
}

/* ------------- Composer (text input) ------------- */
.riley-composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 0;
  background: rgba(6, 22, 51, 0.6);
  flex-shrink: 0;
}
.riley-composer__input {
  flex: 1 1 auto;
  appearance: none;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--riley-border-strong);
  color: #fff;
  border-radius: var(--riley-radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  min-width: 0;
}
.riley-composer__input::placeholder {
  color: var(--riley-text-faint);
}
.riley-composer__input:focus {
  border-color: var(--riley-red);
  background: rgba(255, 255, 255, 0.09);
}
.riley-composer__input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.riley-composer__send {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: var(--riley-radius-sm);
  background: var(--riley-red);
  border: none;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.05s;
}
.riley-composer__send:hover { background: var(--riley-red-hover); }
.riley-composer__send:active { transform: scale(0.96); }
.riley-composer__send[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.08);
}
.riley-composer__send svg { width: 16px; height: 16px; }

/* ------------- Controls ------------- */
.riley-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--riley-border);
  background: rgba(6, 22, 51, 0.6);
  flex-shrink: 0;
  margin-top: 4px;
}
.riley-btn {
  flex: 1 1 auto;
  appearance: none;
  border: 1px solid var(--riley-border-strong);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  border-radius: var(--riley-radius-sm);
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.riley-btn:hover { background: rgba(255, 255, 255, 0.08); }
.riley-btn:active { transform: scale(0.98); }
.riley-btn--primary {
  background: var(--riley-red);
  border-color: var(--riley-red);
  color: #fff;
}
.riley-btn--primary:hover {
  background: var(--riley-red-hover);
  border-color: var(--riley-red-hover);
}
.riley-btn--icon {
  flex: 0 0 auto;
  width: 42px;
  padding: 0;
}
.riley-btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}
.riley-btn svg { width: 16px; height: 16px; }

/* ------------- Footer ------------- */
.riley-footer {
  font-size: 10px;
  text-align: center;
  color: var(--riley-text-faint);
  padding: 6px 12px 10px;
  background: rgba(6, 22, 51, 0.6);
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.riley-footer a { color: var(--riley-text-mute); text-decoration: none; }
.riley-footer a:hover { color: #fff; }

/* ------------- Responsive ------------- */
@media (max-width: 480px) {
  .riley-panel {
    right: 8px;
    left: 8px;
    bottom: 88px;
    width: auto;
    height: calc(100vh - 110px);
  }
  .riley-fab {
    right: 16px;
    bottom: 16px;
    width: 56px;
    height: 56px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .riley-fab__pulse,
  .riley-stage__overlay-dot { animation: none; }
  .riley-panel--open,
  .riley-msg { animation: none; }
}
