/**
 * Neumorphism 2.0 Components
 * Reusable UI Components for Prompts Marketplace
 *
 * Following UX Guidelines for 2025-2026:
 * - Micro Interactions Everywhere
 * - Glass Hierarchy
 * - Tactile Illusion
 * - Minimal Cognitive Steps
 */

/* ============================================================================
   BUTTONS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.75rem;
  font-size: 1rem;
  font-variation-settings: 'wght' 500;
  text-decoration: none;
  border: none;
  border-radius: var(--radius-md);
  background: var(--base);
  color: var(--text);
  box-shadow: var(--shadow-neumorphic);
  cursor: pointer;
  transition: all var(--transition-smooth);
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  box-shadow: var(--shadow-neumorphic-hover);
  transform: translateY(-2px);
}

.btn:active {
  box-shadow: var(--shadow-neumorphic-inset);
  transform: translateY(0);
}

/* Button Sizes */
.btn-sm {
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 1.125rem 2.25rem;
  font-size: 1.125rem;
  border-radius: var(--radius-lg);
}

.btn-xl {
  padding: 1.375rem 2.75rem;
  font-size: 1.25rem;
  border-radius: var(--radius-xl);
}

/* Button Variants */
.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow:
    0 4px 15px color-mix(in srgb, var(--accent) 40%, transparent),
    var(--shadow-neumorphic);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow:
    0 6px 20px color-mix(in srgb, var(--accent) 50%, transparent),
    var(--shadow-neumorphic-hover);
}

.btn-primary:active {
  box-shadow:
    inset 0 2px 8px color-mix(in srgb, var(--accent) 60%, black),
    var(--shadow-neumorphic-inset);
}

.btn-success {
  background: var(--success);
  color: white;
  box-shadow:
    0 4px 15px color-mix(in srgb, var(--success) 40%, transparent),
    var(--shadow-neumorphic);
}

.btn-success:hover {
  background: color-mix(in srgb, var(--success) 90%, black);
}

.btn-glass {
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-border);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  box-shadow: none;
  border: 2px solid var(--accent);
  color: var(--accent);
}

.btn-ghost:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  box-shadow: 0 4px 15px color-mix(in srgb, var(--accent) 20%, transparent);
}

/* Icon Buttons */
.btn-icon {
  width: 3rem;
  height: 3rem;
  padding: 0;
  border-radius: 50%;
}

.btn-icon-sm {
  width: 2.5rem;
  height: 2.5rem;
}

.btn-icon-lg {
  width: 3.5rem;
  height: 3.5rem;
}

/* Button Group */
.btn-group {
  display: inline-flex;
  gap: 0.5rem;
}

.btn-group .btn:not(:last-child) {
  margin-right: -1px;
}

/* ============================================================================
   CARDS
   ========================================================================== */

.card {
  background: var(--base);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-neumorphic);
  padding: 1.5rem;
  transition: all var(--transition-smooth);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-neumorphic-hover);
  transform: translateY(-4px);
}

.card-header {
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
}

.card-title {
  font-size: 1.5rem;
  font-variation-settings: 'wght' 600;
  margin: 0;
  color: var(--text);
}

.card-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.card-body {
  color: var(--text-secondary);
  line-height: 1.6;
}

.card-footer {
  padding-top: 1rem;
  margin-top: 1rem;
  border-top: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Glass Card */
.card-glass {
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Raised Card */
.card-raised {
  box-shadow:
    10px 10px 20px rgba(0, 0, 0, 0.2),
    -10px -10px 20px rgba(255, 255, 255, 0.95);
}

@media (prefers-color-scheme: dark) {
  .card-raised {
    box-shadow:
      10px 10px 20px rgba(0, 0, 0, 0.5),
      -10px -10px 20px rgba(255, 255, 255, 0.08);
  }
}

/* Interactive Card */
.card-interactive {
  cursor: pointer;
  position: relative;
}

.card-interactive::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--accent) 5%, transparent),
    transparent);
  opacity: 0;
  transition: opacity var(--transition-smooth);
  border-radius: var(--radius-lg);
}

.card-interactive:hover::before {
  opacity: 1;
}

.card-interactive:active {
  transform: translateY(0);
  box-shadow: var(--shadow-neumorphic-inset);
}

/* ============================================================================
   FORM INPUTS
   ========================================================================== */

.input,
.textarea,
.select {
  width: 100%;
  padding: 0.875rem 1.25rem;
  font-size: 1rem;
  font-family: inherit;
  background: var(--base);
  color: var(--text);
  border: none;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-neumorphic-inset);
  transition: all var(--transition-smooth);
  outline: none;
}

.input:focus,
.textarea:focus,
.select:focus {
  box-shadow:
    inset 4px 4px 8px rgba(0, 0, 0, 0.15),
    inset -4px -4px 8px rgba(255, 255, 255, 0.5),
    0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

/* Input Sizes */
.input-sm,
.textarea-sm {
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
}

.input-lg,
.textarea-lg {
  padding: 1.125rem 1.5rem;
  font-size: 1.125rem;
  border-radius: var(--radius-lg);
}

/* Input Group */
.input-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.input-group .input {
  flex: 1;
}

.input-group .btn {
  flex-shrink: 0;
}

/* Input with Icon */
.input-icon-wrapper {
  position: relative;
}

.input-icon-wrapper .input {
  padding-left: 3rem;
}

.input-icon-wrapper .icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
}

