@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap');

@tailwind base;
@tailwind components;
@tailwind utilities;

/* ===== Design System ===== */
@layer components {
  /* Card component */
  .card-pickful {
    @apply bg-base-200 rounded-card p-card shadow-card transition-all duration-200;
  }
  .card-pickful:hover {
    @apply shadow-card-hover;
  }
  
  /* Primary button with micro-interactions */
  .btn-pickful {
    @apply bg-primary text-primary-content px-4 py-2 rounded-button font-medium shadow-button transition-all duration-200 relative overflow-hidden;
  }
  .btn-pickful:hover {
    @apply shadow-button-hover -translate-y-0.5 brightness-110;
  }
  .btn-pickful:active {
    @apply translate-y-0 scale-[0.98] brightness-95;
  }
  .btn-pickful:disabled {
    @apply opacity-50 cursor-not-allowed;
  }
  
  /* Button loading state */
  .btn-pickful.loading {
    @apply pointer-events-none;
  }
  .btn-pickful.loading::after {
    content: '';
    @apply absolute inset-0 flex items-center justify-center;
    background: inherit;
  }
  .btn-pickful.loading::before {
    content: '';
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    position: absolute;
  }
  
  /* Secondary button */
  .btn-pickful-secondary {
    @apply bg-base-200 text-base-content px-4 py-2 rounded-button font-medium border border-base-300 transition-all duration-200;
  }
  .btn-pickful-secondary:hover {
    @apply bg-base-300 -translate-y-0.5;
  }
  .btn-pickful-secondary:active {
    @apply translate-y-0 scale-[0.98];
  }
  
  /* Ghost button */
  .btn-pickful-ghost {
    @apply bg-transparent text-base-content px-4 py-2 rounded-button font-medium transition-all duration-200;
  }
  .btn-pickful-ghost:hover {
    @apply bg-base-200;
  }
  
  /* Input field with enhanced focus */
  .input-pickful {
    @apply w-full p-3 bg-base-100 border border-base-300 rounded-input text-base-content transition-all duration-200;
  }
  .input-pickful:focus {
    @apply outline-none ring-2 ring-primary border-primary;
  }
  .input-pickful:hover:not(:focus) {
    @apply border-base-300;
  }
  
  /* Input validation states */
  .input-pickful.input-error {
    @apply border-error;
  }
  .input-pickful.input-error:focus {
    @apply ring-error border-error;
  }
  .input-pickful.input-success {
    @apply border-success;
  }
  .input-pickful.input-success:focus {
    @apply ring-success border-success;
  }
  
  /* Input with icon */
  .input-group-pickful {
    @apply relative;
  }
  .input-group-pickful .input-icon {
    @apply absolute left-3 top-1/2 -translate-y-1/2 text-base-content/50 pointer-events-none;
  }
  .input-group-pickful .input-pickful {
    @apply pl-10;
  }
  
  /* Display font */
  .font-display {
    font-family: 'Space Grotesk', 'Inter var', sans-serif;
  }
  
  /* Skeleton loading placeholder */
  .skeleton {
    @apply bg-base-300 rounded animate-pulse;
  }
  .skeleton-text {
    @apply h-4 bg-base-300 rounded animate-pulse;
  }
  .skeleton-avatar {
    @apply w-10 h-10 bg-base-300 rounded-full animate-pulse;
  }
  .skeleton-card {
    @apply bg-base-200 rounded-card p-card animate-pulse;
  }
  
  /* ===== 8px Grid Spacing System ===== */
  .space-1 { gap: 0.25rem; }  /* 4px */
  .space-2 { gap: 0.5rem; }   /* 8px */
  .space-3 { gap: 0.75rem; }  /* 12px */
  .space-4 { gap: 1rem; }     /* 16px */
  .space-5 { gap: 1.25rem; }  /* 20px */
  .space-6 { gap: 1.5rem; }   /* 24px */
  .space-8 { gap: 2rem; }     /* 32px */
  
  /* Consistent section padding */
  .section-padding {
    @apply px-4 py-6 md:px-6 md:py-8;
  }
  
  /* Content container with consistent spacing */
  .content-container {
    @apply max-w-2xl lg:max-w-4xl xl:max-w-6xl mx-auto px-4;
  }
  
  /* ===== Like/Follow Button Animations ===== */
  .like-btn {
    @apply relative transition-all duration-200;
  }
  .like-btn:active {
    @apply scale-90;
  }
  .like-btn.liked {
    animation: heartPop 0.3s ease-out;
  }
  
  .follow-btn {
    @apply transition-all duration-200;
  }
  .follow-btn:active {
    @apply scale-95;
  }
  .follow-btn.following {
    animation: followPulse 0.3s ease-out;
  }
  
  /* Tab button styling */
  .tab-pickful {
    @apply px-4 py-2 font-medium rounded-button transition-all duration-200;
  }
  .tab-pickful:hover {
    @apply bg-base-200;
  }
  .tab-pickful.active {
    @apply bg-primary text-primary-content;
  }
}

