/* ================================================================
   RESOLVIT AI COPILOT — Premium Neural Assistant Styling
   ================================================================ */

/* --- FLOATING ORB (LAUNCHER) --- */
.copilot-launcher {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9000;
  box-shadow: 0 8px 30px rgba(99, 102, 241, 0.5);
  transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow: visible;
}

/* AI Launcher Glow Ring */
.copilot-launcher::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid rgba(165, 180, 252, 0.5);
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.4s ease;
}

.copilot-launcher:hover::after {
  opacity: 1;
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(165, 180, 252, 0.4);
}

.copilot-launcher::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  opacity: 0.3;
  filter: blur(8px);
  z-index: -1;
  animation: orb-pulse 2s infinite ease-in-out;
}

@keyframes orb-pulse {
  0% { transform: scale(1); opacity: 0.3; box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
  50% { transform: scale(1.15); opacity: 0.15; box-shadow: 0 0 0 15px rgba(99, 102, 241, 0); }
  100% { transform: scale(1); opacity: 0.3; box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

/* --- PREMIUM AI IDENTITY TOKENS --- */
.ai-premium-identity {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.ai-neural-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 1.5px solid rgba(165, 180, 252, 0.3);
  animation: neural-rotate 8s linear infinite;
}

.ai-spark-glow {
  position: absolute;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(165, 180, 252, 0.4) 0%, transparent 70%);
  filter: blur(4px);
  animation: neural-flicker 3s infinite ease-in-out;
}

@keyframes neural-rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes neural-flicker {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 0.8; transform: scale(1.1); }
}

.copilot-launcher:hover {
  transform: scale(1.05) translateY(-5px);
  box-shadow: 0 12px 40px rgba(168, 85, 247, 0.6);
}

.copilot-launcher i {
  color: white;
  font-size: 1.5rem;
  transition: transform 0.3s ease;
}

.copilot-launcher.active i {
  transform: rotate(90deg);
}

/* --- MAIN PANEL (SIDEBAR) --- */
.copilot-panel {
  position: fixed;
  top: 20px;
  right: -420px;
  width: 400px;
  max-width: calc(100vw - 40px);
  height: calc(100dvh - 40px);
  max-height: 800px;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  z-index: 8999;
  display: flex;
  flex-direction: column;
  transition: right 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: -10px 0 50px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255,255,255,0.05);
  overflow: hidden;
}

.copilot-panel.open {
  right: 20px;
}

/* --- HEADER --- */
.copilot-header {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), transparent);
}

.copilot-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.copilot-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1rem;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

.copilot-title-container {
  display: flex;
  flex-direction: column;
}

