/* OAP Widget Styles - Namespaced to avoid conflicts */
:root {
  --oap-bg: #ffffff;
  --oap-text: #1f2937;
  --oap-accent: #6b46c1; /* TrueSky Purple */
  --oap-accent-hover: #553c9a;
  --oap-border: #e5e7eb;
  --oap-outline: 2px dashed #6b46c1;
  --oap-outline-hover: 2px solid #6b46c1;
  --oap-font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

.oap-widget-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999999;
  font-family: var(--oap-font);
  color: var(--oap-text);
}

.oap-toggle-btn {
  background: var(--oap-bg);
  color: var(--oap-text);
  border: 1px solid var(--oap-border);
  border-radius: 50px;
  padding: 10px 20px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.oap-toggle-btn.active {
  background: var(--oap-accent);
  color: white;
  border-color: var(--oap-accent);
}

.oap-marker {
  position: absolute;
  top: -10px;
  right: -10px;
  background: #ef4444;
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  z-index: 99999;
  pointer-events: none;
}

body.oap-active .oap-hoverable {
  outline: var(--oap-outline);
  cursor: pointer;
  position: relative;
  transition: outline 0.1s;
}

body.oap-active .oap-hoverable:hover {
  outline: var(--oap-outline-hover);
  background: rgba(107, 70, 193, 0.05);
}

.oap-popover {
  position: fixed;
  bottom: 75px;
  right: 20px;
  left: auto !important;
  top: auto !important;
  background: rgba(248, 250, 252, 0.72) !important;
  backdrop-filter: blur(24px) saturate(200%);
  -webkit-backdrop-filter: blur(24px) saturate(200%);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 14px;
  padding: 16px;
  width: 360px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 25px 35px -5px rgba(0, 0, 0, 0.18), 0 10px 15px -5px rgba(0, 0, 0, 0.08);
  z-index: 1000000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: var(--oap-text) !important;
  font-family: var(--oap-font);
}

.oap-popover h3 {
  margin: 0 0 2px 0;
  font-size: 17px;
  font-weight: 700;
  color: #111827 !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.oap-target-badge {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.85);
  color: #4b5563;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 600;
  border: 1px solid rgba(229, 231, 235, 0.9);
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.oap-frame {
  background: rgba(255, 255, 255, 0.52) !important;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 2px solid #ffffff !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

.oap-frame-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  color: #4b5563;
  margin: -2px 0 2px 0;
  letter-spacing: 0.5px;
}

/* Tree Structure Styles */
.oap-tree-container {
  max-height: 170px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.40);
  border: 1px solid rgba(209, 213, 219, 0.5);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  user-select: none;
}

.oap-tree-node {
  margin: 2px 0;
}

.oap-tree-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.12s;
  color: #1f2937;
}

.oap-tree-row:hover {
  background: rgba(107, 70, 193, 0.12);
}

.oap-tree-row.selected {
  background: #6b46c1 !important;
  color: #ffffff !important;
  font-weight: 600;
}

.oap-tree-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 11px;
  font-family: monospace;
  font-weight: bold;
  cursor: pointer;
  border-radius: 2px;
  color: #4b5563;
}

.oap-tree-row.selected .oap-tree-toggle {
  color: #ffffff;
}

.oap-tree-toggle.leaf {
  cursor: default;
  color: #9ca3af;
}

.oap-tree-children {
  margin-left: 14px;
  border-left: 1px dashed rgba(156, 163, 175, 0.4);
  padding-left: 4px;
}

.oap-tree-children.collapsed {
  display: none !important;
}

/* Star Rating Styles */
.oap-star-rating {
  display: inline-flex;
  gap: 4px;
  font-size: 22px;
  cursor: pointer;
  user-select: none;
  line-height: 1;
  padding: 4px 0;
}

.oap-star {
  color: #d1d5db;
  transition: color 0.15s, transform 0.1s;
}

.oap-star:hover {
  transform: scale(1.18);
}

.oap-star.active {
  color: #f59e0b;
  text-shadow: 0 0 6px rgba(245, 158, 11, 0.45);
}

/* Visibility Icon Group */
.oap-icon-group {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(209, 213, 219, 0.6);
  border-radius: 6px;
  padding: 2px;
}

.oap-icon-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 5px 6px;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.oap-icon-btn:hover {
  background: rgba(107, 70, 193, 0.1);
  color: #6b46c1;
}

.oap-icon-btn.active {
  background: #6b46c1;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.oap-popover .oap-row {
  display: flex;
  gap: 10px;
}

.oap-popover .oap-col {
  flex: 1;
}

.oap-popover label {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 5px;
  display: block;
}

.oap-popover input[type="text"], 
.oap-popover input[type="number"], 
.oap-popover input[type="date"], 
.oap-popover textarea, 
.oap-popover select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid rgba(209, 213, 219, 0.7);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.65);
  color: #111827;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.oap-popover input:focus, 
.oap-popover textarea:focus, 
.oap-popover select:focus {
  outline: none;
  border-color: var(--oap-accent);
  box-shadow: 0 0 0 2px rgba(107, 70, 193, 0.2);
  background: rgba(255, 255, 255, 0.95);
}

.oap-popover textarea {
  min-height: 80px;
  resize: vertical;
}

.oap-file-input {
  font-size: 12px;
  color: #4b5563;
}

.oap-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.oap-btn {
  background: var(--oap-accent);
  color: white;
  border: none;
  padding: 10px 14px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  flex: 2;
  text-align: center;
  font-size: 14px;
  transition: background 0.15s;
}

