/* ============================================================
   LOFI DEX - Final UX Polish & Production-Ready Styles
   ============================================================ */

/* Smooth Focus States */
input:focus,
textarea:focus,
select:focus,
button:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(168, 184, 237, 0.2);
  transition: box-shadow 0.2s ease-out;
}

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

.button::before,
.btn::before,
button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.button:active::before,
.btn:active::before,
button:active::before {
  width: 300px;
  height: 300px;
}

/* Loading State Polish */
.loading-container {
  position: relative;
  min-height: 60px;
}

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.3s ease-out;
}

.loading-overlay.show {
  opacity: 1;
}

/* Elegant Spinner */
.elegant-spinner {
  width: 40px;
  height: 40px;
  position: relative;
}

.elegant-spinner::before,
.elegant-spinner::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: #a8b8ed;
  animation: elegant-spin 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

.elegant-spinner::after {
  animation-delay: 0.5s;
  border-top-color: #667eea;
}

@keyframes elegant-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Price Update Animation */
.price-update {
  position: relative;
  display: inline-block;
}

.price-update::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, transparent, rgba(168, 184, 237, 0.3), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s ease-out;
}

.price-update.updating::after {
  transform: translateX(100%);
}

/* Modal Polish */
.modal-backdrop {
  backdrop-filter: blur(8px);
  background: rgba(0, 0, 0, 0.8);
  animation: backdrop-fade-in 0.3s ease-out;
}

@keyframes backdrop-fade-in {
  from {
    opacity: 0;
    backdrop-filter: blur(0);
  }
  to {
    opacity: 1;
    backdrop-filter: blur(8px);
  }
}

.modal-content {
  animation: modal-slide-up 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-slide-up {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Success Animation */
.success-animation {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 10001;
}

.success-circle {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: success-pulse 0.6s ease-out;
}

@keyframes success-pulse {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.success-checkmark {
  width: 50px;
  height: 50px;
  stroke: #10b981;
  stroke-width: 3;
  fill: none;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: checkmark-draw 0.6s ease-out 0.3s forwards;
}

@keyframes checkmark-draw {
  to {
    stroke-dashoffset: 0;
  }
}

/* Error Shake */
.error-shake {
  animation: error-shake 0.5s ease-out;
}

@keyframes error-shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Smooth Number Transitions */
.animated-number {
  display: inline-block;
  transition: transform 0.3s ease-out;
}

.animated-number.counting {
  transform: scale(1.1);
}

/* Input Enhancements */
input[type="text"],
input[type="number"] {
  transition: all 0.2s ease-out;
}

input[type="text"]:hover,
input[type="number"]:hover {
  border-color: rgba(168, 184, 237, 0.5);
}

input[type="text"]:focus,
input[type="number"]:focus {
  border-color: #a8b8ed;
  transform: translateY(-1px);
}

/* Tooltip Animations */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: #333;
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease-out;
}

.tooltip:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(-5px);
}

/* Micro-interactions */
.clickable {
  cursor: pointer;
  transition: transform 0.1s ease-out;
}

.clickable:active {
  transform: scale(0.98);
}

/* Loading Skeleton Polish */
.skeleton-text {
  background: linear-gradient(90deg,
    rgba(168, 184, 237, 0.1) 0%,
    rgba(168, 184, 237, 0.2) 20%,
    rgba(168, 184, 237, 0.1) 40%,
    rgba(168, 184, 237, 0.1) 100%
  );
  background-size: 1000px 100%;
  animation: skeleton-loading 2s linear infinite;
  border-radius: 4px;
}

@keyframes skeleton-loading {
  0% { background-position: -1000px 0; }
  100% { background-position: 1000px 0; }
}

/* Notification Polish */
.notification-enter {
  animation: notification-slide-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes notification-slide-in {
  from {
    opacity: 0;
    transform: translateX(100%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

/* Page Transitions */
.page-transition-fade {
  animation: page-fade 0.3s ease-out;
}

@keyframes page-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Smooth Scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(168, 184, 237, 0.1);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb {
  background: rgba(168, 184, 237, 0.3);
  border-radius: 5px;
  transition: background 0.2s;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(168, 184, 237, 0.5);
}

/* Production Error Prevention */
.error-boundary {
  padding: 20px;
  text-align: center;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 12px;
}

/* Performance Optimizations */
.gpu-accelerated {
  transform: translateZ(0);
  will-change: transform;
}

.no-select {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Final Polish */
* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Remove tap highlight on mobile */
* {
  -webkit-tap-highlight-color: transparent;
}

/* Ensure smooth animations even under load */
@media (prefers-reduced-motion: no-preference) {
  * {
    scroll-behavior: smooth;
  }
}