/* ==========================================================================
   AiNoted UI Components — components.css
   Complete component library. All values reference variables.css tokens.
   ========================================================================== */


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

/* --------------------------------------------------------------------------
   Button Base
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  line-height: var(--leading-none);
  color: var(--text-primary);
  background-color: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: all var(--duration-normal) var(--ease-default);
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.btn:hover {
  text-decoration: none;
}

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

/* --------------------------------------------------------------------------
   Button — Primary
   -------------------------------------------------------------------------- */
.btn-primary {
  background: var(--gradient-primary);
  color: var(--text-primary);
  border-color: transparent;
  box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 24px rgba(0, 184, 255, 0.35),
              0 0 48px rgba(0, 184, 255, 0.15);
  filter: brightness(1.1);
}

.btn-primary:active {
  transform: translateY(0);
  filter: brightness(0.95);
}

/* --------------------------------------------------------------------------
   Button — Secondary
   -------------------------------------------------------------------------- */
.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.btn-secondary:hover {
  background-color: var(--bg-elevated);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.btn-secondary:active {
  transform: translateY(0);
  background-color: var(--bg-overlay);
}

/* --------------------------------------------------------------------------
   Button — Ghost
   -------------------------------------------------------------------------- */
.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

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

.btn-ghost:active {
  background-color: var(--bg-elevated);
}

/* --------------------------------------------------------------------------
   Button — Danger
   -------------------------------------------------------------------------- */
.btn-danger {
  background-color: var(--error-500);
  color: var(--text-primary);
  border-color: transparent;
}

.btn-danger:hover {
  background-color: var(--error-400);
  transform: translateY(-1px);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.25);
}

.btn-danger:active {
  background-color: var(--error-600);
  transform: translateY(0);
}

/* --------------------------------------------------------------------------
   Button Sizes
   -------------------------------------------------------------------------- */
.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  border-radius: var(--radius-md);
}

.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-base);
  border-radius: var(--radius-xl);
}

/* --------------------------------------------------------------------------
   Button — Icon (square)
   -------------------------------------------------------------------------- */
.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-lg);
}

.btn-icon.btn-sm {
  width: 32px;
  height: 32px;
}

.btn-icon.btn-lg {
  width: 48px;
  height: 48px;
}

/* --------------------------------------------------------------------------
   Button — Loading State
   -------------------------------------------------------------------------- */
.btn.loading {
  color: transparent;
  pointer-events: none;
}

.btn.loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid var(--text-primary);
  border-top-color: transparent;
  border-radius: var(--radius-full);
  animation: btn-spin 0.6s linear infinite;
}

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


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

/* --------------------------------------------------------------------------
   Form Group
   -------------------------------------------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.form-group:last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   Form Label
   -------------------------------------------------------------------------- */
.form-label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  letter-spacing: var(--tracking-wide);
}

.form-label .required {
  color: var(--error-400);
  margin-left: var(--space-1);
}

/* --------------------------------------------------------------------------
   Form Input
   -------------------------------------------------------------------------- */
.form-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  transition: border-color var(--duration-normal) var(--ease-default),
              box-shadow var(--duration-normal) var(--ease-default),
              background-color var(--duration-normal) var(--ease-default);
}

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

.form-input:hover {
  border-color: var(--border-default);
  background-color: var(--bg-elevated);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(0, 184, 255, 0.15);
  background-color: var(--bg-elevated);
}

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

/* --------------------------------------------------------------------------
   Form Textarea
   -------------------------------------------------------------------------- */
.form-textarea {
  width: 100%;
  min-height: 120px;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  color: var(--text-primary);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  resize: vertical;
  transition: border-color var(--duration-normal) var(--ease-default),
              box-shadow var(--duration-normal) var(--ease-default),
              background-color var(--duration-normal) var(--ease-default);
}

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

.form-textarea:hover {
  border-color: var(--border-default);
  background-color: var(--bg-elevated);
}

.form-textarea:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(0, 184, 255, 0.15);
  background-color: var(--bg-elevated);
}

/* --------------------------------------------------------------------------
   Form Select
   -------------------------------------------------------------------------- */