/* ===== Typography System ===== */
@layer base {
  /* Heading hierarchy */
  h1, .h1 {
    @apply text-3xl md:text-4xl font-bold tracking-tight;
    font-family: 'Space Grotesk', 'Inter var', sans-serif;
  }
  h2, .h2 {
    @apply text-2xl md:text-3xl font-bold tracking-tight;
    font-family: 'Space Grotesk', 'Inter var', sans-serif;
  }
  h3, .h3 {
    @apply text-xl md:text-2xl font-semibold;
    font-family: 'Space Grotesk', 'Inter var', sans-serif;
  }
  h4, .h4 {
    @apply text-lg font-semibold;
  }
  h5, .h5 {
    @apply text-base font-medium;
  }
  
  /* Body text */
  body {
    @apply text-base leading-relaxed;
  }
  
  /* Small/caption text */
  .text-caption {
    @apply text-sm text-base-content/70;
  }
  
  /* Muted text */
  .text-muted {
    @apply text-base-content/60;
  }
}

/* Custom Themes (DaisyUI 5 doesn't auto-generate these) */
[data-theme="crypto"] {
  color-scheme: dark;
  --color-primary: #00d4ff;
  --color-primary-content: #ffffff;
  --color-secondary: #7c3aed;
  --color-secondary-content: #ffffff;
  --color-accent: #22d3ee;
  --color-accent-content: #000000;
  --color-neutral: #1e293b;
  --color-neutral-content: #cbd5e1;
  --color-base-100: #0f172a;
  --color-base-200: #1e293b;
  --color-base-300: #334155;
  --color-base-content: #e2e8f0;
  --color-info: #38bdf8;
  --color-info-content: #000000;
  --color-success: #4ade80;
  --color-success-content: #000000;
  --color-warning: #fbbf24;
  --color-warning-content: #000000;
  --color-error: #f87171;
  --color-error-content: #000000;
}

[data-theme="light"] {
  color-scheme: light;
  --color-primary: #3b82f6;
  --color-primary-content: #ffffff;
  --color-secondary: #8b5cf6;
  --color-secondary-content: #ffffff;
  --color-accent: #06b6d4;
  --color-accent-content: #ffffff;
  --color-neutral: #374151;
  --color-neutral-content: #ffffff;
  --color-base-100: #ffffff;
  --color-base-200: #f3f4f6;
  --color-base-300: #e5e7eb;
  --color-base-content: #1f2937;
  --color-info: #3b82f6;
  --color-info-content: #ffffff;
  --color-success: #22c55e;
  --color-success-content: #ffffff;
  --color-warning: #f59e0b;
  --color-warning-content: #000000;
  --color-error: #ef4444;
  --color-error-content: #ffffff;
}

[data-theme="hermes"] {
  color-scheme: dark;
  --color-primary: #ff6b00;
  --color-primary-content: #ffffff;
  --color-secondary: #d4a574;
  --color-secondary-content: #000000;
  --color-accent: #fbbf24;
  --color-accent-content: #000000;
  --color-neutral: #292524;
  --color-neutral-content: #fef3c7;
  --color-base-100: #1c1917;
  --color-base-200: #292524;
  --color-base-300: #44403c;
  --color-base-content: #fef3c7;
  --color-info: #fb923c;
  --color-info-content: #000000;
  --color-success: #84cc16;
  --color-success-content: #000000;
  --color-warning: #fbbf24;
  --color-warning-content: #000000;
  --color-error: #dc2626;
  --color-error-content: #ffffff;
}

[data-theme="midnight"] {
  color-scheme: dark;
  --color-primary: #a855f7;
  --color-primary-content: #ffffff;
  --color-secondary: #ec4899;
  --color-secondary-content: #ffffff;
  --color-accent: #06b6d4;
  --color-accent-content: #ffffff;
  --color-neutral: #18181b;
  --color-neutral-content: #a1a1aa;
  --color-base-100: #000000;
  --color-base-200: #09090b;
  --color-base-300: #18181b;
  --color-base-content: #fafafa;
  --color-info: #8b5cf6;
  --color-info-content: #ffffff;
  --color-success: #22c55e;
  --color-success-content: #000000;
  --color-warning: #eab308;
  --color-warning-content: #000000;
  --color-error: #ef4444;
  --color-error-content: #ffffff;
}