.oap-btn:hover {
  background: var(--oap-accent-hover);
}

.oap-btn-cancel {
  background: #ffffff;
  color: #374151;
  border: 1px solid #d1d5db;
  padding: 10px 14px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  flex: 1;
  text-align: center;
  font-size: 14px;
  transition: background 0.15s;
}

.oap-btn-cancel:hover {
  background: #f3f4f6;
}

.oap-hidden {
  display: none !important;
}

/* Submit Combo Button with integrated Star Rating */
.oap-submit-combo-btn {
  width: 100%;
  background: linear-gradient(135deg, #6b46c1 0%, #553c9a 100%);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 10px rgba(107, 70, 193, 0.35);
  transition: all 0.2s ease;
  user-select: none;
  box-sizing: border-box;
}

.oap-submit-combo-btn:hover {
  background: linear-gradient(135deg, #5b37b0 0%, #44337a 100%);
  box-shadow: 0 6px 14px rgba(107, 70, 193, 0.45);
  transform: translateY(-1px);
}

.oap-submit-combo-btn:active {
  transform: translateY(0);
}

.oap-submit-combo-btn.oap-btn-success {
  background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.4) !important;
}

.oap-submit-combo-btn.oap-btn-error {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%) !important;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4) !important;
}

.oap-submit-combo-btn .oap-submit-text {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.oap-submit-combo-btn .oap-submit-divider {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.35);
  margin: 0 8px;
}

.oap-submit-combo-btn .oap-star-rating {
  display: inline-flex;
  gap: 3px;
  font-size: 20px;
  line-height: 1;
  padding: 2px 2px;
}

.oap-popover.oap-minimized .oap-widget-body {
  display: none !important;
}

.oap-popover.oap-minimized {
  max-height: 52px !important;
  padding: 10px 14px !important;
  overflow: hidden !important;
  width: 350px !important;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15) !important;
}

.oap-popover.oap-fullscreen {
  position: fixed !important;
  top: 4vh !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  width: 90vw !important;
  max-width: 820px !important;
  height: 92vh !important;
  max-height: 92vh !important;
  bottom: auto !important;
  right: auto !important;
  z-index: 1000005 !important;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.35) !important;
}

.oap-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(229, 231, 235, 0.8);
  margin-bottom: 2px;
}

.oap-widget-title-area {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.oap-widget-title {
  font-weight: 700;
  font-size: 14px;
  color: #111827;
  white-space: nowrap;
}

.oap-window-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.oap-win-btn {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(209, 213, 219, 0.9);
  border-radius: 6px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #4b5563;
  cursor: pointer;
  line-height: 1;
  transition: all 0.15s ease;
  padding: 0;
  user-select: none;
}

.oap-win-btn:hover {
  background: #f3f4f6;
  color: #111827;
  border-color: #9ca3af;
}

.oap-win-close:hover {
  background: #fee2e2 !important;
  border-color: #fca5a5 !important;
  color: #dc2626 !important;
}

.oap-submit-combo-btn .oap-star {
  color: rgba(255, 255, 255, 0.28) !important;
  transition: color 0.12s ease, transform 0.1s ease;
  cursor: pointer;
  display: inline-block;
  user-select: none;
}

.oap-submit-combo-btn .oap-star.active {
  color: #fbbf24 !important;
  text-shadow: 0 0 8px rgba(251, 191, 36, 0.8) !important;
}

.oap-submit-combo-btn .oap-star.dimmed {
  color: rgba(255, 255, 255, 0.25) !important;
  text-shadow: none !important;
}

.oap-submit-combo-btn .oap-star:hover {
  transform: scale(1.3);
}

/* Feedback Messages */
.oap-feedback-msg {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  margin-top: 8px;
  animation: oapFadeIn 0.2s ease;
  line-height: 1.4;
}

.oap-feedback-success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #6ee7b7;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.15);
}

.oap-feedback-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fca5a5;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.15);
}

.oap-input-error {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25) !important;
  animation: oapShake 0.3s ease;
}

@keyframes oapShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

@keyframes oapFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Success Toast Bubble directly above OnPage Prompt toggle */
.oap-success-toast {
  position: fixed;
  bottom: 75px;
  right: 20px;
  z-index: 1000000;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 10px 25px -3px rgba(16, 185, 129, 0.45), 0 4px 10px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.4);
  font-family: var(--oap-font);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  animation: oapToastSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 320px;
  user-select: none;
}

.oap-success-toast:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 14px 30px -3px rgba(16, 185, 129, 0.55), 0 6px 14px rgba(0, 0, 0, 0.18);
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.oap-toast-body {
  display: flex;
  align-items: center;
  gap: 10px;
}

.oap-toast-icon {
  font-size: 24px;
  line-height: 1;
}

.oap-toast-content {
  flex: 1;
  min-width: 0;
}

.oap-toast-title {
  font-weight: 700;
  font-size: 13px;
  color: #ffffff;
  line-height: 1.3;
}

.oap-toast-sub {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.9);
  margin-top: 2px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.oap-toast-close {
  background: rgba(0, 0, 0, 0.18);
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease;
  margin-left: 6px;
  flex-shrink: 0;
}

.oap-toast-close:hover {
  background: rgba(0, 0, 0, 0.35);
}

.oap-toast-fadeout {
  opacity: 0;
  transform: translateY(10px) scale(0.95);
  transition: all 0.35s ease;
}

@keyframes oapToastSlideUp {
  from {
    opacity: 0;
    transform: translateY(15px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
