/**
 * Mr. Omelette — Widget Styles
 * All colors driven by CSS custom properties (--mro-*) injected via PHP.
 *
 * @version 1.0.0
 */

/* ───── Reset ───── */

.mro-panel *,
.mro-panel *::before,
.mro-panel *::after,
.mro-bubble,
.mro-peek {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ───── Bubble ───── */

.mro-bubble {
  position: fixed;
  bottom: 100px;
  right: 24px;
  z-index: 99998;
  width: 85px;
  height: 85px;
  border-radius: 50%;
  background: var(--mro-primary, #1a1a2e);
  border: 3px solid var(--mro-accent, #f5c518);
  color: var(--mro-accent, #f5c518);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.mro-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(245, 197, 24, 0.4);
}

/* Pulse ring */
.mro-bubble::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--mro-accent, #f5c518);
  animation: mro-pulse 2.5s ease-out infinite;
  pointer-events: none;
}

@keyframes mro-pulse {
  0%   { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0; }
}

.mro-bubble--left {
  right: auto;
  left: 24px;
}

.mro-bubble--small {
  width: 60px;
  height: 60px;
}

.mro-bubble--large {
  width: 100px;
  height: 100px;
}

.mro-bubble--hidden {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}

.mro-bubble__icon {
  width: 28px;
  height: 28px;
}

.mro-bubble__img {
  width: calc(100% - 2px);
  height: calc(100% - 2px);
  border-radius: 50%;
  object-fit: cover;
  image-rendering: -webkit-optimize-contrast;
}

/* ───── Peek Image ───── */

.mro-peek {
  width: 180px;
  height: 180px;
  margin-bottom: -40px;
  margin-left: 60px;
  z-index: 2;
  position: relative;
  pointer-events: none;
  flex-shrink: 0;
}

.mro-peek img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
  image-rendering: -webkit-optimize-contrast;
}

/* ───── Panel ───── */

.mro-panel {
  position: fixed;
  bottom: 170px;
  right: 24px;
  z-index: 99999;
  width: 420px;
  max-width: calc(100vw - 32px);
  font-family: var(--mro-font, 'Lexend', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: visible;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.mro-panel--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.mro-panel__body {
  width: 100%;
  background: var(--mro-primary, #1a1a2e);
  border-radius: var(--mro-radius, 16px);
  border: 3px solid var(--mro-accent, #f5c518);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
  min-height: 0;
  flex: 1;
  max-height: calc(100vh - 280px);
}

.mro-panel--left {
  right: auto;
  left: 24px;
}

.mro-panel--inline {
  position: relative;
  bottom: auto;
  right: auto;
  left: auto;
  width: 100%;
  height: 100%;
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* ───── Header ───── */

.mro-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.mro-panel__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--mro-text, #e8e8e8);
}

.mro-panel__actions {
  display: flex;
  gap: 6px;
}

.mro-panel__btn {
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--mro-text-dim, #aaaaaa);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.mro-panel__btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--mro-text, #e8e8e8);
}

.mro-panel__btn svg {
  width: 16px;
  height: 16px;
}

/* ───── Messages ───── */

.mro-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background: var(--mro-chat-bg, #faf6ee);
}

.mro-messages::-webkit-scrollbar {
  width: 5px;
}

.mro-messages::-webkit-scrollbar-track {
  background: transparent;
}

.mro-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

/* ───── Message Bubbles ───── */

.mro-msg {
  display: flex;
  max-width: 85%;
}

.mro-msg--bot {
  align-self: flex-start;
}

.mro-msg--user {
  align-self: flex-end;
}

.mro-msg__content {
  padding: 10px 14px;
  border-radius: var(--mro-radius, 16px);
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.mro-msg--bot .mro-msg__content {
  background: var(--mro-msg-bg, #ffffff);
  color: var(--mro-msg-text, #1a1a2e);
  border-bottom-left-radius: 4px;
}

.mro-msg--user .mro-msg__content {
  background: var(--mro-user-bg, #f5c518);
  color: var(--mro-primary, #1a1a2e);
  border-bottom-right-radius: 4px;
}

.mro-msg__content a {
  color: var(--mro-accent, #f5c518);
  text-decoration: underline;
}

.mro-msg--user .mro-msg__content a {
  color: var(--mro-primary, #1a1a2e);
}

.mro-msg__content code {
  background: rgba(0, 0, 0, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'Fira Code', 'SF Mono', monospace;
}

.mro-msg__content strong {
  font-weight: 600;
}

/* ───── Typing Indicator ───── */

.mro-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
}

.mro-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mro-text-dim, #aaaaaa);
  animation: mro-bounce 1.4s ease-in-out infinite both;
}

.mro-typing span:nth-child(1) { animation-delay: 0s; }
.mro-typing span:nth-child(2) { animation-delay: 0.16s; }
.mro-typing span:nth-child(3) { animation-delay: 0.32s; }

@keyframes mro-bounce {
  0%, 80%, 100% {
    transform: scale(0.7);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ───── Chips ───── */

.mro-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
}

.mro-chip {
  background: transparent;
  color: var(--mro-primary, #1a1a2e);
  border: 1.5px solid var(--mro-accent, #f5c518);
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1.4;
  white-space: normal;
}

.mro-chip:hover {
  background: var(--mro-accent, #f5c518);
  border-color: var(--mro-accent, #f5c518);
  color: var(--mro-primary, #1a1a2e);
  transform: scale(1.04);
}

.mro-chip:active {
  transform: scale(0.97);
}

.mro-chips--inline {
  margin-top: 8px;
}

/* ───── Input Area ───── */

.mro-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.mro-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px 14px;
  color: var(--mro-text, #e8e8e8);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  min-height: 40px;
  max-height: 120px;
  transition: border-color 0.15s;
}

.mro-input::placeholder {
  color: var(--mro-text-dim, #aaaaaa);
}

.mro-input:focus {
  border-color: var(--mro-accent, #f5c518);
}

.mro-send {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: var(--mro-accent, #f5c518);
  color: var(--mro-primary, #1a1a2e);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.mro-send svg {
  width: 18px;
  height: 18px;
}

.mro-send:hover {
  opacity: 0.85;
}

.mro-send--busy {
  opacity: 0.5;
  pointer-events: none;
}

/* ───── Branding ───── */

.mro-branding {
  text-align: center;
  font-size: 11px;
  color: var(--mro-text-dim, #aaaaaa);
  padding: 4px 0;
  opacity: 1;
}

.mro-branding a {
  color: inherit;
  text-decoration: none;
}

.mro-branding a:hover {
  text-decoration: underline;
}

.mro-branding strong {
  color: var(--mro-accent, #f5c518);
}

/* ───── Mobile ───── */

@media (max-width: 480px) {
  .mro-panel {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 90px;
  }

  .mro-panel__body {
    max-height: calc(100vh - 200px);
  }

  .mro-panel--left {
    left: 8px;
    right: auto;
  }

  .mro-peek {
    width: 110px;
    height: 110px;
    margin-bottom: -20px;
  }

  .mro-bubble {
    right: 16px;
  }

  .mro-bubble--left {
    right: auto;
    left: 16px;
  }

  /* Prevent iOS auto-zoom */
  .mro-input {
    font-size: 16px !important;
  }
}

/* ───── Inline Mount ───── */

.mro-inline-mount {
  border-radius: var(--mro-radius, 16px);
  overflow: hidden;
}

.mro-inline-mount .mro-panel--inline {
  border-radius: 0;
  box-shadow: none;
}
