/* ── Tech AI Agent — Floating Widget ── */

:root {
  --taa-primary: #00d8db;
  --taa-primary-dark: #092533;
  --taa-primary-soft: #dffeff;
  --taa-accent-deep: #0f3e50;
  --taa-danger: #dc2626;
  --taa-danger-soft: #fef2f2;
  --taa-gray-50: #f9fafb;
  --taa-gray-100: #f3f4f6;
  --taa-gray-200: #e5e7eb;
  --taa-gray-300: #d1d5db;
  --taa-gray-400: #9ca3af;
  --taa-gray-600: #4b5563;
  --taa-gray-800: #1f2937;
  --taa-white: #ffffff;
  --taa-widget-w: 450px;
  --taa-widget-h: 650px;
  --taa-radius: 18px;
  --taa-btn-size: 56px;
}

/* ── Wrapper (fixed in the lower right corner) ── */
.taa-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--taa-gray-800);
  line-height: 1.5;
  filter: drop-shadow(0 18px 40px rgba(9, 37, 51, 0.18));
}

/* ── Toggle Button ── */
.taa-widget-toggle {
  width: var(--taa-btn-size);
  height: var(--taa-btn-size);
  border-radius: 50%;
  background: linear-gradient(145deg, var(--taa-primary) 0%, #14b8c4 48%, var(--taa-primary-dark) 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 12px 28px rgba(0, 216, 219, 0.28),
    0 4px 10px rgba(9, 37, 51, 0.28);
  transition:
    transform 0.2s,
    box-shadow 0.2s,
    background 0.2s;
  margin-left: auto;
  margin-bottom: 10px;
}
.taa-widget-toggle:hover {
  background: linear-gradient(145deg, #17e5e7 0%, var(--taa-primary) 42%, var(--taa-primary-dark) 100%);
  transform: translateY(-2px) scale(1.05);
  box-shadow:
    0 16px 36px rgba(0, 216, 219, 0.34),
    0 6px 14px rgba(9, 37, 51, 0.32);
}
.taa-widget-toggle .material-icons {
  font-size: 26px;
}

/* ── Panel ── */
.taa-widget-panel {
  width: var(--taa-widget-w);
  height: var(--taa-widget-h);
  background: linear-gradient(180deg, rgba(255, 255, 255, 1) 0%, rgba(247, 250, 251, 1) 100%);
  border-radius: var(--taa-radius);
  border: 1px solid rgba(0, 216, 219, 0.14);
  box-shadow:
    0 22px 60px rgba(9, 37, 51, 0.18),
    0 8px 20px rgba(9, 37, 51, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-bottom: 12px;
  animation: taaSlideUp 0.22s ease;
}

@keyframes taaSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── Header ── */
.taa-widget-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--taa-primary-dark) 0%, #103a4b 46%, var(--taa-primary) 160%);
  color: #fff;
  flex-shrink: 0;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.08);
}
.taa-widget-header .material-icons {
  font-size: 20px;
  opacity: 0.95;
}
.taa-widget-header strong {
  font-size: 15px;
  letter-spacing: 0.1px;
}

/* ── Back Button ── */
.taa-back-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  padding: 2px;
  border-radius: 50%;
  display: flex;
  flex-shrink: 0;
  transition:
    color 0.15s,
    background 0.15s,
    transform 0.15s;
}
.taa-back-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
  transform: translateX(-1px);
}
.taa-back-btn .dashicons {
  font-size: 18px;
  width: 18px;
  height: 18px;
}