.copilot-title {
  color: white;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.copilot-status {
  font-size: 0.75rem;
  color: #10b981;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
}

.copilot-status-dot {
  width: 6px;
  height: 6px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
}

/* --- MESSAGES AREA --- */
.copilot-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

.copilot-messages::-webkit-scrollbar { width: 4px; }
.copilot-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* BUBBLES */
.msg-container {
  display: flex;
  flex-direction: column;
  max-width: 90%;
  animation: msgFadeIn 0.3s ease forwards;
}

@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-user {
  align-self: flex-end;
  align-items: flex-end;
}
.msg-user .msg-bubble {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: white;
  border-radius: 18px 18px 4px 18px;
  padding: 12px 18px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.msg-ai {
  align-self: flex-start;
  align-items: flex-start;
  max-width: 95%;
  position: relative;
  padding-left: 42px;
}

.ai-avatar {
  position: absolute;
  left: 0;
  top: 0;
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #4f46e5, #9333ea);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-avatar i {
  filter: drop-shadow(0 0 5px rgba(255,255,255,0.5));
}

.msg-ai .msg-bubble {
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(10px);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px 18px 18px 18px;
  padding: 16px 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.msg-bubble p {
  margin: 0 0 10px 0;
}
.msg-bubble p:last-child {
  margin: 0;
}
.msg-bubble strong {
  color: #a5b4fc;
}

/* RAG Source Chips */
.rag-sources {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.rag-chip {
  background: rgba(168, 85, 247, 0.1);
  border: 1px solid rgba(168, 85, 247, 0.3);
  color: #c084fc;
  font-size: 0.7rem;
  padding: 4px 10px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
}

/* Formatting inside AI */
.msg-ai pre {
  background: rgba(0,0,0,0.3);
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #cbd5e1;
  border: 1px solid rgba(255,255,255,0.05);
}

.msg-ai .msg-bubble h1, .msg-ai .msg-bubble h2, .msg-ai .msg-bubble h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: white;
  margin: 14px 0 8px 0;
  line-height: 1.4;
}

.msg-ai .msg-bubble h4, .msg-ai .msg-bubble h5 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #c4b5fd;
  margin: 12px 0 6px 0;
}

.msg-ai .msg-bubble ul, .msg-ai .msg-bubble ol {
  margin: 8px 0 12px 0;
  padding-left: 20px;
}

.msg-ai .msg-bubble li {
  margin-bottom: 6px;
  color: #f1f5f9;
  line-height: 1.6;
}

.msg-ai .msg-bubble p {
  color: #e2e8f0;
  line-height: 1.7;
  font-size: 0.95rem;
}

.msg-ai .msg-bubble strong {
  font-weight: 600;
  color: #a5b4fc;
}

/* --- INPUT AREA --- */
.copilot-footer {
  padding: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(0deg, rgba(15,23,42,0.95), rgba(15,23,42,0.6));
}

.copilot-suggestions {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 8px;
}
.copilot-suggestions::-webkit-scrollbar { display: none; }
.copilot-suggestion-chip {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  font-size: 0.8rem;
  padding: 8px 14px;
  border-radius: 100px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
}
.copilot-suggestion-chip:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
  color: white;
}

.copilot-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 4px;
  transition: border-color 0.3s;
}
.copilot-input-wrapper:focus-within {
  border-color: #8b5cf6;
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.2);
}

.copilot-input {
  flex: 1;
  background: transparent;
  border: none;
  color: white;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
}
.copilot-input::placeholder {
  color: #64748b;
}

.copilot-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: none;
  background: transparent;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}
.copilot-btn:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.copilot-send-btn {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: white;
  margin-left: 4px;
}
.copilot-send-btn:hover {
  transform: scale(1.05);
  background: linear-gradient(135deg, #a855f7, #6366f1);
}

/* Typing Indicator Animation */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
}
.typing-dot {
  width: 6px;
  height: 6px;
  background: #a5b4fc;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

@media (max-width: 480px) {
  .copilot-panel {
    top: 0;
    bottom: 0;
    right: -100vw;
    width: 100vw;
    border-radius: 0;
    border: none;
  }
  .copilot-panel.open {
    right: 0;
  }
}

/* --- AUTH GATE & MINI FORM --- */
.auth-gate-card {
  text-align: center;
  border: 1px solid rgba(239, 68, 68, 0.4) !important;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(15, 23, 42, 0.8)) !important;
}

.copilot-card-btn {
  flex: 1;
  padding: 10px 0;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  transition: transform 0.2s, filter 0.2s;
}
.copilot-card-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}
.copilot-card-btn.primary {
  background: white;
  color: #0f172a;
}
.copilot-card-btn.secondary {
  background: rgba(255,255,255,0.1);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
}

