/* ==========================================================================
   Cliply — Contextual AI & Custom Context Menu Styles (Zero Border Policy)
   ========================================================================== */

/* 1. Global Custom Context Menu */
.cliply-context-menu {
  position: fixed;
  z-index: 99999;
  background: var(--bg-surface, #ffffff);
  border-radius: 14px;
  border: none !important;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(0, 0, 0, 0.08);
  padding: 6px;
  min-width: 220px;
  display: none;
  flex-direction: column;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: cm-appear 0.15s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  user-select: none;
}

body.dark .cliply-context-menu {
  background: rgba(30, 41, 59, 0.95);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.25);
}

@keyframes cm-appear {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(-4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.cliply-context-menu.active {
  display: flex;
}

.cm-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text, #0f172a);
  cursor: pointer;
  border: none !important;
  transition: background 0.15s ease, color 0.15s ease;
  position: relative;
}

body.dark .cm-item {
  color: #f1f5f9;
}

.cm-item:hover {
  background: var(--bg-subtle, #f1f5f9);
}

body.dark .cm-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.cm-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cm-item-left i {
  font-size: 13px;
  width: 16px;
  text-align: center;
  color: var(--text-muted, #64748b);
}

.cm-shortcut {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted, #94a3b8);
  margin-left: 14px;
}

.cm-separator {
  height: 1px;
  background: var(--bg-subtle, #f1f5f9);
  margin: 4px 6px;
  border: none !important;
}

body.dark .cm-separator {
  background: rgba(255, 255, 255, 0.06);
}

/* AI Highlighted Item */
.cm-ai-highlight {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(168, 85, 247, 0.08));
  color: #6366f1 !important;
  font-weight: 600;
}

body.dark .cm-ai-highlight {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(168, 85, 247, 0.2));
  color: #a855f7 !important;
}

.cm-ai-highlight i.fa-wand-magic-sparkles {
  color: #6366f1;
}

body.dark .cm-ai-highlight i.fa-wand-magic-sparkles {
  color: #c084fc;
}

.cm-lock-tag {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  margin-left: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Submenu */
.cm-has-submenu:hover > .cm-submenu {
  display: flex;
}

.cm-submenu {
  position: absolute;
  left: 100%;
  top: -4px;
  margin-left: 4px;
  background: var(--bg-surface, #ffffff);
  border-radius: 14px;
  border: none !important;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
  padding: 6px;
  min-width: 230px;
  display: none;
  flex-direction: column;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: cm-appear 0.15s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

body.dark .cm-submenu {
  background: rgba(30, 41, 59, 0.95);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
}

.cm-submenu-header {
  padding: 8px 12px 6px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted, #94a3b8);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cm-badge-quota {
  background: var(--bg-subtle, #f1f5f9);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 600;
  color: #6366f1;
}

body.dark .cm-badge-quota {
  background: rgba(255, 255, 255, 0.08);
  color: #c084fc;
}

/* 2. Floating AI Selection Pill */
.cliply-ai-float-btn {
  position: fixed;
  z-index: 99998;
  display: none;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 24px;
  background: #0f172a;
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 600;
  border: none !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  user-select: none;
  animation: cm-appear 0.15s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

body.dark .cliply-ai-float-btn {
  background: #ffffff;
  color: #0f172a;
}

.cliply-ai-float-btn:hover {
  transform: scale(1.04);
}

.cliply-ai-float-btn i {
  font-size: 12px;
  color: #a855f7;
}

body.dark .cliply-ai-float-btn i {
  color: #7c3aed;
}

/* 3. AI Copilot Main Modal */
.ai-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border: none !important;
  animation: ai-fade-in 0.2s ease forwards;
}

.ai-modal-overlay.open {
  display: flex;
}

@keyframes ai-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.ai-modal-card {
  background: var(--bg-surface, #ffffff);
  border-radius: 20px;
  border: none !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: ai-card-pop 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

body.dark .ai-modal-card {
  background: #1e293b;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

@keyframes ai-card-pop {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.ai-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border: none !important;
}

.ai-modal-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-modal-icon-badge {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 16px;
  border: none !important;
}

.ai-modal-title-wrap h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text, #0f172a);
  display: flex;
  align-items: center;
  gap: 8px;
}

body.dark .ai-modal-title-wrap h3 {
  color: #f1f5f9;
}

.ai-modal-title-wrap span.ai-subtext {
  font-size: 12px;
  color: var(--text-muted, #64748b);
  display: block;
  margin-top: 2px;
}

.ai-modal-body {
  padding: 0 24px 20px 24px;
  overflow-y: auto;
  flex: 1;
}

/* Action Chips (Zero Border) */
.ai-action-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.ai-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--bg-subtle, #f1f5f9);
  color: var(--text, #0f172a);
  font-size: 12.5px;
  font-weight: 600;
  border: none !important;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

body.dark .ai-chip {
  background: rgba(255, 255, 255, 0.07);
  color: #e2e8f0;
}

.ai-chip:hover {
  background: #e2e8f0;
  transform: translateY(-1px);
}

body.dark .ai-chip:hover {
  background: rgba(255, 255, 255, 0.14);
}

.ai-chip.active {
  background: #0f172a;
  color: #ffffff;
}

body.dark .ai-chip.active {
  background: #ffffff;
  color: #0f172a;
}

/* Prompt Textarea (Zero Border) */
.ai-input-box {
  width: 100%;
  border-radius: 12px;
  border: none !important;
  background: var(--bg-subtle, #f8fafc);
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text, #0f172a);
  resize: vertical;
  min-height: 80px;
  outline: none;
  font-family: inherit;
  margin-bottom: 14px;
}

body.dark .ai-input-box {
  background: rgba(255, 255, 255, 0.05);
  color: #f1f5f9;
}

/* Shimmer Loading Animation */
.ai-loading-container {
  display: none;
  padding: 24px 16px;
  text-align: center;
}

.ai-loading-container.active {
  display: block;
}

.ai-shimmer-bar {
  height: 4px;
  width: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #6366f1 0%, #a855f7 50%, #6366f1 100%);
  background-size: 200% 100%;
  animation: cliply-ai-shimmer 1.5s infinite linear;
  margin-bottom: 16px;
  border: none !important;
}

@keyframes cliply-ai-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.ai-loading-pulse {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: #6366f1;
  animation: cliply-ai-pulse 1.4s infinite ease-in-out;
}

body.dark .ai-loading-pulse {
  color: #c084fc;
}

@keyframes cliply-ai-pulse {
  0%, 100% { opacity: 0.6; transform: scale(0.98); }
  50% { opacity: 1; transform: scale(1); }
}

/* Result Box (Zero Border) */
.ai-result-box {
  background: var(--bg-subtle, #f8fafc);
  border-radius: 14px;
  border: none !important;
  padding: 16px 18px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text, #0f172a);
  margin-top: 14px;
  max-height: 280px;
  overflow-y: auto;
  white-space: pre-wrap;
}

body.dark .ai-result-box {
  background: rgba(255, 255, 255, 0.05);
  color: #f1f5f9;
}

/* Cooldown Warning Notice */
.ai-cooldown-alert {
  display: none;
  background: rgba(245, 158, 11, 0.1);
  color: #d97706;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 14px;
  align-items: center;
  gap: 8px;
  border: none !important;
}

body.dark .ai-cooldown-alert {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.ai-cooldown-alert.active {
  display: flex;
}

/* 4. History View inside Modal */
.ai-history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 380px;
  overflow-y: auto;
}

.ai-history-item {
  background: var(--bg-subtle, #f8fafc);
  border-radius: 12px;
  padding: 12px 16px;
  border: none !important;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

body.dark .ai-history-item {
  background: rgba(255, 255, 255, 0.05);
}

.ai-history-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted, #94a3b8);
}

.ai-history-act {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #6366f1;
}

body.dark .ai-history-act {
  color: #c084fc;
}

.ai-history-prompt {
  font-size: 12.5px;
  color: var(--text-muted, #64748b);
  font-style: italic;
}

body.dark .ai-history-prompt {
  color: #94a3b8;
}

.ai-history-result {
  font-size: 13.5px;
  color: var(--text, #0f172a);
  line-height: 1.5;
  max-height: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.dark .ai-history-result {
  color: #f1f5f9;
}
