/**
 * Smooth UI Components v2.0
 * Polished, smooth UI elements with consistent styling
 */

/* ==================== Global Smooth Transitions ==================== */
* {
  transition-property: color, background-color, border-color, box-shadow, opacity, transform;
  transition-duration: 150ms;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Disable transitions for elements that shouldn't animate */
.no-transition,
.no-transition * {
  transition: none !important;
}

/* ==================== Smooth Buttons ==================== */
.smooth-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-weight: 600;
  font-size: 14px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.smooth-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.smooth-btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.smooth-btn-primary {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
}

.smooth-btn-primary:hover {
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.smooth-btn-secondary {
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #334155;
}

.smooth-btn-secondary:hover {
  background: #334155;
  border-color: #475569;
}

.smooth-btn-ghost {
  background: transparent;
  color: #94a3b8;
}

.smooth-btn-ghost:hover {
  background: rgba(100, 116, 139, 0.1);
  color: #e2e8f0;
}

/* ==================== Smooth Inputs ==================== */
.smooth-input {
  width: 100%;
  padding: 12px 16px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  color: #f1f5f9;
  font-size: 15px;
  transition: all 0.2s;
}

.smooth-input:hover {
  border-color: #475569;
}

.smooth-input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.smooth-input::placeholder {
  color: #64748b;
}

/* Textarea */
.smooth-textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.5;
}

/* ==================== Smooth Cards ==================== */
.smooth-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 20px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.smooth-card:hover {
  border-color: #475569;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.smooth-card-elevated {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* ==================== Smooth Modal ==================== */
.smooth-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s;
}

.smooth-modal-backdrop.open {
  opacity: 1;
}

.smooth-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 20px;
  max-width: 90vw;
  max-height: 85vh;
  overflow: hidden;
  z-index: 101;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.smooth-modal.open {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.smooth-modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid #334155;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.smooth-modal-body {
  padding: 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-height: calc(85vh - 140px);
}

.smooth-modal-footer {
  padding: 16px 24px;
  border-top: 1px solid #334155;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ==================== Smooth Dropdown ==================== */
.smooth-dropdown {
  position: relative;
}

.smooth-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 180px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 50;
}

.smooth-dropdown.open .smooth-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.smooth-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.smooth-dropdown-item:hover {
  background: #334155;
}

/* ==================== Smooth Tooltip ==================== */
.smooth-tooltip {
  position: relative;
}

.smooth-tooltip::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
  pointer-events: none;
  z-index: 100;
}

.smooth-tooltip:hover::before {
  opacity: 1;
  visibility: visible;
}

/* ==================== Smooth Badge ==================== */
.smooth-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
  background: #334155;
  color: #e2e8f0;
}

.smooth-badge-primary {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
}

.smooth-badge-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
}

.smooth-badge-warning {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
}

.smooth-badge-error {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
}

/* ==================== Smooth Toggle ==================== */
.smooth-toggle {
  position: relative;
  width: 48px;
  height: 28px;
  background: #334155;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.smooth-toggle.active {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

.smooth-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.smooth-toggle.active::after {
  transform: translateX(20px);
}

/* ==================== Smooth Progress ==================== */
.smooth-progress {
  height: 8px;
  background: #334155;
  border-radius: 4px;
  overflow: hidden;
}

.smooth-progress-bar {
  height: 100%;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  border-radius: 4px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================== Smooth Avatar ==================== */
.smooth-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 16px;
  overflow: hidden;
}

.smooth-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ==================== Smooth Divider ==================== */
.smooth-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, #334155, transparent);
  margin: 16px 0;
}

