/* ==============================================================================
   RAYMA SHOPEE HUB — UTM LINK MANAGER & AI COMMAND TIMELINE WIDGET
   Design System: Enterprise Modern Light Mode
   ============================================================================== */

/* --- TOAST NOTIFICATION --- */
.rayma-utm-toast {
  position: fixed;
  top: 20px;
  right: 24px;
  z-index: 100000;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: #0f172a;
  color: #ffffff;
  border-radius: 10px;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.35), 0 8px 10px -6px rgba(15, 23, 42, 0.2);
  font-family: 'Plus Jakarta Sans', Inter, -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  opacity: 0;
  transform: translateY(-15px) scale(0.96);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}
.rayma-utm-toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.rayma-utm-toast-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #10b981;
  color: #ffffff;
  font-size: 11px;
}

/* --- HEADER BUTTON: SAO CHÉP LINK (UTM) --- */
.header-utm-btn {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  background: #eff6ff !important;
  color: #2563eb !important;
  border: 1px solid #bfdbfe !important;
  font-weight: 600 !important;
  font-size: 12px !important;
  padding: 0 12px !important;
  height: 32px !important;
  border-radius: 6px !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
  white-space: nowrap !important;
}
.header-utm-btn:hover {
  background: #dbeafe !important;
  border-color: #93c5fd !important;
  color: #1d4ed8 !important;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.12) !important;
}
.header-utm-btn:active {
  transform: scale(0.97);
}

/* --- WIDGET CONTAINER --- */
.rayma-cmd-widget-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  font-family: 'Plus Jakarta Sans', Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #0f172a;
  box-sizing: border-box;
}

.rayma-cmd-widget-container * {
  box-sizing: border-box;
}

/* --- FLOATING TRIGGER BUTTON (COLLAPSED) --- */
.rayma-cmd-trigger-btn {
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  border: 2px solid #ffffff;
  box-shadow: 0 10px 25px -3px rgba(37, 99, 235, 0.45), 0 4px 6px -2px rgba(37, 99, 235, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}
.rayma-cmd-trigger-btn:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 14px 28px -4px rgba(37, 99, 235, 0.55), 0 6px 10px -3px rgba(37, 99, 235, 0.25);
}
.rayma-cmd-trigger-btn:active {
  transform: scale(0.95);
}
.rayma-cmd-trigger-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ef4444;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* --- TIMELINE CHAT POPUP WINDOW (EXPANDED) --- */
.rayma-cmd-popup {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 390px;
  height: 580px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 20px 25px -5px rgba(15, 23, 42, 0.15), 0 10px 10px -5px rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: scale(0.92) translateY(20px);
  transform-origin: bottom right;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}
.rayma-cmd-popup.open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

/* POPUP HEADER */
.rayma-cmd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
.rayma-cmd-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.rayma-cmd-icon-box {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #2563eb;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  box-shadow: 0 2px 5px rgba(37, 99, 235, 0.3);
}
.rayma-cmd-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
}
.rayma-cmd-subtitle {
  font-size: 11px;
  color: #64748b;
  margin-top: 1px;
}
.rayma-cmd-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.rayma-cmd-head-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.rayma-cmd-head-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* STATUS FILTER BAR */
.rayma-cmd-filter-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: #ffffff;
  border-bottom: 1px solid #f1f5f9;
}
.rayma-filter-pill {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
}
.rayma-filter-pill:hover {
  background: #f1f5f9;
  color: #0f172a;
}
.rayma-filter-pill.active {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #2563eb;
}

/* TIMELINE BODY */
.rayma-cmd-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
}
.rayma-cmd-body::-webkit-scrollbar {
  width: 5px;
}
.rayma-cmd-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

/* EMPTY STATE */
.rayma-cmd-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  text-align: center;
  color: #64748b;
}
.rayma-cmd-empty-icon {
  font-size: 32px;
  color: #cbd5e1;
  margin-bottom: 12px;
}
.rayma-cmd-empty-text {
  font-size: 12.5px;
  font-weight: 500;
  max-width: 240px;
  line-height: 1.4;
}

