/* AccessMe Universal Agent Styles */

/* ─── Floating Launcher Widget ────────────────────────────────────────── */

#accessme-widget-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2147483647; /* Ensure it floats above all other elements */
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 16px;
  pointer-events: none;
}

#accessme-widget-root * {
  box-sizing: border-box;
  pointer-events: auto;
}

/* Floating Action Button (FAB) */
.accessme-fab {
  width: 60px;
  height: 60px;
  border-radius: 30px;
  background: linear-gradient(135deg, #4f46e5 0%, #1f57d6 100%);
  color: #ffffff;
  border: none;
  box-shadow: 0 6px 20px rgba(31, 87, 214, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.2s ease;
  position: relative;
  outline: none;
}

.accessme-fab::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 30px;
  box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.5);
  animation: accessme-pulse 2.5s infinite;
}

.accessme-fab:hover {
  transform: scale(1.08) rotate(5deg);
}

.accessme-fab:active {
  transform: scale(0.95);
}

.accessme-fab svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
  transition: transform 0.3s ease;
}

.accessme-fab.accessme-open svg {
  transform: rotate(90deg);
}

/* Chat / Activity Panel Drawer */
.accessme-panel {
  width: 380px;
  height: 580px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 120px);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(216, 224, 236, 0.8);
  border-radius: 20px;
  box-shadow: 0 12px 40px rgba(24, 32, 51, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(30px) scale(0.95);
  transform-origin: bottom right;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

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

/* Header */
.accessme-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, #182033 0%, #0c101a 100%);
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.accessme-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.accessme-header-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.accessme-header-title span {
  color: #818cf8;
}

.accessme-header-subtitle {
  font-size: 11px;
  color: #94a3b8;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 5px;
}

.accessme-header-subtitle::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
}

.accessme-close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.accessme-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

/* Message Log Container */
.accessme-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #f8fafc;
}

/* Message Bubbles */
.accessme-message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: accessme-fade-in 0.25s ease-out forwards;
}

.accessme-message--user {
  align-self: flex-end;
}

.accessme-message--assistant {
  align-self: flex-start;
}

.accessme-message-content {
  padding: 12px 16px;
  font-size: 13.5px;
  line-height: 1.5;
  border-radius: 16px;
}

.accessme-message--user .accessme-message-content {
  background: #4f46e5;
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.15);
}

.accessme-message--assistant .accessme-message-content {
  background: #ffffff;
  color: #1e293b;
  border-bottom-left-radius: 4px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

/* Suggestion Chips */
.accessme-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
  margin-bottom: 4px;
}

.accessme-chip {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 16px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  color: #4f46e5;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.accessme-chip:hover {
  background: #f1f5f9;
  border-color: #4f46e5;
  transform: translateY(-1px);
}

.accessme-chip:active {
  transform: translateY(0);
}

/* Activity Steps (Progress Timeline) */
.accessme-activity-list {
  list-style: none;
  margin: 12px 0 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.accessme-activity-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-radius: 12px;
  padding: 10px 12px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  font-size: 12px;
}

.accessme-activity-item.working {
  background: #eef2ff;
  border-color: #c7d2fe;
}

.accessme-activity-item.working .accessme-activity-status {
  color: #4f46e5;
  display: flex;
  align-items: center;
  gap: 4px;
}

.accessme-activity-item.working .accessme-activity-status::after {
  content: '';
  width: 10px;
  height: 10px;
  border: 2px solid #4f46e5;
  border-top-color: transparent;
  border-radius: 50%;
  animation: accessme-spin 0.8s linear infinite;
}

.accessme-activity-label {
  font-weight: 600;
  color: #1e293b;
}

.accessme-activity-detail {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
  word-break: break-all;
}

.accessme-activity-status {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  color: #64748b;
  white-space: nowrap;
}

.accessme-activity-item[data-status="done"] .accessme-activity-status {
  color: #10b981;
}

.accessme-activity-item[data-status="blocked"] .accessme-activity-status {
  color: #ef4444;
}

/* Form Input Area */
.accessme-chat-form {
  display: flex;
  padding: 16px 20px;
  border-top: 1px solid #e2e8f0;
  background: #ffffff;
  gap: 8px;
}

.accessme-chat-input {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 24px;
  padding: 12px 18px;
  font-size: 13.5px;
  outline: none;
  transition: all 0.25s ease;
  background: #f8fafc;
}

.accessme-chat-input:focus {
  border-color: #4f46e5;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.accessme-chat-submit {
  width: 42px;
  height: 42px;
  background: #4f46e5;
  color: #ffffff;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  flex-shrink: 0;
  outline: none;
}

.accessme-chat-submit:hover {
  background: #4338ca;
  transform: scale(1.05);
}

.accessme-chat-submit:active {
  transform: scale(0.95);
}

.accessme-chat-submit:disabled {
  background: #94a3b8;
  cursor: not-allowed;
  transform: none;
}

.accessme-chat-submit svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Human Approval Flow UI Overlay */
.accessme-pause-ui {
  padding: 14px 16px;
  background: #fff5f5;
  border: 1px solid #fee2e2;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  width: 100%;
}

.accessme-pause-reason {
  font-size: 12px;
  color: #991b1b;
  font-weight: 600;
  line-height: 1.4;
}

.accessme-pause-actions {
  display: flex;
  gap: 8px;
}

.accessme-btn {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background 0.2s, transform 0.1s;
  outline: none;
}

.accessme-btn:active {
  transform: scale(0.97);
}

.accessme-btn-approve {
  background: #10b981;
  color: #ffffff;
}

.accessme-btn-approve:hover {
  background: #059669;
}

.accessme-btn-deny {
  background: #ef4444;
  color: #ffffff;
}

.accessme-btn-deny:hover {
  background: #dc2626;
}

/* Animations */
@keyframes accessme-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.4);
  }
  70% {
    box-shadow: 0 0 0 15px rgba(79, 70, 229, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(79, 70, 229, 0);
  }
}

@keyframes accessme-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes accessme-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Custom Scrollbar */
.accessme-messages::-webkit-scrollbar {
  width: 6px;
}
.accessme-messages::-webkit-scrollbar-track {
  background: transparent;
}
.accessme-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}
.accessme-messages::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
  #accessme-widget-root {
    bottom: 12px;
    right: 12px;
  }
  .accessme-panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 100px);
    max-height: calc(100vh - 100px);
    bottom: 0;
    right: 0;
  }
}

/* ─── Backwards Compatibility for Page-bound Activity (AHA) Panels ───── */
.aha-activity {
  margin: 16px 0 0;
  border: 1px solid #d8e0ec;
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
  max-width: 480px;
}

.aha-activity__title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #1f57d6;
  margin-bottom: 6px;
}

.aha-activity__step {
  font-size: 15px;
  font-weight: 700;
  color: #182033;
  margin-bottom: 8px;
}

.aha-activity__meta {
  display: grid;
  gap: 4px;
  font-size: 13px;
  color: #51607a;
}

.aha-activity__list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: grid;
  gap: 8px;
}

.aha-activity__item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border-radius: 12px;
  padding: 10px 12px;
  background: #f7f9fc;
}

.aha-activity__item[data-status="working"] {
  background: #e7efff;
}

.aha-activity__label {
  min-width: 0;
}

.aha-activity__label strong {
  display: block;
  font-size: 14px;
  color: #182033;
}

.aha-activity__label span {
  display: block;
  font-size: 12px;
  color: #65728a;
}

.aha-activity__status {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  color: #1f57d6;
  white-space: nowrap;
}