.form-select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  padding-right: var(--space-10);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8.825a.5.5 0 0 1-.354-.146l-3.5-3.5a.5.5 0 0 1 .708-.708L6 7.617l3.146-3.146a.5.5 0 0 1 .708.708l-3.5 3.5A.5.5 0 0 1 6 8.825z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  background-size: 12px;
  cursor: pointer;
  transition: border-color var(--duration-normal) var(--ease-default),
              box-shadow var(--duration-normal) var(--ease-default),
              background-color var(--duration-normal) var(--ease-default);
}

.form-select:hover {
  border-color: var(--border-default);
  background-color: var(--bg-elevated);
}

.form-select:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(0, 184, 255, 0.15);
}

/* --------------------------------------------------------------------------
   Form Error & Hint
   -------------------------------------------------------------------------- */
.form-error {
  font-size: var(--text-xs);
  color: var(--error-400);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

/* Error state on inputs */
.form-input.error,
.form-textarea.error,
.form-select.error {
  border-color: var(--error-500);
}

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


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

.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: background-color var(--duration-normal) var(--ease-default),
              box-shadow var(--duration-normal) var(--ease-default),
              border-color var(--duration-normal) var(--ease-default),
              transform var(--duration-normal) var(--ease-default);
}

.card:hover {
  background-color: var(--bg-elevated);
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body {
  padding: var(--space-6);
}

.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* Card with no hover effect */
.card-static {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.card-static .card-header,
.card-static .card-body,
.card-static .card-footer {
  /* Inherits the same spacing from above */
}


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

/* --------------------------------------------------------------------------
   Backdrop
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-slow) var(--ease-default),
              visibility var(--duration-slow) var(--ease-default);
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

/* --------------------------------------------------------------------------
   Modal Container
   -------------------------------------------------------------------------- */
.modal {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--duration-slow) var(--ease-spring);
}

.modal-backdrop.open .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: var(--space-6);
  padding-bottom: var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2,
.modal-header h3 {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  transition: background-color var(--duration-fast) var(--ease-default),
              color var(--duration-fast) var(--ease-default);
}

.modal-close:hover {
  background-color: var(--bg-overlay);
  color: var(--text-primary);
}

.modal-body {
  padding: 0 var(--space-6) var(--space-6);
  color: var(--text-secondary);
}

.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* Wider modal variant */
.modal-wide {
  max-width: 680px;
}


/* ==========================================================================
   TOASTS / NOTIFICATIONS
   ========================================================================== */

/* --------------------------------------------------------------------------
   Toast Container
   -------------------------------------------------------------------------- */
.toast-container {
  position: fixed;
  top: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 320px;
  max-width: 420px;
  pointer-events: auto;
  animation: toast-slide-in var(--duration-slow) var(--ease-spring) forwards;
}

.toast-title {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

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

.toast-dismiss {
  margin-left: auto;
  flex-shrink: 0;
  color: var(--text-tertiary);
  transition: color var(--duration-fast) var(--ease-default);
}

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

/* Toast accent variants — left border colour */
.toast-success {
  border-left: 3px solid var(--success-500);
}

.toast-error {
  border-left: 3px solid var(--error-500);
}

.toast-warning {
  border-left: 3px solid var(--warning-500);
}

.toast-info {
  border-left: 3px solid var(--info-500);
}

/* Toast exit animation */
.toast.removing {
  animation: toast-slide-out var(--duration-slow) var(--ease-default) forwards;
}

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

@keyframes toast-slide-out {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}


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

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  line-height: var(--leading-none);
  border-radius: var(--radius-full);
  white-space: nowrap;
}

/* Badge Variants */
.badge-primary {
  background-color: rgba(0, 184, 255, 0.15);
  color: var(--primary-400);
}

.badge-secondary {
  background-color: rgba(99, 102, 241, 0.15);
  color: var(--secondary-400);
}

.badge-tertiary {
  background-color: rgba(168, 85, 247, 0.15);
  color: var(--tertiary-400);
}

.badge-success {
  background-color: rgba(34, 197, 94, 0.15);
  color: var(--success-400);
}

.badge-warning {
  background-color: rgba(234, 179, 8, 0.15);
  color: var(--warning-400);
}

.badge-error {
  background-color: rgba(239, 68, 68, 0.15);
  color: var(--error-400);
}

.badge-neutral {
  background-color: var(--bg-overlay);
  color: var(--text-secondary);
}

/* Tier badges for plans */
.badge-free {
  background-color: var(--bg-overlay);
  color: var(--text-secondary);
}

.badge-pro {
  background: var(--gradient-primary);
  color: var(--text-primary);
}

.badge-enterprise {
  background: var(--gradient-accent);
  color: var(--text-primary);
}

/* Status dot badge */
.badge-status {
  padding-left: var(--space-2);
}

.badge-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background-color: currentColor;
  flex-shrink: 0;
}