/* TIMELINE NODE CARD */
.rayma-node-card {
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  transition: all 0.2s ease;
}
.rayma-node-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
}

.rayma-node-header {
  padding: 10px 12px;
  background: #ffffff;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.rayma-node-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.rayma-badge-shop {
  padding: 2px 7px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #0f172a;
  font-size: 10.5px;
  font-weight: 700;
  border: 1px solid #e2e8f0;
}
.rayma-badge-sku {
  padding: 2px 7px;
  border-radius: 4px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 10.5px;
  font-weight: 700;
  border: 1px solid #bfdbfe;
  font-family: monospace;
}
.rayma-badge-status {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.rayma-badge-status.PENDING {
  background: #fef3c7;
  color: #b45309;
}
.rayma-badge-status.CHECKING {
  background: #e0f2fe;
  color: #0369a1;
}
.rayma-badge-status.EXECUTING {
  background: #ede9fe;
  color: #6d28d9;
}
.rayma-badge-status.COMPLETED {
  background: #dcfce7;
  color: #15803d;
}

.rayma-node-time {
  font-size: 10px;
  color: #94a3b8;
  font-weight: 500;
  white-space: nowrap;
}

.rayma-node-cmd-text {
  padding: 8px 12px;
  font-size: 12px;
  color: #1e293b;
  font-weight: 500;
  line-height: 1.4;
  background: #ffffff;
}

/* MANDATE SPECS ACCORDION / BOX */
.rayma-node-mandate {
  margin: 0 12px 8px 12px;
  padding: 8px 10px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  font-size: 11px;
}
.rayma-mandate-title {
  font-weight: 700;
  color: #334155;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.rayma-mandate-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
  color: #475569;
}
.rayma-mandate-item {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.rayma-mandate-item i {
  color: #10b981;
  font-size: 9px;
}

/* THREAD REPLIES (NESTED RESPONSES) */
.rayma-node-threads {
  border-top: 1px solid #f1f5f9;
  background: #fafafa;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rayma-thread-reply {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  font-size: 11.5px;
}
.rayma-reply-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.rayma-reply-sender {
  font-weight: 700;
  color: #2563eb;
  display: flex;
  align-items: center;
  gap: 4px;
}
.rayma-reply-time {
  font-size: 10px;
  color: #94a3b8;
}
.rayma-reply-content {
  color: #334155;
  line-height: 1.4;
  white-space: pre-wrap;
}

/* DETAILS TABLE / PILLS IN THREAD */
.rayma-reply-sizes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.rayma-size-pill {
  padding: 1px 6px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #1e293b;
  font-size: 10.5px;
  font-weight: 600;
}
.rayma-size-pill.pass {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}
.rayma-size-pill.fail {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* AUDIT & LARK STATUS IN THREAD */
.rayma-reply-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed #e2e8f0;
  font-size: 10.5px;
}
.rayma-audit-badge {
  color: #059669;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}
.rayma-lark-badge {
  color: #0284c7;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* FOOTER INPUT AREA */
.rayma-cmd-footer {
  padding: 10px 12px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rayma-quick-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.rayma-quick-pills::-webkit-scrollbar {
  display: none;
}
.rayma-quick-pill {
  white-space: nowrap;
  padding: 3px 8px;
  border-radius: 12px;
  background: #f1f5f9;
  color: #475569;
  font-size: 10.5px;
  font-weight: 600;
  border: 1px solid #e2e8f0;
  cursor: pointer;
  transition: all 0.15s ease;
}
.rayma-quick-pill:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.rayma-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rayma-cmd-input {
  flex: 1;
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  font-size: 12.5px;
  font-family: inherit;
  color: #0f172a;
  background: #f8fafc;
  outline: none;
  transition: all 0.15s ease;
}
.rayma-cmd-input:focus {
  background: #ffffff;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.rayma-cmd-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #2563eb;
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 13px;
}
.rayma-cmd-send-btn:hover {
  background: #1d4ed8;
}
.rayma-cmd-send-btn:active {
  transform: scale(0.95);
}
.rayma-cmd-send-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}
