/**
 * 999DEX DESIGN SYSTEM - COMPONENTS
 *
 * Base component styles for buttons, cards, forms, modals, and more
 * Production-ready, pump.fun-inspired design
 *
 * Version: 1.0.0
 * Last Updated: November 2, 2025
 * References: Agent 1 (UI/UX), Agent 2 (Animations), Agent 3 (Token Cards)
 */

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: 0 var(--button-padding-x);
  height: var(--button-height-md);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  text-decoration: none;
  border: none;
  border-radius: var(--button-radius);
  cursor: pointer;
  transition:
    transform var(--transition-normal) var(--ease-out),
    background-color var(--transition-normal) var(--ease-out),
    box-shadow var(--transition-normal) var(--ease-out);
  user-select: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.95);
  transition-duration: var(--transition-fast);
}

/* Button Sizes */
.btn-sm {
  height: var(--button-height-sm);
  font-size: var(--font-size-sm);
  padding: 0 var(--button-padding-x-sm);
}

.btn-lg {
  height: var(--button-height-lg);
  font-size: var(--font-size-lg);
  padding: 0 var(--button-padding-x-lg);
}

/* Button Variants */
.btn-primary {
  background: var(--accent-purple);
  color: var(--text-primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-purple);
  box-shadow: var(--shadow-glow-purple);
  filter: brightness(1.1);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--border-hover);
}

.btn-success {
  background: var(--accent-green);
  color: var(--text-primary);
}

.btn-success:hover:not(:disabled) {
  background: var(--accent-green);
  box-shadow: var(--shadow-glow-green);
  filter: brightness(1.1);
}

.btn-danger {
  background: var(--accent-red);
  color: var(--text-primary);
}

.btn-danger:hover:not(:disabled) {
  background: var(--accent-red);
  box-shadow: var(--shadow-glow-red);
  filter: brightness(1.1);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 2px solid var(--border-primary);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.05);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

/* Gradient Button (999PAY/999SWAP Style) */
.btn-gradient {
  background: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-cyan) 100%);
  color: var(--text-primary);
  position: relative;
  overflow: hidden;
}

.btn-gradient:hover:not(:disabled) {
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.4);
  filter: brightness(1.1);
}

.btn-gradient:active:not(:disabled) {
  transform: scale(0.98);
}

/* Button Full Width */
.btn-block {
  width: 100%;
}

/* ========================================
   TOKEN CARDS (Agent 3 Specifications)
   ======================================== */

.token-card {
  background: var(--card-bg);
  border: var(--card-border);
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  box-shadow: var(--card-shadow);
  cursor: pointer;
  transition:
    transform var(--transition-normal) var(--ease-out),
    border-color var(--transition-normal) var(--ease-out),
    box-shadow var(--transition-normal) var(--ease-out);
  will-change: transform;
}

.token-card:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: var(--border-hover);
  box-shadow: var(--card-shadow-hover);
}

.token-card:active {
  transform: translateY(-2px) scale(1.01);
  transition-duration: var(--transition-fast);
}

/* Token Card Image */
.token-card-image-container {
  width: 100%;
  aspect-ratio: 1 / 1;
  margin-bottom: var(--spacing-md);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  position: relative;
}

.token-card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Token Card Header */
.token-card-header {
  margin-bottom: var(--spacing-sm);
}

.token-card-name {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin: 0 0 var(--spacing-xs) 0;
  line-height: var(--line-height-tight);
}

.token-card-symbol {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin: 0;
  text-transform: uppercase;
}

/* Token Card Metrics */
.token-card-metrics {
  display: flex;
  justify-content: space-between;
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--border-primary);
}

.token-card-metric {
  flex: 1;
  text-align: center;
}

.token-card-metric-label {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  margin-bottom: var(--spacing-xs);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
}

.token-card-metric-value {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

/* Token Card Badge */
.token-badge {
  display: inline-block;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  margin-top: var(--spacing-sm);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
}

.token-badge.trending {
  background: var(--success-light);
  color: var(--accent-green);
}

.token-badge.graduated {
  background: rgba(168, 85, 247, 0.2);
  color: var(--accent-purple);
}

.token-badge.new {
  background: var(--info-light);
  color: var(--accent-blue);
}

/* ========================================
   CARDS (Generic)
   ======================================== */

.card {
  background: var(--card-bg);
  border: var(--card-border);
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  box-shadow: var(--card-shadow);
}

.card-header {
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--border-primary);
}

.card-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin: 0;
}

.card-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin: var(--spacing-xs) 0 0 0;
}

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

.card-footer {
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--border-primary);
}

/* ========================================
   FORMS
   ======================================== */

.form-group {
  margin-bottom: var(--spacing-lg);
}

