/* ═══════════════════════════════════════════════════════════
   3mi Store — Component Library
   Modern, token-driven, variant-based components
   Glassmorphism-ready with refined interactions
   ═══════════════════════════════════════════════════════════ */

/* ─── BUTTONS ─── */
/* Base button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-inline-sm);
  padding: var(--space-inset-md) var(--space-inset-lg);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background var(--transition-base),
              color var(--transition-base),
              border-color var(--transition-base),
              box-shadow var(--transition-base),
              transform var(--transition-fast);
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn:focus-visible { box-shadow: var(--focus-ring); }

/* Variants */
.btn--primary {
  background: var(--brand-500);
  color: var(--color-neutral-0);
  box-shadow: var(--shadow-brand-sm);
}
.btn--primary:hover {
  background: var(--brand-600);
  box-shadow: var(--shadow-brand-md);
  transform: translateY(-2px);
}
.btn--primary:active { transform: scale(0.97); }

.btn--secondary {
  background: var(--surface-2);
  color: var(--text-primary);
  border-color: var(--border-default);
}
.btn--secondary:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
}

.btn--ghost {
  background: none;
  color: var(--text-secondary);
}
.btn--ghost:hover { color: var(--text-primary); background: var(--surface-2); }

.btn--outline {
  background: none;
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn--outline:hover { border-color: var(--text-primary); background: var(--surface-1); }

.btn--danger {
  background: var(--error);
  color: var(--color-neutral-0);
  box-shadow: 0 2px 8px -2px var(--error);
}
.btn--danger:hover { background: var(--error-hover); box-shadow: 0 4px 16px -4px var(--error); }

/* Glass button variant */
.btn--glass {
  background: var(--glass-2);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  box-shadow: var(--shadow-glass-1);
}
.btn--glass:hover {
  background: var(--glass-3);
  border-color: var(--glass-border-strong);
  box-shadow: var(--shadow-glass-2);
}

/* Sizes */
.btn--sm { padding: var(--space-inset-xs) var(--space-inset-md); font-size: var(--text-xs); }
.btn--lg { padding: var(--space-inset-lg) var(--space-inset-xl); font-size: var(--text-base); }
.btn--xl { padding: var(--space-4) var(--space-7); font-size: var(--text-lg); }
.btn--block { width: 100%; }
.btn--icon { padding: var(--space-inset-sm); }

/* Pill variant */
.btn--pill { border-radius: var(--radius-full); }

/* ─── CARDS ─── */
.card {
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  overflow: hidden;
  transition: transform var(--transition-base),
              box-shadow var(--transition-base),
              border-color var(--transition-base);
}

/* Elevation variants */
.card--elevated { box-shadow: var(--shadow-card); border: none; }
.card--outlined { box-shadow: none; border-color: var(--border-default); }
.card--filled { background: var(--surface-1); border: none; box-shadow: none; }
.card--flat { box-shadow: none; border: none; background: transparent; }

/* Glassmorphism variants */
.card--glass-1 {
  background: var(--glass-1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-glass-1);
}
.card--glass-2 {
  background: var(--glass-2);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-glass-2);
}
.card--glass-3 {
  background: var(--glass-3);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border-strong);
  box-shadow: var(--shadow-glass-3);
}

.card--interactive:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--border-strong);
}

.card--glass-1:hover,
.card--glass-2:hover,
.card--glass-3:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-glass-3);
  border-color: var(--glass-border-strong);
}

/* Surface levels */
.card--surface-2 { background: var(--surface-2); }
.card--surface-3 { background: var(--surface-3); }

/* ─── INPUTS ─── */
.input, .textarea, .select {
  width: 100%;
  padding: var(--space-inset-md) var(--space-inset-lg);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-input);
  transition: border-color var(--transition-base), box-shadow var(--transition-base), background var(--transition-base);
  outline: none;
}
.input::placeholder, .textarea::placeholder { color: var(--text-tertiary); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--border-focus);
  box-shadow: var(--focus-ring);
  background: var(--surface-0);
}
.input:disabled, .textarea:disabled, .select:disabled {
  background: var(--surface-2);
  color: var(--text-tertiary);
  cursor: not-allowed;
}
.textarea { resize: vertical; line-height: var(--leading-normal); }

/* Glass input variant */
.input--glass, .textarea--glass, .select--glass {
  background: var(--glass-2);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
}
.input--glass:focus, .textarea--glass:focus, .select--glass:focus {
  background: var(--glass-3);
  border-color: var(--glass-border-strong);
  box-shadow: var(--focus-ring), var(--shadow-glass-2);
}

/* Input sizes */
.input--sm { padding: var(--space-inset-xs) var(--space-inset-md); font-size: var(--text-xs); }
.input--lg { padding: var(--space-inset-lg) var(--space-inset-xl); font-size: var(--text-base); }

/* Validation states */
.input--error, .input--error:focus { border-color: var(--error); box-shadow: 0 0 0 3px rgb(239 68 68 / 0.15); }
.input--success, .input--success:focus { border-color: var(--success); box-shadow: 0 0 0 3px rgb(34 197 94 / 0.15); }