.mini-form-card {
  border: 1px solid rgba(139, 92, 246, 0.4) !important;
  background: linear-gradient(180deg, rgba(30, 27, 75, 0.9), rgba(15, 23, 42, 0.95)) !important;
  width: 100%;
}
.mini-form-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #c4b5fd;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(139, 92, 246, 0.2);
}
.copilot-mini-form .form-group {
  margin-bottom: 12px;
}
.copilot-mini-form label {
  display: block;
  font-size: 0.75rem;
  color: #94a3b8;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.copilot-mini-form input,
.copilot-mini-form select,
.copilot-mini-form textarea {
  width: 100%;
  background: rgba(0,0,0,0.3) !important;
  border: 1px solid rgba(255,255,255,0.1);
  color: white;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.85rem;
  font-family: inherit;
  transition: all 0.3s;
  box-sizing: border-box;
}
.copilot-mini-form input:focus,
.copilot-mini-form select:focus,
.copilot-mini-form textarea:focus {
  outline: none;
  border-color: #8b5cf6;
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.1);
}
.copilot-mini-form textarea {
  resize: vertical;
  min-height: 60px;
}
.copilot-submit-btn {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.copilot-submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

@media (max-width: 768px) {
  .copilot-panel {
    width: calc(100vw - 20px);
    right: calc(-100vw - 40px);
    top: 10px;
    height: calc(100dvh - 20px);
    border-radius: 16px;
  }
  .copilot-panel.open {
    right: 10px;
  }
  .copilot-messages {
    padding: 16px;
  }
  .msg-ai .msg-bubble, .msg-user .msg-bubble {
    padding: 12px 16px;
    font-size: 0.85rem;
  }
}
/* --- PRODUCTION FLOW COMPONENTS --- */
.category-picker .chip-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 10px;
}
.category-chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    padding: 8px 12px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    text-align: center;
}
.category-chip:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: #6366f1;
    color: white;
}

.location-picker, .severity-picker {
    width: 100%;
    margin-top: 10px;
}
.gps-btn {
    width: 100%;
    background: linear-gradient(135deg, #0ea5e9, #3b82f6) !important;
    color: white !important;
    padding: 12px !important;
    font-weight: 700 !important;
}

/* Severity Slider Customization */
input[type=range] {
    -webkit-appearance: none;
    background: transparent;
}
input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 18px;
    width: 18px;
    border-radius: 50%;
    background: #8b5cf6;
    margin-top: -6px;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
    cursor: pointer;
}

.preview-card {
    border: 1px solid rgba(165, 180, 252, 0.3) !important;
    background: rgba(15, 23, 42, 0.8) !important;
}
.preview-header {
    font-weight: 700;
    color: #a5b4fc;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 8px;
}
.preview-item {
    font-size: 0.85rem;
    margin-bottom: 8px;
    color: #e2e8f0;
}
.preview-item strong {
    color: #94a3b8;
    margin-right: 5px;
}

.success-card {
    text-align: center;
    border: 1px solid rgba(16, 185, 129, 0.3) !important;
    background: linear-gradient(180deg, rgba(6, 78, 59, 0.2), rgba(15, 23, 42, 0.9)) !important;
}
.success-icon {
    font-size: 3rem;
    color: #10b981;
    margin-bottom: 10px;
}
.success-details {
    background: rgba(0,0,0,0.2);
    border-radius: 12px;
    padding: 15px;
    margin-top: 15px;
    text-align: left;
}
.detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    margin-bottom: 6px;
    color: #94a3b8;
}
.detail-row strong {
    color: #e2e8f0;
}

/* Typing Bubble Fix */
.typing-bubble {
    display: flex;
    align-items: center;
    min-height: 40px;
}
.typing-indicator span {
    height: 8px;
    width: 8px;
    float: left;
    margin: 0 1px;
    background-color: #94a3b8;
    display: block;
    border-radius: 50%;
    opacity: 0.4;
    animation: typing 1s infinite;
}
.typing-indicator span:nth-of-type(1) { animation-delay: 0s; }
.typing-indicator span:nth-of-type(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-of-type(3) { animation-delay: 0.4s; }

@keyframes typing {
  0% { opacity: 0.4; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-5px); }
  100% { opacity: 0.4; transform: translateY(0); }
}