.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
  margin-bottom: var(--spacing-sm);
}

.form-label-required::after {
  content: '*';
  color: var(--accent-red);
  margin-left: var(--spacing-xs);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  height: var(--input-height);
  padding: 0 var(--input-padding-x);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background: var(--input-bg);
  border: var(--input-border);
  border-radius: var(--input-radius);
  transition: var(--transition-colors);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent-purple);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.form-textarea {
  height: auto;
  min-height: 120px;
  padding: var(--spacing-md) var(--input-padding-x);
  resize: vertical;
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Form Validation States */
.form-input.is-valid,
.form-select.is-valid,
.form-textarea.is-valid {
  border-color: var(--accent-green);
  background: var(--success-light);
}

.form-input.is-valid:focus,
.form-select.is-valid:focus,
.form-textarea.is-valid:focus {
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.form-input.is-invalid,
.form-select.is-invalid,
.form-textarea.is-invalid {
  border-color: var(--accent-red);
  background: var(--error-light);
}

.form-input.is-invalid:focus,
.form-select.is-invalid:focus,
.form-textarea.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-feedback {
  margin-top: var(--spacing-xs);
  font-size: var(--font-size-sm);
}

.form-feedback.valid {
  color: var(--accent-green);
}

.form-feedback.invalid {
  color: var(--accent-red);
}

/* ========================================
   MODALS
   ======================================== */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--modal-backdrop);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-lg);
}

.modal {
  background: var(--modal-bg);
  border: 1px solid var(--border-primary);
  border-radius: var(--modal-radius);
  padding: var(--modal-padding);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-2xl);
  z-index: var(--z-modal);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--border-primary);
}

.modal-title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin: 0;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: var(--font-size-2xl);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: var(--transition-colors);
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.modal-body {
  color: var(--text-secondary);
  line-height: var(--line-height-normal);
  margin-bottom: var(--spacing-lg);
}

.modal-footer {
  display: flex;
  gap: var(--spacing-md);
  justify-content: flex-end;
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--border-primary);
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */

.toast-container {
  position: fixed;
  top: var(--spacing-lg);
  right: var(--spacing-lg);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  max-width: 400px;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-md);
  min-width: 300px;
}

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin: 0 0 var(--spacing-xs) 0;
}

.toast-message {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin: 0;
}

.toast-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-close:hover {
  color: var(--text-primary);
}

/* Toast Variants */
.toast.success {
  border-color: var(--accent-green);
}

.toast.success .toast-icon {
  color: var(--accent-green);
}

.toast.error {
  border-color: var(--accent-red);
}

.toast.error .toast-icon {
  color: var(--accent-red);
}

.toast.warning {
  border-color: var(--accent-yellow);
}

.toast.warning .toast-icon {
  color: var(--accent-yellow);
}

.toast.info {
  border-color: var(--accent-blue);
}

.toast.info .toast-icon {
  color: var(--accent-blue);
}

/* ========================================
   BADGES
   ======================================== */

.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--spacing-xs) var(--spacing-sm);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
}

.badge-primary {
  background: rgba(168, 85, 247, 0.2);
  color: var(--accent-purple);
}

.badge-success {
  background: var(--success-light);
  color: var(--accent-green);
}

.badge-danger {
  background: var(--error-light);
  color: var(--accent-red);
}

.badge-warning {
  background: var(--warning-light);
  color: var(--accent-yellow);
}

.badge-info {
  background: var(--info-light);
  color: var(--accent-blue);
}

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

.progress {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--accent-green);
  border-radius: var(--radius-full);
  transition: width 300ms var(--ease-out);
}

.progress-bar.success {
  background: var(--accent-green);
}

.progress-bar.danger {
  background: var(--accent-red);
}

.progress-bar.warning {
  background: var(--accent-yellow);
}

.progress-bar.info {
  background: var(--accent-blue);
}

/* ========================================
   TABLES
   ======================================== */

.table {
  width: 100%;
  border-collapse: collapse;
}

.table thead {
  border-bottom: 1px solid var(--border-primary);
}

.table th {
  padding: var(--spacing-md);
  text-align: left;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
}

.table td {
  padding: var(--spacing-md);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  border-top: 1px solid var(--border-secondary);
}

.table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

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

.tooltip {
  position: relative;
}

.tooltip-content {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  white-space: nowrap;
  z-index: var(--z-tooltip);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-normal) var(--ease-out);
}

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

/* ========================================
   DIVIDERS
   ======================================== */

.divider {
  height: 1px;
  background: var(--border-primary);
  margin: var(--spacing-lg) 0;
}

.divider-vertical {
  width: 1px;
  height: 100%;
  background: var(--border-primary);
  margin: 0 var(--spacing-lg);
}