/* ─── BADGES / TAGS ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-inset-sm);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-badge);
  background: var(--surface-2);
  color: var(--text-secondary);
  letter-spacing: var(--tracking-wide);
}
.badge--primary { background: var(--brand-500); color: var(--color-neutral-0); }
.badge--success { background: var(--success); color: var(--color-neutral-0); }
.badge--warning { background: var(--warning); color: var(--color-neutral-0); }
.badge--error { background: var(--error); color: var(--color-neutral-0); }
.badge--info { background: var(--info); color: var(--color-neutral-0); }
.badge--soft { background: var(--brand-50); color: var(--brand-600); }
.badge--outline { background: none; border: 1px solid var(--border-default); }
.badge--dot::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
}

/* ─── CHIPS / PILLS ─── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-inset-lg);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
}
.chip:hover { border-color: var(--border-focus); color: var(--text-primary); }
.chip--active {
  background: var(--brand-500);
  color: var(--color-neutral-0);
  border-color: var(--brand-500);
  box-shadow: var(--shadow-brand-sm);
}
.chip--active:hover { color: var(--color-neutral-0); }

/* Glass chip variant */
.chip--glass {
  background: var(--glass-2);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
}
.chip--glass:hover {
  background: var(--glass-3);
  border-color: var(--glass-border-strong);
  color: var(--text-primary);
}
.chip--glass.chip--active {
  background: var(--brand-500);
  border-color: var(--brand-500);
  color: var(--color-neutral-0);
}

/* ─── TOGGLE SWITCH ─── */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 44px; height: 24px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch__track {
  position: absolute;
  inset: 0;
  background: var(--surface-3);
  border-radius: var(--radius-full);
  transition: background var(--transition-base);
  cursor: pointer;
}
.switch__track::before {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: var(--surface-0);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-1);
  transition: transform var(--transition-base);
}
.switch input:checked + .switch__track { background: var(--brand-500); }
.switch input:checked + .switch__track::before { transform: translateX(20px); }
.switch input:focus-visible + .switch__track { box-shadow: var(--focus-ring); }

/* Glass switch variant */
.switch--glass .switch__track {
  background: var(--glass-2);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
}
.switch--glass .switch__track::before {
  background: var(--surface-0);
  box-shadow: var(--shadow-glass-1);
}
.switch--glass input:checked + .switch__track {
  background: var(--brand-500);
  border-color: var(--brand-500);
}

/* ─── AVATAR ─── */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
  object-fit: cover;
}

/* ─── TOOLTIP ─── */
.tooltip {
  position: relative;
  display: inline-flex;
}
.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--text-primary);
  color: var(--text-inverse);
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  border-radius: var(--radius-tooltip);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base), transform var(--transition-base);
  z-index: var(--z-tooltip);
}
.tooltip:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── DIVIDER ─── */
.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-4) 0;
}
.divider--vertical {
  width: 1px;
  height: auto;
  align-self: stretch;
  margin: 0 var(--space-3);
}

/* ─── SKELETON LOADING ─── */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── MODAL ─── */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: rgb(0 0 0 / 0.5);
  backdrop-filter: blur(8px);
  z-index: var(--z-modal);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}
.modal--open { opacity: 1; pointer-events: all; }
.modal__panel {
  background: var(--surface-elevated);
  border-radius: var(--radius-modal);
  box-shadow: var(--shadow-modal);
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.94);
  transition: transform var(--transition-spring);
  border: 1px solid var(--border-subtle);
}

/* Glass modal variant */
.modal__panel--glass {
  background: var(--glass-2);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-glass-3);
}
.modal--open .modal__panel { transform: scale(1); }

/* ─── DRAWER ─── */
.drawer {
  position: fixed;
  top: 0;
  height: 100vh;
  background: var(--surface-elevated);
  box-shadow: var(--shadow-modal);
  z-index: var(--z-modal);
  transition: transform var(--transition-slow);
}
.drawer--right { right: 0; transform: translateX(100%); }
.drawer--left { left: 0; transform: translateX(-100%); }
.drawer--open { transform: translateX(0); }

/* Glass drawer variant */
.drawer--glass {
  background: var(--glass-1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--glass-border);
  box-shadow: var(--shadow-glass-2);
}
.drawer--glass.drawer--left { border-right: none; border-left: 1px solid var(--glass-border); }

/* ─── TOAST ─── */
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-inset-md) var(--space-inset-lg);
  background: var(--surface-elevated);
  color: var(--text-primary);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-dropdown);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border: 1px solid var(--border-subtle);
}
.toast--success { border-left: 3px solid var(--success); }
.toast--error { border-left: 3px solid var(--error); }
.toast--info { border-left: 3px solid var(--info); }

/* ─── PROGRESS BAR ─── */
.progress {
  width: 100%;
  height: 4px;
  background: var(--surface-3);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  background: var(--brand-500);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

/* ─── SPINNER ─── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border-default);
  border-top-color: var(--brand-500);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── TOKEN-DRIVEN UTILITIES ─── */
.elevation-0 { box-shadow: var(--shadow-0); }
.elevation-1 { box-shadow: var(--shadow-1); }
.elevation-2 { box-shadow: var(--shadow-2); }
.elevation-3 { box-shadow: var(--shadow-3); }
.elevation-4 { box-shadow: var(--shadow-4); }
.elevation-5 { box-shadow: var(--shadow-5); }

.radius-sm { border-radius: var(--radius-sm); }
.radius-md { border-radius: var(--radius-md); }
.radius-lg { border-radius: var(--radius-lg); }
.radius-xl { border-radius: var(--radius-xl); }
.radius-full { border-radius: var(--radius-full); }

.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-3xl { font-size: var(--text-3xl); }
.text-4xl { font-size: var(--text-4xl); }

.weight-normal { font-weight: var(--weight-normal); }
.weight-medium { font-weight: var(--weight-medium); }
.weight-semibold { font-weight: var(--weight-semibold); }
.weight-bold { font-weight: var(--weight-bold); }

.color-primary { color: var(--text-primary); }
.color-secondary { color: var(--text-secondary); }
.color-tertiary { color: var(--text-tertiary); }
.color-brand { color: var(--brand-500); }
.color-success { color: var(--success); }
.color-error { color: var(--error); }
.color-warning { color: var(--warning); }