/* Admin badge */
.taa-admin-badge {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

/* ── Static Body (for lock/subscribe screens) ── */
.taa-widget-body {
  flex: 1;
  padding: 24px 20px;
  overflow-y: auto;
  background:
    radial-gradient(circle at top center, rgba(0, 216, 219, 0.08), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #f8fbfc 100%);
}
.taa-widget-body--center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
}
.taa-widget-info-icon {
  font-size: 48px !important;
  color: #7aaab1;
}
.taa-widget-body p {
  margin: 0;
  color: var(--taa-gray-600);
}
.taa-widget-btn {
  display: inline-block;
  padding: 9px 24px;
  background: linear-gradient(135deg, var(--taa-primary) 0%, #17c7cf 58%, #14aab6 100%);
  color: #fff;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
  box-shadow: 0 8px 18px rgba(0, 216, 219, 0.24);
  transition:
    transform 0.15s,
    box-shadow 0.15s,
    background 0.15s;
}
.taa-widget-btn:hover {
  background: linear-gradient(135deg, #1be8ea 0%, var(--taa-primary) 56%, #15a8b1 100%);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(0, 216, 219, 0.28);
}
.taa-widget-btn--sm {
  padding: 4px 12px;
  font-size: 12px;
  border-radius: 6px;
  margin-left: 6px;
}

/* ── Usage bar (in the panel) ── */
.taa-widget-usage {
  padding: 8px 14px;
  border-bottom: 1px solid rgba(9, 37, 51, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(245, 250, 251, 0.96) 100%);
  flex-shrink: 0;
}
.taa-widget-usage-text {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--taa-gray-600);
  margin-bottom: 4px;
}
.taa-usage-bar {
  height: 6px;
  background: linear-gradient(180deg, #dce8ea 0%, #edf3f4 100%);
  border-radius: 999px;
  overflow: hidden;
}
.taa-usage-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--taa-primary) 0%, #2ce4e2 100%);
  border-radius: 999px;
  transition: width 0.4s;
}
.taa-usage-bar-fill--danger {
  background: var(--taa-danger);
}

/* Limit Exhausted */
.taa-widget-limit-msg {
  padding: 8px 14px;
  background: linear-gradient(180deg, var(--taa-danger-soft) 0%, #fff5f5 100%);
  color: var(--taa-danger);
  font-size: 12px;
  text-align: center;
  flex-shrink: 0;
  border-top: 1px solid rgba(220, 38, 38, 0.08);
  border-bottom: 1px solid rgba(220, 38, 38, 0.08);
}

/* ── Agent Selection ── */
.taa-widget-agents {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background:
    radial-gradient(circle at top right, rgba(0, 216, 219, 0.08), transparent 28%),
    linear-gradient(180deg, #fbfdfe 0%, #f7fafb 100%);
}
.taa-widget-agents__title {
  margin: 0 0 12px;
  font-weight: 600;
  color: #58707a;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
}
.taa-widget-agents__grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.taa-widget-agent-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(9, 37, 51, 0.08);
  border-radius: 14px;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 4px 12px rgba(9, 37, 51, 0.04);
  transition:
    border-color 0.15s,
    background 0.15s,
    transform 0.15s,
    box-shadow 0.15s;
  width: 100%;
}
.taa-widget-agent-card:hover {
  border-color: rgba(0, 216, 219, 0.42);
  background: linear-gradient(135deg, #ffffff 0%, #eefefe 100%);
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(9, 37, 51, 0.08);
}
.taa-widget-agent-card .material-icons {
  font-size: 22px;
  color: var(--taa-primary-dark);
  flex-shrink: 0;
}
.taa-widget-agent-card span:last-child {
  font-weight: 600;
  color: var(--taa-gray-800);
}

/* ── Messages ── */
.taa-widget-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background:
    radial-gradient(circle at top left, rgba(0, 216, 219, 0.06), transparent 24%),
    linear-gradient(180deg, #fbfdfe 0%, #f4f8f9 100%);
}
.taa-message {
  display: flex;
}
.taa-message--user {
  justify-content: flex-end;
}
.taa-message--assistant {
  justify-content: flex-start;
}
.taa-message__bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 8px 18px rgba(9, 37, 51, 0.06);
}
.taa-message--user .taa-message__bubble {
  background: linear-gradient(135deg, var(--taa-primary-dark) 0%, #103c4d 48%, #0e5267 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.taa-message--assistant .taa-message__bubble {
  background: rgba(255, 255, 255, 0.96);
  color: var(--taa-gray-800);
  border: 1px solid rgba(9, 37, 51, 0.08);
  border-bottom-left-radius: 4px;
}
.taa-message--assistant .taa-message__bubble strong {
  color: var(--taa-primary-dark);
}

/* Typing dots */
.taa-typing .taa-message__bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
}
.taa-typing-dot {
  width: 7px;
  height: 7px;
  background: #6e8f97;
  border-radius: 50%;
  animation: taaTyping 1.2s infinite;
}
.taa-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}
.taa-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes taaTyping {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* ── Input footer ── */
.taa-widget-footer {
  padding: 10px 12px;
  border-top: 1px solid rgba(9, 37, 51, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(247, 251, 252, 0.98) 100%);
  flex-shrink: 0;
}
.taa-chat__input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(9, 37, 51, 0.12);
  border-radius: 22px;
  padding: 5px 5px 5px 12px;
  box-shadow: inset 0 1px 2px rgba(9, 37, 51, 0.03);
  transition:
    border-color 0.15s,
    box-shadow 0.15s,
    background 0.15s;
}
.taa-chat__input-wrap:focus-within {
  border-color: rgba(0, 216, 219, 0.72);
  background: #fff;
  box-shadow:
    0 0 0 4px rgba(0, 216, 219, 0.1),
    inset 0 1px 2px rgba(9, 37, 51, 0.02);
}
.taa-chat__input {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  font-size: 13px;
  line-height: 1.5;
  max-height: 100px;
  outline: none;
  font-family: inherit;
  padding: 3px 0;
  color: var(--taa-gray-800);
}
.taa-chat__input::placeholder {
  color: #7b8f97;
}
.taa-chat__send {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--taa-primary) 0%, #14c6cb 60%, #11a7b2 100%);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 14px rgba(0, 216, 219, 0.24);
  transition:
    transform 0.15s,
    background 0.15s,
    box-shadow 0.15s;
}
.taa-chat__send:hover {
  background: linear-gradient(135deg, #18e6e8 0%, var(--taa-primary) 56%, #10a5ae 100%);
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(0, 216, 219, 0.28);
}
.taa-chat__send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.taa-chat__send .dashicons {
  font-size: 16px;
  width: 16px;
  height: 16px;
}

/* ── Responsive ── */
@media (max-width: 500px) {
  .taa-widget {
    bottom: 12px;
    right: 12px;
    height: 90svh;
    top: 10px;
  }
  .taa-widget-panel {
    width: calc(100vw - 24px);
    height: 100%;
  }
}