.fade-out {
  animation: fadeOut 7s forwards;
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0.4;
    display: none;
  }
}

/* Leaderboard */
.card {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  transform: scale(1.05);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.table-zebra tr:nth-child(even) {
  background-color: var(--color-base-200);
}

/* Search */
#suggestions {
  @apply border rounded shadow-lg overflow-y-auto;
  min-width: var(--input-width, 100%);
  max-height: calc(100vh - 100px);
  max-width: calc(100vw - 20px);
  right: 0;
  top: 100%;
  z-index: 1001;
}

.input {
  padding-left: 2.5rem;
  padding-right: 2.5rem;
}



/* Chat */
.full-screen {
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.avatar-wrapper {
  min-width: 2.5rem !important; /* 40px */
  max-width: 2.5rem !important;
}

/* Lexxy */
lexxy-toolbar {
  position: sticky;
  top: 0px;
  z-index: 1000;
  padding: 0px;
}

/* Lexxy toolbar theme support */
lexxy-editor .lexxy-editor__toolbar {
  background-color: var(--color-base-200) !important;
  border-color: var(--color-base-300) !important;
}

lexxy-editor .lexxy-editor__toolbar-button {
  color: var(--color-base-content) !important;
  background-color: transparent !important;
}

lexxy-editor .lexxy-editor__toolbar-button:hover {
  background-color: var(--color-base-300) !important;
}

lexxy-editor .lexxy-editor__toolbar-button.lexxy-editor__toolbar-button--active {
  background-color: var(--color-primary) !important;
  color: var(--color-primary-content) !important;
}

lexxy-editor .lexxy-editor__toolbar-button svg {
  fill: currentColor !important;
  stroke: currentColor !important;
}

lexxy-editor .lexxy-editor__button-group {
  border-color: var(--color-base-300) !important;
}

/* Lexxy content area theme support */
lexxy-editor .lexxy-editor__content {
  background-color: var(--color-base-200) !important;
  color: var(--color-base-content) !important;
}

/* Lexxy prompt menu (tag suggestions) theme support */
.lexxy-prompt-menu {
  background-color: var(--color-base-100) !important;
  border: 1px solid var(--color-base-300) !important;
  border-radius: 0.5rem !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  padding: 0.25rem 0 !important;
  overflow: hidden !important;
}

.lexxy-prompt-menu__item {
  color: var(--color-base-content) !important;
  background-color: transparent !important;
  padding: 0 !important;
}

.lexxy-prompt-menu__item:hover,
.lexxy-prompt-menu__item--selected {
  background-color: var(--color-base-200) !important;
}

.lexxy-prompt-menu__item > * {
  width: 100%;
}

lexxy-editor .lexxy-editor__content:focus {
  outline-color: var(--color-primary) !important;
}
.lexxy-content ul {
  list-style-type: disc;
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}
.lexxy-content ol {
  list-style-type: decimal;
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}
.lexxy-content li {
  margin-bottom: 0.5rem;
}
.lexxy-content h1 {
  font-size: 1rem;
  font-weight: normal;
}

/* Lexxy table theme support */
.lexxy-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}
.lexxy-content table th,
.lexxy-content table td {
  border: 1px solid var(--color-base-300);
  padding: 0.5rem 0.75rem;
  text-align: left;
}
.lexxy-content table th,
.lexxy-content table tbody th {
  background-color: var(--color-base-200);
  color: var(--color-base-content);
  font-weight: 600;
}
.lexxy-content table td {
  background-color: var(--color-base-100);
  color: var(--color-base-content);
}
.lexxy-content table tr:hover td {
  background-color: var(--color-base-200);
}

/* Lexxy code theme support */
.lexxy-content code {
  background-color: var(--color-base-200);
  color: var(--color-base-content);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.875em;
}
.lexxy-content pre {
  background-color: var(--color-base-200);
  color: var(--color-base-content);
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
}
.lexxy-content pre code {
  background-color: transparent;
  padding: 0;
}

