/* AcademyDSJ Custom Styles - SPA + Animations */

/* ============================================
   BASE
   ============================================ */
html {
  scroll-behavior: smooth;
}

* {
  -webkit-tap-highlight-color: transparent;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: #0f172a;
}
::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* Focus ring override */
input:focus {
  outline: none;
}

/* ============================================
   SPA PAGE TRANSITIONS (handled via inline styles in router.js)
   ============================================ */
#spa-app {
  min-height: 50vh;
}

/* ============================================
   FADE IN UP (legacy + server-rendered pages)
   ============================================ */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.5s ease-out;
}

/* ============================================
   PULSE GLOW - CTA Buttons
   ============================================ */
@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 20px rgba(13, 148, 136, 0.3);
  }
  50% {
    box-shadow: 0 0 40px rgba(13, 148, 136, 0.5);
  }
}

.pulse-glow {
  animation: pulseGlow 2s ease-in-out infinite;
}

/* ============================================
   CARD HOVER EFFECTS
   ============================================ */
.card-hover {
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(13, 148, 136, 0.1);
  border-color: rgba(13, 148, 136, 0.3);
}

/* ============================================
   GRADIENT TEXT ANIMATION
   ============================================ */
@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.gradient-text-animate {
  background-size: 200% 200%;
  animation: gradientShift 4s ease infinite;
}

/* ============================================
   TYPING CURSOR
   ============================================ */
.typing-cursor::after {
  content: '|';
  animation: blink 0.8s step-end infinite;
  color: #2dd4bf;
  font-weight: bold;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ============================================
   FLOATING ANIMATION
   ============================================ */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

.floating-animation {
  animation: float 4s ease-in-out infinite;
}

/* ============================================
   FLOATING PARTICLES (Hero)
   ============================================ */
.floating-particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0.15;
}

.particle-1 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, #0d9488, transparent);
  top: 10%;
  right: -5%;
  animation: float 6s ease-in-out infinite;
}

.particle-2 {
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, #0891b2, transparent);
  bottom: 20%;
  left: -3%;
  animation: float 8s ease-in-out infinite reverse;
}

