/* Enhanced interactions and animations */

/* Grid improvements for better responsiveness */
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (min-width: 768px) {
  .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Better book card hover effects */
.book-card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center;
}

.book-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.book-card:active {
  transform: translateY(-4px) scale(0.98);
  transition-duration: 0.1s;
}

/* Enhanced button interactions */
.micro-interaction {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.micro-interaction::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  z-index: -1;
}

.micro-interaction:hover::before {
  transform: translateX(0);
}

.micro-interaction:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.micro-interaction:active {
  transform: translateY(0);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Navigation tab improvements */
.nav-item {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.nav-item::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.3s ease;
}

.nav-item:hover::before {
  width: 100%;
}

.nav-item.active::before {
  width: 100%;
}

.nav-item:hover:not(.active) {
  transform: translateY(-2px);
}

/* Modal animations */
.modal-overlay {
  animation: fadeInOverlay 0.3s ease-out;
}

.modal-overlay.hidden {
  animation: fadeOutOverlay 0.3s ease-out;
  pointer-events: none;
}

@keyframes fadeInOverlay {
  from {
    opacity: 0;
    backdrop-filter: blur(0px);
  }
  to {
    opacity: 1;
    backdrop-filter: blur(4px);
  }
}

@keyframes fadeOutOverlay {
  from {
    opacity: 1;
    backdrop-filter: blur(4px);
  }
  to {
    opacity: 0;
    backdrop-filter: blur(0px);
  }
}

.auth-modal, .book-modal {
  animation: slideInModal 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInModal {
  from {
    opacity: 0;
    transform: translateY(-50px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Chat window animations */
.chat-window {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: bottom right;
}

.chat-window:not(.hidden) {
  animation: slideInChat 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInChat {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.chat-message {
  animation: slideInMessage 0.3s ease-out;
}

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

/* Toast notifications */
.toast {
  animation: slideInToast 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.show {
  right: 20px;
}

@keyframes slideInToast {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Loading animations */
.spinner {
  animation: spin 1s linear infinite, pulse 2s ease-in-out infinite alternate;
}

@keyframes pulse {
  from {
    opacity: 0.8;
  }
  to {
    opacity: 1;
  }
}

/* Form enhancements */
.form-input {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.form-input:focus {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(37, 99, 235, 0.15);
}

.input-with-icon {
  position: relative;
}

.input-icon {
  transition: all 0.3s ease;
}

.form-input:focus + .input-icon,
.input-with-icon:hover .input-icon {
  color: var(--primary);
  transform: scale(1.1);
}

/* Enhanced hover effects for cards */
.stat-item {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-item:hover {
  transform: translateY(-8px) rotate(1deg);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}

.stat-item:hover .stat-icon {
  transform: scale(1.1);
  transition: transform 0.3s ease;
}

.quick-action-btn {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.quick-action-btn::before {
  content: '';
  position: absolute;
  left: -100%;
  top: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transition: left 0.5s ease;
}

.quick-action-btn:hover::before {
  left: 100%;
}

.quick-action-btn:hover {
  transform: translateX(8px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

/* Resource card enhancements */
.resource-card {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.resource-card:hover {
  transform: translateY(-12px) scale(1.03);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
}

.resource-card:hover .resource-header {
  transform: scale(1.05);
  transition: transform 0.3s ease;
}

/* Dropdown animations */
.dropdown-menu {
  transform: translateY(-10px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.dropdown-menu:not(.hidden) {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.dropdown-item {
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.dropdown-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 100%;
  background: var(--primary);
  opacity: 0.1;
  transition: width 0.3s ease;
}

.dropdown-item:hover::before {
  width: 100%;
}

/* Theme toggle animation */
#themeToggle {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#themeToggle:hover {
  transform: rotate(15deg) scale(1.1);
}

#themeIcon {
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Search bar enhancements */
.search-input {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-input:focus {
  transform: scale(1.02);
  box-shadow: 0 8px 30px rgba(37, 99, 235, 0.15);
}

.search-field {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-field:focus {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(37, 99, 235, 0.15);
}

/* Badge animations */
.notification-badge {
  animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
}

/* Footer link hover effects */
.footer-link {
  position: relative;
  transition: all 0.3s ease;
}

.footer-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: currentColor;
  transition: width 0.3s ease;
}

.footer-link:hover::after {
  width: 100%;
}

/* Stats counter animation */
@keyframes countUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stat-value {
  animation: countUp 0.6s ease-out;
}

/* Improved scroll behavior */
html {
  scroll-behavior: smooth;
}

/* Selection styles */
::selection {
  background: rgba(37, 99, 235, 0.2);
  color: var(--text-primary);
}

/* Focus visible improvements */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Custom scrollbar for chat */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--text-secondary);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* Performance optimizations */
.book-card,
.stat-item,
.resource-card,
.nav-item {
  will-change: transform;
  backface-visibility: hidden;
  perspective: 1000px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .micro-interaction:hover,
  .book-card:hover,
  .stat-item:hover,
  .resource-card:hover {
    transform: none;
  }
}