/* ==========================================================================
   TABS
   ========================================================================== */

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  gap: var(--space-1);
  overflow-x: auto;
}

.tab-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-tertiary);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--duration-normal) var(--ease-default),
              border-color var(--duration-normal) var(--ease-default);
  margin-bottom: -1px;
}

.tab-item:hover {
  color: var(--text-secondary);
}

.tab-item.active {
  color: var(--text-primary);
  border-bottom-color: var(--primary-500);
}

.tab-content {
  padding-top: var(--space-6);
}


/* ==========================================================================
   PROGRESS / USAGE BAR
   ========================================================================== */

.progress-bar {
  width: 100%;
  height: 8px;
  background-color: var(--bg-overlay);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  transition: width var(--duration-slower) var(--ease-out);
  position: relative;
}

/* Glow effect when usage is high (>80%) */
.progress-bar-fill.high-usage {
  box-shadow: 0 0 8px rgba(0, 184, 255, 0.4);
}

.progress-bar-fill.warning {
  background: linear-gradient(135deg, var(--warning-500), var(--error-500));
  box-shadow: 0 0 8px rgba(234, 179, 8, 0.4);
}

.progress-bar-fill.danger {
  background: var(--error-500);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

/* Animated stripe for active processes */
.progress-bar-fill.animated {
  background-image: linear-gradient(
    -45deg,
    rgba(255, 255, 255, 0.08) 25%,
    transparent 25%,
    transparent 50%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.08) 75%,
    transparent 75%
  );
  background-size: 20px 20px;
  animation: progress-stripe 1s linear infinite;
}

@keyframes progress-stripe {
  from { background-position: 0 0; }
  to   { background-position: 20px 0; }
}

/* Usage label */
.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
}

.progress-label-title {
  color: var(--text-secondary);
}

.progress-label-value {
  color: var(--text-primary);
  font-weight: var(--font-medium);
  font-variant-numeric: tabular-nums;
}


/* ==========================================================================
   DROPDOWN
   ========================================================================== */

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

.dropdown-menu {
  position: absolute;
  top: calc(100% + var(--space-1));
  left: 0;
  min-width: 200px;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  padding: var(--space-1);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity var(--duration-normal) var(--ease-default),
              visibility var(--duration-normal) var(--ease-default),
              transform var(--duration-normal) var(--ease-default);
}

.dropdown.open .dropdown-menu,
.dropdown-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Right-aligned variant */
.dropdown-menu.right {
  left: auto;
  right: 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-default),
              color var(--duration-fast) var(--ease-default);
}

.dropdown-item:hover {
  background-color: var(--bg-overlay);
  color: var(--text-primary);
}

.dropdown-item.active {
  background-color: rgba(0, 184, 255, 0.1);
  color: var(--primary-400);
}

.dropdown-item.danger {
  color: var(--error-400);
}

.dropdown-item.danger:hover {
  background-color: rgba(239, 68, 68, 0.1);
}

.dropdown-divider {
  height: 1px;
  background-color: var(--border-subtle);
  margin: var(--space-1) 0;
}

.dropdown-label {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
}


/* ==========================================================================
   AVATAR
   ========================================================================== */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background-color: var(--primary-700);
  color: var(--text-primary);
  font-weight: var(--font-semibold);
  overflow: hidden;
  flex-shrink: 0;
  user-select: none;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Avatar Sizes */
.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: var(--text-xs);
}

.avatar-md {
  width: 40px;
  height: 40px;
  font-size: var(--text-sm);
}

.avatar-lg {
  width: 56px;
  height: 56px;
  font-size: var(--text-lg);
}

.avatar-xl {
  width: 80px;
  height: 80px;
  font-size: var(--text-2xl);
}

