/**
 * UI/UX Improvements - RetroPlay Giveaways
 * Priority fixes for visual consistency, accessibility, and user experience
 */

/* ==========================================================================
   1. BUTTON STATES - Loading and Disabled
   ========================================================================== */

.btn-primary:disabled,
.btn-secondary:disabled,
.btn-outline:disabled,
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
  filter: grayscale(0.3);
}

.btn-loading {
  position: relative;
  color: transparent !important;
}

.btn-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: btn-loading-spin 0.6s linear infinite;
}

@keyframes btn-loading-spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ==========================================================================
   2. TASK COMPLETION FLOW
   ========================================================================== */

.btn-task-verify {
  background: linear-gradient(135deg, var(--accent-success), #16a34a);
  color: white;
  border: 1px solid rgba(34, 197, 94, 0.4);
  box-shadow: 0 0 15px rgba(34, 197, 94, 0.2);
  font-weight: 700;
}

.btn-task-verify:hover:not(:disabled) {
  box-shadow: 0 0 25px rgba(34, 197, 94, 0.4);
  transform: translateY(-2px);
}

.btn-task-verify .timer {
  font-weight: 700;
  animation: pulse-timer 1s ease-in-out infinite;
}

@keyframes pulse-timer {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.completed-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border-radius: var(--radius-sm);
  font-weight: 700;
  border: 1px solid rgba(34, 197, 94, 0.3);
  animation: success-bounce 0.4s ease;
}

@keyframes success-bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.completed-badge::before {
  content: '\2713  ';
  animation: check-pop 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes check-pop {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ==========================================================================
   3. ENHANCED EMPTY STATES - Standardized Component
   ========================================================================== */

.empty-state {
  padding: 4rem 2rem;
  text-align: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.03), transparent);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border);
}

/* Empty state with icon (use FontAwesome or custom icon) */
.empty-state-icon {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--accent-primary);
  opacity: 0.5;
  background: rgba(139, 92, 246, 0.1);
  border-radius: 50%;
  animation: empty-float 3s ease-in-out infinite;
}

/* Fallback emoji icon */
.empty-state:not(:has(.empty-state-icon))::before {
  content: '\1F3AE';
  font-size: 4rem;
  opacity: 0.3;
  filter: grayscale(0.5);
  animation: empty-float 3s ease-in-out infinite;
}

@keyframes empty-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.empty-state-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin: 0;
}

.empty-state-description {
  max-width: 400px;
  line-height: 1.6;
  font-size: 1rem;
  margin: 0;
}

/* Optional CTA button */
.empty-state-cta {
  margin-top: 0.5rem;
}

.empty-state-cta .btn-primary,
.empty-state-cta .btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* Size variants */
.empty-state.empty-state--sm {
  padding: 2rem 1.5rem;
  gap: 0.75rem;
}

.empty-state.empty-state--sm .empty-state-icon {
  width: 60px;
  height: 60px;
  font-size: 1.75rem;
}

.empty-state.empty-state--sm .empty-state-title {
  font-size: 1.1rem;
}

.empty-state.empty-state--sm .empty-state-description {
  font-size: 0.9rem;
}

/* Themed variants */
.empty-state.empty-state--success {
  border-color: rgba(34, 197, 94, 0.3);
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.05), transparent);
}

.empty-state.empty-state--success .empty-state-icon {
  color: var(--accent-success);
  background: rgba(34, 197, 94, 0.1);
}

.empty-state.empty-state--warning {
  border-color: rgba(245, 158, 11, 0.3);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.05), transparent);
}

.empty-state.empty-state--warning .empty-state-icon {
  color: var(--accent-warning);
  background: rgba(245, 158, 11, 0.1);
}

.empty-state.empty-state--info {
  border-color: rgba(99, 102, 241, 0.3);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), transparent);
}

.empty-state.empty-state--info .empty-state-icon {
  color: var(--accent-info);
  background: rgba(99, 102, 241, 0.1);
}

/* ==========================================================================
   4. FORM VALIDATION FEEDBACK
   ========================================================================== */

.form-input.invalid,
.form-textarea.invalid,
.form-select.invalid {
  border-color: var(--accent-danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
  animation: input-shake 0.4s ease;
}

.form-input.valid,
.form-textarea.valid,
.form-select.valid {
  border-color: var(--accent-success);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

@keyframes input-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.form-error {
  color: var(--accent-danger);
  font-size: 0.85rem;
  margin-top: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  animation: fade-in-down 0.3s ease;
}

.form-error::before {
  content: '\26A0\FE0F';
  font-size: 0.9rem;
}

/* Field-level error messages */
.field-error {
  display: block;
  color: var(--accent-danger);
  font-size: 0.8rem;
  margin-top: 0.25rem;
  animation: fade-in-down 0.2s ease;
}

/* Password strength indicator */
.password-strength {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.password-strength .strength-bar {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.password-strength .strength-fill {
  height: 100%;
  width: 0;
  transition: width 0.3s ease, background 0.3s ease;
  border-radius: 2px;
}

.password-strength .strength-label {
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 70px;
  text-align: right;
}

.form-success {
  color: var(--accent-success);
  font-size: 0.85rem;
  margin-top: 0.35rem;
}

@keyframes fade-in-down {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   5. ACCESSIBILITY - FOCUS INDICATORS
   ========================================================================== */

.giveaway-card:focus-within {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  box-shadow: var(--shadow-lg), 0 0 0 4px rgba(139, 92, 246, 0.2);
  transform: translateY(-4px);
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.2);
}

*:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.25), 0 0 20px rgba(139, 92, 246, 0.2);
}

.giveaway-card:focus-within,
.dashboard-card:focus-within {
  box-shadow: var(--shadow-lg), 0 0 0 4px rgba(139, 92, 246, 0.25);
  transform: translateY(-2px);
}

.btn-primary:focus-visible,
.btn-secondary:focus-visible {
  box-shadow: var(--shadow-glow), 0 0 0 4px rgba(139, 92, 246, 0.3);
}

/* ==========================================================================
   6. MOBILE NAVIGATION
   ========================================================================== */

@media (max-width: 768px) {
  .nav-container {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0.5rem;
  }

  .nav-container::-webkit-scrollbar {
    display: none;
  }

  .nav-links {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0.35rem;
  }

  .nav-link {
    flex-shrink: 0;
    font-size: 0.85rem;
    padding: 0.5rem 0.85rem;
  }
}

/* ==========================================================================
   7. LOADING STATE CONSISTENCY
   ========================================================================== */

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(139, 92, 246, 0.1);
  border-top: 4px solid var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  box-shadow: 0 0 25px rgba(139, 92, 246, 0.3);
}

.content-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  gap: 1rem;
}

.content-loader-text {
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 500;
  animation: pulse-text 2s ease-in-out infinite;
}

@keyframes pulse-text {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ==========================================================================
   8. VISUAL HIERARCHY
   ========================================================================== */

.section-heading {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.card-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
}

.card-header p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-top: 0.35rem;
  line-height: 1.5;
}

.task-list {
  gap: 1rem;
}

.task-item {
  padding: 1rem;
}

/* ==========================================================================
   9. 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;
  }
}
