/* ─── Floating Chat Widget ────────────────────────────────────────── */
#orphilWidget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ─── FAB Button ──────────────────────────────────────────────────── */
.ow-fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #22d3ee, #06b6d4);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(6, 182, 212, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ow-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(6, 182, 212, 0.5);
}

/* ─── Panel ───────────────────────────────────────────────────────── */
.ow-panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 380px;
  height: 520px;
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border-subtle, rgba(34,211,238,0.1));
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

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

/* ─── Header ──────────────────────────────────────────────────────── */
.ow-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, #22d3ee, #06b6d4);
  color: #fff;
}

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

.ow-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.ow-name {
  font-weight: 600;
  font-size: 15px;
}

.ow-status {
  font-size: 11px;
  opacity: 0.8;
}

.ow-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.ow-header-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  opacity: 0.7;
  transition: opacity 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ow-header-btn:hover {
  opacity: 1;
  background: rgba(255,255,255,0.15);
}

.ow-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.ow-close:hover {
  opacity: 1;
}

/* ─── Messages ────────────────────────────────────────────────────── */
.ow-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-primary, #f8fafc);
}

.ow-welcome {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-secondary, #475569);
  font-size: 13px;
  line-height: 1.6;
}

.ow-msg {
  display: flex;
  gap: 8px;
  max-width: 100%;
}

.ow-msg-user {
  flex-direction: row-reverse;
}

.ow-msg-avatar {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #22d3ee, #06b6d4);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
}

.ow-msg-text {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-primary, #0f172a);
  word-break: break-word;
  max-width: calc(100% - 40px);
}

.ow-msg-user .ow-msg-text {
  background: linear-gradient(135deg, rgba(34,211,238,0.12), rgba(6,182,212,0.08));
  border: 1px solid rgba(34,211,238,0.25);
  border-radius: 12px 4px 12px 12px;
  padding: 8px 12px;
}

.ow-msg-assistant .ow-msg-text {
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border-subtle, rgba(0,0,0,0.06));
  border-radius: 4px 12px 12px 12px;
  padding: 8px 12px;
}

.ow-msg-sys {
  background: rgba(239,68,68,0.08) !important;
  border-color: rgba(239,68,68,0.2) !important;
  color: #ef4444 !important;
  border-radius: 8px !important;
  padding: 6px 10px !important;
  font-size: 12px !important;
  margin: 0 auto;
}

.ow-msg-text code {
  background: var(--bg-elevated, #f1f5f9);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 12px;
}

.ow-msg-text strong {
  font-weight: 600;
}

/* ─── Typing ──────────────────────────────────────────────────────── */
.ow-typing {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border-subtle, rgba(0,0,0,0.06));
  border-radius: 4px 12px 12px 12px;
}

.ow-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary, #94a3b8);
  animation: owTyping 1.4s infinite;
}

.ow-typing span:nth-child(2) { animation-delay: 0.2s; }
.ow-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes owTyping {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

/* ─── Input ───────────────────────────────────────────────────────── */
.ow-input-area {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--border-subtle, rgba(0,0,0,0.06));
  background: var(--bg-surface, #fff);
}

#owInput {
  flex: 1;
  border: 1px solid var(--border-default, rgba(34,211,238,0.3));
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-primary, #0f172a);
  background: var(--bg-primary, #f8fafc);
  outline: none;
  resize: none;
  max-height: 100px;
  line-height: 1.4;
}

#owInput:focus {
  border-color: #22d3ee;
  box-shadow: 0 0 0 2px rgba(34,211,238,0.2);
}

#owInput::placeholder {
  color: var(--text-tertiary, #94a3b8);
}

.ow-send {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #22d3ee, #06b6d4);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.ow-send:hover { opacity: 0.85; }
.ow-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── Widget Size Modes ──────────────────────────────────────────── */
.ow-panel.ow-size-default {
  width: 380px;
  height: 520px;
}

.ow-panel.ow-size-medium {
  width: 480px;
  height: 620px;
}

.ow-panel.ow-size-large {
  width: 600px;
  height: 75vh;
}

/* ─── Mobile ──────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #orphilWidget { bottom: 16px; right: 16px; }

  .ow-panel {
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
    bottom: 68px;
    right: -8px;
  }

  .ow-fab {
    width: 48px;
    height: 48px;
  }
}