/* Avatar group (overlapping) */
.avatar-group {
  display: flex;
}

.avatar-group .avatar {
  border: 2px solid var(--bg-surface);
  margin-left: -8px;
}

.avatar-group .avatar:first-child {
  margin-left: 0;
}


/* ==========================================================================
   SKELETON LOADERS
   ========================================================================== */

.skeleton {
  background-color: var(--bg-surface);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(148, 163, 184, 0.06) 40%,
    rgba(148, 163, 184, 0.06) 60%,
    transparent 100%
  );
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

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

/* Common skeleton shapes */
.skeleton-text {
  height: 14px;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-sm);
}

.skeleton-text:last-child {
  width: 70%;
}

.skeleton-heading {
  height: 24px;
  width: 50%;
  margin-bottom: var(--space-4);
  border-radius: var(--radius-sm);
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
}

.skeleton-card {
  height: 200px;
  border-radius: var(--radius-xl);
}

.skeleton-button {
  height: 40px;
  width: 120px;
  border-radius: var(--radius-lg);
}


/* ==========================================================================
   DIVIDER
   ========================================================================== */

.divider {
  border: none;
  height: 1px;
  background-color: var(--border-subtle);
  margin: var(--space-6) 0;
}

.divider-sm {
  margin: var(--space-3) 0;
}

.divider-lg {
  margin: var(--space-10) 0;
}

/* Divider with text */
.divider-text {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  color: var(--text-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  margin: var(--space-6) 0;
}

.divider-text::before,
.divider-text::after {
  content: "";
  flex: 1;
  height: 1px;
  background-color: var(--border-subtle);
}


/* ==========================================================================
   TOOLTIP
   ========================================================================== */

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

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + var(--space-2));
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: var(--space-2) var(--space-3);
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  color: var(--text-primary);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  white-space: nowrap;
  z-index: var(--z-tooltip);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--duration-normal) var(--ease-default),
              transform var(--duration-normal) var(--ease-default),
              visibility var(--duration-normal) var(--ease-default);
}

.tooltip:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Tooltip bottom position */
.tooltip-bottom::after {
  bottom: auto;
  top: calc(100% + var(--space-2));
  transform: translateX(-50%) translateY(-4px);
}

.tooltip-bottom:hover::after {
  transform: translateX(-50%) translateY(0);
}


/* ==========================================================================
   EMPTY STATE
   ========================================================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-16) var(--space-6);
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-2xl);
  color: var(--text-muted);
  margin-bottom: var(--space-6);
}

.empty-state-icon svg {
  width: 28px;
  height: 28px;
}

.empty-state-heading {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.empty-state-description {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  max-width: 360px;
  margin-bottom: var(--space-6);
  line-height: var(--leading-relaxed);
}

.empty-state-action {
  /* Uses .btn classes for the actual button */
}


/* ==========================================================================
   TOGGLE / SWITCH
   ========================================================================== */

.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

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

.toggle-slider {
  position: absolute;
  inset: 0;
  background-color: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background-color var(--duration-normal) var(--ease-default),
              border-color var(--duration-normal) var(--ease-default);
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  bottom: 2px;
  background-color: var(--text-secondary);
  border-radius: var(--radius-full);
  transition: transform var(--duration-normal) var(--ease-spring),
              background-color var(--duration-normal) var(--ease-default);
}

.toggle input:checked + .toggle-slider {
  background-color: var(--primary-700);
  border-color: var(--primary-500);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background-color: var(--primary-400);
}

.toggle input:focus-visible + .toggle-slider {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}


/* ==========================================================================
   TABLE
   ========================================================================== */

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
}

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

.table th {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  text-align: left;
  background-color: var(--bg-deepest);
  border-bottom: 1px solid var(--border-subtle);
}

.table td {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}

.table tr:last-child td {
  border-bottom: none;
}

.table tbody tr {
  transition: background-color var(--duration-fast) var(--ease-default);
}

.table tbody tr:hover {
  background-color: var(--bg-surface);
}


/* ==========================================================================
   CHIP / TAG
   ========================================================================== */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  background-color: var(--bg-overlay);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

.chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-default),
              background-color var(--duration-fast) var(--ease-default);
}

.chip-remove:hover {
  color: var(--text-primary);
  background-color: var(--bg-surface);
}