.particle-3 {
  width: 150px;
  height: 150px;
  background: radial-gradient(circle, #7c3aed, transparent);
  top: 40%;
  right: 30%;
  animation: float 7s ease-in-out infinite 1s;
}

/* Hero Grid Background */
.hero-grid-bg {
  background-image:
    linear-gradient(rgba(45, 212, 191, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(45, 212, 191, 0.1) 1px, transparent 1px);
  background-size: 60px 60px;
}

/* ============================================
   INPUT FOCUS GLOW
   ============================================ */
.input-glow:focus {
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

/* ============================================
   LOADING SPINNER
   ============================================ */
.spinner {
  animation: spin 0.8s linear infinite;
}

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

/* ============================================
   SUCCESS CHECK ANIMATION
   ============================================ */
@keyframes scaleIn {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.success-check-animate {
  animation: scaleIn 0.6s ease-out;
}

/* ============================================
   MCP DIAGRAM ARROW ANIMATION
   ============================================ */
@keyframes arrowPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.mcp-arrow {
  animation: arrowPulse 1.5s ease-in-out infinite;
}

/* ============================================
   N8N WORKFLOW ANIMATION
   ============================================ */
.n8n-workflow {
  position: relative;
}

.n8n-node {
  position: relative;
  z-index: 2;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.n8n-node:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.n8n-connector {
  width: 40px;
  height: 2px;
  background: linear-gradient(90deg, #334155, #0d9488, #334155);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes flowDot {
  0% { left: 0; }
  100% { left: calc(100% - 6px); }
}

.n8n-flow-dot {
  width: 6px;
  height: 6px;
  background: #2dd4bf;
  border-radius: 50%;
  position: absolute;
  animation: flowDot 1.5s ease-in-out infinite;
  box-shadow: 0 0 8px rgba(45, 212, 191, 0.6);
}

/* ============================================
   FAQ ACCORDION
   ============================================ */
.faq-item {
  transition: border-color 0.3s ease;
}

.faq-item.faq-open {
  border-color: rgba(13, 148, 136, 0.3);
}

.faq-content {
  transition: max-height 0.35s ease, padding-bottom 0.35s ease;
}

.faq-icon {
  transition: transform 0.3s ease;
}

.faq-toggle {
  cursor: pointer;
  background: none;
  border: none;
}

.faq-toggle:hover {
  background: rgba(13, 148, 136, 0.03);
}

/* ============================================
   COUNTER ANIMATION
   ============================================ */
.counter {
  font-variant-numeric: tabular-nums;
}

/* ============================================
   NAV STYLES
   ============================================ */
#spa-nav {
  transition: background-color 0.3s ease;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .n8n-connector {
    display: none;
  }

  .n8n-workflow {
    flex-direction: column;
    gap: 12px !important;
  }

  .n8n-node {
    width: 100%;
  }

  .mcp-diagram .flex {
    flex-direction: column;
  }

  .mcp-arrow {
    transform: rotate(90deg);
  }

  .floating-particle {
    display: none;
  }
}

@media (max-width: 640px) {
  .hero-grid-bg {
    background-size: 40px 40px;
  }
}

/* ============================================
   PARALLAX GRADIENT BACKGROUND
   ============================================ */
@keyframes bgGradientShift {
  0% { background-position: 0% 0%; }
  50% { background-position: 100% 100%; }
  100% { background-position: 0% 0%; }
}

section.relative {
  background-size: 200% 200%;
}

/* ============================================
   BORDER GLOW EFFECT
   ============================================ */
@keyframes borderGlow {
  0%, 100% {
    border-color: rgba(13, 148, 136, 0.2);
  }
  50% {
    border-color: rgba(13, 148, 136, 0.5);
  }
}

/* ============================================
   DASHBOARD & SERVER-RENDERED PAGE ENHANCEMENTS
   ============================================ */
.dashboard-card {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.dashboard-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(13, 148, 136, 0.08);
}

/* Progress step animation */
@keyframes stepPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(13, 148, 136, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(13, 148, 136, 0); }
}

.step-active {
  animation: stepPulse 2s ease-in-out infinite;
}

/* Drag and drop zone */
.drop-zone {
  transition: border-color 0.3s ease, background-color 0.3s ease;
}

.drop-zone.drag-over {
  border-color: #0d9488;
  background-color: rgba(13, 148, 136, 0.05);
}

/* ============================================
   BUTTON DISABLED STATE
   ============================================ */
button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none !important;
}

/* ============================================
   SELECTION COLOR
   ============================================ */
::selection {
  background: rgba(13, 148, 136, 0.3);
  color: #fff;
}

/* ============================================
   CHAT WIDGET
   ============================================ */

/* Toggle Button */
#chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0d9488, #0891b2);
  border: none;
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(13, 148, 136, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: pulseGlow 2s ease-in-out infinite;
}

#chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(13, 148, 136, 0.5);
}

#chat-toggle svg {
  width: 28px;
  height: 28px;
  fill: #fff;
  transition: transform 0.2s ease;
}

#chat-toggle.chat-open svg.chat-icon-open {
  display: none;
}

#chat-toggle:not(.chat-open) svg.chat-icon-close {
  display: none;
}

/* Chat Window */
#chat-window {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 380px;
  height: 520px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 16px;
  z-index: 9998;
  display: none;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
  animation: chatSlideUp 0.3s ease-out;
}

#chat-window.chat-visible {
  display: flex;
}

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

/* Chat Header */
#chat-header {
  padding: 16px;
  background: linear-gradient(135deg, #0d9488, #0891b2);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

#chat-header .chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

#chat-header .chat-title {
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
}

#chat-header .chat-subtitle {
  color: rgba(255, 255, 255, 0.7);
  font-size: 11px;
}