.smooth-divider-vertical {
  width: 1px;
  height: 100%;
  background: linear-gradient(180deg, transparent, #334155, transparent);
  margin: 0 16px;
}

/* ==================== Smooth Loading ==================== */
.smooth-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #334155;
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.smooth-dots {
  display: flex;
  gap: 6px;
}

.smooth-dots span {
  width: 8px;
  height: 8px;
  background: #6366f1;
  border-radius: 50%;
  animation: bounce-dot 1.2s ease-in-out infinite;
}

.smooth-dots span:nth-child(2) {
  animation-delay: 0.1s;
}

.smooth-dots span:nth-child(3) {
  animation-delay: 0.2s;
}

/* ==================== Glass Effects ==================== */
.smooth-glass {
  background: rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.smooth-glass-light {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* ==================== Buttery Smooth Avatar Animations ==================== */
.avatar-smooth {
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: center center;
  will-change: transform, box-shadow;
}

.avatar-smooth:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 25px rgba(99, 102, 241, 0.35);
}

.avatar-smooth:active {
  transform: scale(0.96);
}

/* AI Avatar Glow Effect */
.ai-avatar-glow {
  position: relative;
}

.ai-avatar-glow::before {
  content: '';
  position: absolute;
  inset: -4px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6, #a855f7);
  border-radius: inherit;
  opacity: 0;
  z-index: -1;
  filter: blur(12px);
  transition: opacity 0.3s ease-out;
}

.ai-avatar-glow:hover::before {
  opacity: 0.5;
}

/* ==================== Silk Smooth Scrolling ==================== */
.silk-scroll {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Custom scrollbar for silk effect */
.silk-scroll::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.silk-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.silk-scroll::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.3);
  border-radius: 3px;
  transition: background 0.2s;
}

.silk-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.5);
}

/* ==================== Mobile Touch Optimizations ==================== */
@media (max-width: 768px) {
  /* Larger touch targets */
  .smooth-btn {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Faster animations on mobile for snappy feel */
  .smooth-btn,
  .smooth-card,
  .smooth-input,
  .avatar-smooth {
    transition-duration: 150ms;
  }
  
  /* Disable hover effects that cause sticky states on touch */
  .smooth-btn:hover {
    transform: none;
  }
  
  .smooth-btn:active {
    transform: scale(0.97);
    opacity: 0.9;
  }
  
  /* Better spacing for touch */
  .smooth-dropdown-item {
    padding: 14px 16px;
  }
}

/* ==================== iOS-specific polish ==================== */
@supports (-webkit-touch-callout: none) {
  /* Smoother momentum scrolling on iOS */
  .silk-scroll {
    -webkit-overflow-scrolling: touch;
  }
  
  /* Prevent iOS rubber-band on fixed elements */
  .ios-fixed {
    position: fixed;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }
  
  /* iOS modal backdrop blur fix */
  .smooth-modal-backdrop {
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
  }
}

/* ==================== Micro-interactions ==================== */
/* Button ripple effect */
.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.3) 10%, transparent 10%);
  background-repeat: no-repeat;
  background-position: 50%;
  transform: scale(10, 10);
  opacity: 0;
  transition: transform 0.5s, opacity 0.5s;
}

.ripple:active::after {
  transform: scale(0, 0);
  opacity: 0.3;
  transition: 0s;
}

/* Smooth icon animations */
.icon-hover-lift {
  transition: transform 0.2s ease-out;
}

.icon-hover-lift:hover {
  transform: translateY(-2px);
}

/* Press effect */
.press-effect {
  transition: transform 0.15s ease-out;
}

.press-effect:active {
  transform: scale(0.95);
}

/* ==================== Staggered Fade In ==================== */
.stagger-fade-in > * {
  opacity: 0;
  transform: translateY(10px);
  animation: staggerFadeIn 0.4s ease-out forwards;
}

.stagger-fade-in > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-fade-in > *:nth-child(2) { animation-delay: 0.10s; }
.stagger-fade-in > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-fade-in > *:nth-child(4) { animation-delay: 0.20s; }
.stagger-fade-in > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-fade-in > *:nth-child(6) { animation-delay: 0.30s; }

@keyframes staggerFadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==================== Pulse Glow Animation ==================== */
.pulse-glow-soft {
  animation: pulseGlowSoft 2s ease-in-out infinite;
}

@keyframes pulseGlowSoft {
  0%, 100% {
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
  }
  50% {
    box-shadow: 0 0 35px rgba(99, 102, 241, 0.4);
  }
}

/* ==================== GPU Acceleration Helpers ==================== */
.gpu-accelerated {
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  perspective: 1000px;
  -webkit-perspective: 1000px;
}

/* ==================== Reduced Motion Support ==================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