/* Checkbox & Radio */
.checkbox,
.radio {
  appearance: none;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: var(--radius-sm);
  background: var(--base);
  box-shadow: var(--shadow-neumorphic-inset);
  cursor: pointer;
  transition: all var(--transition-smooth);
  position: relative;
}

.radio {
  border-radius: 50%;
}

.checkbox:checked,
.radio:checked {
  background: var(--accent);
  box-shadow:
    inset 2px 2px 4px rgba(0, 0, 0, 0.2),
    0 0 10px color-mix(in srgb, var(--accent) 40%, transparent);
}

.checkbox:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 0.875rem;
  font-weight: bold;
}

.radio:checked::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: white;
}

/* Toggle Switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 3.5rem;
  height: 2rem;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--base);
  box-shadow: var(--shadow-neumorphic-inset);
  transition: all var(--transition-smooth);
  border-radius: 2rem;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 1.5rem;
  width: 1.5rem;
  left: 0.25rem;
  bottom: 0.25rem;
  background: var(--base);
  box-shadow: var(--shadow-neumorphic);
  transition: all var(--transition-smooth);
  border-radius: 50%;
}

.toggle input:checked + .toggle-slider {
  background: var(--accent);
  box-shadow:
    inset 2px 2px 4px rgba(0, 0, 0, 0.2),
    0 0 10px color-mix(in srgb, var(--accent) 40%, transparent);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(1.5rem);
  box-shadow:
    3px 3px 6px rgba(0, 0, 0, 0.2),
    -2px -2px 4px rgba(255, 255, 255, 0.8);
}

/* ============================================================================
   NAVIGATION
   ========================================================================== */

.nav {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--base);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-neumorphic);
}

.nav-item {
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  color: var(--text);
  text-decoration: none;
  transition: all var(--transition-smooth);
  font-variation-settings: 'wght' 500;
}

.nav-item:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
}

.nav-item.active {
  background: var(--base);
  color: var(--accent);
  box-shadow: var(--shadow-neumorphic-inset);
}

/* Glass Navigation */
.nav-glass {
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-border);
}

/* ============================================================================
   BADGES & TAGS
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-variation-settings: 'wght' 600;
  border-radius: 9999px;
  background: var(--base);
  color: var(--text);
  box-shadow:
    3px 3px 6px rgba(0, 0, 0, 0.12),
    -3px -3px 6px rgba(255, 255, 255, 0.8);
}

.badge-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 40%, transparent);
}

.badge-success {
  background: var(--success);
  color: white;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--success) 40%, transparent);
}

.badge-warning {
  background: var(--warning);
  color: white;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--warning) 40%, transparent);
}

.badge-error {
  background: var(--error);
  color: white;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--error) 40%, transparent);
}

/* ============================================================================
   MODALS & DIALOGS
   ========================================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity var(--transition-smooth);
}

.modal-overlay.active {
  opacity: 1;
}

.modal {
  background: var(--base);
  border-radius: var(--radius-xl);
  box-shadow:
    20px 20px 40px rgba(0, 0, 0, 0.3),
    -20px -20px 40px rgba(255, 255, 255, 0.95);
  max-width: 500px;
  width: 90%;
  padding: 2rem;
  transform: scale(0.9);
  transition: transform var(--transition-smooth);
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-glass {
  background: var(--glass-bg);
  backdrop-filter: blur(30px) saturate(200%);
  -webkit-backdrop-filter: blur(30px) saturate(200%);
  border: 1px solid var(--glass-border);
}

/* ============================================================================
   PROGRESS BARS
   ========================================================================== */

.progress {
  width: 100%;
  height: 1rem;
  background: var(--base);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-neumorphic-inset);
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 40%, transparent);
  transition: width var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent);
  animation: progress-shimmer 1.5s infinite;
}

@keyframes progress-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ============================================================================
   TOOLTIPS
   ========================================================================== */

.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip-content {
  visibility: hidden;
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 1rem;
  background: var(--base);
  color: var(--text);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-neumorphic);
  white-space: nowrap;
  opacity: 0;
  transition: all var(--transition-quick);
  font-size: 0.875rem;
  z-index: 100;
}

.tooltip:hover .tooltip-content {
  visibility: visible;
  opacity: 1;
}

.tooltip-content::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--base);
}

/* ============================================================================
   LOADING SPINNERS
   ========================================================================== */

.spinner {
  width: 3rem;
  height: 3rem;
  border: 4px solid var(--base);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  box-shadow: var(--shadow-neumorphic);
}

.spinner-sm {
  width: 1.5rem;
  height: 1.5rem;
  border-width: 2px;
}

.spinner-lg {
  width: 4rem;
  height: 4rem;
  border-width: 6px;
}

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