/* Chat Messages */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#chat-messages::-webkit-scrollbar {
  width: 4px;
}

#chat-messages::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 2px;
}

/* Message Bubbles */
.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
  animation: fadeInUp 0.2s ease-out;
}

.chat-msg-user {
  background: #0d9488;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-msg-ai {
  background: #0f172a;
  color: #e2e8f0;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  border: 1px solid #1e293b;
}

/* Typing Indicator */
.chat-typing {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: #0f172a;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  border: 1px solid #1e293b;
}

.chat-typing span {
  width: 7px;
  height: 7px;
  background: #64748b;
  border-radius: 50%;
  animation: typingBounce 1.2s ease-in-out infinite;
}

.chat-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.chat-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Registration Card */
.chat-registration-card {
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.15), rgba(8, 145, 178, 0.1));
  border: 1px solid rgba(13, 148, 136, 0.3);
  border-radius: 12px;
  padding: 14px;
  margin: 4px 0;
  align-self: flex-start;
  max-width: 90%;
  animation: fadeInUp 0.3s ease-out;
}

.chat-registration-card .card-title {
  color: #2dd4bf;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
}

.chat-registration-card .card-detail {
  color: #94a3b8;
  font-size: 12px;
  line-height: 1.6;
}

.chat-registration-card .card-detail strong {
  color: #e2e8f0;
}

/* Upload Card */
.chat-upload-card {
  background: linear-gradient(135deg, #1e3a5f, #1e293b);
  border: 1px solid #0d9488;
  border-radius: 12px;
  padding: 12px 14px;
  margin: 6px 12px 6px 32px;
  animation: fadeInUp 0.3s ease-out;
}

.chat-upload-card .card-title {
  color: #2dd4bf;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
}

.chat-upload-card .card-detail {
  color: #94a3b8;
  font-size: 12px;
  line-height: 1.6;
  margin-bottom: 8px;
}

.chat-upload-card .card-detail strong {
  color: #e2e8f0;
}

.upload-pick-btn {
  display: block;
  width: 100%;
  padding: 8px 12px;
  background: linear-gradient(135deg, #0d9488, #0891b2);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.1s ease;
}

.upload-pick-btn:hover {
  opacity: 0.9;
}

.upload-pick-btn:active {
  transform: scale(0.98);
}

.upload-pick-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.upload-status {
  font-size: 11px;
  margin-top: 6px;
  min-height: 14px;
}

.upload-progress {
  color: #38bdf8;
}

.upload-success {
  color: #2dd4bf;
}

.upload-error {
  color: #f87171;
}

/* Attach Button */
#chat-attach {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid #334155;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s ease, border-color 0.2s ease;
}

#chat-attach:hover {
  background: #334155;
  border-color: #475569;
}

#chat-attach svg {
  width: 18px;
  height: 18px;
  fill: #94a3b8;
}

/* Input Area */
#chat-input-area {
  padding: 12px;
  border-top: 1px solid #334155;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  background: #1e293b;
}

#chat-input {
  flex: 1;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 10px 14px;
  color: #e2e8f0;
  font-size: 13px;
  resize: none;
  max-height: 80px;
  line-height: 1.4;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease;
}

#chat-input:focus {
  border-color: #0d9488;
}

#chat-input::placeholder {
  color: #64748b;
}

#chat-send {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0d9488, #0891b2);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s ease, transform 0.1s ease;
}

#chat-send:hover {
  opacity: 0.9;
}

#chat-send:active {
  transform: scale(0.95);
}

#chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#chat-send svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

/* Mobile Responsive */
@media (max-width: 640px) {
  #chat-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: none;
  }

  #chat-toggle.chat-open {
    display: none;
  }

  #chat-header {
    padding: 14px 16px;
  }

  #chat-header::after {
    content: '\00d7';
    color: rgba(255,255,255,0.7);
    font-size: 24px;
    margin-left: auto;
    cursor: pointer;
    padding: 0 4px;
  }
}