/* Lexxy toolbar */
lexxy-editor .lexxy-editor__toolbar {
  display: flex !important;
  flex-direction: row !important;
  justify-content: flex-start !important;
  align-items: center !important;
  padding: 2px 4px !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  flex-wrap: nowrap !important;
  -webkit-overflow-scrolling: touch !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

/* Hide toolbar for short post */
#short_post_editor .lexxy-editor__toolbar {
  display: block !important;
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  padding: 0 !important;
}

lexxy-editor .lexxy-editor__button-row {
  display: flex !important;
  flex-wrap: nowrap !important;
  justify-content: flex-start !important;
  align-items: center !important;
  gap: 4px !important;
  min-width: max-content !important;
  width: auto !important;
}

lexxy-editor .lexxy-editor__button-group {
  display: flex !important;
  flex-shrink: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  gap: 2px !important;
}

@media (max-width: 768px) {
  lexxy-editor .lexxy-editor__toolbar {
    padding: 2px 3px !important;
    justify-content: flex-start !important;
    overflow: hidden !important;
  }

  lexxy-editor .lexxy-editor__button-row {
    gap: 5px !important;
    max-width: none !important;
    width: 100% !important;
    min-width: unset !important;
    justify-content: space-between !important;
  }

  lexxy-editor .lexxy-editor__toolbar-button {
    padding: 5px 7px !important;
    flex: 1 !important;
    max-width: unset !important;
    min-width: unset !important;
    justify-content: center !important;
  }

  lexxy-editor .lexxy-editor__toolbar-button svg {
    width: 19px !important;
    height: 19px !important;
  }

  lexxy-editor .lexxy-editor__button-group {
    gap: 4px !important;
    flex: 1 !important;
    justify-content: center !important;
  }
}

lexxy-editor .lexxy-editor__toolbar-button {
  padding: 4px 6px !important;
  margin: 0 !important;
  flex-shrink: 0 !important;
  min-width: unset !important;
  border-radius: 6px !important;
  font-size: 14px !important;
}

lexxy-editor .lexxy-editor__toolbar-button svg {
  width: 18px !important;
  height: 18px !important;
}

lexxy-editor .lexxy-editor__toolbar,
lexxy-editor .lexxy-editor {
  margin-right: 0 !important;
  padding-right: 0 !important;
}

lexxy-editor summary.lexxy-editor__toolbar-button[aria-label="Show more toolbar buttons"],
lexxy-toolbar summary.lexxy-editor__toolbar-button[aria-label="Show more toolbar buttons"] {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin-left: auto !important;
  margin-right: 0 !important;
  flex-shrink: 0 !important;
  padding: 2px 4px !important;
  height: auto !important;
  line-height: 1 !important;
}

lexxy-editor summary.lexxy-editor__toolbar-button[aria-label="Show more toolbar buttons"]::before {
  line-height: 1 !important;
}

.lexxy-editor__toolbar-spacer {
  display: none !important;
}

/* Short post editor */
.short-post-toolbar lexxy-editor .lexxy-editor__content {
  min-height: 80px;
}

/* ===== Micro-interactions & Animations ===== */

/* Keyframe animations */
@keyframes heartPop {
  0% { transform: scale(1); }
  25% { transform: scale(1.3); }
  50% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

@keyframes followPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 var(--color-primary); }
  50% { transform: scale(1.02); box-shadow: 0 0 0 4px transparent; }
  100% { transform: scale(1); box-shadow: 0 0 0 0 transparent; }
}

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

/* Turbo page transition animations */
.turbo-progress-bar {
  height: 3px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
  box-shadow: 0 0 10px var(--color-primary);
}

/* Page enter/exit animations */
[data-turbo-preview] {
  opacity: 0.7;
}

/* Smooth page transitions */
turbo-frame[busy] {
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

/* Card entry animation */
@keyframes cardSlideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-card-enter {
  animation: cardSlideUp 0.3s ease-out forwards;
}

/* Staggered list animation */
.stagger-list > *:nth-child(1) { animation-delay: 0ms; }
.stagger-list > *:nth-child(2) { animation-delay: 50ms; }
.stagger-list > *:nth-child(3) { animation-delay: 100ms; }
.stagger-list > *:nth-child(4) { animation-delay: 150ms; }
.stagger-list > *:nth-child(5) { animation-delay: 200ms; }

/* Points effect animation (enhanced) */
@keyframes pointsFloat {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-20px) scale(1.1);
  }
}

.points-float {
  animation: pointsFloat 1.5s ease-out forwards;
}

/* Interactive hover effects */
.hover-lift {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.15);
}

/* Focus visible ring for accessibility */
.focus-ring:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--color-base-100), 0 0 0 4px var(--color-primary);
}
