/* ============================================================================
   controls.css — buttons, badges, form fields, dropdown menus, icon buttons.
   ============================================================================ */

/* ---- Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: var(--text-base);
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
  transition: background var(--transition-fast), border-color var(--transition-fast),
    color var(--transition-fast), box-shadow var(--transition-fast);
}
.btn-sm { padding: var(--space-1) var(--space-3); font-size: var(--text-sm); }
.btn .icon { width: 1rem; height: 1rem; }

.btn-primary {
  /* background-color is the flat fallback if background-image can't paint */
  background-color: var(--gradient-primary-from);
  background-image: var(--gradient-primary);
  color: var(--primary-foreground);
}
.btn-primary:hover { background-image: var(--gradient-primary-hover); }

.btn-outline {
  background: var(--card);
  border-color: var(--border);
  color: var(--foreground);
}
.btn-outline:hover { background: var(--secondary); border-color: var(--muted-foreground); }

.btn-ghost { background: transparent; color: var(--muted-foreground); }
.btn-ghost:hover { background: var(--secondary); color: var(--foreground); }

/* Icon-only button */
.btn-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  flex: none;
  padding: 0;
  border-radius: var(--radius-md);
  color: var(--muted-foreground);
}
.btn-icon:hover { background: var(--secondary); color: var(--foreground); }
.btn-icon .icon { width: 1.2rem; height: 1.2rem; }

.btn-badge {
  position: absolute;
  top: 6px; right: 6px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-pill);
  background: var(--danger);
  color: var(--primary-foreground);
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  line-height: 1;
}

/* ---- Badges -------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  line-height: 1.4;
}
.badge-success { background: var(--success-subtle); color: var(--success); }
.badge-info    { background: var(--info-subtle);    color: var(--info); }
.badge-primary { background: var(--primary-tint);   color: var(--primary); }
.badge-warn    { background: var(--warn-subtle);    color: var(--warn); }
.badge-danger  { background: var(--danger-subtle);  color: var(--danger); }
.badge-muted   { background: var(--secondary);      color: var(--muted-foreground); }

/* ---- Chips (filter strip / removable tags) ------------------------------- */
.chip-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  overflow-x: auto;
  padding-bottom: var(--space-1);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted-foreground);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.chip:hover { background: var(--secondary); color: var(--foreground); }
.chip.active { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }

/* ---- Form fields --------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field-label {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--muted-foreground);
}
.select,
.input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  color: var(--foreground);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.select:focus,
.input:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 22%, transparent);
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  background-size: 1rem;
  padding-right: var(--space-8);
}
.select-sm { padding: var(--space-1) var(--space-6) var(--space-1) var(--space-3); font-size: var(--text-sm); }

/* ---- Dropdown menus ------------------------------------------------------ */
.dropdown { position: relative; }
.dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.dropdown-menu {
  position: absolute;
  top: calc(100% + var(--space-2));
  min-width: 200px;
  padding: var(--space-2);
  background: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  display: none;
}
.dropdown-menu.end { right: 0; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-header {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--popover-foreground);
  /* Keep each entry on one line; the menu widens to the longest label rather
     than wrapping it (min-width above stays the floor). */
  white-space: nowrap;
}
.dropdown-item:hover { background: var(--secondary); }
.dropdown-divider {
  height: 1px;
  margin: var(--space-2) 0;
  background: var(--border);
}

/* ---- User chip ----------------------------------------------------------- */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
}
.user-chip:hover { background: var(--secondary); }
/* Works as an <img> (cropped to the circle) or as a <span> of initials
   (centred on the tinted background fallback). */
.avatar {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  flex: none;
  border-radius: var(--radius-pill);
  background: var(--primary-subtle);
  color: var(--primary-foreground);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
}
/* As an <img> it must be a plain replaced element — `display: grid` would make
   the image a grid container and render it at intrinsic size instead of
   filling the circle. */
img.avatar { display: block; object-fit: cover; }
